summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2021-06-23 12:14:24 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2021-06-25 18:21:22 +0200
commit8a2d7c797958680bcf133fef44abcf2efd1007d1 (patch)
tree463ffbe3d6bd181914295c4ea3e97435204115f9 /sw
parent49cf5e5303d064a66e4ae97223df92238d556dd1 (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 'sw')
-rw-r--r--sw/qa/uitest/chart/tdf138556.py22
-rw-r--r--sw/qa/uitest/writer_tests4/tdf134439.py19
-rw-r--r--sw/qa/uitest/writer_tests4/tdf135636.py13
-rw-r--r--sw/qa/uitest/writer_tests6/tdf131041.py13
4 files changed, 25 insertions, 42 deletions
diff --git a/sw/qa/uitest/chart/tdf138556.py b/sw/qa/uitest/chart/tdf138556.py
index 4a7f325c8df4..14dbc8675f41 100644
--- a/sw/qa/uitest/chart/tdf138556.py
+++ b/sw/qa/uitest/chart/tdf138556.py
@@ -28,23 +28,15 @@ class tdf138556( UITestCase ):
#Change Chart Type to Stock 1
#TODO: test other subtypes
- self.ui_test.execute_dialog_through_action( xChart, "COMMAND",
- mkPropertyValues({ "COMMAND" : "DiagramType" }))
- xDialog = self.xUITest.getTopFocusWindow()
- xChartType = xDialog.getChild( "charttype" )
- xStockType = xChartType.getChild( "8" )
- xStockType.executeAction( "SELECT", tuple())
- xOKBtn = xDialog.getChild( "ok" )
- self.ui_test.close_dialog_through_button( xOKBtn )
+ with self.ui_test.execute_dialog_through_action( xChart, "COMMAND", mkPropertyValues({ "COMMAND" : "DiagramType" })) as xDialog:
+ xChartType = xDialog.getChild( "charttype" )
+ xStockType = xChartType.getChild( "8" )
+ xStockType.executeAction( "SELECT", tuple())
#Insert Data Series
- self.ui_test.execute_dialog_through_action( xChart, "COMMAND",
- mkPropertyValues({ "COMMAND" : "DiagramData" }))
- xDialog = self.xUITest.getTopFocusWindow()
- xToolbar = xDialog.getChild( "toolbar" )
- xToolbar.executeAction( "CLICK", mkPropertyValues({ "POS" : "1" }))
- xOKBtn = xDialog.getChild( "close" )
- self.ui_test.close_dialog_through_button( xOKBtn )
+ with self.ui_test.execute_dialog_through_action( xChart, "COMMAND", mkPropertyValues({ "COMMAND" : "DiagramData" }), close_button="close") as xDialog:
+ xToolbar = xDialog.getChild( "toolbar" )
+ xToolbar.executeAction( "CLICK", mkPropertyValues({ "POS" : "1" }))
#Check Number of Sequences
xDocument = self.ui_test.get_component()
diff --git a/sw/qa/uitest/writer_tests4/tdf134439.py b/sw/qa/uitest/writer_tests4/tdf134439.py
index 6086ae289a12..8d2d7a1a62f9 100644
--- a/sw/qa/uitest/writer_tests4/tdf134439.py
+++ b/sw/qa/uitest/writer_tests4/tdf134439.py
@@ -23,23 +23,20 @@ class tdf134439(UITestCase):
self.assertEqual("Chap 1", xCursor.PageStyleName)
xPageBreak = self.ui_test.wait_until_child_is_available('PageBreak')
- self.ui_test.execute_dialog_through_action(xPageBreak, "EDIT")
+ with self.ui_test.execute_dialog_through_action(xPageBreak, "EDIT") as xDialog:
- xDialog = self.xUITest.getTopFocusWindow()
- self.assertEqual("Page", get_state_as_dict(xDialog.getChild("comboBreakType"))["SelectEntryText"])
- self.assertEqual("Before", get_state_as_dict(xDialog.getChild("comboBreakPosition"))["SelectEntryText"])
+ self.assertEqual("Page", get_state_as_dict(xDialog.getChild("comboBreakType"))["SelectEntryText"])
+ self.assertEqual("Before", get_state_as_dict(xDialog.getChild("comboBreakPosition"))["SelectEntryText"])
- xPageStyle = xDialog.getChild("comboPageStyle")
- self.assertEqual("Chap 2", get_state_as_dict(xPageStyle)["SelectEntryText"])
+ xPageStyle = xDialog.getChild("comboPageStyle")
+ self.assertEqual("Chap 2", get_state_as_dict(xPageStyle)["SelectEntryText"])
- select_by_text(xPageStyle, "Chap 3")
+ select_by_text(xPageStyle, "Chap 3")
- self.assertEqual("Chap 3", get_state_as_dict(xPageStyle)["SelectEntryText"])
+ self.assertEqual("Chap 3", get_state_as_dict(xPageStyle)["SelectEntryText"])
- # tdf#116070: Without the fix in place, this test would have crashed here
- okBtn = xDialog.getChild("ok")
- self.ui_test.close_dialog_through_button(okBtn)
+ # tdf#116070: Without the fix in place, this test would have crashed here
# Without the fix in place, this test would have failed with
# AssertionError: 'Chap 1' != 'Chap 3'
diff --git a/sw/qa/uitest/writer_tests4/tdf135636.py b/sw/qa/uitest/writer_tests4/tdf135636.py
index f4efcddb3c2e..70f2e4e239dc 100644
--- a/sw/qa/uitest/writer_tests4/tdf135636.py
+++ b/sw/qa/uitest/writer_tests4/tdf135636.py
@@ -18,19 +18,16 @@ class tdf135636(UITestCase):
self.assertEqual(document.CurrentController.PageCount, 2)
xPageBreak = self.ui_test.wait_until_child_is_available('PageBreak')
- self.ui_test.execute_dialog_through_action(xPageBreak, "EDIT")
+ with self.ui_test.execute_dialog_through_action(xPageBreak, "EDIT") as xDialog:
- xDialog = self.xUITest.getTopFocusWindow()
- xBreak = xDialog.getChild("break")
- self.assertEqual("true", get_state_as_dict(xBreak)["Selected"])
+ xBreak = xDialog.getChild("break")
+ self.assertEqual("true", get_state_as_dict(xBreak)["Selected"])
- xBreak.executeAction("CLICK", tuple())
+ xBreak.executeAction("CLICK", tuple())
- self.assertEqual("false", get_state_as_dict(xBreak)["Selected"])
+ self.assertEqual("false", get_state_as_dict(xBreak)["Selected"])
- okBtn = xDialog.getChild("ok")
- self.ui_test.close_dialog_through_button(okBtn)
# Without the fix in place, this test would have failed with
# AssertionError: 2 != 1
diff --git a/sw/qa/uitest/writer_tests6/tdf131041.py b/sw/qa/uitest/writer_tests6/tdf131041.py
index 94a6f2b750e7..aa0df0aa1d10 100644
--- a/sw/qa/uitest/writer_tests6/tdf131041.py
+++ b/sw/qa/uitest/writer_tests6/tdf131041.py
@@ -29,17 +29,14 @@ class tdf131041(UITestCase):
self.assertEqual(get_state_as_dict(xHeaderOn)["Selected"], "true")
self.assertEqual(get_state_as_dict(xMoreBtn)["Enabled"], "true")
- self.ui_test.execute_dialog_through_action(xMoreBtn, "CLICK")
+ with self.ui_test.execute_dialog_through_action(xMoreBtn, "CLICK") as xBorderDlg:
- xBorderDlg = self.xUITest.getTopFocusWindow()
- #modify any property
- bottomft = xBorderDlg.getChild("bottommf")
- bottomft.executeAction("UP", tuple())
+ #modify any property
+ bottomft = xBorderDlg.getChild("bottommf")
+ bottomft.executeAction("UP", tuple())
- #it would crash here
- okBtn = xBorderDlg.getChild("ok")
- self.ui_test.close_dialog_through_button(okBtn)
+ #it would crash here
xDialog = self.xUITest.getTopFocusWindow()
okBtn = xDialog.getChild("ok")