[Libreoffice-commits] core.git: include/vcl offapi/com uitest/demo_ui vcl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Jul 27 23:10:48 UTC 2018


 include/vcl/uitest/uitest.hxx             |    8 ++++++++
 offapi/com/sun/star/ui/test/XUITest.idl   |    4 ++++
 uitest/demo_ui/command_with_parameters.py |   24 ++++++++++++++++++++++++
 vcl/source/uitest/uitest.cxx              |   19 +++++++++++++++++++
 vcl/source/uitest/uno/uitest_uno.cxx      |   10 ++++++++++
 5 files changed, 65 insertions(+)

New commits:
commit f458dabcaa18d66b054d00f5d9a389c06240f0eb
Author:     Saurav Chirania <saurav.chir at gmail.com>
AuthorDate: Mon Jul 23 14:32:24 2018 +0530
Commit:     Markus Mohrhard <markus.mohrhard at googlemail.com>
CommitDate: Sat Jul 28 01:10:23 2018 +0200

    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 at googlemail.com>

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;


More information about the Libreoffice-commits mailing list