diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-06-30 11:57:03 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-06-30 13:18:38 +0200 |
commit | 3874e092da4acbaa076d885444f26f014fd781b5 (patch) | |
tree | 8342124c5325ad188f9b4be87052c4a884af560e /cui | |
parent | 57e8d25a40d7c053fef8ecb452e159264c659604 (diff) |
uitest: guard the remaining create_doc_in_start_center
Mostly done by a script
for motivation, see 89aaa17a0a4413f07da2bc5084b0164f15dc01ac
< UITest: introduce guarded context managers >
Change-Id: I2a6149b318d1fdaa36efe5d65af4c238827eaaf5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118154
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/qa/uitest/dialogs/chardlg.py | 125 | ||||
-rw-r--r-- | cui/qa/uitest/dialogs/pastedlg.py | 51 | ||||
-rw-r--r-- | cui/qa/uitest/dialogs/shortcuts.py | 27 |
3 files changed, 98 insertions, 105 deletions
diff --git a/cui/qa/uitest/dialogs/chardlg.py b/cui/qa/uitest/dialogs/chardlg.py index 878f9e2a8ae7..276f7c9a8c53 100644 --- a/cui/qa/uitest/dialogs/chardlg.py +++ b/cui/qa/uitest/dialogs/chardlg.py @@ -14,84 +14,79 @@ class Test(UITestCase): def testSvxCharEffectsPage(self): # Start Impress. - self.ui_test.create_doc_in_start_center("impress") - template = self.xUITest.getTopFocusWindow() - self.ui_test.close_dialog_through_button(template.getChild("close")) - doc = self.xUITest.getTopFocusWindow() - editWin = doc.getChild("impress_win") - # Select the title shape. - editWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) - editWin.executeAction("TYPE", mkPropertyValues({"TEXT": "t"})) - self.xUITest.executeCommand(".uno:SelectAll") + with self.ui_test.create_doc_in_start_center_guarded("impress") as component: + template = self.xUITest.getTopFocusWindow() + self.ui_test.close_dialog_through_button(template.getChild("close")) + doc = self.xUITest.getTopFocusWindow() + editWin = doc.getChild("impress_win") + # Select the title shape. + editWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + editWin.executeAction("TYPE", mkPropertyValues({"TEXT": "t"})) + self.xUITest.executeCommand(".uno:SelectAll") - # Now use Format -> Character. - with self.ui_test.execute_dialog_through_command(".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()) + # Now use Format -> Character. + with self.ui_test.execute_dialog_through_command(".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() - drawPage = component.getDrawPages().getByIndex(0) - shape = drawPage.getByIndex(0) + # Verify the result. + drawPage = component.getDrawPages().getByIndex(0) + shape = drawPage.getByIndex(0) - # Without the accompanying fix in place, this test would have failed with: - # AssertionError: 100 != 5 - # i.e. the dialog did not set transparency to 5%, instead it left the character color at - # COL_AUTO. - self.assertEqual(shape.CharTransparence, 5) - self.ui_test.close_doc() + # Without the accompanying fix in place, this test would have failed with: + # AssertionError: 100 != 5 + # i.e. the dialog did not set transparency to 5%, instead it left the character color at + # COL_AUTO. + self.assertEqual(shape.CharTransparence, 5) def testSvxCharEffectsPageWriter(self): # Start Writer. - self.ui_test.create_doc_in_start_center("writer") - doc = self.xUITest.getTopFocusWindow() - editWin = doc.getChild("writer_edit") - # Type a character and select it. - editWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) - editWin.executeAction("TYPE", mkPropertyValues({"TEXT": "t"})) - self.xUITest.executeCommand(".uno:SelectAll") + with self.ui_test.create_doc_in_start_center_guarded("writer") as component: + doc = self.xUITest.getTopFocusWindow() + editWin = doc.getChild("writer_edit") + # Type a character and select it. + editWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + editWin.executeAction("TYPE", mkPropertyValues({"TEXT": "t"})) + self.xUITest.executeCommand(".uno:SelectAll") - # Now use Format -> Character. - with self.ui_test.execute_dialog_through_command(".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()) + # Now use Format -> Character. + with self.ui_test.execute_dialog_through_command(".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() - paragraph = component.Text.createEnumeration().nextElement() + # Verify the result. + paragraph = component.Text.createEnumeration().nextElement() - self.assertEqual(paragraph.CharTransparence, 5) - self.ui_test.close_doc() + self.assertEqual(paragraph.CharTransparence, 5) def testSvxCharEffectsPageWriterAutomatic(self): # Start Writer. - self.ui_test.create_doc_in_start_center("writer") - doc = self.xUITest.getTopFocusWindow() - editWin = doc.getChild("writer_edit") + with self.ui_test.create_doc_in_start_center_guarded("writer"): + doc = self.xUITest.getTopFocusWindow() + editWin = doc.getChild("writer_edit") - # Use Format -> Character. - with self.ui_test.execute_dialog_through_command(".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") + # Use Format -> Character. + with self.ui_test.execute_dialog_through_command(".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_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 9248f923891d..cb37387ff081 100644 --- a/cui/qa/uitest/dialogs/pastedlg.py +++ b/cui/qa/uitest/dialogs/pastedlg.py @@ -14,31 +14,30 @@ class Test(UITestCase): def testGetFormat(self): # Copy a string in Impress. - self.ui_test.create_doc_in_start_center("impress") - template = self.xUITest.getTopFocusWindow() - self.ui_test.close_dialog_through_button(template.getChild("close")) - doc = self.xUITest.getTopFocusWindow() - editWin = doc.getChild("impress_win") - # Select the title shape. - editWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) - editWin.executeAction("TYPE", mkPropertyValues({"TEXT": "t"})) - self.xUITest.executeCommand(".uno:SelectAll") - self.xUITest.executeCommand(".uno:Copy") - - # Now use paste special to see what formats are offered. - with self.ui_test.execute_dialog_through_command(".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() + with self.ui_test.create_doc_in_start_center_guarded("impress"): + template = self.xUITest.getTopFocusWindow() + self.ui_test.close_dialog_through_button(template.getChild("close")) + doc = self.xUITest.getTopFocusWindow() + editWin = doc.getChild("impress_win") + # Select the title shape. + editWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + editWin.executeAction("TYPE", mkPropertyValues({"TEXT": "t"})) + self.xUITest.executeCommand(".uno:SelectAll") + self.xUITest.executeCommand(".uno:Copy") + + # Now use paste special to see what formats are offered. + with self.ui_test.execute_dialog_through_command(".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) + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/cui/qa/uitest/dialogs/shortcuts.py b/cui/qa/uitest/dialogs/shortcuts.py index 261536d0694f..e1e318384a28 100644 --- a/cui/qa/uitest/dialogs/shortcuts.py +++ b/cui/qa/uitest/dialogs/shortcuts.py @@ -13,28 +13,27 @@ from uitest.uihelper.common import get_state_as_dict class Test(UITestCase): def test_tab_navigation(self): - self.ui_test.create_doc_in_start_center("writer") - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") + with self.ui_test.create_doc_in_start_center_guarded("writer"): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") - with self.ui_test.execute_dialog_through_command(".uno:EditStyle") as xDialog: + with self.ui_test.execute_dialog_through_command(".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)) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: |