diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-06-17 17:01:23 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-06-21 10:29:40 +0200 |
commit | 8298aa62726312eee6f8fbb64a9fc9b12680447f (patch) | |
tree | d35191b8bc0a48e0e086b19c9c3c0503e217c71b /sw/qa/uitest/writer_tests3 | |
parent | e837f50313a703b6b26abb78f224472c1e4734ea (diff) |
uitest: guard execute_blocking_action
so even if an assert fails, the dialog is closed afterwards
for motivation, see 89aaa17a0a4413f07da2bc5084b0164f15dc01ac
< UITest: introduce guarded context managers >
Change-Id: I9a3adb52546238d960eeaaaf03b6bdbbd5718cf8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117392
Tested-by: Jenkins
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw/qa/uitest/writer_tests3')
-rw-r--r-- | sw/qa/uitest/writer_tests3/autoredactDialog.py | 42 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests3/customizeDialog.py | 9 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests3/hyperlinkdialog.py | 5 |
3 files changed, 19 insertions, 37 deletions
diff --git a/sw/qa/uitest/writer_tests3/autoredactDialog.py b/sw/qa/uitest/writer_tests3/autoredactDialog.py index 240e4bd8bce5..9d3281456ca1 100644 --- a/sw/qa/uitest/writer_tests3/autoredactDialog.py +++ b/sw/qa/uitest/writer_tests3/autoredactDialog.py @@ -68,24 +68,18 @@ class AutoRedactDialog(UITestCase): ["target3", "content3"], ] - def handle_add_dlg(dialog): #handle add target dialog - need special handling - xNewNameTxt=dialog.getChild("name") - xNewContentTxt=dialog.getChild("content") - xOKBtn = dialog.getChild("close") - xTypeList = dialog.getChild("type") #0: Text, 1: Regex, 2: Predefined - - select_pos(xTypeList, 0) #Text - self.assertEqual(int(get_state_as_dict(xTypeList)["SelectEntryPos"]), 0) - - type_text(xNewNameTxt, targets_list[self.add_target_counter][0]) - type_text(xNewContentTxt, targets_list[self.add_target_counter][1]) - - self.ui_test.close_dialog_through_button(xOKBtn) - for i in range(0, len(targets_list)): self.add_target_counter = i - self.ui_test.execute_blocking_action(xAddBtn.executeAction, args=('CLICK', ()), - dialog_handler=handle_add_dlg) #close add target dialog with OK button + with self.ui_test.execute_blocking_action(xAddBtn.executeAction, args=('CLICK', ()), close_button="close") as dialog: + xNewNameTxt=dialog.getChild("name") + xNewContentTxt=dialog.getChild("content") + xTypeList = dialog.getChild("type") #0: Text, 1: Regex, 2: Predefined + + select_pos(xTypeList, 0) #Text + self.assertEqual(int(get_state_as_dict(xTypeList)["SelectEntryPos"]), 0) + + type_text(xNewNameTxt, targets_list[self.add_target_counter][0]) + type_text(xNewContentTxt, targets_list[self.add_target_counter][1]) # Make sure targets are added successfully xTargetsListbox = xDialog.getChild("targets") @@ -131,10 +125,9 @@ class AutoRedactDialog(UITestCase): self.clearTargetsbox(xDialog) # We first need to add a target so that we can edit it - def handle_add_dlg(dialog): #handle add target dialog - need special handling + with self.ui_test.execute_blocking_action(xAddBtn.executeAction, args=('CLICK', ()), close_button="close") as dialog: xNewNameTxt=dialog.getChild("name") xNewContentTxt=dialog.getChild("content") - xOKBtn = dialog.getChild("close") xTypeList = dialog.getChild("type") #0: Text, 1: Regex, 2: Predefined select_pos(xTypeList, 0) #Text @@ -143,11 +136,6 @@ class AutoRedactDialog(UITestCase): type_text(xNewNameTxt, "TestTarget") type_text(xNewContentTxt, "TestContent") - self.ui_test.close_dialog_through_button(xOKBtn) - - self.ui_test.execute_blocking_action(xAddBtn.executeAction, args=('CLICK', ()), - dialog_handler=handle_add_dlg) #close add target dialog with OK button - # Make sure target is added successfully xTargetsListbox = xDialog.getChild("targets") targets_box_state_dict = get_state_as_dict(xTargetsListbox) @@ -158,10 +146,9 @@ class AutoRedactDialog(UITestCase): target_entry.executeAction("SELECT", tuple()) # Now edit the target - def handle_edit_dlg(dialog): #handle add target dialog - need special handling + with self.ui_test.execute_blocking_action(xEditBtn.executeAction, args=('CLICK', ()), close_button="close") as dialog: xNameTxt=dialog.getChild("name") xContentTxt=dialog.getChild("content") - xOKBtn = dialog.getChild("close") xNameTxt.executeAction("CLEAR", tuple()) xContentTxt.executeAction("CLEAR", tuple()) @@ -169,11 +156,6 @@ class AutoRedactDialog(UITestCase): type_text(xNameTxt, "TestTargetEdited") type_text(xContentTxt, "TestContentEdited") - self.ui_test.close_dialog_through_button(xOKBtn) - - self.ui_test.execute_blocking_action(xEditBtn.executeAction, args=('CLICK', ()), - dialog_handler=handle_edit_dlg) #close add target dialog with OK button - # Make sure target is still there xTargetsListbox = xDialog.getChild("targets") targets_box_state_dict = get_state_as_dict(xTargetsListbox) diff --git a/sw/qa/uitest/writer_tests3/customizeDialog.py b/sw/qa/uitest/writer_tests3/customizeDialog.py index 52adae2b0ee1..ca97fbe4e10e 100644 --- a/sw/qa/uitest/writer_tests3/customizeDialog.py +++ b/sw/qa/uitest/writer_tests3/customizeDialog.py @@ -108,23 +108,22 @@ class ConfigureDialog(UITestCase): self.ui_test.create_doc_in_start_center("writer") self.ui_test.execute_dialog_through_command(".uno:ConfigureDialog") - def close_dialog(dlg): - CancelBtn = dlg.getChild("cancel") - self.ui_test.close_dialog_through_button(CancelBtn) # Open the New Menu Dialog with id = 0 xDialog = self.xUITest.getTopFocusWindow() xmenugearbtn=xDialog.getChild("menugearbtn") def show_dialog0(): xmenugearbtn.executeAction("OPENFROMLIST", mkPropertyValues({"POS": "0" })) - self.ui_test.execute_blocking_action( action=show_dialog0, dialog_handler=close_dialog) + with self.ui_test.execute_blocking_action( action=show_dialog0, close_button="cancel"): + pass # Open the Rename Menu Dialog with id = 2 xDialog = self.xUITest.getTopFocusWindow() xmenugearbtn=xDialog.getChild("menugearbtn") def show_dialog2(): xmenugearbtn.executeAction("OPENFROMLIST", mkPropertyValues({"POS": "2"})) - self.ui_test.execute_blocking_action( action=show_dialog2, dialog_handler=close_dialog) + with self.ui_test.execute_blocking_action( action=show_dialog2, close_button="cancel"): + pass xDialog = self.xUITest.getTopFocusWindow() xcancBtn = xDialog.getChild("cancel") diff --git a/sw/qa/uitest/writer_tests3/hyperlinkdialog.py b/sw/qa/uitest/writer_tests3/hyperlinkdialog.py index ff1a30931b5a..5fd946afab0f 100644 --- a/sw/qa/uitest/writer_tests3/hyperlinkdialog.py +++ b/sw/qa/uitest/writer_tests3/hyperlinkdialog.py @@ -105,8 +105,9 @@ class HyperlinkDialog(UITestCase): xHelp.executeAction('FOCUS', tuple()) # Without the fix in place, this test would have crashed here - self.ui_test.execute_blocking_action(xHelp.executeAction, - args=("CLICK", tuple()), dialog_element="cancel") + with self.ui_test.execute_blocking_action(xHelp.executeAction, + args=("CLICK", tuple()), close_button="cancel"): + pass self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: |