Kaydet (Commit) fb4d5885 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

uitest: add timeout for blocking actions

Change-Id: I796d4ea0034ddae0427418f0d53a00c3dfa66871
Reviewed-on: https://gerrit.libreoffice.org/49939Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 55f5afe5
...@@ -178,7 +178,7 @@ class UITest(object): ...@@ -178,7 +178,7 @@ class UITest(object):
time.sleep(DEFAULT_SLEEP) time.sleep(DEFAULT_SLEEP)
def execute_blocking_action(self, action, dialog_element=None, def execute_blocking_action(self, action, dialog_element=None,
args=(), dialog_handler=None): args=(), dialog_handler=None, dialog_timeout=30):
"""Executes an action which blocks while a dialog is shown. """Executes an action which blocks while a dialog is shown.
Click a button or perform some other action on the dialog when it Click a button or perform some other action on the dialog when it
...@@ -192,6 +192,8 @@ class UITest(object): ...@@ -192,6 +192,8 @@ class UITest(object):
args(tuple, optional): The arguments to be passed to `action` args(tuple, optional): The arguments to be passed to `action`
dialog_handler(callable, optional): Will be called when the dialog dialog_handler(callable, optional): Will be called when the dialog
is shown, with the dialog object passed as a parameter. is shown, with the dialog object passed as a parameter.
timeout(optional): The maximum time the thread will wait for the
dialog actions to happen. None means wait forever.
""" """
thread = threading.Thread(target=action, args=args) thread = threading.Thread(target=action, args=args)
...@@ -207,7 +209,9 @@ class UITest(object): ...@@ -207,7 +209,9 @@ class UITest(object):
xUIElement.executeAction("CLICK", tuple()) xUIElement.executeAction("CLICK", tuple())
if dialog_handler: if dialog_handler:
dialog_handler(xDlg) dialog_handler(xDlg)
thread.join() thread.join(dialog_timeout)
if thread.isAlive():
raise DialogNotClosedException()
return return
time_ += DEFAULT_SLEEP time_ += DEFAULT_SLEEP
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment