sw/qa/extras/accessibility/accessible_relation_set.cxx |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

New commits:
commit 98180644fe2125027dc3a5df637618d717a54e86
Author:     Colomban Wendling <cwendl...@hypra.fr>
AuthorDate: Wed Jul 27 15:29:36 2022 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Wed Jul 27 17:19:24 2022 +0200

    Don't use magic numbers or off-range enum values
    
    Stop using magic numbers standing for enumeration items.  It makes the
    code clearer, and this test is not here to verify the API stays stable
    but that the semantics are correct so there's no need for magic values.
    
    Also don't use placeholder values outside the enumeration range and
    replace them with the legitimate and pretty appropriate INVALID value,
    which has the same effect in the context of this test, and avoids
    abusing the APIs.
    
    Change-Id: Ib5c9d768ba83470d41c65e00ebe3e8878ce32f3f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137505
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/sw/qa/extras/accessibility/accessible_relation_set.cxx 
b/sw/qa/extras/accessibility/accessible_relation_set.cxx
index 3839a61d0504..9220606be3d0 100644
--- a/sw/qa/extras/accessibility/accessible_relation_set.cxx
+++ b/sw/qa/extras/accessibility/accessible_relation_set.cxx
@@ -133,7 +133,8 @@ void AccessibleRelationSet::contents_flows_to_and_from()
     css::uno::Reference<css::accessibility::XAccessibleRelationSet> set2
         = oObj2->getAccessibleRelationSet();
 
-    sal_Int16 relationtypes[2] = { -1, -1 };
+    sal_Int16 relationtypes[2] = { 
accessibility::AccessibleRelationType::INVALID,
+                                   
accessibility::AccessibleRelationType::INVALID };
     css::uno::Reference<css::accessibility::XAccessibleText> atargets[2];
 
     if (set2.is())
@@ -141,14 +142,14 @@ void AccessibleRelationSet::contents_flows_to_and_from()
         CPPUNIT_ASSERT_EQUAL_MESSAGE("didn't gain correct count of relations", 
sal_Int32(2),
                                      set2->getRelationCount());
         sal_Int16 tmprelation = set2->getRelation(0).RelationType;
-        if (tmprelation == 1)
+        if (tmprelation == 
accessibility::AccessibleRelationType::CONTENT_FLOWS_FROM)
         {
             css::uno::Reference<css::accessibility::XAccessibleText> adummy(
                 set2->getRelation(0).TargetSet[0], uno::UNO_QUERY_THROW);
             atargets[0] = adummy;
             relationtypes[0] = tmprelation;
         }
-        else if (tmprelation == 2)
+        else if (tmprelation == 
accessibility::AccessibleRelationType::CONTENT_FLOWS_TO)
         {
             css::uno::Reference<css::accessibility::XAccessibleText> adummy(
                 set2->getRelation(0).TargetSet[0], uno::UNO_QUERY_THROW);
@@ -160,14 +161,14 @@ void AccessibleRelationSet::contents_flows_to_and_from()
             CPPUNIT_FAIL("didn't gain correct relation type");
         }
         tmprelation = set2->getRelation(1).RelationType;
-        if (tmprelation == 1)
+        if (tmprelation == 
accessibility::AccessibleRelationType::CONTENT_FLOWS_FROM)
         {
             css::uno::Reference<css::accessibility::XAccessibleText> adummy(
                 set2->getRelation(1).TargetSet[0], uno::UNO_QUERY_THROW);
             atargets[0] = adummy;
             relationtypes[0] = tmprelation;
         }
-        else if (tmprelation == 2)
+        else if (tmprelation == 
accessibility::AccessibleRelationType::CONTENT_FLOWS_TO)
         {
             css::uno::Reference<css::accessibility::XAccessibleText> adummy(
                 set2->getRelation(1).TargetSet[0], uno::UNO_QUERY_THROW);

Reply via email to