summaryrefslogtreecommitdiff
path: root/sc/qa/uitest/options/tdf122977.py
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2021-06-28 16:52:26 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2021-06-29 13:24:54 +0200
commit279ab35ad07a958b5b8d7d593b9817e7365b9bb5 (patch)
tree725d143d62d22e1ce9bf44f3f58ef3907f24498f /sc/qa/uitest/options/tdf122977.py
parentbeeb10a097cdb44af931b92d2849a7e4d09414c0 (diff)
uitest: guard execute_dialog_through_command in sc
Mostly done with a script for motivation, see 89aaa17a0a4413f07da2bc5084b0164f15dc01ac < UITest: introduce guarded context managers > Change-Id: Id49eb66ba2827a6e2d0a737e48726a1d1c49c814 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118029 Tested-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc/qa/uitest/options/tdf122977.py')
-rw-r--r--sc/qa/uitest/options/tdf122977.py65
1 files changed, 31 insertions, 34 deletions
diff --git a/sc/qa/uitest/options/tdf122977.py b/sc/qa/uitest/options/tdf122977.py
index b81adbc2616a..342faf23df50 100644
--- a/sc/qa/uitest/options/tdf122977.py
+++ b/sc/qa/uitest/options/tdf122977.py
@@ -21,40 +21,37 @@ class chartDefaultColors(UITestCase):
document = self.ui_test.get_component()
#Go to Tools -> Options -> Charts -> Default Colors
- self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog
- xDialogOpt = self.xUITest.getTopFocusWindow()
-
- xPages = xDialogOpt.getChild("pages")
- xChartEntry = xPages.getChild('5') # Charts
- xChartEntry.executeAction("EXPAND", tuple())
- xChartGeneralEntry = xChartEntry.getChild('0')
- xChartGeneralEntry.executeAction("SELECT", tuple()) #Default Colors
- xColors = xDialogOpt.getChild("colors")
- xAdd = xDialogOpt.getChild("add")
- xDelete = xDialogOpt.getChild("delete")
- xDefault = xDialogOpt.getChild("default")
-
- #click Default - reset
- xDefault.executeAction("CLICK", tuple())
- nrDefaultColors = get_state_as_dict(xColors)["Children"]
- nrDefaultColors1 = int(nrDefaultColors) + 1
- xAdd.executeAction("CLICK", tuple()) #add new color
- self.assertEqual(get_state_as_dict(xColors)["Children"], str(nrDefaultColors1))
-
- #delete new color
- with self.ui_test.execute_blocking_action(xDelete.executeAction, args=('CLICK', ()), close_button="yes"):
- pass
-
- self.assertEqual(get_state_as_dict(xColors)["Children"], nrDefaultColors)
-
- xAdd.executeAction("CLICK", tuple()) #add new color
- self.assertEqual(get_state_as_dict(xColors)["Children"], str(nrDefaultColors1))
- #click Default
- xDefault.executeAction("CLICK", tuple())
- self.assertEqual(get_state_as_dict(xColors)["Children"], nrDefaultColors)
-
- xCancelBtn = xDialogOpt.getChild("cancel")
- self.ui_test.close_dialog_through_button(xCancelBtn)
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog", close_button="cancel") as xDialogOpt:
+
+ xPages = xDialogOpt.getChild("pages")
+ xChartEntry = xPages.getChild('5') # Charts
+ xChartEntry.executeAction("EXPAND", tuple())
+ xChartGeneralEntry = xChartEntry.getChild('0')
+ xChartGeneralEntry.executeAction("SELECT", tuple()) #Default Colors
+ xColors = xDialogOpt.getChild("colors")
+ xAdd = xDialogOpt.getChild("add")
+ xDelete = xDialogOpt.getChild("delete")
+ xDefault = xDialogOpt.getChild("default")
+
+ #click Default - reset
+ xDefault.executeAction("CLICK", tuple())
+ nrDefaultColors = get_state_as_dict(xColors)["Children"]
+ nrDefaultColors1 = int(nrDefaultColors) + 1
+ xAdd.executeAction("CLICK", tuple()) #add new color
+ self.assertEqual(get_state_as_dict(xColors)["Children"], str(nrDefaultColors1))
+
+ #delete new color
+ with self.ui_test.execute_blocking_action(xDelete.executeAction, args=('CLICK', ()), close_button="yes"):
+ pass
+
+ self.assertEqual(get_state_as_dict(xColors)["Children"], nrDefaultColors)
+
+ xAdd.executeAction("CLICK", tuple()) #add new color
+ self.assertEqual(get_state_as_dict(xColors)["Children"], str(nrDefaultColors1))
+ #click Default
+ xDefault.executeAction("CLICK", tuple())
+ self.assertEqual(get_state_as_dict(xColors)["Children"], nrDefaultColors)
+
self.ui_test.close_doc()