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

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Wed Feb 24 13:16:36 UTC 2021


 sc/qa/uitest/calc_tests7/tdf137397.py                   |   11 ++++-------
 sw/qa/uitest/navigator/tdf137274.py                     |    8 +++-----
 sw/qa/uitest/navigator/tdf140257.py                     |    8 ++------
 sw/qa/uitest/sidebar/tdf99711.py                        |    8 ++++----
 sw/qa/uitest/writer_tests/comments.py                   |   12 ++++--------
 sw/qa/uitest/writer_tests/tdf137459_editeng_ctrl-DEL.py |    7 +------
 sw/qa/uitest/writer_tests4/tdf134439.py                 |    6 +-----
 sw/qa/uitest/writer_tests4/tdf135636.py                 |    6 +-----
 sw/qa/uitest/writer_tests4/tdf136578.py                 |    8 +-------
 sw/qa/uitest/writer_tests7/tdf132169.py                 |    6 +-----
 sw/qa/uitest/writer_tests7/tdf137802.py                 |    4 ++--
 sw/qa/uitest/writer_tests7/tdf137803.py                 |    4 +---
 sw/qa/uitest/writer_tests7/tdf139301.py                 |   10 +---------
 uitest/uitest/test.py                                   |   10 ++++++++--
 14 files changed, 34 insertions(+), 74 deletions(-)

New commits:
commit 6631aa3060ebbb3462391d784e406ac2a1060f8c
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Wed Feb 24 10:25:09 2021 +0100
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Wed Feb 24 14:14:58 2021 +0100

    uitest: no need to pass the parent as a parameter
    
    Change-Id: I750b5600d3e4ef8ba5a0666133b9066904b4cbec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111450
    Tested-by: Xisco Fauli <xiscofauli at libreoffice.org>
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/sc/qa/uitest/calc_tests7/tdf137397.py b/sc/qa/uitest/calc_tests7/tdf137397.py
index 48ac40f27dcd..ae67f9837bfc 100644
--- a/sc/qa/uitest/calc_tests7/tdf137397.py
+++ b/sc/qa/uitest/calc_tests7/tdf137397.py
@@ -25,16 +25,13 @@ class tdf137397(UITestCase):
         self.xUITest.executeCommand(".uno:Sidebar")
         xGridWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "TextPropertyPanel"}))
 
-        xCalcDoc = self.xUITest.getTopFocusWindow()
-
-
-        self.ui_test.wait_until_child_is_available(xCalcDoc, 'selectwidth')
-        self.assertEqual(get_state_as_dict(xCalcDoc.getChild('selectwidth'))['Text'], '6.00 cm')
+        xChild = self.ui_test.wait_until_child_is_available('selectwidth')
+        self.assertEqual(get_state_as_dict(xChild)['Text'], '6.00 cm')
 
         # Without the fix in place, this test would have failed with
         # AssertionError: '-14,585,309.84 cm' != '2.00 cm'
-        self.ui_test.wait_until_child_is_available(xCalcDoc, 'selectheight')
-        self.assertEqual(get_state_as_dict(xCalcDoc.getChild('selectheight'))['Text'], '2.00 cm')
+        xChild = self.ui_test.wait_until_child_is_available('selectheight')
+        self.assertEqual(get_state_as_dict(xChild)['Text'], '2.00 cm')
 
 
         self.xUITest.executeCommand(".uno:Sidebar")
diff --git a/sw/qa/uitest/navigator/tdf137274.py b/sw/qa/uitest/navigator/tdf137274.py
index f1e153992e2d..a4a48dbb9693 100644
--- a/sw/qa/uitest/navigator/tdf137274.py
+++ b/sw/qa/uitest/navigator/tdf137274.py
@@ -24,16 +24,14 @@ class tdf137274(UITestCase):
         self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", xArgs)
 
         # wait until the comment is available
-        self.ui_test.wait_until_child_is_available(xMainWindow, 'Comment1')
+        self.ui_test.wait_until_child_is_available('Comment1')
 
         self.xUITest.executeCommand(".uno:Sidebar")
 
         xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"}))
 
         # wait until the navigator panel is available
