LibreOffice Module vcl (master) 1
uitest_uno.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 */
9
13#include <com/sun/star/lang/XServiceInfo.hpp>
14#include <com/sun/star/uno/XComponentContext.hpp>
15#include <com/sun/star/ui/test/XUITest.hpp>
16
17#include <memory>
18
19#include <vcl/uitest/uitest.hxx>
20#include <vcl/svapp.hxx>
21#include <vcl/window.hxx>
22
23#include "uiobject_uno.hxx"
24
25namespace
26{
27 typedef ::cppu::WeakComponentImplHelper <
28 css::ui::test::XUITest, css::lang::XServiceInfo
29 > UITestBase;
30
31class UITestUnoObj : public cppu::BaseMutex,
32 public UITestBase
33{
34private:
35 std::unique_ptr<UITest> mpUITest;
36
37public:
38
39 UITestUnoObj();
40
41 sal_Bool SAL_CALL executeCommand(const OUString& rCommand) override;
42
43 sal_Bool SAL_CALL executeCommandWithParameters(const OUString& rCommand,
44 const css::uno::Sequence< css::beans::PropertyValue >& rArgs) override;
45
46 sal_Bool SAL_CALL executeDialog(const OUString& rCommand) override;
47
48 css::uno::Reference<css::ui::test::XUIObject> SAL_CALL getTopFocusWindow() override;
49
50 css::uno::Reference<css::ui::test::XUIObject> SAL_CALL getFloatWindow() override;
51
52 OUString SAL_CALL getImplementationName() override;
53
54 sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override;
55
56 css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
57};
58
59}
60
61UITestUnoObj::UITestUnoObj():
62 UITestBase(m_aMutex),
63 mpUITest(new UITest)
64{
65}
66
67sal_Bool SAL_CALL UITestUnoObj::executeCommand(const OUString& rCommand)
68{
69 SolarMutexGuard aGuard;
70 return UITest::executeCommand(rCommand);
71}
72
73sal_Bool SAL_CALL UITestUnoObj::executeCommandWithParameters(const OUString& rCommand,
74 const css::uno::Sequence< css::beans::PropertyValue >& rArgs)
75{
76 SolarMutexGuard aGuard;
77 return UITest::executeCommandWithParameters(rCommand,rArgs);
78}
79
80sal_Bool SAL_CALL UITestUnoObj::executeDialog(const OUString& rCommand)
81{
82 SolarMutexGuard aGuard;
83 return UITest::executeDialog(rCommand);
84}
85
86css::uno::Reference<css::ui::test::XUIObject> SAL_CALL UITestUnoObj::getTopFocusWindow()
87{
88 SolarMutexGuard aGuard;
89 std::unique_ptr<UIObject> pObj = UITest::getFocusTopWindow();
90 return new UIObjectUnoObj(std::move(pObj));
91}
92
93css::uno::Reference<css::ui::test::XUIObject> SAL_CALL UITestUnoObj::getFloatWindow()
94{
95 SolarMutexGuard aGuard;
96 std::unique_ptr<UIObject> pObj = UITest::getFloatWindow();
97 return new UIObjectUnoObj(std::move(pObj));
98}
99
100OUString SAL_CALL UITestUnoObj::getImplementationName()
101{
102 return "org.libreoffice.uitest.UITest";
103}
104
105sal_Bool UITestUnoObj::supportsService(OUString const & ServiceName)
106{
107 return cppu::supportsService(this, ServiceName);
108}
109
110css::uno::Sequence<OUString> UITestUnoObj::getSupportedServiceNames()
111{
112 return { "com.sun.star.ui.test.UITest" };
113}
114
115extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
116UITest_get_implementation(css::uno::XComponentContext*, css::uno::Sequence<css::uno::Any> const &)
117{
118 return cppu::acquire(new UITestUnoObj());
119}
120
121/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static std::unique_ptr< UIObject > getFocusTopWindow()
Definition: uitest.cxx:55
static bool executeCommand(const OUString &rCommand)
Definition: uitest.cxx:22
static std::unique_ptr< UIObject > getFloatWindow()
Definition: uitest.cxx:68
static bool executeDialog(const OUString &rCommand)
Definition: uitest.cxx:47
static bool executeCommandWithParameters(const OUString &rCommand, const css::uno::Sequence< css::beans::PropertyValue > &rArgs)
Definition: uitest.cxx:30
std::mutex m_aMutex
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
unsigned char sal_Bool
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * UITest_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
Definition: uitest_uno.cxx:116