include/test/a11y/XAccessibleComponentTester.hxx    |    4 ++
 include/test/a11y/XAccessibleContextTester.hxx      |    4 ++
 test/Library_subsequenttest.mk                      |    2 +
 test/source/a11y/XAccessibleComponentTester.cxx     |   27 ++++++++++++++++----
 test/source/a11y/XAccessibleContextTester.cxx       |    3 --
 toolkit/CppunitTest_toolkit_a11y.mk                 |    2 -
 toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx |    4 +-
 7 files changed, 33 insertions(+), 13 deletions(-)

New commits:
commit 8e5f5938ed7316d1dbc6a1ad365ffd8e938c6e06
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Sat Mar 15 10:53:41 2025 -0700
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sat Mar 15 20:50:18 2025 +0100

    a11y tests: Don't assume that child on top has higher child index
    
    An accessible can have multiple children at the same point. As the
    XAccessibleComponent::getAccessibleAtPoint doc says:
    
            @return
                If there is one child which is rendered so that its bounding box
                contains the test point then a reference to that object is
                returned.  If there is more than one child which satisfies that
                condition then a reference to that one is returned that is
                painted on top of the others.  If there is no child which is
                rendered at the test point an empty reference is returned.
    
    So far, XAccessibleComponentTester::testAccessibleAtPoint was making
    the assumption that if multiple children are at the same point, the
    one on top has the higher child index. Otherwise, the test would fail.
    
    The reason for that assumption is unclear. Replace that by checking
    whether the accessible returned by 
XAccessibleComponent::getAccessibleAtPoint
    is a direct child (by checking its parent) and actually contains the
    point instead.
    
    Without this, the test was seen failing in a WIP branch that converts
    the AccessibleDropDownListBox JUnit test to a cppunit test.
    Related failure output:
    
        Found 2 children
        * Found child: (0x562c20b3b7b8) role=TEXT name="" description=""
          states: ENABLED | SENSITIVE
          component: 0x562c20b3b770
          bounds: X: 0, Y: 0, Width: 100, Height: 21
          bounds: 100x21+0+0
        finding the point which lies on the component
        Child found at point +0+0
        * Found child: (0x562c20b30028) role=LIST name="" description=""
          states: ENABLED | FOCUSABLE | MANAGES_DESCENDANTS | SENSITIVE
          component: 0x562c20b30010
          bounds: X: 0, Y: 20, Width: 100, Height: 88
          bounds: 100x88+0+20
        finding the point which lies on the component
        Child found at point +0+20
        The child found ((0x562c20b3b7b8) role=TEXT name="" description="") is 
not the expected one ((0x562c20b30028) role=LIST name="" description="")
        
/home/michi/development/git/libreoffice/test/source/a11y/XAccessibleComponentTester.cxx:204:AccessibleDropDownListBox::TestBody
        equality assertion failed
        - Expected: (0x562c20b30028) role=LIST name="" description=""
        - Actual  : (0x562c20b3b7b8) role=TEXT name="" description=""
        - The child found is NOT the expected one
    
    Change-Id: I8bc01c333ff0b3b9e90948bfd21b5abb86989687
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182968
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/test/source/a11y/XAccessibleComponentTester.cxx 
b/test/source/a11y/XAccessibleComponentTester.cxx
index 7421b31a5d19..cba6ee936569 100644
--- a/test/source/a11y/XAccessibleComponentTester.cxx
+++ b/test/source/a11y/XAccessibleComponentTester.cxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/uno/Reference.hxx>
 
 #include <tools/color.hxx>
+#include <vcl/unohelp.hxx>
 
 #include <test/a11y/AccessibilityTools.hxx>
 #include <test/a11y/XAccessibleComponentTester.hxx>
@@ -186,12 +187,29 @@ void XAccessibleComponentTester::testAccessibleAtPoint()
         CPPUNIT_ASSERT_MESSAGE("Child not found at point", xAccAtPoint.is());
         if (!AccessibilityTools::equals(child, xAccAtPoint))
         {
-            auto idxExpected = childContext->getAccessibleIndexInParent();
-            auto idxResult = 
xAccAtPoint->getAccessibleContext()->getAccessibleIndexInParent();
             std::cout << "The child found (" << 
AccessibilityTools::debugString(xAccAtPoint)
                       << ") is not the expected one (" << 
AccessibilityTools::debugString(child)
                       << ")" << std::endl;
-            if (idxExpected < idxResult)
+
+            const bool bDirectChild
+                = 
xAccAtPoint->getAccessibleContext()->getAccessibleParent()->getAccessibleContext()
+                  == mxContext;
+            CPPUNIT_ASSERT_MESSAGE("Accessible returned by "
+                                   "XAccessibleComponent::getAccessibleAtPoint 
has different "
+                                   "parent",
+                                   bDirectChild);
+
+            css::uno::Reference<css::accessibility::XAccessibleComponent> 
xComponentAtPoint(
+                xAccAtPoint->getAccessibleContext(), 
css::uno::UNO_QUERY_THROW);
+            const bool bContainsPoint
+                = 
vcl::unohelper::ConvertToVCLRect(xComponentAtPoint->getBounds())
+                      .Contains(Point(childBounds.X, childBounds.Y));
+            CPPUNIT_ASSERT_MESSAGE("Accessible returned by "
+                                   "XAccessibleComponent::getAccessibleAtPoint 
doesn't contain the "
+                                   "point",
+                                   bContainsPoint);
+
+            if (bContainsPoint)
             {
                 std::cout << "-- it probably is hidden behind?  Skipping." << 
std::endl;
             }
commit f69fa9e37232d0d41e5f224872d0e86391f19f2f
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Mar 14 19:55:14 2025 -0700
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sat Mar 15 20:50:09 2025 +0100

    a11y tests: Move helpers from toolkit to test
    
    Move the XAccessibleComponentTester and XAccessibleContextTester
    classes from toolkit to test, so they can be reused for a11y tests
    in other modules.
    
    Change-Id: I9a4bb3f96d92b05d58a5e8afe7f86b5eb2fd0c38
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182967
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.hxx 
b/include/test/a11y/XAccessibleComponentTester.hxx
similarity index 96%
rename from toolkit/qa/cppunit/a11y/XAccessibleComponentTester.hxx
rename to include/test/a11y/XAccessibleComponentTester.hxx
index 5965374a3f84..f290fea0c171 100644
--- a/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.hxx
+++ b/include/test/a11y/XAccessibleComponentTester.hxx
@@ -19,13 +19,15 @@
 
 #pragma once
 
+#include <test/testdllapi.hxx>
+
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
 
 #include <test/a11y/AccessibilityTools.hxx>
 
-class XAccessibleComponentTester
+class OOO_DLLPUBLIC_TEST XAccessibleComponentTester
 {
 private:
     const css::uno::Reference<css::accessibility::XAccessibleComponent> 
mxComponent;
diff --git a/toolkit/qa/cppunit/a11y/XAccessibleContextTester.hxx 
b/include/test/a11y/XAccessibleContextTester.hxx
similarity index 96%
rename from toolkit/qa/cppunit/a11y/XAccessibleContextTester.hxx
rename to include/test/a11y/XAccessibleContextTester.hxx
index b399028cf85e..f45954ce5661 100644
--- a/toolkit/qa/cppunit/a11y/XAccessibleContextTester.hxx
+++ b/include/test/a11y/XAccessibleContextTester.hxx
@@ -19,10 +19,12 @@
 
 #pragma once
 
+#include <test/testdllapi.hxx>
+
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
 
-class XAccessibleContextTester
+class OOO_DLLPUBLIC_TEST XAccessibleContextTester
 {
 protected:
     const css::uno::Reference<css::accessibility::XAccessibleContext> 
mxContext;
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 6a7abe7eb3f2..d5294bf2f4de 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -47,6 +47,8 @@ $(eval $(call 
gb_Library_add_exception_objects,subsequenttest,\
        test/source/unoapi_test \
        test/source/unoapixml_test \
        test/source/a11y/AccessibilityTools \
+       test/source/a11y/XAccessibleComponentTester \
+       test/source/a11y/XAccessibleContextTester \
        test/source/a11y/accessibletestbase \
        test/source/a11y/eventposter \
        test/source/beans/xpropertyset \
diff --git a/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.cxx 
b/test/source/a11y/XAccessibleComponentTester.cxx
similarity index 99%
rename from toolkit/qa/cppunit/a11y/XAccessibleComponentTester.cxx
rename to test/source/a11y/XAccessibleComponentTester.cxx
index fa5fb9f7054f..7421b31a5d19 100644
--- a/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.cxx
+++ b/test/source/a11y/XAccessibleComponentTester.cxx
@@ -17,8 +17,6 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "XAccessibleComponentTester.hxx"
-
 #include <cppunit/TestAssert.h>
 
 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
@@ -31,6 +29,7 @@
 #include <tools/color.hxx>
 
 #include <test/a11y/AccessibilityTools.hxx>
+#include <test/a11y/XAccessibleComponentTester.hxx>
 
 using namespace css;
 
diff --git a/toolkit/qa/cppunit/a11y/XAccessibleContextTester.cxx 
b/test/source/a11y/XAccessibleContextTester.cxx
similarity index 99%
rename from toolkit/qa/cppunit/a11y/XAccessibleContextTester.cxx
rename to test/source/a11y/XAccessibleContextTester.cxx
index 9d7fdb992eae..3a96aaea000c 100644
--- a/toolkit/qa/cppunit/a11y/XAccessibleContextTester.cxx
+++ b/test/source/a11y/XAccessibleContextTester.cxx
@@ -17,14 +17,13 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "XAccessibleContextTester.hxx"
-
 #include <cppunit/TestAssert.h>
 
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
 
 #include <test/a11y/AccessibilityTools.hxx>
+#include <test/a11y/XAccessibleContextTester.hxx>
 
 /**
  * @brief Tries to get every child and checks its parent.
diff --git a/toolkit/CppunitTest_toolkit_a11y.mk 
b/toolkit/CppunitTest_toolkit_a11y.mk
index 4b8c60b0a6e6..2fe929a31591 100644
--- a/toolkit/CppunitTest_toolkit_a11y.mk
+++ b/toolkit/CppunitTest_toolkit_a11y.mk
@@ -11,8 +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/XAccessibleComponentTester \
-       toolkit/qa/cppunit/a11y/XAccessibleContextTester \
        toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester \
        toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester \
 ))
diff --git a/toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx 
b/toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx
index 5bf522fb2e2e..ce088f53d7d1 100644
--- a/toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx
+++ b/toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx
@@ -34,8 +34,8 @@
 #include <vcl/scheduler.hxx>
 
 #include <test/a11y/AccessibilityTools.hxx>
-#include "XAccessibleComponentTester.hxx"
-#include "XAccessibleContextTester.hxx"
+#include <test/a11y/XAccessibleComponentTester.hxx>
+#include <test/a11y/XAccessibleContextTester.hxx>
 #include "XAccessibleExtendedComponentTester.hxx"
 #include "XAccessibleEventBroadcasterTester.hxx"
 

Reply via email to