summaryrefslogtreecommitdiff
path: root/uitest
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2020-05-21 19:32:58 +0200
committerXisco Faulí <xiscofauli@libreoffice.org>2020-05-22 20:05:06 +0200
commit4534d8146f383f75df5f6f4ba2cfe547bcf66a4b (patch)
tree27e9c5998a1400141ffabbe5a7ac4524acc2a0bd /uitest
parent2674248307e11e113f28680c2a13be0c8103be24 (diff)
uitest: Add wait methods for slow elements
some elements take some time to be updated, specially with slow machines or ASan+UBSan builds Use the same time based approach used for launching the dialogs also reintroduce 634ce6f2d87a30b8abd2e8c67668e3bb5d87406b Change-Id: Ia1cca74474ef65578bbc60a53a8a511402a082b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94648 Tested-by: Xisco Faulí <xiscofauli@libreoffice.org> Reviewed-by: Xisco Faulí <xiscofauli@libreoffice.org>
Diffstat (limited to 'uitest')
-rw-r--r--uitest/uitest/test.py18
-rw-r--r--uitest/writer_tests5/tdf114724.py22
2 files changed, 30 insertions, 10 deletions
diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index f0cc1747b02e..ab8f650d548d 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -48,6 +48,24 @@ class UITest(object):
if component is not None:
return component
+ def wait_until_child_is_available(self, parent, childName):
+ time_ = 0
+ while time_ < MAX_WAIT:
+ if childName in parent.getChildren():
+ break
+ else:
+ time_ += DEFAULT_SLEEP
+ time.sleep(DEFAULT_SLEEP)
+
+ def wait_until_property_is_updated(self, element, propertyName, value):
+ time_ = 0
+ while time_ < MAX_WAIT:
+ if get_state_as_dict(element)[propertyName] == value:
+ break
+ else:
+ time_ += DEFAULT_SLEEP
+ time.sleep(DEFAULT_SLEEP)
+
def load_file(self, url):
desktop = self.get_desktop()
with EventListener(self._xContext, "OnLoad") as event:
diff --git a/uitest/writer_tests5/tdf114724.py b/uitest/writer_tests5/tdf114724.py
index 46d19468d43c..09341149c242 100644
--- a/uitest/writer_tests5/tdf114724.py
+++ b/uitest/writer_tests5/tdf114724.py
@@ -6,7 +6,6 @@
from uitest.framework import UITestCase
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.uihelper.common import get_state_as_dict
-import time
from uitest.path import get_srcdir_url
def get_url_for_data_file(file_name):
@@ -25,21 +24,24 @@ class tdf114724(UITestCase):
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanelParent")
xNavigatorPanel.executeAction("ROOT", tuple())
- xContentTree = xNavigatorPanel.getChild('contenttree')
- #Check the content has changed
- self.assertEqual(len(xContentTree.getChildren()), 1)
-
xWriterEdit.executeAction("FOCUS", tuple())
- time.sleep(2)
+
+ self.ui_test.wait_until_property_is_updated(xNavigatorPanel, "selectedtext", "Headings")
+ self.assertEqual(get_state_as_dict(xNavigatorPanel)["selectedtext"], "Headings")
self.assertEqual(get_state_as_dict(xNavigatorPanel)["selectioncount"], "1")
for _ in range(0,3):
xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
- time.sleep(2)
- self.assertEqual(get_state_as_dict(xNavigatorPanel)["selectioncount"], "1")
+
+ self.ui_test.wait_until_property_is_updated(xNavigatorPanel, "selectedtext", "HEADING 4")
+ self.assertEqual(get_state_as_dict(xNavigatorPanel)["selectedtext"], "HEADING 4")
+ self.assertEqual(get_state_as_dict(xNavigatorPanel)["selectioncount"], "1")
+
for _ in range(0,3):
xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"}))
- time.sleep(2)
- self.assertEqual(get_state_as_dict(xNavigatorPanel)["selectioncount"], "1")
+
+ self.ui_test.wait_until_property_is_updated(xNavigatorPanel, "selectedtext", "HEADING 1")
+ self.assertEqual(get_state_as_dict(xNavigatorPanel)["selectedtext"], "HEADING 1")
+ self.assertEqual(get_state_as_dict(xNavigatorPanel)["selectioncount"], "1")
self.xUITest.executeCommand(".uno:Sidebar")
self.ui_test.close_doc()