[Libreoffice-commits] core.git: sc/qa uitest/uitest

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Thu Jan 21 23:42:19 UTC 2021


 sc/qa/uitest/calc_tests8/tdf118308.py |   58 ++++++++++++++++++++++++++++++++++
 uitest/uitest/test.py                 |   15 ++++++--
 2 files changed, 69 insertions(+), 4 deletions(-)

New commits:
commit 86c8c775bbefe333d684e12c99855a3c1de68051
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Thu Jan 21 23:16:19 2021 +0100
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Fri Jan 22 00:41:28 2021 +0100

    tdf#118308: sc: Add UItest
    
    Change-Id: I4d23b4eda9ab3333eb0c062259601ba9bfb2179d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109775
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/sc/qa/uitest/calc_tests8/tdf118308.py b/sc/qa/uitest/calc_tests8/tdf118308.py
new file mode 100644
index 000000000000..313a2dc35ec8
--- /dev/null
+++ b/sc/qa/uitest/calc_tests8/tdf118308.py
@@ -0,0 +1,58 @@
+# -*- 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 get_state_as_dict
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.calc import enter_text_to_cell
+from libreoffice.calc.document import get_cell_by_position
+
+class tdf118308(UITestCase):
+
+    def test_tdf118308(self):
+        calc_doc = self.ui_test.create_doc_in_start_center("calc")
+        xCalcDoc = self.xUITest.getTopFocusWindow()
+        gridwin = xCalcDoc.getChild("grid_window")
+        document = self.ui_test.get_component()
+
+        enter_text_to_cell(gridwin, "A1", "A")
+        gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
+        self.xUITest.executeCommand(".uno:Copy")
+
+        self.ui_test.close_doc()
+
+        calc_doc = self.ui_test.load_empty_file("calc")
+
+        xCalcDoc = self.xUITest.getTopFocusWindow()
+        gridwin = xCalcDoc.getChild("grid_window")
+        document = self.ui_test.get_component()
+
+        gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
+
+        self.ui_test.execute_dialog_through_command(".uno:PasteSpecial")
+        xDialog = self.xUITest.getTopFocusWindow()
+
+        # Without the fix in place, this test would have failed here
+        # since a different dialog would have been opened and the children
+        # wouldn't have been found
+        xText = xDialog.getChild("text")
+        xNumbers = xDialog.getChild("numbers")
+        xDatetime = xDialog.getChild("datetime")
+        xFormats = xDialog.getChild("formats")
+
+        self.assertEqual("true", get_state_as_dict(xText)["Selected"])
+        self.assertEqual("true", get_state_as_dict(xNumbers)["Selected"])
+        self.assertEqual("true", get_state_as_dict(xDatetime)["Selected"])
+        self.assertEqual("false", get_state_as_dict(xFormats)["Selected"])
+
+        xOkBtn = xDialog.getChild("ok")
+        self.ui_test.close_dialog_through_button(xOkBtn)
+
+        self.assertEqual("A", get_cell_by_position(document, 0, 0, 0).getString())
+        self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
+
diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 556fb511cc97..a746643638bf 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -66,10 +66,14 @@ class UITest(object):
                 time_ += DEFAULT_SLEEP
                 time.sleep(DEFAULT_SLEEP)
 
-    def load_file(self, url):
+    def load_file(self, url, eventName="OnLoad"):
+        target = "_default"
+        if eventName == "OnNew":
+            target = "_blank"
+
         desktop = self.get_desktop()
-        with EventListener(self._xContext, "OnLoad") as event:
-            component = desktop.loadComponentFromURL(url, "_default", 0, tuple())
+        with EventListener(self._xContext, eventName) as event:
+            component = desktop.loadComponentFromURL(url, target, 0, tuple())
             time_ = 0
             while time_ < MAX_WAIT:
                 if event.executed:
@@ -81,6 +85,10 @@ class UITest(object):
                 time_ += DEFAULT_SLEEP
                 time.sleep(DEFAULT_SLEEP)
 
+    def load_empty_file(self, app):
+        url = "private:factory/s" + app
+        return self.load_file(url, "OnNew")
+
     def execute_dialog_through_command(self, command, printNames=False):
         with EventListener(self._xContext, "DialogExecute", printNames=printNames) as event:
             if not self._xUITest.executeDialog(command):
@@ -149,7 +157,6 @@ class UITest(object):
                 if event.executed:
                     frames = self.get_frames()
                     self.get_desktop().setActiveFrame(frames[0])
-                    print(len(frames))
                     return
                 time_ += DEFAULT_SLEEP
                 time.sleep(DEFAULT_SLEEP)


More information about the Libreoffice-commits mailing list