summaryrefslogtreecommitdiffstats
path: root/toolkit/qa/cppunit
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/qa/cppunit')
-rw-r--r--toolkit/qa/cppunit/Dialog.cxx73
-rw-r--r--toolkit/qa/cppunit/EventContainer.cxx84
-rw-r--r--toolkit/qa/cppunit/UnitConversion.cxx215
-rw-r--r--toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx139
-rw-r--r--toolkit/qa/cppunit/a11y/XAccessibleComponentTester.cxx291
-rw-r--r--toolkit/qa/cppunit/a11y/XAccessibleComponentTester.hxx66
-rw-r--r--toolkit/qa/cppunit/a11y/XAccessibleContextTester.cxx164
-rw-r--r--toolkit/qa/cppunit/a11y/XAccessibleContextTester.hxx62
-rw-r--r--toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.cxx185
-rw-r--r--toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.hxx54
-rw-r--r--toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.cxx53
-rw-r--r--toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.hxx50
12 files changed, 1436 insertions, 0 deletions
diff --git a/toolkit/qa/cppunit/Dialog.cxx b/toolkit/qa/cppunit/Dialog.cxx
new file mode 100644
index 0000000000..6ddf3f7258
--- /dev/null
+++ b/toolkit/qa/cppunit/Dialog.cxx
@@ -0,0 +1,73 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#include <test/bootstrapfixture.hxx>
+#include <unotest/macros_test.hxx>
+
+#include <com/sun/star/awt/UnoControlDialog.hpp>
+#include <com/sun/star/awt/XUnoControlDialog.hpp>
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+
+#include <comphelper/processfactory.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/vclptr.hxx>
+#include <vcl/window.hxx>
+
+using namespace css;
+
+namespace
+{
+/// Test dialogs constructed via UNO
+class DialogTest : public test::BootstrapFixture, public unotest::MacrosTest
+{
+protected:
+ uno::Reference<uno::XComponentContext> mxContext;
+
+public:
+ virtual void setUp() override;
+};
+
+void DialogTest::setUp()
+{
+ test::BootstrapFixture::setUp();
+
+ mxContext.set(comphelper::getComponentContext(getMultiServiceFactory()));
+}
+
+CPPUNIT_TEST_FIXTURE(DialogTest, testDialogSizeable)
+{
+ uno::Reference<awt::XDialog> xDialog;
+ uno::Reference<lang::XMultiComponentFactory> xFactory(mxContext->getServiceManager(),
+ uno::UNO_SET_THROW);
+ uno::Reference<awt::XControlModel> xControlModel(
+ xFactory->createInstanceWithContext("com.sun.star.awt.UnoControlDialogModel", mxContext),
+ uno::UNO_QUERY_THROW);
+
+ uno::Reference<beans::XPropertySet> xPropSet(xControlModel, uno::UNO_QUERY_THROW);
+ xPropSet->setPropertyValue("Sizeable", uno::Any(true));
+
+ uno::Reference<awt::XUnoControlDialog> xControl = awt::UnoControlDialog::create(mxContext);
+ xControl->setModel(xControlModel);
+ xControl->setVisible(true);
+ xDialog.set(xControl, uno::UNO_QUERY_THROW);
+ xDialog->execute();
+
+ VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xControl->getPeer());
+ CPPUNIT_ASSERT(pWindow);
+ CPPUNIT_ASSERT(pWindow->GetStyle() & WB_SIZEABLE);
+
+ xDialog->endExecute();
+ css::uno::Reference<css::lang::XComponent>(xDialog, css::uno::UNO_QUERY_THROW)->dispose();
+ css::uno::Reference<css::lang::XComponent>(xControlModel, css::uno::UNO_QUERY_THROW)->dispose();
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/toolkit/qa/cppunit/EventContainer.cxx b/toolkit/qa/cppunit/EventContainer.cxx
new file mode 100644
index 0000000000..ad62f93105
--- /dev/null
+++ b/toolkit/qa/cppunit/EventContainer.cxx
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#include <test/bootstrapfixture.hxx>
+
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/script/ScriptEventDescriptor.hpp>
+#include <com/sun/star/script/XScriptEventsSupplier.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <comphelper/processfactory.hxx>
+
+using namespace css;
+using namespace css::awt;
+using namespace css::container;
+using namespace css::lang;
+using namespace css::script;
+using namespace css::uno;
+
+namespace
+{
+/// Test EventContainer class
+class EventContainerTest : public test::BootstrapFixture
+{
+protected:
+ Reference<XComponentContext> mxContext;
+
+public:
+ virtual void setUp() override;
+};
+
+void EventContainerTest::setUp()
+{
+ test::BootstrapFixture::setUp();
+
+ mxContext.set(comphelper::getComponentContext(getMultiServiceFactory()));
+}
+
+// Make sure that EventContainer keeps insertion order, and does not reorder its elements.
+// Otherwise this would break macro signatures.
+CPPUNIT_TEST_FIXTURE(EventContainerTest, testInsertOrder)
+{
+ Reference<XMultiComponentFactory> xFactory(mxContext->getServiceManager(), UNO_SET_THROW);
+ Reference<XControlModel> xControlModel(
+ xFactory->createInstanceWithContext("com.sun.star.awt.UnoControlDialogModel", mxContext),
+ UNO_QUERY_THROW);
+
+ Reference<beans::XPropertySet> xPropSet(xControlModel, UNO_QUERY_THROW);
+
+ Reference<XScriptEventsSupplier> xEventsSupplier(xPropSet, UNO_QUERY_THROW);
+ Reference<XNameContainer> xEvents(xEventsSupplier->getEvents(), UNO_SET_THROW);
+ script::ScriptEventDescriptor descr1;
+ script::ScriptEventDescriptor descr2;
+ script::ScriptEventDescriptor descr3;
+ script::ScriptEventDescriptor descr4;
+ xEvents->insertByName("b", Any(descr1));
+ xEvents->insertByName("a", Any(descr2));
+ xEvents->insertByName("1", Any(descr3));
+ xEvents->insertByName("A", Any(descr4));
+
+ Sequence<OUString> aEventNames(xEvents->getElementNames());
+ sal_Int32 nEventCount = aEventNames.getLength();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), nEventCount);
+
+ CPPUNIT_ASSERT_EQUAL(OUString("b"), aEventNames[0]);
+ CPPUNIT_ASSERT_EQUAL(OUString("a"), aEventNames[1]);
+ CPPUNIT_ASSERT_EQUAL(OUString("1"), aEventNames[2]);
+ CPPUNIT_ASSERT_EQUAL(OUString("A"), aEventNames[3]);
+
+ css::uno::Reference<css::lang::XComponent>(xControlModel, css::uno::UNO_QUERY_THROW)->dispose();
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/toolkit/qa/cppunit/UnitConversion.cxx b/toolkit/qa/cppunit/UnitConversion.cxx
new file mode 100644
index 0000000000..5e28667f5a
--- /dev/null
+++ b/toolkit/qa/cppunit/UnitConversion.cxx
@@ -0,0 +1,215 @@
+/* -*- 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 <test/bootstrapfixture.hxx>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/util/MeasureUnit.hpp>
+#include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
+#include <com/sun/star/awt/WindowAttribute.hpp>
+#include <com/sun/star/awt/WindowDescriptor.hpp>
+#include <com/sun/star/awt/XUnitConversion.hpp>
+#include <com/sun/star/awt/XWindowPeer.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+
+#ifdef _WIN32
+#include <windows.h>
+#endif
+
+using namespace ::com::sun::star;
+
+namespace
+{
+class ToolkitTest : public test::BootstrapFixture
+{
+public:
+ void testXUnitConversion();
+
+ CPPUNIT_TEST_SUITE(ToolkitTest);
+ CPPUNIT_TEST(testXUnitConversion);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+/**
+ * Creates a floating XWindow on the given position and size.
+ * @return a floating XWindow
+ * @param X the X-Position of the floating XWindow
+ * @param Y the Y-Position of the floating XWindow
+ * @param width the width of the floating XWindow
+ * @param height the height of the floating XWindow
+ * @param xMSF the MultiServiceFactory
+ */
+uno::Reference<awt::XWindowPeer>
+createFloatingWindow(uno::Reference<lang::XMultiServiceFactory> const& xMSF, sal_Int32 const nX,
+ sal_Int32 const nY, sal_Int32 const nWidth, sal_Int32 const nHeight)
+{
+ uno::Reference<awt::XToolkit> const xTk(xMSF->createInstance("com.sun.star.awt.Toolkit"),
+ uno::UNO_QUERY);
+
+ awt::WindowDescriptor descriptor;
+ descriptor.Type = awt::WindowClass_TOP;
+ descriptor.WindowServiceName = "modelessdialog";
+ descriptor.ParentIndex = -1;
+ descriptor.Bounds.X = nX;
+ descriptor.Bounds.Y = nY;
+ descriptor.Bounds.Width = nWidth;
+ descriptor.Bounds.Height = nHeight;
+ descriptor.WindowAttributes
+ = (awt::WindowAttribute::BORDER + awt::WindowAttribute::MOVEABLE
+ + awt::WindowAttribute::SIZEABLE + awt::WindowAttribute::CLOSEABLE
+ + awt::VclWindowPeerAttribute::CLIPCHILDREN);
+
+ return xTk->createWindow(descriptor);
+}
+
+/**
+ * Not really a check,
+ * only a simple test call to convertSizeToLogic(...) with different parameters
+ */
+void checkSize(uno::Reference<awt::XUnitConversion> const& xConv, awt::Size const& rSize,
+ sal_Int16 const nMeasureUnit, OUString const& rUnit)
+{
+ awt::Size const aSizeIn = xConv->convertSizeToLogic(rSize, nMeasureUnit);
+ std::cerr << "Window size:\n";
+ std::cerr << "Width: " << aSizeIn.Width << " " << rUnit << "\n";
+ std::cerr << "Height: " << aSizeIn.Height << " " << rUnit << "\n";
+}
+
+/**
+ * The real test function
+ * 2. try to create an empty window
+ * 3. try to convert the WindowPeer to an XWindow
+ * 4. try to resize and move the window to another position, so we get a well knowing position and size.
+ * 5. run some more tests
+ */
+void ToolkitTest::testXUnitConversion()
+{
+#ifdef _WIN32
+ HKEY hkey;
+ DWORD type;
+ DWORD data;
+ DWORD size(sizeof(data));
+ LONG ret = ::RegOpenKeyW(HKEY_CURRENT_USER, L"Control Panel\\Desktop", &hkey);
+ if (ret == ERROR_SUCCESS)
+ {
+ ret = ::RegQueryValueExW(hkey, L"LogPixels", nullptr, &type,
+ reinterpret_cast<LPBYTE>(&data), &size);
+ if (ret == ERROR_SUCCESS && type == REG_DWORD && data != 96)
+ {
+ std::cerr << "non-default resolution, skipping textXUnitConversion\n";
+ return;
+ }
+ }
+#endif
+
+ // create a window
+ sal_Int32 x = 100;
+ sal_Int32 y = 100;
+ sal_Int32 width = 640;
+ sal_Int32 height = 480;
+ uno::Reference<awt::XWindowPeer> const xWindowPeer
+ = createFloatingWindow(getMultiServiceFactory(), x, y, width, height);
+ CPPUNIT_ASSERT(xWindowPeer.is());
+
+ // resize and move the window to a well known position and size
+ uno::Reference<awt::XWindow> const xWindow(xWindowPeer, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xWindow.is());
+
+ xWindow->setVisible(true);
+
+ awt::Rectangle aRect = xWindow->getPosSize();
+ awt::Point aPoint(aRect.X, aRect.Y);
+ awt::Size aSize(aRect.Width, aRect.Height);
+
+ std::cerr << "Window position and size in pixel:\n";
+ std::cerr << "X: " << aPoint.X << "\n";
+ std::cerr << "Y: " << aPoint.Y << "\n";
+ std::cerr << "Width: " << aSize.Width << "\n";
+ std::cerr << "Height: " << aSize.Height << "\n";
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Window size wrong", width, aSize.Width);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Window size wrong", height, aSize.Height);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Window pos wrong", x, aPoint.X);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Window pos wrong", y, aPoint.Y);
+
+ uno::Reference<awt::XUnitConversion> const xConv(xWindowPeer, uno::UNO_QUERY);
+
+ // try to get the position of the window in 1/100mm with the XUnitConversion method
+ awt::Point const aPointInMM_100TH
+ = xConv->convertPointToLogic(aPoint, util::MeasureUnit::MM_100TH);
+ std::cerr << "Window position:\n";
+ std::cerr << "X: " << aPointInMM_100TH.X << " 1/100mm\n";
+ std::cerr << "Y: " << aPointInMM_100TH.Y << " 1/100mm\n";
+
+ // try to get the size of the window in 1/100mm with the XUnitConversion method
+ awt::Size const aSizeInMM_100TH = xConv->convertSizeToLogic(aSize, util::MeasureUnit::MM_100TH);
+ std::cerr << "Window size:\n";
+ std::cerr << "Width: " << aSizeInMM_100TH.Width << " 1/100mm\n";
+ std::cerr << "Height: " << aSizeInMM_100TH.Height << " 1/100mm\n";
+
+ // try to get the size of the window in 1/10mm with the XUnitConversion method
+ awt::Size const aSizeInMM_10TH = xConv->convertSizeToLogic(aSize, util::MeasureUnit::MM_10TH);
+ std::cerr << "Window size:\n";
+ std::cerr << "Width: " << aSizeInMM_10TH.Width << " 1/10mm\n";
+ std::cerr << "Height: " << aSizeInMM_10TH.Height << " 1/10mm\n";
+
+ // check the size with a delta which must be smaller a given difference
+ CPPUNIT_ASSERT_MESSAGE("Size.Width not correct",
+ std::abs(aSizeInMM_100TH.Width - aSizeInMM_10TH.Width * 10) < 10);
+ CPPUNIT_ASSERT_MESSAGE("Size.Height not correct",
+ std::abs(aSizeInMM_100TH.Height - aSizeInMM_10TH.Height * 10) < 10);
+
+ // new
+ checkSize(xConv, aSize, util::MeasureUnit::PIXEL, "pixel");
+ checkSize(xConv, aSize, util::MeasureUnit::APPFONT, "appfont");
+ checkSize(xConv, aSize, util::MeasureUnit::SYSFONT, "sysfont");
+
+ // simply check some more parameters
+ checkSize(xConv, aSize, util::MeasureUnit::MM, "mm");
+ checkSize(xConv, aSize, util::MeasureUnit::CM, "cm");
+ checkSize(xConv, aSize, util::MeasureUnit::INCH_1000TH, "1/1000inch");
+ checkSize(xConv, aSize, util::MeasureUnit::INCH_100TH, "1/100inch");
+ checkSize(xConv, aSize, util::MeasureUnit::INCH_10TH, "1/10inch");
+ checkSize(xConv, aSize, util::MeasureUnit::INCH, "inch");
+ checkSize(xConv, aSize, util::MeasureUnit::POINT, "point");
+ checkSize(xConv, aSize, util::MeasureUnit::TWIP, "twip");
+
+ // convert the 1/100mm window size back to pixel
+ awt::Size const aNewSize
+ = xConv->convertSizeToPixel(aSizeInMM_100TH, util::MeasureUnit::MM_100TH);
+ std::cerr << "Window size:\n";
+ std::cerr << "Width: " << aNewSize.Width << " pixel\n";
+ std::cerr << "Height: " << aNewSize.Height << " pixel\n";
+
+ // assure the pixels are the same as we already know
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("failed: Size from pixel to 1/100mm to pixel", aNewSize.Width,
+ aSize.Width);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("failed: Size from pixel to 1/100mm to pixel", aNewSize.Height,
+ aSize.Height);
+
+ // close the window.
+ xWindow->dispose();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ToolkitTest);
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx b/toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx
new file mode 100644
index 0000000000..5bf522fb2e
--- /dev/null
+++ b/toolkit/qa/cppunit/a11y/AccessibleStatusBarTest.cxx
@@ -0,0 +1,139 @@
+/* -*- 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 <string>
+
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <com/sun/star/accessibility/XAccessibleComponent.hpp>
+#include <com/sun/star/accessibility/XAccessibleContext.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <rtl/ustrbuf.hxx>
+#include <test/a11y/accessibletestbase.hxx>
+#include <vcl/scheduler.hxx>
+
+#include <test/a11y/AccessibilityTools.hxx>
+#include "XAccessibleComponentTester.hxx"
+#include "XAccessibleContextTester.hxx"
+#include "XAccessibleExtendedComponentTester.hxx"
+#include "XAccessibleEventBroadcasterTester.hxx"
+
+using namespace css;
+
+namespace
+{
+class AccessibleStatusBarTest : public test::AccessibleTestBase
+{
+private:
+ uno::Reference<accessibility::XAccessibleContext>
+ getTestObject(const uno::Reference<awt::XWindow>& xWindow);
+ void runAllTests();
+ void testDocument(std::string_view sKind);
+
+ void testWriterDoc() { testDocument("swriter"); }
+ void testMathDoc() { testDocument("smath"); }
+ void testDrawDoc() { testDocument("sdraw"); }
+ void testImpressDoc() { testDocument("simpress"); }
+ void testCalcDoc() { testDocument("scalc"); }
+
+public:
+ CPPUNIT_TEST_SUITE(AccessibleStatusBarTest);
+ CPPUNIT_TEST(testWriterDoc);
+ CPPUNIT_TEST(testMathDoc);
+ CPPUNIT_TEST(testDrawDoc);
+ CPPUNIT_TEST(testImpressDoc);
+ CPPUNIT_TEST(testCalcDoc);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+uno::Reference<accessibility::XAccessibleContext>
+AccessibleStatusBarTest::getTestObject(const uno::Reference<awt::XWindow>& xWindow)
+{
+ uno::Reference<accessibility::XAccessible> xAccessible(xWindow, uno::UNO_QUERY_THROW);
+ std::cout << "got accessible: " << xAccessible << std::endl;
+ std::cout << "accessible name: " << AccessibilityTools::debugString(xAccessible) << std::endl;
+
+ auto xContext = AccessibilityTools::getAccessibleObjectForRole(
+ xAccessible, accessibility::AccessibleRole::STATUS_BAR);
+ std::cout << "got context: " << xContext << std::endl;
+ std::cout << "context name: " << AccessibilityTools::debugString(xContext) << std::endl;
+
+ Scheduler::ProcessEventsToIdle(); // not sure why?
+
+ uno::Reference<lang::XServiceInfo> xSI(xContext, uno::UNO_QUERY_THROW);
+ std::cout << "implementation name: " << xSI->getImplementationName() << std::endl;
+ auto serviceNames = xSI->getSupportedServiceNames();
+ std::cout << "has " << serviceNames.size() << " services:" << std::endl;
+ for (auto& service : serviceNames)
+ std::cout << " * service: " << service << std::endl;
+
+ return xContext;
+}
+
+void AccessibleStatusBarTest::runAllTests()
+{
+ auto xContext = getTestObject(mxWindow);
+
+ uno::Reference<accessibility::XAccessibleComponent> xAccessibleComponent(xContext,
+ uno::UNO_QUERY_THROW);
+ XAccessibleComponentTester componentTester(xAccessibleComponent);
+ componentTester.testAll();
+
+ XAccessibleContextTester contextTester(xContext);
+ contextTester.testAll();
+
+ uno::Reference<accessibility::XAccessibleExtendedComponent> xAccessibleExtendedComponent(
+ xContext, uno::UNO_QUERY_THROW);
+ XAccessibleExtendedComponentTester extendedComponentTester(xAccessibleExtendedComponent);
+ extendedComponentTester.testAll();
+
+ uno::Reference<accessibility::XAccessibleEventBroadcaster> xAccessibleEventBroadcaster(
+ xContext, uno::UNO_QUERY_THROW);
+ XAccessibleEventBroadcasterTester eventBroadcasterTester(xAccessibleEventBroadcaster, mxWindow);
+ eventBroadcasterTester.testAll();
+}
+
+void AccessibleStatusBarTest::testDocument(std::string_view sKind)
+{
+ rtl::OUStringBuffer sURL("private:factory/");
+ sURL.appendAscii(sKind.data(), sKind.length());
+
+ load(sURL.makeStringAndClear());
+
+ std::cout << "got document: " << mxDocument << std::endl;
+
+ Scheduler::ProcessEventsToIdle();
+
+ runAllTests();
+
+ // close document
+ close();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(AccessibleStatusBarTest);
+} // namespace
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.cxx b/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.cxx
new file mode 100644
index 0000000000..fa5fb9f705
--- /dev/null
+++ b/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.cxx
@@ -0,0 +1,291 @@
+/* -*- 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 "XAccessibleComponentTester.hxx"
+
+#include <cppunit/TestAssert.h>
+
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <com/sun/star/accessibility/XAccessibleComponent.hpp>
+#include <com/sun/star/accessibility/XAccessibleContext.hpp>
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <tools/color.hxx>
+
+#include <test/a11y/AccessibilityTools.hxx>
+
+using namespace css;
+
+/**
+ * @brief Checks the component's bounds
+ *
+ * Checks the X and Y coordinates are non-negative, and that the width and
+ * height are greater than 0.
+ *
+ * Coherence with @c getLocation() is tested in the test for the
+ * latter.
+ */
+void XAccessibleComponentTester::testBounds()
+{
+ auto bounds = mxComponent->getBounds();
+ std::cout << "bounds: " << bounds.Width << "x" << bounds.Height << std::showpos << bounds.X
+ << bounds.Y << std::noshowpos << std::endl;
+ CPPUNIT_ASSERT_GREATEREQUAL(static_cast<sal_Int32>(0), bounds.X);
+ CPPUNIT_ASSERT_GREATEREQUAL(static_cast<sal_Int32>(0), bounds.Y);
+ CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(0), bounds.Width);
+ CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(0), bounds.Height);
+}
+
+/**
+ * @brief Tests results of XAccessibleComponent::getSize()
+ *
+ * Succeeds if the size is the same as in bounds.
+ */
+void XAccessibleComponentTester::testSize()
+{
+ auto bounds = mxComponent->getBounds();
+ auto size = mxComponent->getSize();
+ CPPUNIT_ASSERT_EQUAL(bounds.Width, size.Width);
+ CPPUNIT_ASSERT_EQUAL(bounds.Height, size.Height);
+}
+
+/**
+ * @brief Tests results of XAccessibleComponent::getBounds()
+ *
+ * First checks 4 inner bounds (upper, lower, left and right) of component
+ * bounding box to contain at least one point of the component. Second 4 outer
+ * bounds are checked to not contain any component points.
+ *
+ * Succeeds if inner bounds contain component points and outer bounds don't
+ * contain any component points.
+ */
+void XAccessibleComponentTester::testContainsPoint()
+{
+ auto bounds = mxComponent->getBounds();
+
+ /* upper end */
+ int curX = 0;
+ while (!mxComponent->containsPoint(awt::Point(curX, 0)) && curX < bounds.Width)
+ curX++;
+ CPPUNIT_ASSERT_MESSAGE("Upper bound of box contains no component points", curX < bounds.Width);
+ std::cout << "Upper bound of box contains point (" << curX << ",0)" << std::endl;
+ /* lower end */
+ curX = 0;
+ while (!mxComponent->containsPoint(awt::Point(curX, bounds.Height - 1)) && curX < bounds.Width)
+ curX++;
+ CPPUNIT_ASSERT_MESSAGE("Lower bound of box contains no component points", curX < bounds.Width);
+ std::cout << "Lower bound of box contains point (" << curX << "," << (bounds.Height - 1) << ")"
+ << std::endl;
+ /* left end */
+ int curY = 0;
+ while (!mxComponent->containsPoint(awt::Point(0, curY)) && curY < bounds.Height)
+ curY++;
+ CPPUNIT_ASSERT_MESSAGE("Left bound of box contains no component points", curY < bounds.Height);
+ std::cout << "Left bound of box contains point (0," << curY << ")" << std::endl;
+ /* right end */
+ curY = 0;
+ while (!mxComponent->containsPoint(awt::Point(bounds.Width - 1, curY)) && curY < bounds.Height)
+ curY++;
+ CPPUNIT_ASSERT_MESSAGE("Right bound of box contains no component points", curY < bounds.Height);
+ std::cout << "Right bound of box contains point (" << (bounds.Width - 1) << "," << curY << ")"
+ << std::endl;
+ /* no match outside the bounds */
+ for (int x = -1; x <= bounds.Width; x++)
+ {
+ CPPUNIT_ASSERT_MESSAGE("Outer upper bound CONTAINS a component point",
+ !mxComponent->containsPoint(awt::Point(x, -1)));
+ CPPUNIT_ASSERT_MESSAGE("Outer lower bound CONTAINS a component point",
+ !mxComponent->containsPoint(awt::Point(x, bounds.Height)));
+ }
+ for (int y = -1; y <= bounds.Height; y++)
+ {
+ CPPUNIT_ASSERT_MESSAGE("Outer left bound CONTAINS a component point",
+ !mxComponent->containsPoint(awt::Point(-1, y)));
+ CPPUNIT_ASSERT_MESSAGE("Outer right bound CONTAINS a component point",
+ !mxComponent->containsPoint(awt::Point(bounds.Width, y)));
+ }
+}
+
+/**
+ * @brief Tests results of XAccessibleComponent::getAccessibleAtPoint()
+ *
+ * Iterates through all children which implement
+ * <code>XAccessibleComponent</code> (if they exist) determines their
+ * boundaries and tries to get each child by <code>getAccessibleAtPoint</code>
+ * passing point which belongs to the child.
+ * Also the point is checked which doesn't belong to child boundary box.
+ *
+ * Succeeds if in the first cases the right children are returned, and in the
+ * second <code>null</code> or another child is returned.
+ */
+void XAccessibleComponentTester::testAccessibleAtPoint()
+{
+ sal_Int64 count = mxContext->getAccessibleChildCount();
+ std::cout << "Found " << count << " children" << std::endl;
+ for (sal_Int64 i = 0; i < count && i < AccessibilityTools::MAX_CHILDREN; i++)
+ {
+ auto child = mxContext->getAccessibleChild(i);
+ uno::Reference<accessibility::XAccessibleContext> childContext(
+ child->getAccessibleContext(), uno::UNO_SET_THROW);
+ std::cout << "* Found child: " << AccessibilityTools::debugString(child) << std::endl;
+ std::cout << " states: "
+ << AccessibilityTools::debugAccessibleStateSet(
+ childContext->getAccessibleStateSet())
+ << std::endl;
+ uno::Reference<accessibility::XAccessibleComponent> xChildComponent(childContext,
+ uno::UNO_QUERY);
+ std::cout << " component: " << xChildComponent << std::endl;
+ if (!xChildComponent)
+ continue;
+
+ auto childBounds = xChildComponent->getBounds();
+ if (childBounds.X == -1)
+ continue;
+ std::cout << " bounds: " << childBounds.Width << "x" << childBounds.Height << std::showpos
+ << childBounds.X << childBounds.Y << std::noshowpos << std::endl;
+
+ std::cout << "finding the point which lies on the component" << std::endl;
+ int curX = 0;
+ int curY = 0;
+ while (!xChildComponent->containsPoint(awt::Point(curX, curY)) && curX < childBounds.Width)
+ {
+ curX++;
+ curY++;
+ }
+ if (curX >= childBounds.Width)
+ {
+ std::cout << "Couldn't find a point with contains" << std::endl;
+ continue;
+ }
+ else
+ {
+ std::cout << "Child found at point +" << childBounds.X + curX << "+"
+ << childBounds.Y + curY << std::endl;
+ }
+
+ // trying the point laying on child
+ auto xAccAtPoint
+ = mxComponent->getAccessibleAtPoint(awt::Point(childBounds.X, childBounds.Y));
+ 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)
+ {
+ std::cout << "-- it probably is hidden behind? Skipping." << std::endl;
+ }
+ else
+ {
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("The child found is NOT the expected one", child,
+ xAccAtPoint);
+ }
+ }
+
+ // trying the point NOT laying on child
+ xAccAtPoint
+ = mxComponent->getAccessibleAtPoint(awt::Point(childBounds.X - 1, childBounds.Y - 1));
+ if (xAccAtPoint.is())
+ {
+ CPPUNIT_ASSERT_MESSAGE("Child found OUTSIDE its bounds",
+ !AccessibilityTools::equals(child, xAccAtPoint));
+ }
+ }
+}
+
+/**
+ * @brief Tests results of XAccessibleComponent::getLocation()
+ *
+ * Succeeds if the location is the same as location of boundary obtained by
+ * the <code>getBounds()</code> method.
+ */
+void XAccessibleComponentTester::testLocation()
+{
+ auto bounds = mxComponent->getBounds();
+ auto location = mxComponent->getLocation();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid X location", bounds.X, location.X);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid Y location", bounds.Y, location.Y);
+}
+
+/**
+ * @brief Tests results of XAccessibleComponent::getLocationOnScreen()
+ * @returns @c true on success.
+ *
+ * Get the screen location of the component and its parent
+ * (if it exists and supports <code>XAccessibleComponent</code>).
+ *
+ * Succeeds component screen location equals to screen location of its parent
+ * plus location of the component relative to the parent.
+ */
+void XAccessibleComponentTester::testLocationOnScreen()
+{
+ auto location = mxComponent->getLocationOnScreen();
+ std::cout << "location on screen: +" << location.X << "+" << location.Y << std::endl;
+
+ auto xParent = mxContext->getAccessibleParent();
+ if (!xParent.is())
+ std::cout << "No parent" << std::endl;
+ else
+ {
+ std::cout << "Found parent: " << AccessibilityTools::debugString(xParent) << std::endl;
+ uno::Reference<accessibility::XAccessibleComponent> xParentComponent(
+ xParent->getAccessibleContext(), uno::UNO_QUERY);
+ if (!xParentComponent.is())
+ std::cout << "Parent is not a Component" << std::endl;
+ else
+ {
+ auto bounds = mxComponent->getBounds();
+ auto parentLocation = xParentComponent->getLocationOnScreen();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid X screen location", parentLocation.X + bounds.X,
+ location.X);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid Y screen location", parentLocation.Y + bounds.Y,
+ location.Y);
+ }
+ }
+}
+
+/**
+ * Just calls the method.
+ */
+void XAccessibleComponentTester::testGrabFocus() { mxComponent->grabFocus(); }
+
+/**
+ * Just calls the method.
+ */
+void XAccessibleComponentTester::testGetForeground()
+{
+ auto color = mxComponent->getForeground();
+ std::cout << "foreground color: " << Color(ColorAlpha, color) << std::endl;
+}
+
+/**
+ * Just calls the method.
+ */
+void XAccessibleComponentTester::testGetBackground()
+{
+ auto color = mxComponent->getBackground();
+ std::cout << "background color: " << Color(ColorAlpha, color) << std::endl;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.hxx b/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.hxx
new file mode 100644
index 0000000000..5965374a3f
--- /dev/null
+++ b/toolkit/qa/cppunit/a11y/XAccessibleComponentTester.hxx
@@ -0,0 +1,66 @@
+/* -*- 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 <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
+{
+private:
+ const css::uno::Reference<css::accessibility::XAccessibleComponent> mxComponent;
+ const css::uno::Reference<css::accessibility::XAccessibleContext> mxContext;
+
+public:
+ XAccessibleComponentTester(
+ const css::uno::Reference<css::accessibility::XAccessibleComponent>& component)
+ : mxComponent(component)
+ , mxContext(component, css::uno::UNO_QUERY_THROW)
+ {
+ }
+
+ void testBounds();
+ void testSize();
+ void testContainsPoint();
+ void testAccessibleAtPoint();
+ void testLocation();
+ void testLocationOnScreen();
+ void testGrabFocus();
+ void testGetForeground();
+ void testGetBackground();
+
+ void testAll()
+ {
+ testBounds();
+ testSize();
+ testContainsPoint();
+ testAccessibleAtPoint();
+ testLocation();
+ testLocationOnScreen();
+ testGrabFocus();
+ testGetForeground();
+ testGetBackground();
+ }
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/toolkit/qa/cppunit/a11y/XAccessibleContextTester.cxx b/toolkit/qa/cppunit/a11y/XAccessibleContextTester.cxx
new file mode 100644
index 0000000000..9d7fdb992e
--- /dev/null
+++ b/toolkit/qa/cppunit/a11y/XAccessibleContextTester.cxx
@@ -0,0 +1,164 @@
+/* -*- 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 "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>
+
+/**
+ * @brief Tries to get every child and checks its parent.
+ *
+ * Checks that the parent of every child and the tested component are the same object.
+ */
+void XAccessibleContextTester::testGetAccessibleChild()
+{
+ sal_Int64 count = mxContext->getAccessibleChildCount();
+ for (sal_Int64 i = 0; i < count && i < AccessibilityTools::MAX_CHILDREN; i++)
+ {
+ auto child = mxContext->getAccessibleChild(i);
+ auto childCtx = child->getAccessibleContext();
+
+ std::cout << " Child " << i << ": " << AccessibilityTools::debugString(childCtx)
+ << std::endl;
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("child's parent context is not parent's context!",
+ childCtx->getAccessibleParent()->getAccessibleContext(),
+ mxContext);
+ }
+}
+
+/**
+ * @brief Calls the method.
+ *
+ * Checks that the child count is non-negative.
+ */
+void XAccessibleContextTester::testGetAccessibleChildCount()
+{
+ sal_Int64 childCount = mxContext->getAccessibleChildCount();
+ std::cout << childCount << " children found." << std::endl;
+ CPPUNIT_ASSERT_GREATEREQUAL(static_cast<sal_Int64>(0), childCount);
+}
+
+/**
+ * @brief Get the accessible description of the component.
+ */
+void XAccessibleContextTester::testGetAccessibleDescription()
+{
+ auto desc = mxContext->getAccessibleDescription();
+ std::cout << "The description is '" << desc << "'" << std::endl;
+}
+
+/**
+ * @brief Checks the index in parent
+ *
+ * Checks that the parent's child and the tested component are the same objects.
+ *
+ * Retrieves the index of tested component in its parent.
+ * Then gets the parent's child by this index and compares
+ * it with tested component.
+ */
+void XAccessibleContextTester::testGetAccessibleIndexInParent()
+{
+ sal_Int64 idx = mxContext->getAccessibleIndexInParent();
+ std::cout << "The index in parent is " << idx << std::endl;
+
+ auto parent = mxContext->getAccessibleParent();
+ CPPUNIT_ASSERT(parent.is());
+ auto parentCtx = parent->getAccessibleContext();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Parent's child context at our index is not us!", mxContext,
+ parentCtx->getAccessibleChild(idx)->getAccessibleContext());
+}
+
+/**
+ * @brief Get the accessible name of the component.
+ */
+void XAccessibleContextTester::testGetAccessibleName()
+{
+ auto name = mxContext->getAccessibleName();
+ std::cout << "The name is '" << name << "'" << std::endl;
+}
+
+/**
+ * @brief Just gets the parent.
+ *
+ * Checks that the parent is not null.
+ */
+void XAccessibleContextTester::testGetAccessibleParent()
+{
+ // assume that the component is not ROOT
+ auto parent = mxContext->getAccessibleParent();
+ std::cout << "The parent is " << AccessibilityTools::debugString(parent) << std::endl;
+ CPPUNIT_ASSERT_MESSAGE("parent is not set", parent.is());
+}
+
+/**
+ * @brief Just gets the relation set.
+ *
+ * Checks that the relation set is not null.
+ */
+void XAccessibleContextTester::testGetAccessibleRelationSet()
+{
+ auto relSet = mxContext->getAccessibleRelationSet();
+ CPPUNIT_ASSERT_MESSAGE("relation set is not set", relSet.is());
+}
+
+/**
+ * @brief Get the accessible role of component.
+ *
+ * Checks that the role is a non-negative number.
+ */
+void XAccessibleContextTester::testGetAccessibleRole()
+{
+ sal_Int32 role = mxContext->getAccessibleRole();
+ std::cout << "The role is " << role << " (" << AccessibilityTools::getRoleName(role) << ")"
+ << std::endl;
+ CPPUNIT_ASSERT_GREATEREQUAL(static_cast<sal_Int32>(0), role);
+}
+
+/**
+ * @brief Just gets the state set.
+ *
+ * Checks that the state set is not null.
+ */
+void XAccessibleContextTester::testGetAccessibleStateSet()
+{
+ sal_Int64 stateSet = mxContext->getAccessibleStateSet();
+ std::cout << "The state set is: " << AccessibilityTools::debugAccessibleStateSet(stateSet)
+ << std::endl;
+}
+
+/**
+ * @brief Gets the locale.
+ *
+ * Checks that @c Country and @c Language fields of locale structure are not empty.
+ */
+void XAccessibleContextTester::testGetLocale()
+{
+ auto loc = mxContext->getLocale();
+ std::cout << "The locale is " << loc.Language << "," << loc.Country << std::endl;
+ CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(0), loc.Language.getLength());
+ CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(0), loc.Country.getLength());
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/toolkit/qa/cppunit/a11y/XAccessibleContextTester.hxx b/toolkit/qa/cppunit/a11y/XAccessibleContextTester.hxx
new file mode 100644
index 0000000000..b399028cf8
--- /dev/null
+++ b/toolkit/qa/cppunit/a11y/XAccessibleContextTester.hxx
@@ -0,0 +1,62 @@
+/* -*- 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 <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/accessibility/XAccessibleContext.hpp>
+
+class XAccessibleContextTester
+{
+protected:
+ const css::uno::Reference<css::accessibility::XAccessibleContext> mxContext;
+
+public:
+ XAccessibleContextTester(const css::uno::Reference<css::accessibility::XAccessibleContext>& ctx)
+ : mxContext(ctx)
+ {
+ }
+
+ void testGetAccessibleChild();
+ void testGetAccessibleChildCount();
+ void testGetAccessibleDescription();
+ void testGetAccessibleIndexInParent();
+ void testGetAccessibleName();
+ void testGetAccessibleParent();
+ void testGetAccessibleRelationSet();
+ void testGetAccessibleRole();
+ void testGetAccessibleStateSet();
+ void testGetLocale();
+
+ void testAll()
+ {
+ testGetAccessibleChild();
+ testGetAccessibleChildCount();
+ testGetAccessibleDescription();
+ testGetAccessibleIndexInParent();
+ testGetAccessibleName();
+ testGetAccessibleParent();
+ testGetAccessibleRelationSet();
+ testGetAccessibleRole();
+ testGetAccessibleStateSet();
+ testGetLocale();
+ }
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.cxx b/toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.cxx
new file mode 100644
index 0000000000..852c91c341
--- /dev/null
+++ b/toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.cxx
@@ -0,0 +1,185 @@
+/* -*- 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 "XAccessibleEventBroadcasterTester.hxx"
+
+#include <iostream>
+
+#include <cppunit/TestAssert.h>
+
+#include <com/sun/star/accessibility/AccessibleEventObject.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <com/sun/star/accessibility/XAccessibleContext.hpp>
+#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
+#include <com/sun/star/accessibility/XAccessibleEventListener.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/lang/EventObject.hpp>
+
+#include <cppuhelper/implbase.hxx>
+#include <rtl/ref.hxx>
+#include <sal/log.hxx>
+
+#include <test/a11y/AccessibilityTools.hxx>
+
+using namespace css;
+
+namespace
+{
+class EvListener : public cppu::WeakImplHelper<accessibility::XAccessibleEventListener>
+{
+public:
+ bool mbGotEvent;
+
+ EvListener()
+ : mbGotEvent(false)
+ {
+ }
+
+ // XEventListener
+ virtual void SAL_CALL disposing(const lang::EventObject&) override {}
+
+ // XAccessibleEventListener
+ virtual void SAL_CALL notifyEvent(const accessibility::AccessibleEventObject& aEvent) override
+ {
+ std::cout << "Listener got event: " << AccessibilityTools::debugString(aEvent) << std::endl;
+ uno::Reference<accessibility::XAccessible> xOld(aEvent.OldValue, uno::UNO_QUERY);
+ if (xOld.is())
+ std::cout << "Old: " << AccessibilityTools::debugString(xOld) << std::endl;
+
+ uno::Reference<accessibility::XAccessible> xNew(aEvent.NewValue, uno::UNO_QUERY);
+ if (xNew.is())
+ std::cout << "New: " << AccessibilityTools::debugString(xNew) << std::endl;
+
+ mbGotEvent = true;
+ }
+};
+}
+
+XAccessibleEventBroadcasterTester::XAccessibleEventBroadcasterTester(
+ const uno::Reference<accessibility::XAccessibleEventBroadcaster>& xBroadcaster,
+ const uno::Reference<awt::XWindow>& xWindow)
+ : mxBroadcaster(xBroadcaster)
+ , mxWindow(xWindow)
+{
+}
+
+bool XAccessibleEventBroadcasterTester::isTransient(
+ const uno::Reference<accessibility::XAccessibleEventBroadcaster> xBroadcaster)
+{
+ uno::Reference<accessibility::XAccessibleContext> xCtx(xBroadcaster, uno::UNO_QUERY_THROW);
+ return isTransient(xCtx);
+}
+
+bool XAccessibleEventBroadcasterTester::isTransient(
+ const uno::Reference<accessibility::XAccessibleContext> xCtx)
+{
+ return ((xCtx->getAccessibleStateSet() & accessibility::AccessibleStateType::TRANSIENT)
+ && (xCtx->getAccessibleParent()->getAccessibleContext()->getAccessibleStateSet()
+ & accessibility::AccessibleStateType::MANAGES_DESCENDANTS));
+}
+
+/**
+ * @brief Generates an event on @c mxBroadcaster.
+ *
+ * This method indirectly alters the state of @c mxBroadcaster so that an
+ * accessible event will be fired for it. It can be called as many times as
+ * needed and triggers an event each time.
+ */
+void XAccessibleEventBroadcasterTester::fireEvent()
+{
+ awt::Rectangle newPosSize = mxWindow->getPosSize();
+ newPosSize.Width = newPosSize.Width - 20;
+ newPosSize.Height = newPosSize.Height - 20;
+ newPosSize.X = newPosSize.X + 20;
+ newPosSize.Y = newPosSize.Y + 20;
+ mxWindow->setPosSize(newPosSize.X, newPosSize.Y, newPosSize.Width, newPosSize.Height,
+ awt::PosSize::POSSIZE);
+}
+
+/**
+ * @brief Adds a listener and fires events by mean of object relation.
+ *
+ * Asserts that the listener was properly called.
+ */
+void XAccessibleEventBroadcasterTester::testAddEventListener()
+{
+ rtl::Reference<EvListener> xListener(new EvListener);
+ mxBroadcaster->addAccessibleEventListener(xListener);
+ bool transient = isTransient(mxBroadcaster);
+
+ std::cout << "firing event" << std::endl;
+ fireEvent();
+
+ AccessibilityTools::Await([&xListener]() { return xListener->mbGotEvent; });
+
+ if (!transient)
+ CPPUNIT_ASSERT_MESSAGE("listener wasn't called", xListener->mbGotEvent);
+ else
+ CPPUNIT_ASSERT_MESSAGE("Object is Transient, listener isn't expected to be called",
+ !xListener->mbGotEvent);
+
+ mxBroadcaster->removeAccessibleEventListener(xListener);
+}
+
+/**
+ * @brief Similar to @c testAddEventListener() but also removes the listener
+ *
+ * Adds an event listener just like @c testAddEventListener(), and then removes it and verifies an
+ * event doesn't trigger the supposedly removed listener.
+ *
+ * @see testAddEventListener()
+ */
+void XAccessibleEventBroadcasterTester::testRemoveEventListener()
+{
+ /* there is nothing we can really test for transient objects */
+ if (isTransient(mxBroadcaster))
+ {
+ std::cerr << "could not test removing listener on transient object " << mxBroadcaster
+ << std::endl;
+ return;
+ }
+
+ rtl::Reference<EvListener> xListener(new EvListener);
+ mxBroadcaster->addAccessibleEventListener(xListener);
+
+ std::cout << "firing event (with listener)" << std::endl;
+ fireEvent();
+
+ AccessibilityTools::Await([&xListener]() { return xListener->mbGotEvent; });
+
+ CPPUNIT_ASSERT_MESSAGE("listener wasn't called", xListener->mbGotEvent);
+
+ /* reset listener, remove it and try again */
+ xListener->mbGotEvent = false;
+
+ std::cout << "removing listener" << std::endl;
+ mxBroadcaster->removeAccessibleEventListener(xListener);
+
+ std::cout << "firing event (without listener)" << std::endl;
+ fireEvent();
+
+ AccessibilityTools::Wait(500);
+
+ CPPUNIT_ASSERT_MESSAGE("removed listener was called", !xListener->mbGotEvent);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.hxx b/toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.hxx
new file mode 100644
index 0000000000..0fc7c23bd3
--- /dev/null
+++ b/toolkit/qa/cppunit/a11y/XAccessibleEventBroadcasterTester.hxx
@@ -0,0 +1,54 @@
+/* -*- 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 <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
+{
+private:
+ const css::uno::Reference<css::accessibility::XAccessibleEventBroadcaster> mxBroadcaster;
+ const css::uno::Reference<css::awt::XWindow> mxWindow;
+
+ static bool isTransient(
+ const css::uno::Reference<css::accessibility::XAccessibleEventBroadcaster> xBroadcaster);
+ static bool isTransient(const css::uno::Reference<css::accessibility::XAccessibleContext> xCtx);
+
+ void fireEvent();
+
+public:
+ XAccessibleEventBroadcasterTester(
+ const css::uno::Reference<css::accessibility::XAccessibleEventBroadcaster>& xBroadcaster,
+ const css::uno::Reference<css::awt::XWindow>& xWindow);
+
+ void testAddEventListener();
+ void testRemoveEventListener();
+
+ void testAll()
+ {
+ testAddEventListener();
+ testRemoveEventListener();
+ }
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.cxx b/toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.cxx
new file mode 100644
index 0000000000..a7137c4ba5
--- /dev/null
+++ b/toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.cxx
@@ -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 .
+ */
+
+#include "XAccessibleExtendedComponentTester.hxx"
+
+#include <iostream>
+
+#include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp>
+
+/**
+ * @brief Just calls the method.
+ */
+void XAccessibleExtendedComponentTester::testGetFont()
+{
+ auto font = mxExtendedComponent->getFont();
+ std::cout << "font: " << font << std::endl;
+}
+
+/**
+ * @brief Just calls the method.
+ */
+void XAccessibleExtendedComponentTester::testGetTitledBorderText()
+{
+ auto titleBorderText = mxExtendedComponent->getTitledBorderText();
+ std::cout << "getTitledBorderText(): '" << titleBorderText << "'" << std::endl;
+}
+
+/**
+ * @brief Just calls the method.
+ */
+void XAccessibleExtendedComponentTester::testGetToolTipText()
+{
+ auto toolTipText = mxExtendedComponent->getToolTipText();
+ std::cout << "getToolTipText(): '" << toolTipText << "'" << std::endl;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.hxx b/toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.hxx
new file mode 100644
index 0000000000..1297052822
--- /dev/null
+++ b/toolkit/qa/cppunit/a11y/XAccessibleExtendedComponentTester.hxx
@@ -0,0 +1,50 @@
+/* -*- 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 <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp>
+
+class XAccessibleExtendedComponentTester
+{
+protected:
+ const css::uno::Reference<css::accessibility::XAccessibleExtendedComponent> mxExtendedComponent;
+
+public:
+ XAccessibleExtendedComponentTester(
+ const css::uno::Reference<css::accessibility::XAccessibleExtendedComponent>&
+ extendedComponent)
+ : mxExtendedComponent(extendedComponent)
+ {
+ }
+
+ void testGetFont();
+ void testGetTitledBorderText();
+ void testGetToolTipText();
+
+ void testAll()
+ {
+ testGetFont();
+ testGetTitledBorderText();
+ testGetToolTipText();
+ }
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */