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

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 25 16:37:31 UTC 2021


 uitest/uitest/test.py |   31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

New commits:
commit 66494118ec1ddad3af56a1ed708f0a59fe063e86
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Thu Jun 24 14:28:22 2021 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Fri Jun 25 18:36:49 2021 +0200

    uitest: raise exception if timeout is reached
    
    Change-Id: Ibcde404456f5c71484d925c47eb2a0c20c601033
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117785
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 833f5a726049..e8238f790d6b 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -16,13 +16,6 @@ from com.sun.star.uno import RuntimeException
 
 from libreoffice.uno.eventlistener import EventListener
 
-class DialogNotExecutedException(Exception):
-    def __init__(self, command):
-        self.command = command
-
-    def __str__(self):
-        return "Dialog not executed for: " + self.command
-
 class UITest(object):
 
     def __init__(self, xUITest, xContext):
@@ -58,28 +51,28 @@ class UITest(object):
 
     def wait_until_child_is_available(self, childName):
         time_ = 0
-        xChild = None
 
         while time_ < MAX_WAIT:
             xDialog = self._xUITest.getTopFocusWindow()
             if childName in xDialog.getChildren():
-                xChild = xDialog.getChild(childName)
-                break
+                return xDialog.getChild(childName)
             else:
                 time_ += DEFAULT_SLEEP
                 time.sleep(DEFAULT_SLEEP)
 
-        return xChild
+        raise Exception("Child not found: " + childName)
 
     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
+                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:
@@ -91,10 +84,12 @@ class UITest(object):
                     if len(frames) == 1:
                         self.get_desktop().setActiveFrame(frames[0])
                     time.sleep(DEFAULT_SLEEP)
-                    break
+                    return
                 time_ += DEFAULT_SLEEP
                 time.sleep(DEFAULT_SLEEP)
 
+        raise Exception("Component not loaded")
+
     # Calls UITest.close_doc at exit
     @contextmanager
     def load_file(self, url):
@@ -107,7 +102,7 @@ class UITest(object):
     def execute_dialog_through_command(self, command, printNames=False):
         with EventListener(self._xContext, "DialogExecute", printNames=printNames) as event:
             if not self._xUITest.executeDialog(command):
-                raise DialogNotExecutedException(command)
+                raise Exception("Dialog not executed for: " + command)
             while True:
                 if event.executed:
                     time.sleep(DEFAULT_SLEEP)
@@ -117,7 +112,7 @@ class UITest(object):
     def execute_modeless_dialog_through_command(self, command, printNames=False):
         with EventListener(self._xContext, "ModelessDialogVisible", printNames = printNames) as event:
             if not self._xUITest.executeCommand(command):
-                raise DialogNotExecutedException(command)
+                raise Exception("Dialog not executed for: " + command)
             time_ = 0
             while time_ < MAX_WAIT:
                 if event.executed:
@@ -126,7 +121,7 @@ class UITest(object):
                 time_ += DEFAULT_SLEEP
                 time.sleep(DEFAULT_SLEEP)
 
-        raise DialogNotExecutedException(command)
+        raise Exception("Dialog not executed for: " + command)
 
     # Calls UITest.close_dialog_through_button at exit
     @contextmanager
@@ -147,7 +142,7 @@ class UITest(object):
                     return
                 time_ += DEFAULT_SLEEP
                 time.sleep(DEFAULT_SLEEP)
-        raise DialogNotExecutedException(action)
+        raise Exception("Dialog not executed for: " + action)
 
     def _handle_crash_reporter(self):
         xCrashReportDlg = self._xUITest.getTopFocusWindow()
@@ -244,6 +239,6 @@ class UITest(object):
                     return
                 time_ += DEFAULT_SLEEP
                 time.sleep(DEFAULT_SLEEP)
-        raise DialogNotExecutedException("did not execute a dialog for a blocking action")
+        raise Exception("Did not execute a dialog for a blocking action")
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:


More information about the Libreoffice-commits mailing list