summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColomban Wendling <cwendling@hypra.fr>2022-07-21 15:58:16 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2022-07-27 10:41:03 +0200
commit8fe5a832b02ea6c5113c573f5b9c23e58049a4d2 (patch)
tree3649df777c1f3bdf8ceb237da97ca3cab95da4cb
parentbbb57e8198863ee7bdadd3f2aac4420c08da94a3 (diff)
Make AccessibilityTools available more widely and use it
Move AccessibilityTools helper to test/ and use it in accessible_relation_set test replacing the copied over feature and consolidating the test as well. Change-Id: Ia5ea69bb08bb2a86e3eb6c3dba2ab182b612561d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137307 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
-rw-r--r--include/test/a11y/AccessibilityTools.hxx (renamed from toolkit/qa/cppunit/a11y/AccessibilityTools.hxx)5
-rw-r--r--sw/qa/extras/accessibility/accessible_relation_set.cxx67
-rw-r--r--test/Library_subsequenttest.mk1
-rw-r--r--test/source/a11y/AccessibilityTools.cxx (renamed from toolkit/qa/cppunit/a11y/AccessibilityTools.cxx)35
-rw-r--r--toolkit/CppunitTest_toolkit_a11y.mk2
-rw-r--r--toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx2
-rw-r--r--toolkit/qa/cppunit/a11y/XAccessibleComponentTester.cxx2
-rw-r--r--toolkit/qa/cppunit/a11y/XAccessibleComponentTester.hxx2
-rw-r--r--toolkit/qa/cppunit/a11y/XAccessibleContextTester.cxx2
-rw-r--r--toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.cxx2
10 files changed, 58 insertions, 62 deletions
diff --git a/toolkit/qa/cppunit/a11y/AccessibilityTools.hxx b/include/test/a11y/AccessibilityTools.hxx
index 96afe4377f94..e56c68c9bebb 100644
--- a/toolkit/qa/cppunit/a11y/AccessibilityTools.hxx
+++ b/include/test/a11y/AccessibilityTools.hxx
@@ -19,6 +19,8 @@
#pragma once
+#include <test/testdllapi.hxx>
+
#include <functional>
#include <string>
@@ -28,7 +30,7 @@
#include <com/sun/star/accessibility/XAccessible.hpp>
#include <com/sun/star/accessibility/XAccessibleContext.hpp>
-class AccessibilityTools
+class OOO_DLLPUBLIC_TEST AccessibilityTools
{
public:
/** Maximum number of children to work on. This is especially useful for
@@ -47,6 +49,7 @@ public:
static OUString getRoleName(const sal_Int16 role);
static OUString getStateName(const sal_Int16 state);
static OUString getEventIdName(const sal_Int16 event_id);
+ static OUString getRelationTypeName(const sal_Int16 rel_type);
template <typename T> static std::string debugString(const css::uno::Reference<T>& x)
{
diff --git a/sw/qa/extras/accessibility/accessible_relation_set.cxx b/sw/qa/extras/accessibility/accessible_relation_set.cxx
index ce053c95b07b..3839a61d0504 100644
--- a/sw/qa/extras/accessibility/accessible_relation_set.cxx
+++ b/sw/qa/extras/accessibility/accessible_relation_set.cxx
@@ -20,6 +20,7 @@
#include <test/unoapi_test.hxx>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
#include <com/sun/star/accessibility/AccessibleRole.hpp>
#include <com/sun/star/accessibility/XAccessibleText.hpp>
#include <com/sun/star/accessibility/XAccessible.hpp>
@@ -33,54 +34,13 @@
#include <com/sun/star/text/XTextCursor.hpp>
#include <com/sun/star/text/ControlCharacter.hpp>
+#include <test/a11y/AccessibilityTools.hxx>
+
using namespace com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::accessibility;
using namespace css::lang;
-namespace
-{
-class AccessibilityTools
-{
-public:
- static css::uno::Reference<css::accessibility::XAccessibleContext>
- getAccessibleObjectForRole(const css::uno::Reference<css::accessibility::XAccessible>& xacc,
- sal_Int16 role);
-};
-}
-
-css::uno::Reference<css::accessibility::XAccessibleContext>
-AccessibilityTools::getAccessibleObjectForRole(
- const css::uno::Reference<css::accessibility::XAccessible>& xacc, sal_Int16 role)
-{
- css::uno::Reference<css::accessibility::XAccessibleContext> ac = xacc->getAccessibleContext();
- bool isShowing = ac->getAccessibleStateSet() & AccessibleStateType::SHOWING;
-
- if ((ac->getAccessibleRole() == role) && isShowing)
- {
- return ac;
- }
- else
- {
- int k = ac->getAccessibleChildCount();
- if (ac->getAccessibleChildCount() > 100)
- {
- k = 50;
- }
-
- for (int i = 0; i < k; i++)
- {
- css::uno::Reference<css::accessibility::XAccessibleContext> ac2
- = AccessibilityTools::getAccessibleObjectForRole(ac->getAccessibleChild(i), role);
- if (ac2.is())
- {
- return ac2;
- }
- }
- }
- return nullptr;
-}
-
class AccessibleRelationSet : public UnoApiTest
{
public:
@@ -137,9 +97,6 @@ AccessibleRelationSet::init(uno::Reference<css::accessibility::XAccessible>& par
void AccessibleRelationSet::contents_flows_to_and_from()
{
//contents_flows_to
- std::vector<OUString> types{ "INVALID", "CONTENT_FLOWS_FROM", "CONTENT_FLOWS_TO",
- "CONTROLLED_BY", "CONTROLLER_FOR", "LABEL_FOR",
- "LABELED_BY", "MEMBER_OF", "SUB_WINDOW_OF" };
css::uno::Reference<css::accessibility::XAccessible> para1;
css::uno::Reference<css::accessibility::XAccessible> para2;
@@ -160,8 +117,10 @@ void AccessibleRelationSet::contents_flows_to_and_from()
css::uno::Reference<css::accessibility::XAccessibleText> adummy(
set->getRelation(0).TargetSet[0], uno::UNO_QUERY_THROW);
atarget = adummy;
- CPPUNIT_ASSERT_EQUAL_MESSAGE("didn't gain correct relation type for paragraph 0", types[2],
- types[firstrelation]);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("didn't gain correct relation type for paragraph 0",
+ AccessibilityTools::getRelationTypeName(
+ accessibility::AccessibleRelationType::CONTENT_FLOWS_TO),
+ AccessibilityTools::getRelationTypeName(firstrelation));
css::uno::Reference<css::accessibility::XAccessibleText> paraText2(para2,
uno::UNO_QUERY_THROW);
@@ -221,15 +180,19 @@ void AccessibleRelationSet::contents_flows_to_and_from()
}
}
- CPPUNIT_ASSERT_EQUAL_MESSAGE("didn't gain correct relation type for paragraph 1", types[1],
- types[relationtypes[0]]);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("didn't gain correct relation type for paragraph 1",
+ AccessibilityTools::getRelationTypeName(
+ accessibility::AccessibleRelationType::CONTENT_FLOWS_FROM),
+ AccessibilityTools::getRelationTypeName(relationtypes[0]));
css::uno::Reference<css::accessibility::XAccessibleText> paraText1(para1, uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL_MESSAGE("didn't gain correct target paragraph", atargets[0]->getText(),
paraText1->getText());
- CPPUNIT_ASSERT_EQUAL_MESSAGE("didn't gain correct relation type for paragraph 3", types[2],
- types[relationtypes[1]]);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("didn't gain correct relation type for paragraph 3",
+ AccessibilityTools::getRelationTypeName(
+ accessibility::AccessibleRelationType::CONTENT_FLOWS_TO),
+ AccessibilityTools::getRelationTypeName(relationtypes[1]));
css::uno::Reference<css::accessibility::XAccessibleText> paraText3(para3, uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL_MESSAGE("didn't gain correct target paragraph", atargets[1]->getText(),
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 0715cc47af63..9b35eda003ba 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -42,6 +42,7 @@ $(eval $(call gb_Library_use_externals,subsequenttest,\
$(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/unoapi_test \
test/source/calc_unoapi_test \
+ test/source/a11y/AccessibilityTools \
test/source/beans/xpropertyset \
test/source/chart/xchartdata \
test/source/container/xchild \
diff --git a/toolkit/qa/cppunit/a11y/AccessibilityTools.cxx b/test/source/a11y/AccessibilityTools.cxx
index 816e9b82b168..f727bd41087f 100644
--- a/toolkit/qa/cppunit/a11y/AccessibilityTools.cxx
+++ b/test/source/a11y/AccessibilityTools.cxx
@@ -17,9 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "AccessibilityTools.hxx"
+#include <test/a11y/AccessibilityTools.hxx>
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
#include <com/sun/star/accessibility/AccessibleRole.hpp>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <com/sun/star/accessibility/XAccessible.hpp>
@@ -31,7 +32,6 @@
using namespace css;
-/* FIXME: mostly copied from sw/qa/extras/accessibility/accessible_relation_set.cxx */
css::uno::Reference<css::accessibility::XAccessibleContext>
AccessibilityTools::getAccessibleObjectForRole(
const css::uno::Reference<css::accessibility::XAccessible>& xacc, sal_Int16 role)
@@ -57,7 +57,6 @@ AccessibilityTools::getAccessibleObjectForRole(
}
return nullptr;
}
-/* FIXME: end copy */
bool AccessibilityTools::equals(const uno::Reference<accessibility::XAccessible>& xacc1,
const uno::Reference<accessibility::XAccessible>& xacc2)
@@ -492,6 +491,36 @@ OUString AccessibilityTools::getEventIdName(const sal_Int16 event_id)
return "unknown";
}
+OUString AccessibilityTools::getRelationTypeName(const sal_Int16 rel_type)
+{
+ switch (rel_type)
+ {
+ case accessibility::AccessibleRelationType::CONTENT_FLOWS_FROM:
+ return "CONTENT_FLOWS_FROM";
+ case accessibility::AccessibleRelationType::CONTENT_FLOWS_TO:
+ return "CONTENT_FLOWS_TO";
+ case accessibility::AccessibleRelationType::CONTROLLED_BY:
+ return "CONTROLLED_BY";
+ case accessibility::AccessibleRelationType::CONTROLLER_FOR:
+ return "CONTROLLER_FOR";
+ case accessibility::AccessibleRelationType::DESCRIBED_BY:
+ return "DESCRIBED_BY";
+ case accessibility::AccessibleRelationType::INVALID:
+ return "INVALID";
+ case accessibility::AccessibleRelationType::LABELED_BY:
+ return "LABELED_BY";
+ case accessibility::AccessibleRelationType::LABEL_FOR:
+ return "LABEL_FOR";
+ case accessibility::AccessibleRelationType::MEMBER_OF:
+ return "MEMBER_OF";
+ case accessibility::AccessibleRelationType::NODE_CHILD_OF:
+ return "NODE_CHILD_OF";
+ case accessibility::AccessibleRelationType::SUB_WINDOW_OF:
+ return "SUB_WINDOW_OF";
+ }
+ return "unknown";
+}
+
OUString AccessibilityTools::debugName(accessibility::XAccessibleContext* ctx)
{
return "role=" + AccessibilityTools::getRoleName(ctx->getAccessibleRole()) + " name=\""
diff --git a/toolkit/CppunitTest_toolkit_a11y.mk b/toolkit/CppunitTest_toolkit_a11y.mk
index 06468a49c286..4b8c60b0a6e6 100644
--- a/toolkit/CppunitTest_toolkit_a11y.mk
+++ b/toolkit/CppunitTest_toolkit_a11y.mk
@@ -11,7 +11,6 @@ $(eval $(call gb_CppunitTest_CppunitTest,toolkit_a11y))
$(eval $(call gb_CppunitTest_add_exception_objects,toolkit_a11y, \
toolkit/qa/cppunit/a11y/AccessibleStatusBarTest \
- toolkit/qa/cppunit/a11y/AccessibilityTools \
toolkit/qa/cppunit/a11y/XAccessibleComponentTester \
toolkit/qa/cppunit/a11y/XAccessibleContextTester \
toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester \
@@ -25,6 +24,7 @@ $(eval $(call gb_CppunitTest_use_libraries,toolkit_a11y, \
cppuhelper \
sal \
salhelper \
+ subsequenttest \
test \
tk \
tl \
diff --git a/toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx b/toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx
index 822223a740b9..20d8b42f8c0c 100644
--- a/toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx
+++ b/toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx
@@ -38,7 +38,7 @@
#include <test/bootstrapfixture.hxx>
#include <vcl/scheduler.hxx>
-#include "AccessibilityTools.hxx"
+#include <test/a11y/AccessibilityTools.hxx>
#include "XAccessibleComponentTester.hxx"
#include "XAccessibleContextTester.hxx"
#include "XAccessibleExtendedComponentTester.hxx"
diff --git a/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.cxx b/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.cxx
index 3c743d3223da..4e9ed7a1ee00 100644
--- a/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.cxx
+++ b/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.cxx
@@ -30,7 +30,7 @@
#include <tools/color.hxx>
-#include "AccessibilityTools.hxx"
+#include <test/a11y/AccessibilityTools.hxx>
using namespace css;
diff --git a/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.hxx b/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.hxx
index ba84fbbac50d..5965374a3f84 100644
--- a/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.hxx
+++ b/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.hxx
@@ -23,7 +23,7 @@
#include <com/sun/star/accessibility/XAccessibleComponent.hpp>
#include <com/sun/star/accessibility/XAccessibleContext.hpp>
-#include "AccessibilityTools.hxx"
+#include <test/a11y/AccessibilityTools.hxx>
class XAccessibleComponentTester
{
diff --git a/toolkit/qa/cppunit/a11y/XAccessibleContextTester.cxx b/toolkit/qa/cppunit/a11y/XAccessibleContextTester.cxx
index b330d5ba9544..e9b605c73956 100644
--- a/toolkit/qa/cppunit/a11y/XAccessibleContextTester.cxx
+++ b/toolkit/qa/cppunit/a11y/XAccessibleContextTester.cxx
@@ -24,7 +24,7 @@
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/accessibility/XAccessibleContext.hpp>
-#include "AccessibilityTools.hxx"
+#include <test/a11y/AccessibilityTools.hxx>
/**
* @brief Tries to get every child and checks its parent.
diff --git a/toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.cxx b/toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.cxx
index 1ac5d4e3b56b..852c91c341be 100644
--- a/toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.cxx
+++ b/toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.cxx
@@ -38,7 +38,7 @@
#include <rtl/ref.hxx>
#include <sal/log.hxx>
-#include "AccessibilityTools.hxx"
+#include <test/a11y/AccessibilityTools.hxx>
using namespace css;