-        self.ui_test.wait_until_child_is_available(xMainWindow, 'NavigatorPanelParent')
-
-        xNavigatorPanel = xWriterEdit.getChild("NavigatorPanelParent")
+        xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanelParent')
 
         xContentTree = xNavigatorPanel.getChild("contenttree")
         xComments = xContentTree.getChild('10')
@@ -50,7 +48,7 @@ class tdf137274(UITestCase):
         self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", xArgs)
 
         # wait until the second comment is available
-        self.ui_test.wait_until_child_is_available(xMainWindow, 'Comment2')
+        self.ui_test.wait_until_child_is_available('Comment2')
 
         xComments.executeAction("EXPAND", tuple())
 
diff --git a/sw/qa/uitest/navigator/tdf140257.py b/sw/qa/uitest/navigator/tdf140257.py
index 8982b7d2901f..6a6674d8f7e8 100644
--- a/sw/qa/uitest/navigator/tdf140257.py
+++ b/sw/qa/uitest/navigator/tdf140257.py
@@ -45,9 +45,7 @@ class Tdf140257(UITestCase):
     xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"}))
 
     # wait until the navigator panel is available
-    self.ui_test.wait_until_child_is_available(xMainWindow, 'NavigatorPanelParent')
-
-    xNavigatorPanel = xWriterEdit.getChild("NavigatorPanelParent")
+    xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanelParent')
 
     xContentTree = xNavigatorPanel.getChild("contenttree")
     xHeadings = xContentTree.getChild('0')
@@ -86,9 +84,7 @@ class Tdf140257(UITestCase):
     xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"}))
 
     # wait until the navigator panel is available
-    self.ui_test.wait_until_child_is_available(xMainWindow, 'NavigatorPanelParent')
-
-    xNavigatorPanel = xWriterEdit.getChild("NavigatorPanelParent")
+    xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanelParent')
 
     xContentTree = xNavigatorPanel.getChild("contenttree")
     xHeadings = xContentTree.getChild('0')
diff --git a/sw/qa/uitest/sidebar/tdf99711.py b/sw/qa/uitest/sidebar/tdf99711.py
index 776894431b92..1cc899f42cc1 100644
--- a/sw/qa/uitest/sidebar/tdf99711.py
+++ b/sw/qa/uitest/sidebar/tdf99711.py
@@ -26,11 +26,11 @@ class tdf99711(UITestCase):
         xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "TextPropertyPanel"}))
 
         #wait until the sidebar is available
-        self.ui_test.wait_until_child_is_available(xWriterEdit, 'selectwidth')
-        self.assertEqual(get_state_as_dict(xWriterEdit.getChild('selectwidth'))['Text'], '10.00 mm')
+        xChild = self.ui_test.wait_until_child_is_available('selectwidth')
+        self.assertEqual(get_state_as_dict(xChild)['Text'], '10.00 mm')
 
-        self.ui_test.wait_until_child_is_available(xWriterEdit, 'selectheight')
-        self.assertEqual(get_state_as_dict(xWriterEdit.getChild('selectheight'))['Text'], '10.00 mm')
+        xChild = self.ui_test.wait_until_child_is_available('selectheight')
+        self.assertEqual(get_state_as_dict(xChild)['Text'], '10.00 mm')
 
         self.xUITest.executeCommand(".uno:Sidebar")
 
diff --git a/sw/qa/uitest/writer_tests/comments.py b/sw/qa/uitest/writer_tests/comments.py
index 6127f44fcfb3..c846372a99aa 100644
--- a/sw/qa/uitest/writer_tests/comments.py
+++ b/sw/qa/uitest/writer_tests/comments.py
@@ -30,9 +30,8 @@ class Comments(UITestCase):
         self.xUITest.executeCommand(".uno:InsertAnnotation")
 
         # wait until the comment is available
-        self.ui_test.wait_until_child_is_available(xMainWindow, 'Comment1')
+        xComment1 = self.ui_test.wait_until_child_is_available('Comment1')
 
-        xComment1 = xMainWindow.getChild("Comment1")
         xEditView1 = xComment1.getChild("editview")
         xEditView1.executeAction("TYPE", mkPropertyValues({"TEXT": "This is the First Comment"}))
         self.assertEqual(get_state_as_dict(xComment1)["Text"], "This is the First Comment" )
@@ -78,8 +77,7 @@ class Comments(UITestCase):
         xwriter_edit.executeAction("TYPE", mkPropertyValues({"TEXT": "Line 1"}))
         self.xUITest.executeCommand(".uno:InsertAnnotation")
         # wait until the comment is available
-        self.ui_test.wait_until_child_is_available(xMainWindow, 'Comment1')
-        xComment1 = xMainWindow.getChild("Comment1")
+        xComment1 = self.ui_test.wait_until_child_is_available('Comment1')
         xEditView1 = xComment1.getChild("editview")
         xEditView1.executeAction("TYPE", mkPropertyValues({"TEXT": "First Comment"}))
         xComment1.executeAction("LEAVE", mkPropertyValues({}))
@@ -88,8 +86,7 @@ class Comments(UITestCase):
         xwriter_edit.executeAction("TYPE", mkPropertyValues({"TEXT": "Line 2"}))
         self.xUITest.executeCommand(".uno:InsertAnnotation")
         # wait until the comment is available
-        self.ui_test.wait_until_child_is_available(xMainWindow, 'Comment2')
-        xComment2 = xMainWindow.getChild("Comment2")
+        xComment2 = self.ui_test.wait_until_child_is_available('Comment2')
         xEditView2 = xComment2.getChild("editview")
         xEditView2.executeAction("TYPE", mkPropertyValues({"TEXT": "Second Comment"}))
         xComment2.executeAction("LEAVE", mkPropertyValues({}))
@@ -98,8 +95,7 @@ class Comments(UITestCase):
         xwriter_edit.executeAction("TYPE", mkPropertyValues({"TEXT": "Line 3"}))
         self.xUITest.executeCommand(".uno:InsertAnnotation")
         # wait until the comment is available
-        self.ui_test.wait_until_child_is_available(xMainWindow, 'Comment3')
-        xComment3 = xMainWindow.getChild("Comment3")
+        xComment3 = self.ui_test.wait_until_child_is_available('Comment3')
         xEditView3 = xComment3.getChild("editview")
         xEditView3.executeAction("TYPE", mkPropertyValues({"TEXT": "Third Comment"}))
         xComment3.executeAction("LEAVE", mkPropertyValues({}))
diff --git a/sw/qa/uitest/writer_tests/tdf137459_editeng_ctrl-DEL.py b/sw/qa/uitest/writer_tests/tdf137459_editeng_ctrl-DEL.py
index 5b11c9ac5a09..97e60b8c07de 100644
--- a/sw/qa/uitest/writer_tests/tdf137459_editeng_ctrl-DEL.py
+++ b/sw/qa/uitest/writer_tests/tdf137459_editeng_ctrl-DEL.py
@@ -8,7 +8,6 @@
 #
 
 from uitest.framework import UITestCase
-import time
 from uitest.uihelper.common import get_state_as_dict, type_text
 from libreoffice.uno.propertyvalue import mkPropertyValues
 
@@ -18,15 +17,11 @@ class tdf137459(UITestCase):
 
         xMainDoc = self.ui_test.create_doc_in_start_center("writer")
 
-        xMainWindow = self.xUITest.getTopFocusWindow()
-
-        xwriter_edit = xMainWindow.getChild("writer_edit")
         # adding new Comment
         self.xUITest.executeCommand(".uno:InsertAnnotation")
         # wait until the comment is available
-        self.ui_test.wait_until_child_is_available(xMainWindow, 'Comment1')
+        xComment1 = self.ui_test.wait_until_child_is_available('Comment1')
 
-        xComment1 = xMainWindow.getChild("Comment1")
         xEditView1 = xComment1.getChild("editview")
         sText = "Ctrl+Del should not delete BACKWARDS"
         xEditView1.executeAction("TYPE", mkPropertyValues({"TEXT": sText}))
diff --git a/sw/qa/uitest/writer_tests4/tdf134439.py b/sw/qa/uitest/writer_tests4/tdf134439.py
index 738820c71fca..c10b28b448b7 100644
--- a/sw/qa/uitest/writer_tests4/tdf134439.py
+++ b/sw/qa/uitest/writer_tests4/tdf134439.py
@@ -21,11 +21,7 @@ class tdf134439(UITestCase):
         xCursor = document.CurrentController.ViewCursor
         self.assertEqual("Chap 1", xCursor.PageStyleName)
 
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        xWriterEdit = xWriterDoc.getChild("writer_edit")
-        self.ui_test.wait_until_child_is_available(xWriterEdit, 'PageBreak')
-        xPageBreak = xWriterEdit.getChild('PageBreak')
-
+        xPageBreak = self.ui_test.wait_until_child_is_available('PageBreak')
         self.ui_test.execute_dialog_through_action(xPageBreak, "EDIT")
 
         xDialog = self.xUITest.getTopFocusWindow()
diff --git a/sw/qa/uitest/writer_tests4/tdf135636.py b/sw/qa/uitest/writer_tests4/tdf135636.py
index e4da391121e9..3347a4404722 100644
--- a/sw/qa/uitest/writer_tests4/tdf135636.py
+++ b/sw/qa/uitest/writer_tests4/tdf135636.py
@@ -17,11 +17,7 @@ class tdf135636(UITestCase):
 
         self.assertEqual(document.CurrentController.PageCount, 2)
 
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        xWriterEdit = xWriterDoc.getChild("writer_edit")
-        self.ui_test.wait_until_child_is_available(xWriterEdit, 'PageBreak')
-        xPageBreak = xWriterEdit.getChild('PageBreak')
-
+        xPageBreak = self.ui_test.wait_until_child_is_available('PageBreak')
         self.ui_test.execute_dialog_through_action(xPageBreak, "EDIT")
 
         xDialog = self.xUITest.getTopFocusWindow()
diff --git a/sw/qa/uitest/writer_tests4/tdf136578.py b/sw/qa/uitest/writer_tests4/tdf136578.py
index 7475ffd7a606..b30005430deb 100644
--- a/sw/qa/uitest/writer_tests4/tdf136578.py
+++ b/sw/qa/uitest/writer_tests4/tdf136578.py
@@ -13,16 +13,10 @@ class tdf136578(UITestCase):
 
         self.ui_test.load_file(get_url_for_data_file("tdf136578.odt"))
 
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        xWriterEdit = xWriterDoc.getChild("writer_edit")
-
         document = self.ui_test.get_component()
-
         self.assertEqual(document.CurrentController.PageCount, 2)
 
-        self.ui_test.wait_until_child_is_available(xWriterEdit, 'PageBreak')
-        xPageBreak = xWriterEdit.getChild('PageBreak')
-
+        xPageBreak = self.ui_test.wait_until_child_is_available('PageBreak')
         xPageBreak.executeAction("DELETE", tuple())
 
         # Without the fix in place, this test would have failed with
diff --git a/sw/qa/uitest/writer_tests7/tdf132169.py b/sw/qa/uitest/writer_tests7/tdf132169.py
index 90cc4c11dcc9..552c2f5cb409 100644
--- a/sw/qa/uitest/writer_tests7/tdf132169.py
+++ b/sw/qa/uitest/writer_tests7/tdf132169.py
@@ -17,14 +17,10 @@ class tdf132169(UITestCase):
         #set measurement to points
         change_measurement_unit(self, "Point")
 
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        xWriterEdit = xWriterDoc.getChild("writer_edit")
-
         self.xUITest.executeCommand(".uno:JumpToNextFrame")
 
         #wait until the toolbar is available
-        self.ui_test.wait_until_child_is_available(xWriterEdit, 'metricfield')
-        xLineMetric = xWriterEdit.getChild('metricfield')
+        xLineMetric = self.ui_test.wait_until_child_is_available('metricfield')
         self.assertEqual(get_state_as_dict(xLineMetric)["Text"], "0.0 pt")
 
         #Check changing value from dialog also works
diff --git a/sw/qa/uitest/writer_tests7/tdf137802.py b/sw/qa/uitest/writer_tests7/tdf137802.py
index 96c2fa5193af..3062d7009195 100644
--- a/sw/qa/uitest/writer_tests7/tdf137802.py
+++ b/sw/qa/uitest/writer_tests7/tdf137802.py
@@ -24,7 +24,7 @@ class tdf137802(UITestCase):
 
         self.xUITest.executeCommand(".uno:JumpToNextFrame")
 
-        self.ui_test.wait_until_child_is_available(xWriterEdit, 'metricfield')
+        self.ui_test.wait_until_child_is_available('metricfield')
 
         self.ui_test.execute_dialog_through_command(".uno:TransformDialog")
 
@@ -49,7 +49,7 @@ class tdf137802(UITestCase):
         xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ESC"}))
 
         # Wait until the shape is deselected and the cursor is on the document
-        self.ui_test.wait_until_child_is_available(xWriterEdit, 'FontNameBox')
+        self.ui_test.wait_until_child_is_available('FontNameBox')
 
         # Delete the second paragraph. Shape 2 is anchored to this paragraph
         # so it should be deleted
diff --git a/sw/qa/uitest/writer_tests7/tdf137803.py b/sw/qa/uitest/writer_tests7/tdf137803.py
index 249dbbb7cacc..2c3f0fcb3713 100644
--- a/sw/qa/uitest/writer_tests7/tdf137803.py
+++ b/sw/qa/uitest/writer_tests7/tdf137803.py
@@ -19,13 +19,11 @@ class tdf137803(UITestCase):
     def test_tdf137803(self):
         # load the sample file
         self.ui_test.load_file(get_url_for_data_file("tdf137803.odt"))
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        xWriterEdit = xWriterDoc.getChild("writer_edit")
         document = self.ui_test.get_component()
 
         # select the shape
         self.xUITest.executeCommand(".uno:JumpToNextFrame")
-        self.ui_test.wait_until_child_is_available(xWriterEdit, 'metricfield')
+        self.ui_test.wait_until_child_is_available('metricfield')
 
         # open textattrs dialog
         self.ui_test.execute_dialog_through_command(".uno:TextAttributes")
diff --git a/sw/qa/uitest/writer_tests7/tdf139301.py b/sw/qa/uitest/writer_tests7/tdf139301.py
index db48b4d9a5f6..62a80b29998f 100644
--- a/sw/qa/uitest/writer_tests7/tdf139301.py
+++ b/sw/qa/uitest/writer_tests7/tdf139301.py
@@ -6,7 +6,6 @@
 #
 from uitest.framework import UITestCase
 from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
-import time
 
 class tdf139301(UITestCase):
 
@@ -15,25 +14,18 @@ class tdf139301(UITestCase):
 
         styles = ('Long Dash', 'Long Dash Dot', 'Long Dot', 'Double Dash', 'Double Dash Dot', 'Double Dash Dot Dot', 'Dash', 'Dash Dot', 'Dash Dot Dot', 'Dot')
 
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        xWriterEdit = xWriterDoc.getChild("writer_edit")
-
         for i in range(len(styles)):
             # select next line shape
             writer_doc.getCurrentController().select(writer_doc.getDrawPage()[i])
 
             # wait for available line style setting
-            self.ui_test.wait_until_child_is_available(xWriterEdit, 'metricfield')
-            time.sleep(1)
+            self.ui_test.wait_until_child_is_available('metricfield')
 
             # line setting dialog window
             self.ui_test.execute_dialog_through_command(".uno:FormatLine")
-            time.sleep(1)
             xFormatLineDlg = self.xUITest.getTopFocusWindow()
-            time.sleep(1)
             # get line style combo box
             xLineStyle = xFormatLineDlg.getChild("LB_LINE_STYLE")
-            time.sleep(1)
 
             # check preset line style
             style = get_state_as_dict(xLineStyle)['SelectEntryText']
diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 675d8eea4e03..6c10d9821016 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -48,15 +48,21 @@ class UITest(object):
             if component is not None:
                 return component
 
-    def wait_until_child_is_available(self, parent, childName):
+    def wait_until_child_is_available(self, childName):
         time_ = 0
+        xChild = None
+
         while time_ < MAX_WAIT:
-            if childName in parent.getChildren():
+            xDialog = self._xUITest.getTopFocusWindow()
+            if childName in xDialog.getChildren():
+                xChild = xDialog.getChild(childName)
                 break
             else:
                 time_ += DEFAULT_SLEEP
                 time.sleep(DEFAULT_SLEEP)
 
+        return xChild
+
     def wait_until_property_is_updated(self, element, propertyName, value):
         time_ = 0
         while time_ < MAX_WAIT:


More information about the Libreoffice-commits mailing list