diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-06-28 21:21:47 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-06-29 13:25:57 +0200 |
commit | 8b961addb7887a8b8dc8dbc6758c3dc7c1068ac4 (patch) | |
tree | 7314f1340c336d5fc0e39bd12c5701ed52309bef /sw/qa/uitest/writer_tests | |
parent | 279ab35ad07a958b5b8d7d593b9817e7365b9bb5 (diff) |
uitest: guard execute_dialog_through_command in sw
Mostly done with a script
for motivation, see 89aaa17a0a4413f07da2bc5084b0164f15dc01ac
< UITest: introduce guarded context managers >
Change-Id: I9def7e8fd8256c3131ca2904f78976b9cd59aa96
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118037
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw/qa/uitest/writer_tests')
-rw-r--r-- | sw/qa/uitest/writer_tests/compareDocuments.py | 40 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests/insertCaption.py | 58 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests/tdf134734.py | 75 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests/tdf53460.py | 13 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests/tdf78068.py | 9 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests/tdf81457.py | 39 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests/tdf93068.py | 32 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests/versionDialog.py | 19 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests/watermark.py | 72 |
9 files changed, 149 insertions, 208 deletions
diff --git a/sw/qa/uitest/writer_tests/compareDocuments.py b/sw/qa/uitest/writer_tests/compareDocuments.py index caac05e583a6..df0315466694 100644 --- a/sw/qa/uitest/writer_tests/compareDocuments.py +++ b/sw/qa/uitest/writer_tests/compareDocuments.py @@ -20,19 +20,17 @@ class compareDocuments(UITestCase): xWriterDoc = self.xUITest.getTopFocusWindow() - self.ui_test.execute_dialog_through_command(".uno:CompareDocuments") + with self.ui_test.execute_dialog_through_command_guarded(".uno:CompareDocuments", close_button="") as xOpenDialog: - xOpenDialog = self.xUITest.getTopFocusWindow() - xFileName = xOpenDialog.getChild("file_name") - xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf130960_2.odt")})) + xFileName = xOpenDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf130960_2.odt")})) + xOpenBtn = xOpenDialog.getChild("open") + xOpenBtn.executeAction("CLICK", tuple()) - xOpenBtn = xOpenDialog.getChild("open") - xOpenBtn.executeAction("CLICK", tuple()) - - # Close the dialog and open it again so the list of changes is updated - xTrackDlg = self.xUITest.getTopFocusWindow() - xcloseBtn = xTrackDlg.getChild("close") - xcloseBtn.executeAction("CLICK", tuple()) + # Close the dialog and open it again so the list of changes is updated + xTrackDlg = self.xUITest.getTopFocusWindow() + xcloseBtn = xTrackDlg.getChild("close") + self.ui_test.close_dialog_through_button(xcloseBtn) self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges") xTrackDlg = self.xUITest.getTopFocusWindow() @@ -52,19 +50,17 @@ class compareDocuments(UITestCase): xWriterDoc = self.xUITest.getTopFocusWindow() - self.ui_test.execute_dialog_through_command(".uno:CompareDocuments") + with self.ui_test.execute_dialog_through_command_guarded(".uno:CompareDocuments", close_button="") as xOpenDialog: - xOpenDialog = self.xUITest.getTopFocusWindow() - xFileName = xOpenDialog.getChild("file_name") - xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf137855_2.odt")})) + xFileName = xOpenDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf137855_2.odt")})) + xOpenBtn = xOpenDialog.getChild("open") + xOpenBtn.executeAction("CLICK", tuple()) - xOpenBtn = xOpenDialog.getChild("open") - xOpenBtn.executeAction("CLICK", tuple()) - - # Close the dialog and open it again so the list of changes is updated - xTrackDlg = self.xUITest.getTopFocusWindow() - xcloseBtn = xTrackDlg.getChild("close") - xcloseBtn.executeAction("CLICK", tuple()) + # Close the dialog and open it again so the list of changes is updated + xTrackDlg = self.xUITest.getTopFocusWindow() + xcloseBtn = xTrackDlg.getChild("close") + self.ui_test.close_dialog_through_button(xcloseBtn) self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges") xTrackDlg = self.xUITest.getTopFocusWindow() diff --git a/sw/qa/uitest/writer_tests/insertCaption.py b/sw/qa/uitest/writer_tests/insertCaption.py index 57f6273875db..2bc6e6578ca2 100644 --- a/sw/qa/uitest/writer_tests/insertCaption.py +++ b/sw/qa/uitest/writer_tests/insertCaption.py @@ -13,58 +13,46 @@ class insertCaption(UITestCase): def test_insert_caption(self): self.ui_test.create_doc_in_start_center("writer") document = self.ui_test.get_component() - self.ui_test.execute_dialog_through_command(".uno:InsertFrame") # insert frame - xDialogFr = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertFrame") as xDialogFr: - xWidth = xDialogFr.getChild("width") - xWidth.executeAction("UP", tuple()) - xWidth.executeAction("UP", tuple()) + xWidth = xDialogFr.getChild("width") + xWidth.executeAction("UP", tuple()) + xWidth.executeAction("UP", tuple()) - xHeight = xDialogFr.getChild("height") - xHeight.executeAction("UP", tuple()) - xHeight.executeAction("UP", tuple()) + xHeight = xDialogFr.getChild("height") + xHeight.executeAction("UP", tuple()) + xHeight.executeAction("UP", tuple()) - xOkBtn=xDialogFr.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) self.assertEqual(document.TextFrames.getCount(), 1) - self.ui_test.execute_dialog_through_command(".uno:InsertCaptionDialog") # caption - xDialogCaption = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertCaptionDialog") as xDialogCaption: - xCapt = xDialogCaption.getChild("caption_edit") - xCapt.executeAction("TYPE", mkPropertyValues({"TEXT":"Caption"})) + xCapt = xDialogCaption.getChild("caption_edit") + xCapt.executeAction("TYPE", mkPropertyValues({"TEXT":"Caption"})) - xOkBtn=xDialogCaption.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) xFrame = document.TextFrames[0] self.assertEqual(document.TextFrames[0].Text.String.replace('\r\n', '\n'), "\nText 1: Caption") - self.ui_test.execute_dialog_through_command(".uno:InsertCaptionDialog") # 2nd caption - xDialogCaption = self.xUITest.getTopFocusWindow() - xCapt = xDialogCaption.getChild("caption_edit") - xCapt.executeAction("TYPE", mkPropertyValues({"TEXT":"Caption2"})) - xSep = xDialogCaption.getChild("separator_edit") - xSep.executeAction("TYPE", mkPropertyValues({"TEXT":"-"})) + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertCaptionDialog") as xDialogCaption: + xCapt = xDialogCaption.getChild("caption_edit") + xCapt.executeAction("TYPE", mkPropertyValues({"TEXT":"Caption2"})) + xSep = xDialogCaption.getChild("separator_edit") + xSep.executeAction("TYPE", mkPropertyValues({"TEXT":"-"})) - xOkBtn=xDialogCaption.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) self.assertEqual(document.TextFrames[0].Text.String.replace('\r\n', '\n'), "\nText 1: Caption\nText 2-: Caption2") - self.ui_test.execute_dialog_through_command(".uno:InsertCaptionDialog") # 3. caption - xDialogCaption = self.xUITest.getTopFocusWindow() - xCapt = xDialogCaption.getChild("caption_edit") - xCapt.executeAction("TYPE", mkPropertyValues({"TEXT":"Caption3"})) - xSep = xDialogCaption.getChild("separator_edit") - xSep.executeAction("TYPE", mkPropertyValues({"TEXT":"-"})) - xPos = xDialogCaption.getChild("position") - select_pos(xPos, "1") - - xOkBtn=xDialogCaption.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertCaptionDialog") as xDialogCaption: + xCapt = xDialogCaption.getChild("caption_edit") + xCapt.executeAction("TYPE", mkPropertyValues({"TEXT":"Caption3"})) + xSep = xDialogCaption.getChild("separator_edit") + xSep.executeAction("TYPE", mkPropertyValues({"TEXT":"-"})) + xPos = xDialogCaption.getChild("position") + select_pos(xPos, "1") + self.assertEqual(document.TextFrames[0].Text.String.replace('\r\n', '\n'), "\nText 1: Caption\nText 2-: Caption2\nText 3--: Caption3") diff --git a/sw/qa/uitest/writer_tests/tdf134734.py b/sw/qa/uitest/writer_tests/tdf134734.py index 5685f00a55a9..178a25adc080 100644 --- a/sw/qa/uitest/writer_tests/tdf134734.py +++ b/sw/qa/uitest/writer_tests/tdf134734.py @@ -17,30 +17,27 @@ class TestClass(UITestCase): document = self.ui_test.get_component() # set margins and fill color - self.ui_test.execute_dialog_through_command(".uno:PageDialog") - DrawPageDialog = self.xUITest.getTopFocusWindow() - xTabs = DrawPageDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - checkBackgroundFullSize = DrawPageDialog.getChild("checkBackgroundFullSize") - self.assertEqual(get_state_as_dict(checkBackgroundFullSize)["Selected"], "true") - spinMargLeft = DrawPageDialog.getChild("spinMargLeft") - for _ in range(20): - spinMargLeft.executeAction("UP",tuple()) - spinMargRight = DrawPageDialog.getChild("spinMargRight") - for _ in range(15): - spinMargRight.executeAction("UP",tuple()) - spinMargTop = DrawPageDialog.getChild("spinMargTop") - for _ in range(10): - spinMargTop.executeAction("UP",tuple()) - spinMargBot = DrawPageDialog.getChild("spinMargBot") - for _ in range(5): - spinMargBot.executeAction("UP",tuple()) - xTabs = DrawPageDialog.getChild("tabcontrol") - select_pos(xTabs, "2") - btncolor = DrawPageDialog.getChild("btncolor") - btncolor.executeAction("CLICK",tuple()) - ok = DrawPageDialog.getChild("ok") - self.ui_test.close_dialog_through_button(ok) + with self.ui_test.execute_dialog_through_command_guarded(".uno:PageDialog") as DrawPageDialog: + xTabs = DrawPageDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + checkBackgroundFullSize = DrawPageDialog.getChild("checkBackgroundFullSize") + self.assertEqual(get_state_as_dict(checkBackgroundFullSize)["Selected"], "true") + spinMargLeft = DrawPageDialog.getChild("spinMargLeft") + for _ in range(20): + spinMargLeft.executeAction("UP",tuple()) + spinMargRight = DrawPageDialog.getChild("spinMargRight") + for _ in range(15): + spinMargRight.executeAction("UP",tuple()) + spinMargTop = DrawPageDialog.getChild("spinMargTop") + for _ in range(10): + spinMargTop.executeAction("UP",tuple()) + spinMargBot = DrawPageDialog.getChild("spinMargBot") + for _ in range(5): + spinMargBot.executeAction("UP",tuple()) + xTabs = DrawPageDialog.getChild("tabcontrol") + select_pos(xTabs, "2") + btncolor = DrawPageDialog.getChild("btncolor") + btncolor.executeAction("CLICK",tuple()) xStyle = document.StyleFamilies["PageStyles"]["Standard"] @@ -52,15 +49,12 @@ class TestClass(UITestCase): self.assertEqual(xStyle.BackgroundFullSize, True) # uncheck it - self.ui_test.execute_dialog_through_command(".uno:PageDialog") - DrawPageDialog = self.xUITest.getTopFocusWindow() - xTabs = DrawPageDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - checkBackgroundFullSize = DrawPageDialog.getChild("checkBackgroundFullSize") - self.assertEqual(get_state_as_dict(checkBackgroundFullSize)["Selected"], "true") - checkBackgroundFullSize.executeAction("CLICK",tuple()) - ok = DrawPageDialog.getChild("ok") - self.ui_test.close_dialog_through_button(ok) + with self.ui_test.execute_dialog_through_command_guarded(".uno:PageDialog") as DrawPageDialog: + xTabs = DrawPageDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + checkBackgroundFullSize = DrawPageDialog.getChild("checkBackgroundFullSize") + self.assertEqual(get_state_as_dict(checkBackgroundFullSize)["Selected"], "true") + checkBackgroundFullSize.executeAction("CLICK",tuple()) self.assertEqual(xStyle.FillStyle, SOLID) self.assertEqual(xStyle.LeftMargin, 2997) @@ -70,15 +64,12 @@ class TestClass(UITestCase): self.assertEqual(xStyle.BackgroundFullSize, False) # check it again - self.ui_test.execute_dialog_through_command(".uno:PageDialog") - DrawPageDialog = self.xUITest.getTopFocusWindow() - xTabs = DrawPageDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - checkBackgroundFullSize = DrawPageDialog.getChild("checkBackgroundFullSize") - self.assertEqual(get_state_as_dict(checkBackgroundFullSize)["Selected"], "false") - checkBackgroundFullSize.executeAction("CLICK",tuple()) - ok = DrawPageDialog.getChild("ok") - self.ui_test.close_dialog_through_button(ok) + with self.ui_test.execute_dialog_through_command_guarded(".uno:PageDialog") as DrawPageDialog: + xTabs = DrawPageDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + checkBackgroundFullSize = DrawPageDialog.getChild("checkBackgroundFullSize") + self.assertEqual(get_state_as_dict(checkBackgroundFullSize)["Selected"], "false") + checkBackgroundFullSize.executeAction("CLICK",tuple()) self.assertEqual(xStyle.FillStyle, SOLID) self.assertEqual(xStyle.LeftMargin, 2997) diff --git a/sw/qa/uitest/writer_tests/tdf53460.py b/sw/qa/uitest/writer_tests/tdf53460.py index 7f4b57416e6f..1688f155dcb6 100644 --- a/sw/qa/uitest/writer_tests/tdf53460.py +++ b/sw/qa/uitest/writer_tests/tdf53460.py @@ -17,17 +17,14 @@ class tdf53460(UITestCase): xWriterEdit = xWriterDoc.getChild("writer_edit") document = self.ui_test.get_component() #-insert a table (by default 2x2) - self.ui_test.execute_dialog_through_command(".uno:InsertTable") - xDialog = self.xUITest.getTopFocusWindow() - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertTable"): + pass #-put the cursor inside first cell top left for example #-insert an inner table (by default 2x2) inside this cell - self.ui_test.execute_dialog_through_command(".uno:InsertTable") - xDialog = self.xUITest.getTopFocusWindow() - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertTable"): + pass + #-still in top left cell, go to the line after the inner table xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) diff --git a/sw/qa/uitest/writer_tests/tdf78068.py b/sw/qa/uitest/writer_tests/tdf78068.py index 1989722a3b1f..f8944196402d 100644 --- a/sw/qa/uitest/writer_tests/tdf78068.py +++ b/sw/qa/uitest/writer_tests/tdf78068.py @@ -19,12 +19,9 @@ class tdf78068(UITestCase): #- add some text type_text(xWriterEdit, "Test") #- go to Format > Paragraph - self.ui_test.execute_dialog_through_command(".uno:ParagraphDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xOK = xDialog.getChild("ok") - xOK.executeAction("CLICK", tuple()) #close dialog + with self.ui_test.execute_dialog_through_command_guarded(".uno:ParagraphDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") self.assertEqual(document.Text.String[0:4], "Test") self.ui_test.close_doc() diff --git a/sw/qa/uitest/writer_tests/tdf81457.py b/sw/qa/uitest/writer_tests/tdf81457.py index 7a15327a45bc..496479e33f66 100644 --- a/sw/qa/uitest/writer_tests/tdf81457.py +++ b/sw/qa/uitest/writer_tests/tdf81457.py @@ -16,26 +16,23 @@ class tdf81457(UITestCase): #tdf 81457 def test_open_documentProperties_tdf81457(self): with self.ui_test.load_file(get_url_for_data_file("tdf81457.odt")) as writer_doc: - self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "2") #tab Custom properties - - aExpectedNames = ['BookMarkCount', 'BookMarkInfo1', 'BookMarkInfo10', 'BookMarkInfo11', - 'BookMarkInfo12', 'BookMarkInfo13'] - aExpectedValues = ['78', '00FF0000FF010', '00FF0000FF1E0', '00FF0000FF1E0', - '00FF0000FF210', '00FF0000FF230'] - - for i in range(6): - xNameBox = xDialog.getChild("namebox" + str(i + 1)) - xTypeBox = xDialog.getChild("typebox" + str(i + 1)) - xValueEdit = xDialog.getChild("valueedit" + str(i + 1)) - self.assertEqual(aExpectedNames[i], get_state_as_dict(xNameBox)['Text']) - self.assertEqual('Text', get_state_as_dict(xTypeBox)['DisplayText']) - self.assertEqual(aExpectedValues[i], get_state_as_dict(xValueEdit)['Text'][:13]) - - - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:SetDocumentProperties") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "2") #tab Custom properties + + aExpectedNames = ['BookMarkCount', 'BookMarkInfo1', 'BookMarkInfo10', 'BookMarkInfo11', + 'BookMarkInfo12', 'BookMarkInfo13'] + aExpectedValues = ['78', '00FF0000FF010', '00FF0000FF1E0', '00FF0000FF1E0', + '00FF0000FF210', '00FF0000FF230'] + + for i in range(6): + xNameBox = xDialog.getChild("namebox" + str(i + 1)) + xTypeBox = xDialog.getChild("typebox" + str(i + 1)) + xValueEdit = xDialog.getChild("valueedit" + str(i + 1)) + self.assertEqual(aExpectedNames[i], get_state_as_dict(xNameBox)['Text']) + self.assertEqual('Text', get_state_as_dict(xTypeBox)['DisplayText']) + self.assertEqual(aExpectedValues[i], get_state_as_dict(xValueEdit)['Text'][:13]) + + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests/tdf93068.py b/sw/qa/uitest/writer_tests/tdf93068.py index a77b4e42da91..2d0177a4f328 100644 --- a/sw/qa/uitest/writer_tests/tdf93068.py +++ b/sw/qa/uitest/writer_tests/tdf93068.py @@ -18,33 +18,23 @@ class tdf93068(UITestCase): # tdf#135950: Character dialog crashes if multiple cells in a # table are selected - self.ui_test.execute_dialog_through_command(".uno:InsertTable") - xDialog = self.xUITest.getTopFocusWindow() - - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertTable"): + pass self.xUITest.executeCommand(".uno:SelectAll") # Check the table is selected self.assertEqual("SwXTextTableCursor", document.CurrentSelection.getImplementationName()) - self.ui_test.execute_dialog_through_command(".uno:FontDialog") - xFontDlg = self.xUITest.getTopFocusWindow() - xOKBtn = xFontDlg.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - self.ui_test.execute_dialog_through_command(".uno:FontDialog") - xFontDlg = self.xUITest.getTopFocusWindow() - xCancBtn = xFontDlg.getChild("cancel") - xCancBtn.executeAction("CLICK", tuple()) - - self.ui_test.execute_dialog_through_command(".uno:FontDialog") - xFontDlg = self.xUITest.getTopFocusWindow() - xDiscardBtn = xFontDlg.getChild("reset") - xDiscardBtn.executeAction("CLICK", tuple()) - xOKBtn = xFontDlg.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:FontDialog"): + pass + + with self.ui_test.execute_dialog_through_command_guarded(".uno:FontDialog", close_button="cancel"): + pass + + with self.ui_test.execute_dialog_through_command_guarded(".uno:FontDialog") as xFontDlg: + xDiscardBtn = xFontDlg.getChild("reset") + xDiscardBtn.executeAction("CLICK", tuple()) self.xUITest.getTopFocusWindow() diff --git a/sw/qa/uitest/writer_tests/versionDialog.py b/sw/qa/uitest/writer_tests/versionDialog.py index df8d09102f1f..e5a1f1fa0ab5 100644 --- a/sw/qa/uitest/writer_tests/versionDialog.py +++ b/sw/qa/uitest/writer_tests/versionDialog.py @@ -18,22 +18,19 @@ class versionDialog(UITestCase): xWriterDoc = self.xUITest.getTopFocusWindow() - self.ui_test.execute_dialog_through_command(".uno:VersionDialog") + with self.ui_test.execute_dialog_through_command_guarded(".uno:VersionDialog", close_button="close") as xVersionDialog: - xVersionDialog = self.xUITest.getTopFocusWindow() - versiondList = xVersionDialog.getChild("versions") + versiondList = xVersionDialog.getChild("versions") - text = "04/06/2020 15:18\t\tHELLO" - self.assertEqual(1, len(versiondList.getChildren())) - self.assertEqual(get_state_as_dict(versiondList.getChild('0'))["Text"].strip(), text) + text = "04/06/2020 15:18\t\tHELLO" + self.assertEqual(1, len(versiondList.getChildren())) + self.assertEqual(get_state_as_dict(versiondList.getChild('0'))["Text"].strip(), text) - xDeleteBtn = xVersionDialog.getChild("delete") - xDeleteBtn.executeAction("CLICK", tuple()) + xDeleteBtn = xVersionDialog.getChild("delete") + xDeleteBtn.executeAction("CLICK", tuple()) - self.assertEqual(0, len(versiondList.getChildren())) + self.assertEqual(0, len(versiondList.getChildren())) - xCloseBtn = xVersionDialog.getChild("close") - xCloseBtn.executeAction("CLICK", tuple()) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests/watermark.py b/sw/qa/uitest/writer_tests/watermark.py index 3cf7c6fd84f6..3802ce17f478 100644 --- a/sw/qa/uitest/writer_tests/watermark.py +++ b/sw/qa/uitest/writer_tests/watermark.py @@ -16,48 +16,36 @@ class watermark(UITestCase): document = self.ui_test.get_component() xWriterDoc = self.xUITest.getTopFocusWindow() - self.ui_test.execute_dialog_through_command(".uno:Watermark") - xDialog = self.xUITest.getTopFocusWindow() - xTextInput = xDialog.getChild("TextInput") - xAngle = xDialog.getChild("Angle") - xTransparency = xDialog.getChild("Transparency") - - xTextInput.executeAction("TYPE", mkPropertyValues({"TEXT":"Watermark"})) - xAngle.executeAction("UP", tuple()) - xTransparency.executeAction("UP", tuple()) - - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) - - self.ui_test.execute_dialog_through_command(".uno:Watermark") - xDialog = self.xUITest.getTopFocusWindow() - xTextInput = xDialog.getChild("TextInput") - xAngle = xDialog.getChild("Angle") - xTransparency = xDialog.getChild("Transparency") - - self.assertEqual(get_state_as_dict(xTextInput)["Text"], "Watermark") - self.assertEqual(get_state_as_dict(xAngle)["Text"], "90°") - self.assertEqual(get_state_as_dict(xTransparency)["Text"], "51%") - - xCancBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancBtn) - - self.ui_test.execute_dialog_through_command(".uno:Watermark") - xDialog = self.xUITest.getTopFocusWindow() - xTextInput = xDialog.getChild("TextInput") - xTextInput.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xTextInput.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) - - self.ui_test.execute_dialog_through_command(".uno:Watermark") - xDialog = self.xUITest.getTopFocusWindow() - xTextInput = xDialog.getChild("TextInput") - - self.assertEqual(get_state_as_dict(xTextInput)["Text"], "") - - xCancBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:Watermark") as xDialog: + xTextInput = xDialog.getChild("TextInput") + xAngle = xDialog.getChild("Angle") + xTransparency = xDialog.getChild("Transparency") + + xTextInput.executeAction("TYPE", mkPropertyValues({"TEXT":"Watermark"})) + xAngle.executeAction("UP", tuple()) + xTransparency.executeAction("UP", tuple()) + + + with self.ui_test.execute_dialog_through_command_guarded(".uno:Watermark", close_button="cancel") as xDialog: + xTextInput = xDialog.getChild("TextInput") + xAngle = xDialog.getChild("Angle") + xTransparency = xDialog.getChild("Transparency") + + self.assertEqual(get_state_as_dict(xTextInput)["Text"], "Watermark") + self.assertEqual(get_state_as_dict(xAngle)["Text"], "90°") + self.assertEqual(get_state_as_dict(xTransparency)["Text"], "51%") + + + with self.ui_test.execute_dialog_through_command_guarded(".uno:Watermark") as xDialog: + xTextInput = xDialog.getChild("TextInput") + xTextInput.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xTextInput.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + + with self.ui_test.execute_dialog_through_command_guarded(".uno:Watermark", close_button="cancel") as xDialog: + xTextInput = xDialog.getChild("TextInput") + + self.assertEqual(get_state_as_dict(xTextInput)["Text"], "") + self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: |