sc/qa/uitest/calc_tests8/tdf126248.py | 4 sd/qa/uitest/impress_tests/autocorrectOptions.py | 153 +++++++++++------------ sd/qa/uitest/impress_tests/customSlideShow.py | 74 ++++------- sd/qa/uitest/impress_tests/masterElements.py | 38 ++--- sd/qa/uitest/impress_tests/masterSlides.py | 9 - sd/qa/uitest/impress_tests/renameSlide.py | 33 +--- sd/qa/uitest/impress_tests/slideShowSettings.py | 70 ++++------ sd/qa/uitest/impress_tests/tdf125449.py | 17 +- sd/qa/uitest/impress_tests/tdf134734.py | 75 ++++------- sd/qa/uitest/impress_tests/tdf137729.py | 17 +- sd/qa/uitest/impress_tests/tdf139511.py | 21 +-- sd/qa/uitest/impress_tests/tdf141297.py | 55 +++----- sd/qa/uitest/impress_tests/tdf91762.py | 9 - sd/qa/uitest/impress_tests/textColumnsDialog.py | 4 sw/qa/uitest/writer_tests2/fontworks.py | 4 uitest/uitest/test.py | 10 + uitest/uitest/uihelper/guarded.py | 10 - 17 files changed, 269 insertions(+), 334 deletions(-)
New commits: commit beeb10a097cdb44af931b92d2849a7e4d09414c0 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Mon Jun 28 10:43:26 2021 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Jun 29 13:24:24 2021 +0200 uitest: guard execute_dialog_through_command in sd Mostly done with a script for motivation, see 89aaa17a0a4413f07da2bc5084b0164f15dc01ac < UITest: introduce guarded context managers > Change-Id: I162dcf802474a27580cfbe9349d1a48d3a111c9e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117999 Tested-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/qa/uitest/calc_tests8/tdf126248.py b/sc/qa/uitest/calc_tests8/tdf126248.py index 27482acd0cde..1609a43cb2bf 100644 --- a/sc/qa/uitest/calc_tests8/tdf126248.py +++ b/sc/qa/uitest/calc_tests8/tdf126248.py @@ -31,7 +31,7 @@ class tdf126248(UITestCase): self.xUITest.executeCommand(".uno:Sidebar") def changeLocalSetting(self, language): - with guarded.execute_dialog_through_command(self, ".uno:OptionsTreeDialog") as xDialog: + with self.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog") as xDialog: xPages = xDialog.getChild("pages") xLanguageEntry = xPages.getChild('2') xLanguageEntry.executeAction("EXPAND", tuple()) @@ -53,7 +53,7 @@ class tdf126248(UITestCase): self.changeLocalSetting("Chinese (traditional)") - with guarded.execute_dialog_through_command(self, ".uno:FormatCellDialog") as xDialog: + with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog: xTabs = xDialog.getChild("tabcontrol") select_pos(xTabs, "1") diff --git a/sd/qa/uitest/impress_tests/autocorrectOptions.py b/sd/qa/uitest/impress_tests/autocorrectOptions.py index d386aa8b189c..d4bc3c5392a9 100644 --- a/sd/qa/uitest/impress_tests/autocorrectOptions.py +++ b/sd/qa/uitest/impress_tests/autocorrectOptions.py @@ -20,84 +20,81 @@ class autocorrectOptions(UITestCase): self.ui_test.close_dialog_through_button(xCancelBtn) document = self.ui_test.get_component() - self.ui_test.execute_dialog_through_command(".uno:AutoCorrectDlg") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") #tab replace - origtext = xDialog.getChild("origtext") - newtext = xDialog.getChild("newtext") - xnew = xDialog.getChild("new") - xdelete = xDialog.getChild("delete") - xtabview = xDialog.getChild("tabview") - xreset = xDialog.getChild("reset") - nrRows = get_state_as_dict(xtabview)["VisibleCount"] - - self.assertTrue(int(nrRows) > 0) - - #add new rule - origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"})) - newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"})) - xnew.executeAction("CLICK", tuple()) - nrRowsNew = get_state_as_dict(xtabview)["VisibleCount"] - nrRowsDiff = int(nrRowsNew) - int(nrRows) - self.assertEqual(nrRowsDiff, 1) #we have +1 rule - #delete rule - origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"})) - newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"})) - xdelete.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(xtabview)["VisibleCount"], nrRows) #we have default nr of rules - - select_pos(xTabs, "1") #tab Exceptions - #abbreviations - abbrev = xDialog.getChild("abbrev") - newabbrev = xDialog.getChild("newabbrev") - delabbrev = xDialog.getChild("delabbrev") - abbrevlist = xDialog.getChild("abbrevlist") - - nrRowsAbb = get_state_as_dict(abbrevlist)["VisibleCount"] - - self.assertTrue(int(nrRowsAbb) > 0) - - abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - abbrev.executeAction("TYPE", mkPropertyValues({"TEXT":"qqqqq"})) - newabbrev.executeAction("CLICK", tuple()) - nrRowsAbbNew = get_state_as_dict(abbrevlist)["VisibleCount"] - nrRowsAbbDiff = int(nrRowsAbbNew) - int(nrRowsAbb) - self.assertEqual(nrRowsAbbDiff, 1) #we have +1 rule - delabbrev.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(abbrevlist)["VisibleCount"], nrRowsAbb) #we have default nr of rules - - #words with two initial capitals - double = xDialog.getChild("double") - newdouble = xDialog.getChild("newdouble") - deldouble = xDialog.getChild("deldouble") - doublelist = xDialog.getChild("doublelist") - - nrRowsDouble = get_state_as_dict(doublelist)["VisibleCount"] - - self.assertTrue(int(nrRowsDouble) > 0) - - double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - double.executeAction("TYPE", mkPropertyValues({"TEXT":"QQqqq"})) - newdouble.executeAction("CLICK", tuple()) - nrRowsDoubleNew = get_state_as_dict(doublelist)["VisibleCount"] - nrRowsDoubleDiff = int(nrRowsDoubleNew) - int(nrRowsDouble) #convert string and - self.assertEqual(nrRowsDoubleDiff, 1) #we have +1 rule - deldouble.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(doublelist)["VisibleCount"], nrRowsDouble) #we have default nr of rules - - xCancelButton = xDialog.getChild("cancel") - xCancelButton.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:AutoCorrectDlg", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab replace + origtext = xDialog.getChild("origtext") + newtext = xDialog.getChild("newtext") + xnew = xDialog.getChild("new") + xdelete = xDialog.getChild("delete") + xtabview = xDialog.getChild("tabview") + xreset = xDialog.getChild("reset") + nrRows = get_state_as_dict(xtabview)["VisibleCount"] + + self.assertTrue(int(nrRows) > 0) + + #add new rule + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"})) + xnew.executeAction("CLICK", tuple()) + nrRowsNew = get_state_as_dict(xtabview)["VisibleCount"] + nrRowsDiff = int(nrRowsNew) - int(nrRows) + self.assertEqual(nrRowsDiff, 1) #we have +1 rule + #delete rule + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"})) + xdelete.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xtabview)["VisibleCount"], nrRows) #we have default nr of rules + + select_pos(xTabs, "1") #tab Exceptions + #abbreviations + abbrev = xDialog.getChild("abbrev") + newabbrev = xDialog.getChild("newabbrev") + delabbrev = xDialog.getChild("delabbrev") + abbrevlist = xDialog.getChild("abbrevlist") + + nrRowsAbb = get_state_as_dict(abbrevlist)["VisibleCount"] + + self.assertTrue(int(nrRowsAbb) > 0) + + abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + abbrev.executeAction("TYPE", mkPropertyValues({"TEXT":"qqqqq"})) + newabbrev.executeAction("CLICK", tuple()) + nrRowsAbbNew = get_state_as_dict(abbrevlist)["VisibleCount"] + nrRowsAbbDiff = int(nrRowsAbbNew) - int(nrRowsAbb) + self.assertEqual(nrRowsAbbDiff, 1) #we have +1 rule + delabbrev.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(abbrevlist)["VisibleCount"], nrRowsAbb) #we have default nr of rules + + #words with two initial capitals + double = xDialog.getChild("double") + newdouble = xDialog.getChild("newdouble") + deldouble = xDialog.getChild("deldouble") + doublelist = xDialog.getChild("doublelist") + + nrRowsDouble = get_state_as_dict(doublelist)["VisibleCount"] + + self.assertTrue(int(nrRowsDouble) > 0) + + double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + double.executeAction("TYPE", mkPropertyValues({"TEXT":"QQqqq"})) + newdouble.executeAction("CLICK", tuple()) + nrRowsDoubleNew = get_state_as_dict(doublelist)["VisibleCount"] + nrRowsDoubleDiff = int(nrRowsDoubleNew) - int(nrRowsDouble) #convert string and + self.assertEqual(nrRowsDoubleDiff, 1) #we have +1 rule + deldouble.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(doublelist)["VisibleCount"], nrRowsDouble) #we have default nr of rules + self.ui_test.close_doc() diff --git a/sd/qa/uitest/impress_tests/customSlideShow.py b/sd/qa/uitest/impress_tests/customSlideShow.py index a7aa67b25816..688fb01f5685 100644 --- a/sd/qa/uitest/impress_tests/customSlideShow.py +++ b/sd/qa/uitest/impress_tests/customSlideShow.py @@ -14,57 +14,49 @@ class customSlideShow(UITestCase): TemplateDialog = self.xUITest.getTopFocusWindow() cancel = TemplateDialog.getChild("close") self.ui_test.close_dialog_through_button(cancel) - self.ui_test.execute_dialog_through_command(".uno:CustomShowDialog") - CustomSlideShows = self.xUITest.getTopFocusWindow() - new = CustomSlideShows.getChild("new") - ok = CustomSlideShows.getChild("ok") + with self.ui_test.execute_dialog_through_command_guarded(".uno:CustomShowDialog") as CustomSlideShows: + new = CustomSlideShows.getChild("new") + + with self.ui_test.execute_blocking_action(new.executeAction, args=('CLICK', ())) as DefineCustomSlideShow: + customname = DefineCustomSlideShow.getChild("customname") + customname.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) + customname.executeAction("TYPE", mkPropertyValues({"TEXT": "a"})) + customname.executeAction("TYPE", mkPropertyValues({"TEXT": "a"})) + pages = DefineCustomSlideShow.getChild("pages") + xEntry = pages.getChild("0") + xEntry.executeAction("SELECT", tuple()) + add = DefineCustomSlideShow.getChild("add") + add.executeAction("CLICK",tuple()) - with self.ui_test.execute_blocking_action(new.executeAction, args=('CLICK', ())) as DefineCustomSlideShow: - customname = DefineCustomSlideShow.getChild("customname") - customname.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) - customname.executeAction("TYPE", mkPropertyValues({"TEXT": "a"})) - customname.executeAction("TYPE", mkPropertyValues({"TEXT": "a"})) - pages = DefineCustomSlideShow.getChild("pages") - xEntry = pages.getChild("0") - xEntry.executeAction("SELECT", tuple()) - add = DefineCustomSlideShow.getChild("add") - add.executeAction("CLICK",tuple()) - - self.ui_test.close_dialog_through_button(ok) #verify - self.ui_test.execute_dialog_through_command(".uno:CustomShowDialog") - CustomSlideShows = self.xUITest.getTopFocusWindow() - edit = CustomSlideShows.getChild("edit") - customshowlist = CustomSlideShows.getChild("customshowlist") - self.assertEqual(get_state_as_dict(customshowlist)["SelectionCount"], "1") - ok = CustomSlideShows.getChild("ok") - - with self.ui_test.execute_blocking_action(edit.executeAction, args=('CLICK', ()), close_button="cancel") as DefineCustomSlideShow: - customname = DefineCustomSlideShow.getChild("customname") - self.assertEqual(get_state_as_dict(customname)["Text"], "aa") + with self.ui_test.execute_dialog_through_command_guarded(".uno:CustomShowDialog") as CustomSlideShows: + edit = CustomSlideShows.getChild("edit") + customshowlist = CustomSlideShows.getChild("customshowlist") + self.assertEqual(get_state_as_dict(customshowlist)["SelectionCount"], "1") + + with self.ui_test.execute_blocking_action(edit.executeAction, args=('CLICK', ()), close_button="cancel") as DefineCustomSlideShow: + customname = DefineCustomSlideShow.getChild("customname") + self.assertEqual(get_state_as_dict(customname)["Text"], "aa") # print(DefineCustomSlideShow.getChildren()) - custompages = DefineCustomSlideShow.getChild("custompages") - pages = DefineCustomSlideShow.getChild("pages") - remove = DefineCustomSlideShow.getChild("remove") + custompages = DefineCustomSlideShow.getChild("custompages") + pages = DefineCustomSlideShow.getChild("pages") + remove = DefineCustomSlideShow.getChild("remove") # print(get_state_as_dict(custompages)) - self.assertEqual(get_state_as_dict(custompages)["Children"], "1") - self.assertEqual(get_state_as_dict(pages)["Children"], "1") - xEntry = custompages.getChild("0") - xEntry.executeAction("SELECT", tuple()) + self.assertEqual(get_state_as_dict(custompages)["Children"], "1") + self.assertEqual(get_state_as_dict(pages)["Children"], "1") + xEntry = custompages.getChild("0") + xEntry.executeAction("SELECT", tuple()) # remove.executeAction("CLICK",tuple()) #tdf126951 - self.assertEqual(get_state_as_dict(custompages)["Children"], "1") - self.assertEqual(get_state_as_dict(pages)["Children"], "1") + self.assertEqual(get_state_as_dict(custompages)["Children"], "1") + self.assertEqual(get_state_as_dict(pages)["Children"], "1") - CustomSlideShows = self.xUITest.getTopFocusWindow() - delete = CustomSlideShows.getChild("delete") - customshowlist = CustomSlideShows.getChild("customshowlist") - self.assertEqual(get_state_as_dict(customshowlist)["Children"], "1") + delete = CustomSlideShows.getChild("delete") + customshowlist = CustomSlideShows.getChild("customshowlist") + self.assertEqual(get_state_as_dict(customshowlist)["Children"], "1") # delete.executeAction("CLICK",tuple()) # self.assertEqual(get_state_as_dict(customshowlist)["Children"], "0") - ok = CustomSlideShows.getChild("ok") - self.ui_test.close_dialog_through_button(ok) self.ui_test.close_doc() diff --git a/sd/qa/uitest/impress_tests/masterElements.py b/sd/qa/uitest/impress_tests/masterElements.py index 00e865d269d5..6dedb805efa2 100644 --- a/sd/qa/uitest/impress_tests/masterElements.py +++ b/sd/qa/uitest/impress_tests/masterElements.py @@ -20,32 +20,26 @@ class masterElements(UITestCase): self.ui_test.close_dialog_through_button(xCancelBtn) document = self.ui_test.get_component() - self.ui_test.execute_dialog_through_command(".uno:MasterLayouts") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:MasterLayouts") as xDialog: - xpagenumber = xDialog.getChild("pagenumber") - xfooter = xDialog.getChild("footer") - datetime = xDialog.getChild("datetime") - xpagenumber.executeAction("CLICK", tuple()) - xfooter.executeAction("CLICK", tuple()) - datetime.executeAction("CLICK", tuple()) + xpagenumber = xDialog.getChild("pagenumber") + xfooter = xDialog.getChild("footer") + datetime = xDialog.getChild("datetime") + xpagenumber.executeAction("CLICK", tuple()) + xfooter.executeAction("CLICK", tuple()) + datetime.executeAction("CLICK", tuple()) - xOKButton = xDialog.getChild("ok") - xOKButton.executeAction("CLICK", tuple()) #verify - self.ui_test.execute_dialog_through_command(".uno:MasterLayouts") - xDialog = self.xUITest.getTopFocusWindow() - xfooter = xDialog.getChild("footer") - datetime = xDialog.getChild("datetime") - xpagenumber = xDialog.getChild("pagenumber") - - self.assertEqual(get_state_as_dict(xfooter)["Selected"], "false") - self.assertEqual(get_state_as_dict(datetime)["Selected"], "false") - self.assertEqual(get_state_as_dict(xpagenumber)["Selected"], "false") - - xOKButton = xDialog.getChild("ok") - xOKButton.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command_guarded(".uno:MasterLayouts") as xDialog: + xfooter = xDialog.getChild("footer") + datetime = xDialog.getChild("datetime") + xpagenumber = xDialog.getChild("pagenumber") + + self.assertEqual(get_state_as_dict(xfooter)["Selected"], "false") + self.assertEqual(get_state_as_dict(datetime)["Selected"], "false") + self.assertEqual(get_state_as_dict(xpagenumber)["Selected"], "false") + self.ui_test.close_doc() diff --git a/sd/qa/uitest/impress_tests/masterSlides.py b/sd/qa/uitest/impress_tests/masterSlides.py index 8a3415576d0a..3bea28a90b6e 100644 --- a/sd/qa/uitest/impress_tests/masterSlides.py +++ b/sd/qa/uitest/impress_tests/masterSlides.py @@ -31,14 +31,11 @@ class masterSlides(UITestCase): xCloseMasterButton = xImpress.getChild("closemasterslide") xCloseMasterButton.executeAction("CLICK", tuple()) - self.ui_test.execute_dialog_through_command(".uno:PresentationLayout") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:PresentationLayout") as xDialog: - xSelect = xDialog.getChild('select') - xSelect.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + xSelect = xDialog.getChild('select') + xSelect.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) xMasterSlide = xImpress.getChild("masterslide") self.assertEqual("Default 1", get_state_as_dict(xMasterSlide)['SelectEntryText']) diff --git a/sd/qa/uitest/impress_tests/renameSlide.py b/sd/qa/uitest/impress_tests/renameSlide.py index 7393a4145a44..afb053e44a24 100644 --- a/sd/qa/uitest/impress_tests/renameSlide.py +++ b/sd/qa/uitest/impress_tests/renameSlide.py @@ -16,39 +16,30 @@ class renameSlide(UITestCase): xCancelBtn = xTemplateDlg.getChild("close") self.ui_test.close_dialog_through_button(xCancelBtn) - self.ui_test.execute_dialog_through_command(".uno:RenamePage") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:RenamePage") as xDialog: - name_entry = xDialog.getChild("name_entry") - name_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName"})) + name_entry = xDialog.getChild("name_entry") + name_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) #verify - self.ui_test.execute_dialog_through_command(".uno:RenamePage") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:RenamePage") as xDialog: - name_entry = xDialog.getChild("name_entry") - self.assertEqual(get_state_as_dict(name_entry)["Text"], "NewName") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + name_entry = xDialog.getChild("name_entry") + self.assertEqual(get_state_as_dict(name_entry)["Text"], "NewName") self.xUITest.executeCommand(".uno:InsertPage") - self.ui_test.execute_dialog_through_command(".uno:RenamePage") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:RenamePage", close_button="cancel") as xDialog: - xOKBtn = xDialog.getChild("ok") - self.assertEqual("true", get_state_as_dict(xOKBtn)['Enabled']) + xOKBtn = xDialog.getChild("ok") + self.assertEqual("true", get_state_as_dict(xOKBtn)['Enabled']) - name_entry = xDialog.getChild("name_entry") - name_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName"})) + name_entry = xDialog.getChild("name_entry") + name_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName"})) - self.assertEqual("false", get_state_as_dict(xOKBtn)['Enabled']) + self.assertEqual("false", get_state_as_dict(xOKBtn)['Enabled']) - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/uitest/impress_tests/slideShowSettings.py b/sd/qa/uitest/impress_tests/slideShowSettings.py index 5b9e44ffa1cc..8d064c895b6b 100644 --- a/sd/qa/uitest/impress_tests/slideShowSettings.py +++ b/sd/qa/uitest/impress_tests/slideShowSettings.py @@ -14,48 +14,42 @@ class slideShowSettings(UITestCase): cancel = TemplateDialog.getChild("close") self.ui_test.close_dialog_through_button(cancel) self.xUITest.executeCommand(".uno:InsertPage") - self.ui_test.execute_dialog_through_command(".uno:PresentationDialog") - PresentationDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:PresentationDialog") as PresentationDialog: - xfrom = PresentationDialog.getChild("from") - xfrom.executeAction("CLICK",tuple()) - from_cb = PresentationDialog.getChild("from_cb") - from_cb.executeAction("SELECT", mkPropertyValues({"POS": "0"})) - window = PresentationDialog.getChild("window") - window.executeAction("CLICK",tuple()) - manualslides = PresentationDialog.getChild("manualslides") - manualslides.executeAction("CLICK",tuple()) - pointervisible = PresentationDialog.getChild("pointervisible") - pointervisible.executeAction("CLICK",tuple()) - pointeraspen = PresentationDialog.getChild("pointeraspen") - pointeraspen.executeAction("CLICK",tuple()) - animationsallowed = PresentationDialog.getChild("animationsallowed") - animationsallowed.executeAction("CLICK",tuple()) - changeslidesbyclick = PresentationDialog.getChild("changeslidesbyclick") - changeslidesbyclick.executeAction("CLICK",tuple()) + xfrom = PresentationDialog.getChild("from") + xfrom.executeAction("CLICK",tuple()) + from_cb = PresentationDialog.getChild("from_cb") + from_cb.executeAction("SELECT", mkPropertyValues({"POS": "0"})) + window = PresentationDialog.getChild("window") + window.executeAction("CLICK",tuple()) + manualslides = PresentationDialog.getChild("manualslides") + manualslides.executeAction("CLICK",tuple()) + pointervisible = PresentationDialog.getChild("pointervisible") + pointervisible.executeAction("CLICK",tuple()) + pointeraspen = PresentationDialog.getChild("pointeraspen") + pointeraspen.executeAction("CLICK",tuple()) + animationsallowed = PresentationDialog.getChild("animationsallowed") + animationsallowed.executeAction("CLICK",tuple()) + changeslidesbyclick = PresentationDialog.getChild("changeslidesbyclick") + changeslidesbyclick.executeAction("CLICK",tuple()) - ok = PresentationDialog.getChild("ok") - self.ui_test.close_dialog_through_button(ok) #verify - self.ui_test.execute_dialog_through_command(".uno:PresentationDialog") - PresentationDialog = self.xUITest.getTopFocusWindow() - xfrom = PresentationDialog.getChild("from") - self.assertEqual(get_state_as_dict(xfrom)["Checked"], "true") - from_cb = PresentationDialog.getChild("from_cb") - self.assertEqual(get_state_as_dict(from_cb)["SelectEntryText"], "Slide 1") - manualslides = PresentationDialog.getChild("manualslides") - self.assertEqual(get_state_as_dict(manualslides)["Selected"], "true") - pointervisible = PresentationDialog.getChild("pointervisible") - self.assertEqual(get_state_as_dict(pointervisible)["Selected"], "true") - pointeraspen = PresentationDialog.getChild("pointeraspen") - self.assertEqual(get_state_as_dict(pointeraspen)["Selected"], "true") - animationsallowed = PresentationDialog.getChild("animationsallowed") - self.assertEqual(get_state_as_dict(animationsallowed)["Selected"], "false") - changeslidesbyclick = PresentationDialog.getChild("changeslidesbyclick") - self.assertEqual(get_state_as_dict(changeslidesbyclick)["Selected"], "false") + with self.ui_test.execute_dialog_through_command_guarded(".uno:PresentationDialog", close_button="cancel") as PresentationDialog: + xfrom = PresentationDialog.getChild("from") + self.assertEqual(get_state_as_dict(xfrom)["Checked"], "true") + from_cb = PresentationDialog.getChild("from_cb") + self.assertEqual(get_state_as_dict(from_cb)["SelectEntryText"], "Slide 1") + manualslides = PresentationDialog.getChild("manualslides") + self.assertEqual(get_state_as_dict(manualslides)["Selected"], "true") + pointervisible = PresentationDialog.getChild("pointervisible") + self.assertEqual(get_state_as_dict(pointervisible)["Selected"], "true") + pointeraspen = PresentationDialog.getChild("pointeraspen") + self.assertEqual(get_state_as_dict(pointeraspen)["Selected"], "true") + animationsallowed = PresentationDialog.getChild("animationsallowed") + self.assertEqual(get_state_as_dict(animationsallowed)["Selected"], "false") + changeslidesbyclick = PresentationDialog.getChild("changeslidesbyclick") + self.assertEqual(get_state_as_dict(changeslidesbyclick)["Selected"], "false") - cancel = PresentationDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(cancel) self.ui_test.close_doc() diff --git a/sd/qa/uitest/impress_tests/tdf125449.py b/sd/qa/uitest/impress_tests/tdf125449.py index 43db59b3be14..206a9a88eae6 100644 --- a/sd/qa/uitest/impress_tests/tdf125449.py +++ b/sd/qa/uitest/impress_tests/tdf125449.py @@ -18,20 +18,17 @@ class tdf125449(UITestCase): xCancelBtn = xTemplateDlg.getChild("close") self.ui_test.close_dialog_through_button(xCancelBtn) - self.ui_test.execute_dialog_through_command(".uno:PageSetup") + with self.ui_test.execute_dialog_through_command_guarded(".uno:PageSetup") as xPageSetupDlg: - xPageSetupDlg = self.xUITest.getTopFocusWindow() - tabcontrol = xPageSetupDlg.getChild("tabcontrol") - select_pos(tabcontrol, "1") + tabcontrol = xPageSetupDlg.getChild("tabcontrol") + select_pos(tabcontrol, "1") - xBtn = xPageSetupDlg.getChild('btngradient') - xBtn.executeAction("CLICK", tuple()) + xBtn = xPageSetupDlg.getChild('btngradient') + xBtn.executeAction("CLICK", tuple()) - xAngle = xPageSetupDlg.getChild('anglemtr') - xAngle.executeAction("UP", tuple()) + xAngle = xPageSetupDlg.getChild('anglemtr') + xAngle.executeAction("UP", tuple()) - xOkBtn = xPageSetupDlg.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) document = self.ui_test.get_component() self.assertEqual( diff --git a/sd/qa/uitest/impress_tests/tdf134734.py b/sd/qa/uitest/impress_tests/tdf134734.py index 29641e06403a..b5db370c7f76 100644 --- a/sd/qa/uitest/impress_tests/tdf134734.py +++ b/sd/qa/uitest/impress_tests/tdf134734.py @@ -20,30 +20,27 @@ class TestClass(UITestCase): self.ui_test.close_dialog_through_button(close) # set margins and fill color - self.ui_test.execute_dialog_through_command(".uno:PageSetup") - DrawPageDialog = self.xUITest.getTopFocusWindow() - xTabs = DrawPageDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - checkBackgroundFullSize = DrawPageDialog.getChild("checkBackgroundFullSize") - self.assertEqual(get_state_as_dict(checkBackgroundFullSize)["Selected"], "false") - 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, "1") - 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:PageSetup") as DrawPageDialog: + xTabs = DrawPageDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + checkBackgroundFullSize = DrawPageDialog.getChild("checkBackgroundFullSize") + self.assertEqual(get_state_as_dict(checkBackgroundFullSize)["Selected"], "false") + 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, "1") + btncolor = DrawPageDialog.getChild("btncolor") + btncolor.executeAction("CLICK",tuple()) self.assertEqual( document.DrawPages.getByIndex(0).Background.FillStyle, SOLID) @@ -59,15 +56,12 @@ class TestClass(UITestCase): document.MasterPages.getByIndex(0).BackgroundFullSize, False) # check it - self.ui_test.execute_dialog_through_command(".uno:PageSetup") - DrawPageDialog = self.xUITest.getTopFocusWindow() - xTabs = DrawPageDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - 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:PageSetup") as DrawPageDialog: + xTabs = DrawPageDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + checkBackgroundFullSize = DrawPageDialog.getChild("checkBackgroundFullSize") + self.assertEqual(get_state_as_dict(checkBackgroundFullSize)["Selected"], "false") + checkBackgroundFullSize.executeAction("CLICK",tuple()) self.assertEqual( document.DrawPages.getByIndex(0).Background.FillStyle, SOLID) @@ -83,15 +77,12 @@ class TestClass(UITestCase): document.MasterPages.getByIndex(0).BackgroundFullSize, True) # uncheck it again - self.ui_test.execute_dialog_through_command(".uno:PageSetup") - DrawPageDialog = self.xUITest.getTopFocusWindow() - xTabs = DrawPageDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - 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:PageSetup") as DrawPageDialog: + xTabs = DrawPageDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + checkBackgroundFullSize = DrawPageDialog.getChild("checkBackgroundFullSize") + self.assertEqual(get_state_as_dict(checkBackgroundFullSize)["Selected"], "true") + checkBackgroundFullSize.executeAction("CLICK",tuple()) self.assertEqual( document.DrawPages.getByIndex(0).Background.FillStyle, SOLID) diff --git a/sd/qa/uitest/impress_tests/tdf137729.py b/sd/qa/uitest/impress_tests/tdf137729.py index 1e4dfb050b5a..49b96d042f2e 100644 --- a/sd/qa/uitest/impress_tests/tdf137729.py +++ b/sd/qa/uitest/impress_tests/tdf137729.py @@ -19,20 +19,17 @@ class tdf137729(UITestCase): xCancelBtn = xTemplateDlg.getChild("close") self.ui_test.close_dialog_through_button(xCancelBtn) - self.ui_test.execute_dialog_through_command(".uno:PageSetup") + with self.ui_test.execute_dialog_through_command_guarded(".uno:PageSetup") as xPageSetupDlg: - xPageSetupDlg = self.xUITest.getTopFocusWindow() - tabcontrol = xPageSetupDlg.getChild("tabcontrol") - select_pos(tabcontrol, "1") + tabcontrol = xPageSetupDlg.getChild("tabcontrol") + select_pos(tabcontrol, "1") - xBtn = xPageSetupDlg.getChild('btnhatch') - xBtn.executeAction("CLICK", tuple()) + xBtn = xPageSetupDlg.getChild('btnhatch') + xBtn.executeAction("CLICK", tuple()) - xDistance = xPageSetupDlg.getChild('distancemtr') - xDistance.executeAction("UP", tuple()) + xDistance = xPageSetupDlg.getChild('distancemtr') + xDistance.executeAction("UP", tuple()) - xOkBtn = xPageSetupDlg.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) document = self.ui_test.get_component() self.assertEqual( diff --git a/sd/qa/uitest/impress_tests/tdf139511.py b/sd/qa/uitest/impress_tests/tdf139511.py index 190d224f10d1..bc12360eed29 100644 --- a/sd/qa/uitest/impress_tests/tdf139511.py +++ b/sd/qa/uitest/impress_tests/tdf139511.py @@ -25,23 +25,20 @@ class tdf139511(UITestCase): self.assertEqual(8004, document.DrawPages[0].getByIndex(2).BoundRect.Height) self.assertEqual(14104, document.DrawPages[0].getByIndex(2).BoundRect.Width) - self.ui_test.execute_dialog_through_command(".uno:TransformDialog") + with self.ui_test.execute_dialog_through_command_guarded(".uno:TransformDialog") as xDialog: - xDialog = self.xUITest.getTopFocusWindow() - xWidth = xDialog.getChild('MTR_FLD_WIDTH') - xHeight = xDialog.getChild('MTR_FLD_HEIGHT') + xWidth = xDialog.getChild('MTR_FLD_WIDTH') + xHeight = xDialog.getChild('MTR_FLD_HEIGHT') - xWidth.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+A"})) - xWidth.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) - xWidth.executeAction("TYPE", mkPropertyValues({"TEXT": "10"})) + xWidth.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+A"})) + xWidth.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) + xWidth.executeAction("TYPE", mkPropertyValues({"TEXT": "10"})) - xHeight.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+A"})) - xHeight.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) - xHeight.executeAction("TYPE", mkPropertyValues({"TEXT": "5"})) + xHeight.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+A"})) + xHeight.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) + xHeight.executeAction("TYPE", mkPropertyValues({"TEXT": "5"})) - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) document = self.ui_test.get_component() diff --git a/sd/qa/uitest/impress_tests/tdf141297.py b/sd/qa/uitest/impress_tests/tdf141297.py index cf6991414715..da15efda1dc9 100644 --- a/sd/qa/uitest/impress_tests/tdf141297.py +++ b/sd/qa/uitest/impress_tests/tdf141297.py @@ -21,62 +21,53 @@ class tdf141297(UITestCase): xCancelBtn = xTemplateDlg.getChild("close") self.ui_test.close_dialog_through_button(xCancelBtn) - self.ui_test.execute_dialog_through_command(".uno:InsertGraphic") + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertGraphic", close_button="open") as xOpenDialog: - xOpenDialog = self.xUITest.getTopFocusWindow() - xFileName = xOpenDialog.getChild("file_name") - xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("LibreOffice.jpg")})) + xFileName = xOpenDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("LibreOffice.jpg")})) - xLink = xOpenDialog.getChild("link") - self.assertEqual("false", get_state_as_dict(xLink)['Selected']) + xLink = xOpenDialog.getChild("link") + self.assertEqual("false", get_state_as_dict(xLink)['Selected']) - xLink.executeAction("CLICK", tuple()) + xLink.executeAction("CLICK", tuple()) - xOpenBtn = xOpenDialog.getChild("open") - xOpenBtn.executeAction("CLICK", tuple()) #Confirmation dialog is displayed xWarnDialog = self.xUITest.getTopFocusWindow() xOK = xWarnDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOK) - self.ui_test.execute_dialog_through_command(".uno:ManageLinks") + with self.ui_test.execute_dialog_through_command_guarded(".uno:ManageLinks", close_button="close") as xDialog: - xDialog = self.xUITest.getTopFocusWindow() - sLinks = "TB_LINKS" - xLinks = xDialog.getChild(sLinks) - self.assertEqual(1, len(xLinks.getChildren())) + sLinks = "TB_LINKS" + xLinks = xDialog.getChild(sLinks) + self.assertEqual(1, len(xLinks.getChildren())) - sFileName = "FULL_FILE_NAME" - xFileName = xDialog.getChild(sFileName) - self.assertTrue(get_state_as_dict(xFileName)["Text"].endswith("/LibreOffice.jpg")) + sFileName = "FULL_FILE_NAME" + xFileName = xDialog.getChild(sFileName) + self.assertTrue(get_state_as_dict(xFileName)["Text"].endswith("/LibreOffice.jpg")) - sBreakLink = "BREAK_LINK" - xBreakLink = xDialog.getChild(sBreakLink) + sBreakLink = "BREAK_LINK" + xBreakLink = xDialog.getChild(sBreakLink) - with self.ui_test.execute_blocking_action(xBreakLink.executeAction, - args=("CLICK", tuple()), close_button="yes"): - pass + with self.ui_test.execute_blocking_action(xBreakLink.executeAction, + args=("CLICK", tuple()), close_button="yes"): + pass - xClose = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xClose) with TemporaryDirectory() as tempdir: xFilePath = os.path.join(tempdir, "tdf141297-tmp.odp") # Save Copy as - self.ui_test.execute_dialog_through_command(".uno:SaveAs") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_dialog_through_command_guarded(".uno:SaveAs", close_button="open") as xDialog: - xFileName = xDialog.getChild("file_name") - xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) + xFileName = xDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) - xOpenBtn = xDialog.getChild("open") - self.ui_test.close_dialog_through_button(xOpenBtn) # Close the Writer document self.ui_test.close_doc() diff --git a/sd/qa/uitest/impress_tests/tdf91762.py b/sd/qa/uitest/impress_tests/tdf91762.py index 8492e3425373..7f732c97f187 100644 --- a/sd/qa/uitest/impress_tests/tdf91762.py +++ b/sd/qa/uitest/impress_tests/tdf91762.py @@ -18,12 +18,9 @@ class tdf91762(UITestCase): self.xUITest.executeCommand(".uno:AssignLayout?WhatLayout:long=1") - self.ui_test.execute_dialog_through_command(".uno:InsertTable") - xDialog = self.xUITest.getTopFocusWindow() - self.assertEqual('5', get_state_as_dict(xDialog.getChild('columns'))['Text']) - self.assertEqual('2', get_state_as_dict(xDialog.getChild('rows'))['Text']) - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) + with self.ui_test.execute_dialog_through_command_guarded(".uno:InsertTable") as xDialog: + self.assertEqual('5', get_state_as_dict(xDialog.getChild('columns'))['Text']) + self.assertEqual('2', get_state_as_dict(xDialog.getChild('rows'))['Text']) document = self.ui_test.get_component() self.assertEqual(1931, document.DrawPages[0].getByIndex(1).BoundRect.Height) diff --git a/sd/qa/uitest/impress_tests/textColumnsDialog.py b/sd/qa/uitest/impress_tests/textColumnsDialog.py index d6ae7d248000..d2119dbb37ce 100644 --- a/sd/qa/uitest/impress_tests/textColumnsDialog.py +++ b/sd/qa/uitest/impress_tests/textColumnsDialog.py @@ -31,7 +31,7 @@ class textColumnsDialog(UITestCase): self.assertEqual("com.sun.star.drawing.SvxShapeCollection", document.CurrentSelection.getImplementationName()) # Test defaults and set some values - with guarded.execute_dialog_through_command(self, ".uno:TextAttributes") as xDialog: + with self.ui_test.execute_dialog_through_command_guarded(".uno:TextAttributes") as xDialog: xTabs = xDialog.getChild("tabcontrol") select_pos(xTabs, "2") colNumber = xDialog.getChild('FLD_COL_NUMBER') @@ -42,7 +42,7 @@ class textColumnsDialog(UITestCase): colSpacing.executeAction("SET", mkPropertyValues({"TEXT": "1.5"})) # Test that settings persist - with guarded.execute_dialog_through_command(self, ".uno:TextAttributes") as xDialog: + with self.ui_test.execute_dialog_through_command_guarded(".uno:TextAttributes") as xDialog: xTabs = xDialog.getChild("tabcontrol") select_pos(xTabs, "2") colNumber = xDialog.getChild('FLD_COL_NUMBER') diff --git a/sw/qa/uitest/writer_tests2/fontworks.py b/sw/qa/uitest/writer_tests2/fontworks.py index d9ef76c10602..489bf3a120a8 100644 --- a/sw/qa/uitest/writer_tests2/fontworks.py +++ b/sw/qa/uitest/writer_tests2/fontworks.py @@ -10,7 +10,7 @@ from uitest.framework import UITestCase from uitest.uihelper.common import get_state_as_dict from libreoffice.uno.propertyvalue import mkPropertyValues -from uitest.uihelper import guarded + #test FontWorks dialog class fontWorksDialog(UITestCase): @@ -19,7 +19,7 @@ class fontWorksDialog(UITestCase): xWriterDoc = self.xUITest.getTopFocusWindow() xWriterEdit = xWriterDoc.getChild("writer_edit") - with guarded.execute_dialog_through_command(self, ".uno:FontworkGalleryFloater", close_button="cancel") as xDialog: + with self.ui_test.execute_dialog_through_command_guarded(".uno:FontworkGalleryFloater", close_button="cancel") as xDialog: FontWorkSelector = xDialog.getChild("ctlFavoriteswin") # Select element with id (3) element3 = FontWorkSelector.getChild("2") diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py index 633e6816e7fd..d4a953715978 100644 --- a/uitest/uitest/test.py +++ b/uitest/uitest/test.py @@ -118,6 +118,16 @@ class UITest(object): return time.sleep(DEFAULT_SLEEP) + # Calls UITest.close_dialog_through_button at exit + @contextmanager + def execute_dialog_through_command_guarded(self, command, printNames=False, close_button = "ok"): + self.execute_dialog_through_command(command, printNames) + xDialog = self._xUITest.getTopFocusWindow() + try: + yield xDialog + finally: + self.close_dialog_through_button(xDialog.getChild(close_button)) + def execute_modeless_dialog_through_command(self, command, printNames=False): with EventListener(self._xContext, "ModelessDialogVisible", printNames = printNames) as event: if not self._xUITest.executeCommand(command): diff --git a/uitest/uitest/uihelper/guarded.py b/uitest/uitest/uihelper/guarded.py index f6e91b0f5088..67a11137357d 100644 --- a/uitest/uitest/uihelper/guarded.py +++ b/uitest/uitest/uihelper/guarded.py @@ -19,14 +19,4 @@ def create_doc_in_start_center(testCase, app): finally: testCase.ui_test.close_doc() -# Calls UITest.close_dialog_through_button at exit -@contextmanager -def execute_dialog_through_command(testCase, command, printNames=False, close_button = "ok"): - testCase.ui_test.execute_dialog_through_command(command, printNames) - xDialog = testCase.xUITest.getTopFocusWindow() - try: - yield xDialog - finally: - testCase.ui_test.close_dialog_through_button(xDialog.getChild(close_button)) - # vim: set shiftwidth=4 softtabstop=4 expandtab: _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits