include/test/a11y/XAccessibleActionTester.hxx            |   53 ++++++
 include/test/a11y/XAccessibleEventBroadcasterTester.hxx  |    4 
 include/test/a11y/XAccessibleExtendedComponentTester.hxx |    4 
 test/Library_subsequenttest.mk                           |    3 
 test/source/a11y/XAccessibleActionTester.cxx             |  117 +++++++++++++++
 test/source/a11y/XAccessibleEventBroadcasterTester.cxx   |    3 
 test/source/a11y/XAccessibleExtendedComponentTester.cxx  |    3 
 toolkit/CppunitTest_toolkit_a11y.mk                      |    2 
 toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx      |    4 
 9 files changed, 183 insertions(+), 10 deletions(-)

New commits:
commit cadee0d0d9906b3f648172e354ad71982e9761bc
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Sat Mar 15 12:31:28 2025 -0700
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sun Mar 16 08:28:29 2025 +0100

    a11y tests: Introduce XAccessibleActionTester
    
    Similar to how e.g. XAccessibleContextTester tests
    the methods of the XAccessibleContext interface, this
    one tests the methods of the XAccessibleAction interface.
    
    This C++ version is similar to what the Java implementation in
    qadevOOo/tests/java/ifc/accessibility/_XAccessibleAction.java
    does.
    
    XAccessibleActionTester::testGetAccessibleActionDescription is
    more strict in that it also requires that the action description
    is non-empty.
    
    This will be used to replace the existing AccessibleDropDownListBox
    Java test with a C++ one in an upcoming commit.
    
    Change-Id: I41e9fe2fb5011cd8f33dbfc2494b04f4833c43cc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182983
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/include/test/a11y/XAccessibleActionTester.hxx 
b/include/test/a11y/XAccessibleActionTester.hxx
new file mode 100644
index 000000000000..4b1851649386
--- /dev/null
+++ b/include/test/a11y/XAccessibleActionTester.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <test/testdllapi.hxx>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/accessibility/XAccessibleAction.hpp>
+
+class OOO_DLLPUBLIC_TEST XAccessibleActionTester
+{
+protected:
+    const css::uno::Reference<css::accessibility::XAccessibleAction> mxAction;
+
+public:
+    XAccessibleActionTester(
+        const css::uno::Reference<css::accessibility::XAccessibleAction>& 
xAction)
+        : mxAction(xAction)
+    {
+    }
+
+    void testGetAccessibleActionCount();
+    void testDoAccessibleAction();
+    void testGetAccessibleActionDescription();
+    void testGetAccessibleActionKeyBinding();
+
+    void testAll()
+    {
+        testGetAccessibleActionCount();
+        testDoAccessibleAction();
+        testGetAccessibleActionDescription();
+        testGetAccessibleActionKeyBinding();
+    }
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index a0db2a2ef7ca..56e96a1b2470 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -47,6 +47,7 @@ $(eval $(call 
gb_Library_add_exception_objects,subsequenttest,\
        test/source/unoapi_test \
        test/source/unoapixml_test \
        test/source/a11y/AccessibilityTools \
+       test/source/a11y/XAccessibleActionTester \
        test/source/a11y/XAccessibleComponentTester \
        test/source/a11y/XAccessibleContextTester \
        test/source/a11y/XAccessibleEventBroadcasterTester \
diff --git a/test/source/a11y/XAccessibleActionTester.cxx 
b/test/source/a11y/XAccessibleActionTester.cxx
new file mode 100644
index 000000000000..9d29b9bf21c3
--- /dev/null
+++ b/test/source/a11y/XAccessibleActionTester.cxx
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <cppunit/TestAssert.h>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <test/a11y/XAccessibleActionTester.hxx>
+
+/**
+ * @brief Calls XAccessibleAction::getAccessibleActionCount.
+ *
+ * Checks that the action count is non-negative.
+ */
+void XAccessibleActionTester::testGetAccessibleActionCount()
+{
+    sal_Int32 nActionCount = mxAction->getAccessibleActionCount();
+    std::cout << nActionCount << " actions found." << std::endl;
+    CPPUNIT_ASSERT_GREATEREQUAL(static_cast<sal_Int32>(0), nActionCount);
+}
+
+/**
+ * @brief Calls XAccessibleAction::doAccessibleAction for all actions.
+ *
+ * Also checks that calling the method with an invalid index
+ * throws the expected exception.
+ */
+void XAccessibleActionTester::testDoAccessibleAction()
+{
+    const sal_Int32 nActionCount = mxAction->getAccessibleActionCount();
+
+    try
+    {
+        mxAction->doAccessibleAction(nActionCount);
+        CPPUNIT_FAIL("Didn't throw expected exception.");
+    }
+    catch (css::lang::IndexOutOfBoundsException&)
+    {
+    }
+
+    for (sal_Int32 i = 0; i < nActionCount; i++)
+    {
+        std::cout << "do action " + 
mxAction->getAccessibleActionDescription(i);
+        mxAction->doAccessibleAction(i);
+    }
+}
+
+/**
+ * @brief Calls XAccessibleAction::getAccessibleActionDescription for all 
actions.
+ *
+ * Checks that the description is not empty.
+ *
+ * Also checks that calling the method with an invalid index
+ * throws the expected exception.
+ */
+void XAccessibleActionTester::testGetAccessibleActionDescription()
+{
+    const sal_Int32 nActionCount = mxAction->getAccessibleActionCount();
+
+    try
+    {
+        mxAction->getAccessibleActionDescription(nActionCount);
+        CPPUNIT_FAIL("Didn't throw expected exception.");
+    }
+    catch (css::lang::IndexOutOfBoundsException&)
+    {
+    }
+
+    for (sal_Int32 i = 0; i < nActionCount; i++)
+    {
+        const OUString sDescription = 
mxAction->getAccessibleActionDescription(i);
+        CPPUNIT_ASSERT_MESSAGE("Action description is empty", 
!sDescription.isEmpty());
+    }
+}
+
+/**
+ * @brief Calls XAccessibleAction::getAccessibleActionKeyBinding for all 
actions.
+ *
+ * Also checks that calling the method with an invalid index
+ * throws the expected exception.
+ */
+void XAccessibleActionTester::testGetAccessibleActionKeyBinding()
+{
+    const sal_Int32 nActionCount = mxAction->getAccessibleActionCount();
+
+    try
+    {
+        mxAction->getAccessibleActionKeyBinding(nActionCount);
+        CPPUNIT_FAIL("Didn't throw expected exception.");
+    }
+    catch (css::lang::IndexOutOfBoundsException&)
+    {
+    }
+
+    for (sal_Int32 i = 0; i < nActionCount; i++)
+    {
+        mxAction->getAccessibleActionKeyBinding(i);
+    }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
commit 1b704035f5b5f41e12b2cb9b30bc3e34fd20937f
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Sat Mar 15 11:53:41 2025 -0700
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sun Mar 16 08:28:20 2025 +0100

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

diff --git a/toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.hxx 
b/include/test/a11y/XAccessibleEventBroadcasterTester.hxx
similarity index 95%
rename from toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.hxx
rename to include/test/a11y/XAccessibleEventBroadcasterTester.hxx
index 5642d10005c2..2680f9a22e2c 100644
--- a/toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.hxx
+++ b/include/test/a11y/XAccessibleEventBroadcasterTester.hxx
@@ -19,12 +19,14 @@
 
 #pragma once
 
+#include <test/testdllapi.hxx>
+
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
 #include <com/sun/star/awt/XWindow.hpp>
 
-class XAccessibleEventBroadcasterTester
+class OOO_DLLPUBLIC_TEST XAccessibleEventBroadcasterTester
 {
 private:
     const css::uno::Reference<css::accessibility::XAccessibleEventBroadcaster> 
mxBroadcaster;
diff --git a/toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.hxx 
b/include/test/a11y/XAccessibleExtendedComponentTester.hxx
similarity index 94%
rename from toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.hxx
rename to include/test/a11y/XAccessibleExtendedComponentTester.hxx
index 353fd663b1a9..2f252dd935db 100644
--- a/toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.hxx
+++ b/include/test/a11y/XAccessibleExtendedComponentTester.hxx
@@ -19,10 +19,12 @@
 
 #pragma once
 
+#include <test/testdllapi.hxx>
+
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp>
 
-class XAccessibleExtendedComponentTester
+class OOO_DLLPUBLIC_TEST XAccessibleExtendedComponentTester
 {
 protected:
     const 
css::uno::Reference<css::accessibility::XAccessibleExtendedComponent> 
mxExtendedComponent;
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index d5294bf2f4de..a0db2a2ef7ca 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -49,6 +49,8 @@ $(eval $(call 
gb_Library_add_exception_objects,subsequenttest,\
        test/source/a11y/AccessibilityTools \
        test/source/a11y/XAccessibleComponentTester \
        test/source/a11y/XAccessibleContextTester \
+       test/source/a11y/XAccessibleEventBroadcasterTester \
+       test/source/a11y/XAccessibleExtendedComponentTester \
        test/source/a11y/accessibletestbase \
        test/source/a11y/eventposter \
        test/source/beans/xpropertyset \
diff --git a/toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.cxx 
b/test/source/a11y/XAccessibleEventBroadcasterTester.cxx
similarity index 99%
rename from toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.cxx
rename to test/source/a11y/XAccessibleEventBroadcasterTester.cxx
index cdf4ccbcf592..7c4ff56127b3 100644
--- a/toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.cxx
+++ b/test/source/a11y/XAccessibleEventBroadcasterTester.cxx
@@ -17,8 +17,6 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "XAccessibleEventBroadcasterTester.hxx"
-
 #include <iostream>
 
 #include <cppunit/TestAssert.h>
@@ -39,6 +37,7 @@
 #include <sal/log.hxx>
 
 #include <test/a11y/AccessibilityTools.hxx>
+#include <test/a11y/XAccessibleEventBroadcasterTester.hxx>
 
 using namespace css;
 
diff --git a/toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.cxx 
b/test/source/a11y/XAccessibleExtendedComponentTester.cxx
similarity index 96%
rename from toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.cxx
rename to test/source/a11y/XAccessibleExtendedComponentTester.cxx
index ec192bdf0f47..0fa078c31479 100644
--- a/toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.cxx
+++ b/test/source/a11y/XAccessibleExtendedComponentTester.cxx
@@ -17,11 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "XAccessibleExtendedComponentTester.hxx"
-
 #include <iostream>
 
 #include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp>
+#include <test/a11y/XAccessibleExtendedComponentTester.hxx>
 
 /**
  * @brief Just calls the method.
diff --git a/toolkit/CppunitTest_toolkit_a11y.mk 
b/toolkit/CppunitTest_toolkit_a11y.mk
index 2fe929a31591..65103b42bdca 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/XAccessibleEventBroadcasterTester \
-       toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester \
 ))
 
 $(eval $(call gb_CppunitTest_use_libraries,toolkit_a11y, \
diff --git a/toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx 
b/toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx
index ce088f53d7d1..ae7a16536d45 100644
--- a/toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx
+++ b/toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx
@@ -36,8 +36,8 @@
 #include <test/a11y/AccessibilityTools.hxx>
 #include <test/a11y/XAccessibleComponentTester.hxx>
 #include <test/a11y/XAccessibleContextTester.hxx>
-#include "XAccessibleExtendedComponentTester.hxx"
-#include "XAccessibleEventBroadcasterTester.hxx"
+#include <test/a11y/XAccessibleExtendedComponentTester.hxx>
+#include <test/a11y/XAccessibleEventBroadcasterTester.hxx>
 
 using namespace css;
 

Reply via email to