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 class UITestUnoObj : public cppu::BaseMutex,
31  public UITestBase
32 {
33 private:
34  std::unique_ptr<UITest> mpUITest;
35 
36 public:
37 
38  UITestUnoObj();
39 
40  sal_Bool SAL_CALL executeCommand(const OUString& rCommand) override;
41 
42  sal_Bool SAL_CALL executeCommandWithParameters(const OUString& rCommand,
43  const css::uno::Sequence< css::beans::PropertyValue >& rArgs) override;
44 
45  sal_Bool SAL_CALL executeDialog(const OUString& rCommand) override;
46 
47  css::uno::Reference<css::ui::test::XUIObject> SAL_CALL getTopFocusWindow() override;
48 
49  css::uno::Reference<css::ui::test::XUIObject> SAL_CALL getFloatWindow() override;
50 
51  OUString SAL_CALL getImplementationName() override;
52 
53  sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override;
54 
55  css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
56 };
57 
58 }
59 
60 UITestUnoObj::UITestUnoObj():
61  UITestBase(m_aMutex),
62  mpUITest(new UITest)
63 {
64 }
65 
66 sal_Bool SAL_CALL UITestUnoObj::executeCommand(const OUString& rCommand)
67 {
68  SolarMutexGuard aGuard;
69  return UITest::executeCommand(rCommand);
70 }
71 
72 sal_Bool SAL_CALL UITestUnoObj::executeCommandWithParameters(const OUString& rCommand,
73  const css::uno::Sequence< css::beans::PropertyValue >& rArgs)
74 {
75  SolarMutexGuard aGuard;
76  return UITest::executeCommandWithParameters(rCommand,rArgs);
77 }
78 
79 sal_Bool SAL_CALL UITestUnoObj::executeDialog(const OUString& rCommand)
80 {
81  SolarMutexGuard aGuard;
82  return UITest::executeDialog(rCommand);
83 }
84 
85 css::uno::Reference<css::ui::test::XUIObject> SAL_CALL UITestUnoObj::getTopFocusWindow()
86 {
87  SolarMutexGuard aGuard;
88  std::unique_ptr<UIObject> pObj = UITest::getFocusTopWindow();
89  return new UIObjectUnoObj(std::move(pObj));
90 }
91 
92 css::uno::Reference<css::ui::test::XUIObject> SAL_CALL UITestUnoObj::getFloatWindow()
93 {
94  SolarMutexGuard aGuard;
95  std::unique_ptr<UIObject> pObj = UITest::getFloatWindow();
96  return new UIObjectUnoObj(std::move(pObj));
97 }
98 
99 OUString SAL_CALL UITestUnoObj::getImplementationName()
100 {
101  return "org.libreoffice.uitest.UITest";
102 }
103 
104 sal_Bool UITestUnoObj::supportsService(OUString const & ServiceName)
105 {
106  return cppu::supportsService(this, ServiceName);
107 }
108 
109 css::uno::Sequence<OUString> UITestUnoObj::getSupportedServiceNames()
110 {
111  return { "com.sun.star.ui.test.UITest" };
112 }
113 
114 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
115 UITest_get_implementation(css::uno::XComponentContext*, css::uno::Sequence<css::uno::Any> const &)
116 {
117  return cppu::acquire(new UITestUnoObj());
118 }
119 
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static std::unique_ptr< UIObject > getFloatWindow()
Definition: uitest.cxx:68
OUString getImplementationName()
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * UITest_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
Definition: uitest_uno.cxx:115
static bool executeCommand(const OUString &rCommand)
Definition: uitest.cxx:22
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
css::uno::Sequence< OUString > getSupportedServiceNames()
unsigned char sal_Bool
static std::unique_ptr< UIObject > getFocusTopWindow()
Definition: uitest.cxx:55
static bool executeCommandWithParameters(const OUString &rCommand, const css::uno::Sequence< css::beans::PropertyValue > &rArgs)
Definition: uitest.cxx:30
osl::Mutex m_aMutex
Definition: dtranscomp.cxx:61
static bool executeDialog(const OUString &rCommand)
Definition: uitest.cxx:47