Kaydet (Commit) 343ba6ac authored tarafından Markus Mohrhard's avatar Markus Mohrhard

uitest: actually implement the UNO interfaces

Change-Id: I3cbb3d8f7c6fa0d2616a31192a959f89d4cc7703
üst 070d9231
......@@ -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,\
......
/* -*- 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: */
/* -*- 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: */
/* -*- 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: */
......@@ -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>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment