summaryrefslogtreecommitdiff
path: root/uitest
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-02-25 12:32:32 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2022-02-25 14:04:18 +0100
commitacbd88e677502e12ccaea39330efc5885db0a153 (patch)
tree44807079a0ca9b68cb23c09c52be92839acf1697 /uitest
parentb1d500e8a4eadb72d0e574f77ebf33fbc5701900 (diff)
uitest: unify code and use while True everywhere
No need for MAX_WAIT anymore Change-Id: Ia063068bd7c47f79d8991922086c22250c01f77d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130527 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'uitest')
-rw-r--r--uitest/test_main.py2
-rw-r--r--uitest/uitest/config.py12
-rw-r--r--uitest/uitest/test.py47
3 files changed, 9 insertions, 52 deletions
diff --git a/uitest/test_main.py b/uitest/test_main.py
index daad6dca8c1d..f69e7523530a 100644
--- a/uitest/test_main.py
+++ b/uitest/test_main.py
@@ -12,8 +12,6 @@ import unittest
import importlib
import importlib.machinery
-import uitest.config
-
from uitest.framework import UITestCase
from libreoffice.connection import OfficeConnection
diff --git a/uitest/uitest/config.py b/uitest/uitest/config.py
deleted file mode 100644
index 400fd51f75c2..000000000000
--- a/uitest/uitest/config.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# -*- 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/.
-#
-
-DEFAULT_SLEEP = 0.1
-
-MAX_WAIT = 60
-
-# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 11cb15dab9c8..b718c84bee5e 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -8,14 +8,14 @@
import time
import threading
from contextlib import contextmanager
-from uitest.config import DEFAULT_SLEEP
-from uitest.config import MAX_WAIT
from uitest.uihelper.common import get_state_as_dict
from com.sun.star.uno import RuntimeException
from libreoffice.uno.eventlistener import EventListener
+DEFAULT_SLEEP = 0.1
+
class UITest(object):
def __init__(self, xUITest, xContext):
@@ -50,61 +50,44 @@ class UITest(object):
time.sleep(DEFAULT_SLEEP)
def wait_until_child_is_available(self, childName):
- time_ = 0
-
- while time_ < MAX_WAIT:
+ while True:
xDialog = self._xUITest.getTopFocusWindow()
if childName in xDialog.getChildren():
return xDialog.getChild(childName)
else:
- time_ += DEFAULT_SLEEP
time.sleep(DEFAULT_SLEEP)
- raise Exception("Child not found: " + childName)
-
def wait_until_property_is_updated(self, element, propertyName, value):
- time_ = 0
- while time_ < MAX_WAIT:
+ while True:
if get_state_as_dict(element)[propertyName] == value:
return
else:
- time_ += DEFAULT_SLEEP
time.sleep(DEFAULT_SLEEP)
- raise Exception("Property not updated: " + childName)
-
@contextmanager
def wait_until_component_loaded(self):
with EventListener(self._xContext, "OnLoad") as event:
yield
- time_ = 0
- while time_ < MAX_WAIT:
+ while True:
if event.executed:
frames = self.get_frames()
if len(frames) == 1:
self.get_desktop().setActiveFrame(frames[0])
time.sleep(DEFAULT_SLEEP)
return
- time_ += DEFAULT_SLEEP
time.sleep(DEFAULT_SLEEP)
- raise Exception("Component not loaded")
-
def load_component_from_url(self, url, eventName="OnLoad"):
with EventListener(self._xContext, eventName) as event:
component = self.get_desktop().loadComponentFromURL(url, "_default", 0, tuple())
- time_ = 0
- while time_ < MAX_WAIT:
+ while True:
if event.executed:
frames = self.get_frames()
#activate the newest frame
self.get_desktop().setActiveFrame(frames[-1])
return component
- time_ += DEFAULT_SLEEP
time.sleep(DEFAULT_SLEEP)
- raise Exception("Document not loaded")
-
# Calls UITest.close_doc at exit
@contextmanager
def load_file(self, url):
@@ -121,7 +104,6 @@ class UITest(object):
finally:
self.close_doc()
-
# Calls UITest.close_dialog_through_button at exit
@contextmanager
def execute_dialog_through_command(self, command, printNames=False, close_button = "ok", eventName = "DialogExecute"):
@@ -157,8 +139,7 @@ class UITest(object):
with EventListener(self._xContext, event_name) as event:
ui_object.executeAction(action, parameters)
- time_ = 0
- while time_ < MAX_WAIT:
+ while True:
if event.executed:
xDialog = self._xUITest.getTopFocusWindow()
try:
@@ -167,9 +148,7 @@ class UITest(object):
if close_button:
self.close_dialog_through_button(xDialog.getChild(close_button))
return
- time_ += DEFAULT_SLEEP
time.sleep(DEFAULT_SLEEP)
- raise Exception("Dialog not executed for: " + action)
def _handle_crash_reporter(self):
xCrashReportDlg = self._xUITest.getTopFocusWindow()
@@ -197,8 +176,7 @@ class UITest(object):
with EventListener(self._xContext, "OnNew") as event:
xBtn.executeAction("CLICK", tuple())
- time_ = 0
- while time_ < MAX_WAIT:
+ while True:
if event.executed:
frames = self.get_frames()
self.get_desktop().setActiveFrame(frames[0])
@@ -208,11 +186,8 @@ class UITest(object):
finally:
self.close_doc()
return
- time_ += DEFAULT_SLEEP
time.sleep(DEFAULT_SLEEP)
- raise Exception("Failure doc in start center")
-
def close_dialog_through_button(self, button):
with EventListener(self._xContext, "DialogClosed" ) as event:
button.executeAction("CLICK", tuple())
@@ -257,9 +232,7 @@ class UITest(object):
thread = threading.Thread(target=action, args=args)
with EventListener(self._xContext, ["DialogExecute", "ModelessDialogExecute", "ModelessDialogVisible"], printNames=printNames) as event:
thread.start()
- time_ = 0
- # we are not necessarily opening a dialog, so wait much longer
- while time_ < 10 * MAX_WAIT:
+ while True:
if event.executed:
xDialog = self._xUITest.getTopFocusWindow()
try:
@@ -274,8 +247,6 @@ class UITest(object):
self.close_dialog_through_button(xDialog.getChild(close_button))
thread.join()
return
- time_ += DEFAULT_SLEEP
time.sleep(DEFAULT_SLEEP)
- raise Exception("Did not execute a dialog for a blocking action")
# vim: set shiftwidth=4 softtabstop=4 expandtab: