Kaydet (Commit) f458dabc authored tarafından Saurav Chirania's avatar Saurav Chirania Kaydeden (comit) Markus Mohrhard

uitest: support parameters when sending UNO commands

This patch introduces a new function to send parameters
with UNO commands in UI Tests and adds a test which
uses the function to change the color of text in writer.

Change-Id: Ic687872ab826b50360e1bd042d9668a9f6ddbf63
Reviewed-on: https://gerrit.libreoffice.org/57857
Tested-by: Jenkins
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 0c350906
......@@ -12,6 +12,11 @@
#include <vcl/dllapi.h>
#include <memory>
#include <com/sun/star/uno/Sequence.hxx>
namespace com { namespace sun { namespace star {
namespace beans { struct PropertyValue; }
} } }
class UIObject;
......@@ -21,6 +26,9 @@ public:
static bool executeCommand(const OUString& rCommand);
static bool executeCommandWithParameters(const OUString& rCommand,
const css::uno::Sequence< css::beans::PropertyValue >& rArgs);
static bool executeDialog(const OUString& rCommand);
static std::unique_ptr<UIObject> getFocusTopWindow();
......
......@@ -11,6 +11,7 @@
#define __com_sun_star_ui_test_XUITest_idl__
#include <com/sun/star/ui/test/XUIObject.idl>
#include <com/sun/star/beans/PropertyValues.idl>
module com { module sun { module star { module ui { module test {
......@@ -18,6 +19,9 @@ interface XUITest
{
boolean executeCommand([in] string command);
boolean executeCommandWithParameters([in] string command,
[in] com::sun::star::beans::PropertyValues propValues);
boolean executeDialog([in] string command);
XUIObject getTopFocusWindow();
......
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
# 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/.
#
from uitest.framework import UITestCase
from uitest.uihelper.common import type_text
from libreoffice.uno.propertyvalue import mkPropertyValues
class CommandWithParametersTest(UITestCase):
def test_text_color_change(self):
self.ui_test.create_doc_in_start_center("writer")
self.xUITest.executeCommandWithParameters(".uno:Color",
mkPropertyValues({"Color": 16776960}))
xWriterEdit = self.xUITest.getTopFocusWindow().getChild("writer_edit")
type_text(xWriterEdit, "Libreoffice")
self.ui_test.close_doc()
# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file
......@@ -25,6 +25,25 @@ bool UITest::executeCommand(const OUString& rCommand)
css::beans::PropertyState_DIRECT_VALUE}});
}
bool UITest::executeCommandWithParameters(const OUString& rCommand,
const css::uno::Sequence< css::beans::PropertyValue >& rArgs)
{
css::uno::Sequence< css::beans::PropertyValue > lNewArgs =
{{"SynchronMode", -1, css::uno::Any(true),
css::beans::PropertyState_DIRECT_VALUE}};
sal_uInt32 nArgs = rArgs.getLength();
if ( nArgs > 0 )
{
sal_uInt32 nIndex( lNewArgs.getLength() );
lNewArgs.realloc( lNewArgs.getLength()+rArgs.getLength() );
for ( sal_uInt32 i = 0; i < nArgs; i++ )
lNewArgs[nIndex++] = rArgs[i];
}
return comphelper::dispatchCommand(rCommand,lNewArgs);
}
bool UITest::executeDialog(const OUString& rCommand)
{
return comphelper::dispatchCommand(
......
......@@ -40,6 +40,9 @@ public:
sal_Bool SAL_CALL executeCommand(const OUString& rCommand) override;
sal_Bool SAL_CALL executeCommandWithParameters(const OUString& rCommand,
const css::uno::Sequence< css::beans::PropertyValue >& rArgs) override;
sal_Bool SAL_CALL executeDialog(const OUString& rCommand) override;
css::uno::Reference<css::ui::test::XUIObject> SAL_CALL getTopFocusWindow() override;
......@@ -65,6 +68,13 @@ sal_Bool SAL_CALL UITestUnoObj::executeCommand(const OUString& rCommand)
return UITest::executeCommand(rCommand);
}
sal_Bool SAL_CALL UITestUnoObj::executeCommandWithParameters(const OUString& rCommand,
const css::uno::Sequence< css::beans::PropertyValue >& rArgs)
{
SolarMutexGuard aGuard;
return UITest::executeCommandWithParameters(rCommand,rArgs);
}
sal_Bool SAL_CALL UITestUnoObj::executeDialog(const OUString& rCommand)
{
SolarMutexGuard aGuard;
......
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