summaryrefslogtreecommitdiff
path: root/uitest
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-12-21 23:41:47 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-12-22 01:17:44 +0100
commitffd3a78206ae66bacd35bedc548d3d923ac070d0 (patch)
tree16f219df1659b11fe1664967c58cd18b87abdc78 /uitest
parent02db166d5f45d659a992911292da452cdb475de0 (diff)
uitest: add a way to execute blocking actions
Change-Id: I312a835fd8de82d5f31e6ba09105b22587c43513
Diffstat (limited to 'uitest')
-rw-r--r--uitest/uitest/test.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index d68a67edd78a..0f8cee182754 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -6,6 +6,7 @@
#
import time
+import threading
from uitest.config import DEFAULT_SLEEP
from libreoffice.uno.eventlistener import EventListener
@@ -151,4 +152,21 @@ class UITest(object):
time_ += DEFAULT_SLEEP
time.sleep(DEFAULT_SLEEP)
+ def execute_blocking_action(self, action, dialog_element, args = ()):
+ thread = threading.Thread(target=action, args=args)
+ with EventListener(self._xContext, ["DialogExecute", "ModelessDialogExecute"]) as event:
+ thread.start()
+ time_ = 0
+ while time_ < 30:
+ if event.executed:
+ xDlg = self._xUITest.getTopFocusWindow()
+ xUIElement = xDlg.getChild(dialog_element)
+ xUIElement.executeAction("CLICK", tuple())
+ thread.join()
+ return
+
+ time_ += DEFAULT_SLEEP
+ time.sleep(DEFAULT_SLEEP)
+ raise DialogNotExecutedException("did not execute a dialog for a blocking action")
+
# vim: set shiftwidth=4 softtabstop=4 expandtab: