diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-06-23 12:14:24 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-06-25 18:21:22 +0200 |
commit | 8a2d7c797958680bcf133fef44abcf2efd1007d1 (patch) | |
tree | 463ffbe3d6bd181914295c4ea3e97435204115f9 /uitest | |
parent | 49cf5e5303d064a66e4ae97223df92238d556dd1 (diff) |
uitest: guard execute_dialog_through_action
Mostly done with a script
for motivation, see 89aaa17a0a4413f07da2bc5084b0164f15dc01ac
< UITest: introduce guarded context managers >
Change-Id: I8b0e4aa746f7973b1bd1343219820d8b2315cf19
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117703
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/uitest/test.py | 10 | ||||
-rw-r--r-- | uitest/uitest/uihelper/guarded.py | 10 |
2 files changed, 8 insertions, 12 deletions
diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py index c601116d2a6b..833f5a726049 100644 --- a/uitest/uitest/test.py +++ b/uitest/uitest/test.py @@ -128,7 +128,9 @@ class UITest(object): raise DialogNotExecutedException(command) - def execute_dialog_through_action(self, ui_object, action, parameters = None, event_name = "DialogExecute"): + # Calls UITest.close_dialog_through_button at exit + @contextmanager + def execute_dialog_through_action(self, ui_object, action, parameters = None, event_name = "DialogExecute", close_button = "ok"): if parameters is None: parameters = tuple() @@ -137,7 +139,11 @@ class UITest(object): time_ = 0 while time_ < MAX_WAIT: if event.executed: - time.sleep(DEFAULT_SLEEP) + xDialog = self._xUITest.getTopFocusWindow() + try: + yield xDialog + finally: + self.close_dialog_through_button(xDialog.getChild(close_button)) return time_ += DEFAULT_SLEEP time.sleep(DEFAULT_SLEEP) diff --git a/uitest/uitest/uihelper/guarded.py b/uitest/uitest/uihelper/guarded.py index 5cfed2d49e1a..f6e91b0f5088 100644 --- a/uitest/uitest/uihelper/guarded.py +++ b/uitest/uitest/uihelper/guarded.py @@ -21,16 +21,6 @@ def create_doc_in_start_center(testCase, app): # Calls UITest.close_dialog_through_button at exit @contextmanager -def execute_dialog_through_action(testCase, ui_object, action, parameters = None, event_name = "DialogExecute", close_button = "ok"): - testCase.ui_test.execute_dialog_through_action(ui_object, action, parameters, event_name) - xDialog = testCase.xUITest.getTopFocusWindow() - try: - yield xDialog - finally: - testCase.ui_test.close_dialog_through_button(xDialog.getChild(close_button)) - -# Calls UITest.close_dialog_through_button at exit -@contextmanager def execute_dialog_through_command(testCase, command, printNames=False, close_button = "ok"): testCase.ui_test.execute_dialog_through_command(command, printNames) xDialog = testCase.xUITest.getTopFocusWindow() |