summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2021-06-29 11:35:20 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2021-06-29 13:26:30 +0200
commit8fe4a2cb1ad3b4819e069179cc11430c5127613c (patch)
treef8265029a84d6a97b9abbe90ab66599749892fa0 /cui
parent8b961addb7887a8b8dc8dbc6758c3dc7c1068ac4 (diff)
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 <xiscofauli@libreoffice.org> Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'cui')
-rw-r--r--cui/qa/uitest/dialogs/chardlg.py60
-rw-r--r--cui/qa/uitest/dialogs/pastedlg.py29
-rw-r--r--cui/qa/uitest/dialogs/shortcuts.py23
3 files changed, 50 insertions, 62 deletions
diff --git a/cui/qa/uitest/dialogs/chardlg.py b/cui/qa/uitest/dialogs/chardlg.py
index fb1c1286cbae..e2c518d18ef3 100644
--- a/cui/qa/uitest/dialogs/chardlg.py
+++ b/cui/qa/uitest/dialogs/chardlg.py
@@ -25,15 +25,13 @@ class Test(UITestCase):
self.xUITest.executeCommand(".uno:SelectAll")
# Now use Format -> Character.
- self.ui_test.execute_dialog_through_command(".uno:FontDialog")
- xDialog = self.xUITest.getTopFocusWindow()
- xTabs = xDialog.getChild("tabcontrol")
- # Select RID_SVXPAGE_CHAR_EFFECTS.
- select_pos(xTabs, "1")
- xFontTransparency = xDialog.getChild("fonttransparencymtr")
- for _ in range(5):
- xFontTransparency.executeAction("UP", tuple())
- self.ui_test.close_dialog_through_button(xDialog.getChild("ok"))
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:FontDialog") as xDialog:
+ xTabs = xDialog.getChild("tabcontrol")
+ # Select RID_SVXPAGE_CHAR_EFFECTS.
+ select_pos(xTabs, "1")
+ xFontTransparency = xDialog.getChild("fonttransparencymtr")
+ for _ in range(5):
+ xFontTransparency.executeAction("UP", tuple())
# Verify the result.
component = self.ui_test.get_component()
@@ -58,19 +56,17 @@ class Test(UITestCase):
self.xUITest.executeCommand(".uno:SelectAll")
# Now use Format -> Character.
- self.ui_test.execute_dialog_through_command(".uno:FontDialog")
- xDialog = self.xUITest.getTopFocusWindow()
- xTabs = xDialog.getChild("tabcontrol")
- # Select RID_SVXPAGE_CHAR_EFFECTS.
- select_pos(xTabs, "1")
- xFontTransparency = xDialog.getChild("fonttransparencymtr")
- # Without the accompanying fix in place, this test would have failed with:
- # AssertionError: 'false' != 'true'
- # i.e. the transparency widget was hidden.
- self.assertEqual(get_state_as_dict(xFontTransparency)["Visible"], "true")
- for _ in range(5):
- xFontTransparency.executeAction("UP", tuple())
- self.ui_test.close_dialog_through_button(xDialog.getChild("ok"))
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:FontDialog") as xDialog:
+ xTabs = xDialog.getChild("tabcontrol")
+ # Select RID_SVXPAGE_CHAR_EFFECTS.
+ select_pos(xTabs, "1")
+ xFontTransparency = xDialog.getChild("fonttransparencymtr")
+ # Without the accompanying fix in place, this test would have failed with:
+ # AssertionError: 'false' != 'true'
+ # i.e. the transparency widget was hidden.
+ self.assertEqual(get_state_as_dict(xFontTransparency)["Visible"], "true")
+ for _ in range(5):
+ xFontTransparency.executeAction("UP", tuple())
# Verify the result.
component = self.ui_test.get_component()
@@ -86,18 +82,16 @@ class Test(UITestCase):
editWin = doc.getChild("writer_edit")
# Use Format -> Character.
- self.ui_test.execute_dialog_through_command(".uno:FontDialog")
- xDialog = self.xUITest.getTopFocusWindow()
- xTabs = xDialog.getChild("tabcontrol")
- # Select RID_SVXPAGE_CHAR_EFFECTS.
- select_pos(xTabs, "1")
- xFontColorLB = xDialog.getChild("fontcolorlb")
- # Without the accompanying fix in place, this test would have failed with:
- # AssertionError: 'White' != 'Automatic'
- # i.e. the auto color lost its alpha component and appeared as white.
- self.assertEqual(get_state_as_dict(xFontColorLB)["Text"], "Automatic")
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:FontDialog") as xDialog:
+ xTabs = xDialog.getChild("tabcontrol")
+ # Select RID_SVXPAGE_CHAR_EFFECTS.
+ select_pos(xTabs, "1")
+ xFontColorLB = xDialog.getChild("fontcolorlb")
+ # Without the accompanying fix in place, this test would have failed with:
+ # AssertionError: 'White' != 'Automatic'
+ # i.e. the auto color lost its alpha component and appeared as white.
+ self.assertEqual(get_state_as_dict(xFontColorLB)["Text"], "Automatic")
- self.ui_test.close_dialog_through_button(xDialog.getChild("ok"))
self.ui_test.close_doc()
# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/cui/qa/uitest/dialogs/pastedlg.py b/cui/qa/uitest/dialogs/pastedlg.py
index 9ac40c55d2b6..048463286003 100644
--- a/cui/qa/uitest/dialogs/pastedlg.py
+++ b/cui/qa/uitest/dialogs/pastedlg.py
@@ -26,22 +26,19 @@ class Test(UITestCase):
self.xUITest.executeCommand(".uno:Copy")
# Now use paste special to see what formats are offered.
- self.ui_test.execute_dialog_through_command(".uno:PasteSpecial")
- pasteSpecial = self.xUITest.getTopFocusWindow()
- formats = pasteSpecial.getChild("list")
- entryCount = int(get_state_as_dict(formats)["Children"])
- items = []
- for index in range(entryCount):
- entry = formats.getChild(str(index))
- entry.executeAction("SELECT", tuple())
- items.append(get_state_as_dict(formats)["SelectEntryText"])
-
- # Make sure there is no RTF vs Richtext duplication.
- self.assertTrue("Rich text formatting (RTF)" in items)
- self.assertFalse("Rich text formatting (Richtext)" in items)
-
- # Close the dialog and the document.
- self.ui_test.close_dialog_through_button(pasteSpecial.getChild("cancel"))
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:PasteSpecial", close_button="cancel") as pasteSpecial:
+ formats = pasteSpecial.getChild("list")
+ entryCount = int(get_state_as_dict(formats)["Children"])
+ items = []
+ for index in range(entryCount):
+ entry = formats.getChild(str(index))
+ entry.executeAction("SELECT", tuple())
+ items.append(get_state_as_dict(formats)["SelectEntryText"])
+
+ # Make sure there is no RTF vs Richtext duplication.
+ self.assertTrue("Rich text formatting (RTF)" in items)
+ self.assertFalse("Rich text formatting (Richtext)" in items)
+
self.ui_test.close_doc()
# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/cui/qa/uitest/dialogs/shortcuts.py b/cui/qa/uitest/dialogs/shortcuts.py
index 8a52ee42315a..7f3f9337a525 100644
--- a/cui/qa/uitest/dialogs/shortcuts.py
+++ b/cui/qa/uitest/dialogs/shortcuts.py
@@ -17,26 +17,23 @@ class Test(UITestCase):
xWriterDoc = self.xUITest.getTopFocusWindow()
xWriterEdit = xWriterDoc.getChild("writer_edit")
- self.ui_test.execute_dialog_through_command(".uno:EditStyle") #open style dialog
- xDialog = self.xUITest.getTopFocusWindow()
+ with self.ui_test.execute_dialog_through_command_guarded(".uno:EditStyle") as xDialog:
- xTabs = xDialog.getChild("tabcontrol")
- select_pos(xTabs, "0")
+ xTabs = xDialog.getChild("tabcontrol")
+ select_pos(xTabs, "0")
- for i in range(16):
- self.assertEqual(get_state_as_dict(xTabs)["CurrPagePos"], str(i))
+ for i in range(16):
+ self.assertEqual(get_state_as_dict(xTabs)["CurrPagePos"], str(i))
- xTabs.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+PAGEDOWN"}))
+ xTabs.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+PAGEDOWN"}))
- self.assertEqual(get_state_as_dict(xTabs)["CurrPagePos"], "0")
+ self.assertEqual(get_state_as_dict(xTabs)["CurrPagePos"], "0")
- for i in reversed(range(16)):
- xTabs.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+PAGEUP"}))
+ for i in reversed(range(16)):
+ xTabs.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+PAGEUP"}))
- self.assertEqual(get_state_as_dict(xTabs)["CurrPagePos"], str(i))
+ self.assertEqual(get_state_as_dict(xTabs)["CurrPagePos"], str(i))
- xOkBtn = xDialog.getChild("ok")
- xOkBtn.executeAction("CLICK", tuple())
self.ui_test.close_doc()