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>
This commit is contained in:
parent
bbb57e8198
commit
8fe5a832b0
10 changed files with 58 additions and 62 deletions
|
@ -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)
|
||||
{
|
|
@ -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(),
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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=\""
|
|
@ -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 \
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include <tools/color.hxx>
|
||||
|
||||
#include "AccessibilityTools.hxx"
|
||||
#include <test/a11y/AccessibilityTools.hxx>
|
||||
|
||||
using namespace css;
|
||||
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include <rtl/ref.hxx>
|
||||
#include <sal/log.hxx>
|
||||
|
||||
#include "AccessibilityTools.hxx"
|
||||
#include <test/a11y/AccessibilityTools.hxx>
|
||||
|
||||
using namespace css;
|
||||
|
||||
|
|
Loading…
Reference in a new issue