diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-01-09 23:41:42 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-06-18 17:01:31 +0200 |
commit | 343ba6ac089a926c9ee6cadd58b6c3637bcbc5eb (patch) | |
tree | 459e306e8a35e9e35f20f4a65fba15328a04ad77 | |
parent | 070d9231560ab8272fe3baa392d9cf3a2f7d6f95 (diff) |
uitest: actually implement the UNO interfaces
Change-Id: I3cbb3d8f7c6fa0d2616a31192a959f89d4cc7703
-rw-r--r-- | vcl/Library_vcl.mk | 2 | ||||
-rw-r--r-- | vcl/source/uitest/uno/uiobject_uno.cxx | 58 | ||||
-rw-r--r-- | vcl/source/uitest/uno/uiobject_uno.hxx | 57 | ||||
-rw-r--r-- | vcl/source/uitest/uno/uitest_uno.cxx | 108 | ||||
-rw-r--r-- | vcl/vcl.unx.component | 4 |
5 files changed, 229 insertions, 0 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 42ef62c38f37..0cb7d260871a 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -396,6 +396,8 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/uitest/factory \ vcl/source/uitest/uiobject \ vcl/source/uitest/uitest \ + vcl/source/uitest/uno/uiobject_uno \ + vcl/source/uitest/uno/uitest_uno \ )) $(eval $(call gb_Library_add_cobjects,vcl,\ diff --git a/vcl/source/uitest/uno/uiobject_uno.cxx b/vcl/source/uitest/uno/uiobject_uno.cxx new file mode 100644 index 000000000000..5913dff112d4 --- /dev/null +++ b/vcl/source/uitest/uno/uiobject_uno.cxx @@ -0,0 +1,58 @@ +/* -*- 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 "uiobject_uno.hxx" +#include <vcl/svapp.hxx> + +UIObjectUnoObj::UIObjectUnoObj(std::unique_ptr<UIObject> pObj): + UIObjectBase(m_aMutex), + mpObj(std::move(pObj)) +{ +} + +UIObjectUnoObj::~UIObjectUnoObj() +{ +} + +css::uno::Reference<css::ui::test::XUIObject> SAL_CALL UIObjectUnoObj::getChild(const OUString& rID) + throw (css::uno::RuntimeException, std::exception) +{ + SolarMutexGuard aGuard; + std::unique_ptr<UIObject> pObj = mpObj->get_child(rID); + return new UIObjectUnoObj(std::move(pObj)); +} + +void SAL_CALL UIObjectUnoObj::executeAction(const OUString& rAction) + throw (css::uno::RuntimeException, std::exception) +{ + SolarMutexGuard aGuard; + mpObj->execute(rAction, StringMap()); +} + +OUString SAL_CALL UIObjectUnoObj::getImplementationName() + throw (css::uno::RuntimeException, std::exception) +{ + return OUString("org.libreoffice.uitest.UIObject"); +} + +sal_Bool UIObjectUnoObj::supportsService(OUString const & ServiceName) + throw (css::uno::RuntimeException, std::exception) +{ + return cppu::supportsService(this, ServiceName); +} + +css::uno::Sequence<OUString> UIObjectUnoObj::getSupportedServiceNames() + throw (css::uno::RuntimeException, std::exception) +{ + css::uno::Sequence<OUString> aServiceNames(1); + aServiceNames[0] = "com.sun.star.ui.test.UIObject"; + return aServiceNames; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/uitest/uno/uiobject_uno.hxx b/vcl/source/uitest/uno/uiobject_uno.hxx new file mode 100644 index 000000000000..10b6fb36bcd4 --- /dev/null +++ b/vcl/source/uitest/uno/uiobject_uno.hxx @@ -0,0 +1,57 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_VCL_SOURCE_UITEST_UNO_UIOBJECT_UNO_HXX +#define INCLUDED_VCL_SOURCE_UITEST_UNO_UIOBJECT_UNO_HXX + +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/supportsservice.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/ui/test/XUIObject.hpp> + +#include <memory> + +#include <vcl/uitest/uiobject.hxx> + +typedef ::cppu::WeakComponentImplHelper < + css::ui::test::XUIObject, css::lang::XServiceInfo + > UIObjectBase; + +class UIObjectUnoObj : public cppu::BaseMutex, + public UIObjectBase +{ +private: + std::unique_ptr<UIObject> mpObj; + +public: + + UIObjectUnoObj(std::unique_ptr<UIObject> pObj); + virtual ~UIObjectUnoObj(); + + css::uno::Reference<css::ui::test::XUIObject> SAL_CALL getChild(const OUString& rID) + throw (css::uno::RuntimeException, std::exception) override; + + void SAL_CALL executeAction(const OUString& rAction) + throw (css::uno::RuntimeException, std::exception) override; + + OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException, std::exception) override; + + sal_Bool SAL_CALL supportsService(OUString const & ServiceName) + throw (css::uno::RuntimeException, std::exception) override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() + throw (css::uno::RuntimeException, std::exception) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/uitest/uno/uitest_uno.cxx b/vcl/source/uitest/uno/uitest_uno.cxx new file mode 100644 index 000000000000..10b7f127441e --- /dev/null +++ b/vcl/source/uitest/uno/uitest_uno.cxx @@ -0,0 +1,108 @@ +/* -*- 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 <cppuhelper/compbase.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/supportsservice.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/ui/test/XUITest.hpp> + +#include <memory> + +#include <vcl/uitest/uitest.hxx> +#include <vcl/svapp.hxx> + +#include "uiobject_uno.hxx" + +namespace +{ + typedef ::cppu::WeakComponentImplHelper < + css::ui::test::XUITest, css::lang::XServiceInfo + > UITestBase; +} + +class UITestUnoObj : public cppu::BaseMutex, + public UITestBase +{ +private: + std::unique_ptr<UITest> mpUITest; + +public: + + UITestUnoObj(); + virtual ~UITestUnoObj(); + + void SAL_CALL executeCommand(const OUString& rCommand) + throw (css::uno::RuntimeException, std::exception) override; + + css::uno::Reference<css::ui::test::XUIObject> SAL_CALL getTopFocusWindow() + throw (css::uno::RuntimeException, std::exception) override; + + OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException, std::exception) override; + + sal_Bool SAL_CALL supportsService(OUString const & ServiceName) + throw (css::uno::RuntimeException, std::exception) override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() + throw (css::uno::RuntimeException, std::exception) override; +}; + +UITestUnoObj::UITestUnoObj(): + UITestBase(m_aMutex), + mpUITest(new UITest) +{ +} + +UITestUnoObj::~UITestUnoObj() +{ +} + +void SAL_CALL UITestUnoObj::executeCommand(const OUString& rCommand) + throw (css::uno::RuntimeException, std::exception) +{ + SolarMutexGuard aGuard; + mpUITest->executeCommand(rCommand); +} + +css::uno::Reference<css::ui::test::XUIObject> SAL_CALL UITestUnoObj::getTopFocusWindow() + throw (css::uno::RuntimeException, std::exception) +{ + std::unique_ptr<UIObject> pObj = mpUITest->getFocusTopWindow(); + return new UIObjectUnoObj(std::move(pObj)); +} + +OUString SAL_CALL UITestUnoObj::getImplementationName() + throw (css::uno::RuntimeException, std::exception) +{ + return OUString("org.libreoffice.uitest.UITest"); +} + +sal_Bool UITestUnoObj::supportsService(OUString const & ServiceName) + throw (css::uno::RuntimeException, std::exception) +{ + return cppu::supportsService(this, ServiceName); +} + +css::uno::Sequence<OUString> UITestUnoObj::getSupportedServiceNames() + throw (css::uno::RuntimeException, std::exception) +{ + css::uno::Sequence<OUString> aServiceNames(1); + aServiceNames[0] = "com.sun.star.ui.test.UITest"; + return aServiceNames; +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* SAL_CALL +UITest_get_implementation(css::uno::XComponentContext*, css::uno::Sequence<css::uno::Any> const &) +{ + return cppu::acquire(new UITestUnoObj()); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/vcl.unx.component b/vcl/vcl.unx.component index d69012780262..3e84d352c31c 100644 --- a/vcl/vcl.unx.component +++ b/vcl/vcl.unx.component @@ -34,4 +34,8 @@ <implementation name="vcl::FontIdentificator"> <service name="com.sun.star.awt.FontIdentificator"/> </implementation> + <implementation name="org.libreoffice.uitest.UITest" + constructor="UITest_get_implementation"> + <service name="com.sun.star.ui.test.UITest"/> + </implementation> </component> |