diff options
author | Saurav Chirania <saurav.chir@gmail.com> | 2018-07-23 14:32:24 +0530 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2018-07-28 01:10:23 +0200 |
commit | f458dabcaa18d66b054d00f5d9a389c06240f0eb (patch) | |
tree | 68f5aa7858c75729f99caddc950ac585f71cb95f | |
parent | 0c350906b1d6dc27383619dd3338fe28768f1c2e (diff) |
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: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r-- | include/vcl/uitest/uitest.hxx | 8 | ||||
-rw-r--r-- | offapi/com/sun/star/ui/test/XUITest.idl | 4 | ||||
-rw-r--r-- | uitest/demo_ui/command_with_parameters.py | 24 | ||||
-rw-r--r-- | vcl/source/uitest/uitest.cxx | 19 | ||||
-rw-r--r-- | vcl/source/uitest/uno/uitest_uno.cxx | 10 |
5 files changed, 65 insertions, 0 deletions
diff --git a/include/vcl/uitest/uitest.hxx b/include/vcl/uitest/uitest.hxx index 4031402e8fc0..1759ea7656b0 100644 --- a/include/vcl/uitest/uitest.hxx +++ b/include/vcl/uitest/uitest.hxx @@ -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(); diff --git a/offapi/com/sun/star/ui/test/XUITest.idl b/offapi/com/sun/star/ui/test/XUITest.idl index f4926a19bd09..b8dba4f9a901 100644 --- a/offapi/com/sun/star/ui/test/XUITest.idl +++ b/offapi/com/sun/star/ui/test/XUITest.idl @@ -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(); diff --git a/uitest/demo_ui/command_with_parameters.py b/uitest/demo_ui/command_with_parameters.py new file mode 100644 index 000000000000..3fd8c85e3ca7 --- /dev/null +++ b/uitest/demo_ui/command_with_parameters.py @@ -0,0 +1,24 @@ +# -*- 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 diff --git a/vcl/source/uitest/uitest.cxx b/vcl/source/uitest/uitest.cxx index 658b8cf75a82..bf1f69bfe54b 100644 --- a/vcl/source/uitest/uitest.cxx +++ b/vcl/source/uitest/uitest.cxx @@ -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( diff --git a/vcl/source/uitest/uno/uitest_uno.cxx b/vcl/source/uitest/uno/uitest_uno.cxx index a625e670667e..69d0c717a9bb 100644 --- a/vcl/source/uitest/uno/uitest_uno.cxx +++ b/vcl/source/uitest/uno/uitest_uno.cxx @@ -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; |