From ffd3a78206ae66bacd35bedc548d3d923ac070d0 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Wed, 21 Dec 2016 23:41:47 +0100 Subject: uitest: add a way to execute blocking actions Change-Id: I312a835fd8de82d5f31e6ba09105b22587c43513 --- uitest/uitest/test.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'uitest') 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: -- cgit