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 
10 #include <cppuhelper/compbase.hxx>
11 #include <cppuhelper/basemutex.hxx>
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 
22 #include "uiobject_uno.hxx"
23 
24 namespace
25 {
26  typedef ::cppu::WeakComponentImplHelper <
27  css::ui::test::XUITest, css::lang::XServiceInfo
28  > UITestBase;
29 }
30 
32  public UITestBase
33 {
34 private:
35  std::unique_ptr<UITest> mpUITest;
36 
37 public:
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 
60  UITestBase(m_aMutex),
61  mpUITest(new UITest)
62 {
63 }
64 
65 sal_Bool SAL_CALL UITestUnoObj::executeCommand(const OUString& rCommand)
66 {
67  SolarMutexGuard aGuard;
68  return UITest::executeCommand(rCommand);
69 }
70 
71 sal_Bool SAL_CALL UITestUnoObj::executeCommandWithParameters(const OUString& rCommand,
72  const css::uno::Sequence< css::beans::PropertyValue >& rArgs)
73 {
74  SolarMutexGuard aGuard;
75  return UITest::executeCommandWithParameters(rCommand,rArgs);
76 }
77 
78 sal_Bool SAL_CALL UITestUnoObj::executeDialog(const OUString& rCommand)
79 {
80  SolarMutexGuard aGuard;
81  return UITest::executeDialog(rCommand);
82 }
83 
84 css::uno::Reference<css::ui::test::XUIObject> SAL_CALL UITestUnoObj::getTopFocusWindow()
85 {
86  SolarMutexGuard aGuard;
87  std::unique_ptr<UIObject> pObj = UITest::getFocusTopWindow();
88  return new UIObjectUnoObj(std::move(pObj));
89 }
90 
91 css::uno::Reference<css::ui::test::XUIObject> SAL_CALL UITestUnoObj::getFloatWindow()
92 {
93  SolarMutexGuard aGuard;
94  std::unique_ptr<UIObject> pObj = UITest::getFloatWindow();
95  return new UIObjectUnoObj(std::move(pObj));
96 }
97 
99 {
100  return "org.libreoffice.uitest.UITest";
101 }
102 
103 sal_Bool UITestUnoObj::supportsService(OUString const & ServiceName)
104 {
105  return cppu::supportsService(this, ServiceName);
106 }
107 
108 css::uno::Sequence<OUString> UITestUnoObj::getSupportedServiceNames()
109 {
110  return { "com.sun.star.ui.test.UITest" };
111 }
112 
113 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
114 UITest_get_implementation(css::uno::XComponentContext*, css::uno::Sequence<css::uno::Any> const &)
115 {
116  return cppu::acquire(new UITestUnoObj());
117 }
118 
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::osl::Mutex m_aMutex
static std::unique_ptr< UIObject > getFloatWindow()
Definition: uitest.cxx:67
std::unique_ptr< UITest > mpUITest
Definition: uitest_uno.cxx:35
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * UITest_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
Definition: uitest_uno.cxx:114
static bool executeCommand(const OUString &rCommand)
Definition: uitest.cxx:21
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
sal_Bool SAL_CALL executeDialog(const OUString &rCommand) override
Definition: uitest_uno.cxx:78
css::uno::Reference< css::ui::test::XUIObject > SAL_CALL getTopFocusWindow() override
Definition: uitest_uno.cxx:84
sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
Definition: uitest_uno.cxx:103
unsigned char sal_Bool
css::uno::Reference< css::ui::test::XUIObject > SAL_CALL getFloatWindow() override
Definition: uitest_uno.cxx:91
sal_Bool SAL_CALL executeCommandWithParameters(const OUString &rCommand, const css::uno::Sequence< css::beans::PropertyValue > &rArgs) override
Definition: uitest_uno.cxx:71
static std::unique_ptr< UIObject > getFocusTopWindow()
Definition: uitest.cxx:54
OUString SAL_CALL getImplementationName() override
Definition: uitest_uno.cxx:98
sal_Bool SAL_CALL executeCommand(const OUString &rCommand) override
Definition: uitest_uno.cxx:65
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: uitest_uno.cxx:108
static bool executeCommandWithParameters(const OUString &rCommand, const css::uno::Sequence< css::beans::PropertyValue > &rArgs)
Definition: uitest.cxx:29
static bool executeDialog(const OUString &rCommand)
Definition: uitest.cxx:46