From 8fe4a2cb1ad3b4819e069179cc11430c5127613c Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Tue, 29 Jun 2021 11:35:20 +0200 Subject: uitest: guard remaining execute_dialog_through_command Mostly done with a script for motivation, see 89aaa17a0a4413f07da2bc5084b0164f15dc01ac < UITest: introduce guarded context managers > Change-Id: Ib8e7c5f5e2c9b8a7756fe533ea4f30349dd68761 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118076 Tested-by: Xisco Fauli Reviewed-by: Xisco Fauli --- svx/qa/uitest/table/tablecontroller.py | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'svx/qa') diff --git a/svx/qa/uitest/table/tablecontroller.py b/svx/qa/uitest/table/tablecontroller.py index 607df44a3a4f..1b6989f039dd 100644 --- a/svx/qa/uitest/table/tablecontroller.py +++ b/svx/qa/uitest/table/tablecontroller.py @@ -22,14 +22,12 @@ class SvxTableControllerTest(UITestCase): self.xUITest.executeCommand(".uno:InsertTable?Columns:short=2&Rows:short=2") # Enable shadow. - self.ui_test.execute_dialog_through_command(".uno:TableDialog") - tableDialog = self.xUITest.getTopFocusWindow() - tabs = tableDialog.getChild("tabcontrol") - # Select "shadow". - select_pos(tabs, "4") - shadowCheckbox = tableDialog.getChild("TSB_SHOW_SHADOW") - shadowCheckbox.executeAction("CLICK", tuple()) - self.ui_test.close_dialog_through_button(tableDialog.getChild("ok")) + with self.ui_test.execute_dialog_through_command_guarded(".uno:TableDialog") as tableDialog: + tabs = tableDialog.getChild("tabcontrol") + # Select "shadow". + select_pos(tabs, "4") + shadowCheckbox = tableDialog.getChild("TSB_SHOW_SHADOW") + shadowCheckbox.executeAction("CLICK", tuple()) # Check if the shadow was enabled. component = self.ui_test.get_component() @@ -61,14 +59,12 @@ class SvxTableControllerTest(UITestCase): impress.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+TAB"})) impress.executeAction("TYPE", mkPropertyValues({"TEXT": "A3"})) self.xUITest.executeCommand(".uno:SelectAll") - self.ui_test.execute_dialog_through_command(".uno:TableDialog") - tableDialog = self.xUITest.getTopFocusWindow() - tabs = tableDialog.getChild("tabcontrol") - # Select "shadow". - select_pos(tabs, "4") - shadowCheckbox = tableDialog.getChild("TSB_SHOW_SHADOW") - shadowCheckbox.executeAction("CLICK", tuple()) - self.ui_test.close_dialog_through_button(tableDialog.getChild("ok")) + with self.ui_test.execute_dialog_through_command_guarded(".uno:TableDialog") as tableDialog: + tabs = tableDialog.getChild("tabcontrol") + # Select "shadow". + select_pos(tabs, "4") + shadowCheckbox = tableDialog.getChild("TSB_SHOW_SHADOW") + shadowCheckbox.executeAction("CLICK", tuple()) # Then make sure we don't crash: # Without the accompanying fix in place, this test would have failed crashed due to a -- cgit