tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / toolkit / qa / cppunit / a11y / AccessibleStatusBarTest.cxx
blob5bf522fb2e2ebd946e0e35f031cc42d99a21aa79
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <string>
22 #include <com/sun/star/accessibility/AccessibleRole.hpp>
23 #include <com/sun/star/accessibility/XAccessible.hpp>
24 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
25 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
26 #include <com/sun/star/awt/XWindow.hpp>
27 #include <com/sun/star/frame/Desktop.hpp>
28 #include <com/sun/star/frame/XFrame.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/uno/Reference.hxx>
32 #include <rtl/ustrbuf.hxx>
33 #include <test/a11y/accessibletestbase.hxx>
34 #include <vcl/scheduler.hxx>
36 #include <test/a11y/AccessibilityTools.hxx>
37 #include "XAccessibleComponentTester.hxx"
38 #include "XAccessibleContextTester.hxx"
39 #include "XAccessibleExtendedComponentTester.hxx"
40 #include "XAccessibleEventBroadcasterTester.hxx"
42 using namespace css;
44 namespace
46 class AccessibleStatusBarTest : public test::AccessibleTestBase
48 private:
49 uno::Reference<accessibility::XAccessibleContext>
50 getTestObject(const uno::Reference<awt::XWindow>& xWindow);
51 void runAllTests();
52 void testDocument(std::string_view sKind);
54 void testWriterDoc() { testDocument("swriter"); }
55 void testMathDoc() { testDocument("smath"); }
56 void testDrawDoc() { testDocument("sdraw"); }
57 void testImpressDoc() { testDocument("simpress"); }
58 void testCalcDoc() { testDocument("scalc"); }
60 public:
61 CPPUNIT_TEST_SUITE(AccessibleStatusBarTest);
62 CPPUNIT_TEST(testWriterDoc);
63 CPPUNIT_TEST(testMathDoc);
64 CPPUNIT_TEST(testDrawDoc);
65 CPPUNIT_TEST(testImpressDoc);
66 CPPUNIT_TEST(testCalcDoc);
67 CPPUNIT_TEST_SUITE_END();
70 uno::Reference<accessibility::XAccessibleContext>
71 AccessibleStatusBarTest::getTestObject(const uno::Reference<awt::XWindow>& xWindow)
73 uno::Reference<accessibility::XAccessible> xAccessible(xWindow, uno::UNO_QUERY_THROW);
74 std::cout << "got accessible: " << xAccessible << std::endl;
75 std::cout << "accessible name: " << AccessibilityTools::debugString(xAccessible) << std::endl;
77 auto xContext = AccessibilityTools::getAccessibleObjectForRole(
78 xAccessible, accessibility::AccessibleRole::STATUS_BAR);
79 std::cout << "got context: " << xContext << std::endl;
80 std::cout << "context name: " << AccessibilityTools::debugString(xContext) << std::endl;
82 Scheduler::ProcessEventsToIdle(); // not sure why?
84 uno::Reference<lang::XServiceInfo> xSI(xContext, uno::UNO_QUERY_THROW);
85 std::cout << "implementation name: " << xSI->getImplementationName() << std::endl;
86 auto serviceNames = xSI->getSupportedServiceNames();
87 std::cout << "has " << serviceNames.size() << " services:" << std::endl;
88 for (auto& service : serviceNames)
89 std::cout << " * service: " << service << std::endl;
91 return xContext;
94 void AccessibleStatusBarTest::runAllTests()
96 auto xContext = getTestObject(mxWindow);
98 uno::Reference<accessibility::XAccessibleComponent> xAccessibleComponent(xContext,
99 uno::UNO_QUERY_THROW);
100 XAccessibleComponentTester componentTester(xAccessibleComponent);
101 componentTester.testAll();
103 XAccessibleContextTester contextTester(xContext);
104 contextTester.testAll();
106 uno::Reference<accessibility::XAccessibleExtendedComponent> xAccessibleExtendedComponent(
107 xContext, uno::UNO_QUERY_THROW);
108 XAccessibleExtendedComponentTester extendedComponentTester(xAccessibleExtendedComponent);
109 extendedComponentTester.testAll();
111 uno::Reference<accessibility::XAccessibleEventBroadcaster> xAccessibleEventBroadcaster(
112 xContext, uno::UNO_QUERY_THROW);
113 XAccessibleEventBroadcasterTester eventBroadcasterTester(xAccessibleEventBroadcaster, mxWindow);
114 eventBroadcasterTester.testAll();
117 void AccessibleStatusBarTest::testDocument(std::string_view sKind)
119 rtl::OUStringBuffer sURL("private:factory/");
120 sURL.appendAscii(sKind.data(), sKind.length());
122 load(sURL.makeStringAndClear());
124 std::cout << "got document: " << mxDocument << std::endl;
126 Scheduler::ProcessEventsToIdle();
128 runAllTests();
130 // close document
131 close();
134 CPPUNIT_TEST_SUITE_REGISTRATION(AccessibleStatusBarTest);
135 } // namespace
137 CPPUNIT_PLUGIN_IMPLEMENT();
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */