diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-06-29 22:35:46 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-06-30 13:17:07 +0200 |
commit | f7300b2f07f308118967c797206dbc4a1e9a61a4 (patch) | |
tree | 6952440b9cb4849e70aafdc6e0f68df4a2767827 | |
parent | 6e8c9047f4bf6194bd1423422bd2dc9f92c50725 (diff) |
uitest: guard create_doc_in_start_center in sd
Mostly done by a script
for motivation, see 89aaa17a0a4413f07da2bc5084b0164f15dc01ac
< UITest: introduce guarded context managers >
Change-Id: I314f3e2245bf57538073499f60528a455cba1a91
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118138
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
22 files changed, 584 insertions, 629 deletions
diff --git a/sc/qa/uitest/calc_tests8/tdf126248.py b/sc/qa/uitest/calc_tests8/tdf126248.py index 773518c6e35b..f314e1a7d64c 100644 --- a/sc/qa/uitest/calc_tests8/tdf126248.py +++ b/sc/qa/uitest/calc_tests8/tdf126248.py @@ -11,7 +11,6 @@ from libreoffice.uno.propertyvalue import mkPropertyValues from uitest.uihelper.calc import enter_text_to_cell from uitest.uihelper.common import select_pos from uitest.uihelper.common import select_by_text -from uitest.uihelper import guarded class tdf126248(UITestCase): @@ -49,7 +48,7 @@ class tdf126248(UITestCase): def test_tdf126248(self): - with guarded.create_doc_in_start_center(self, "calc"): + with self.ui_test.create_doc_in_start_center_guarded("calc"): self.changeLocalSetting("Chinese (traditional)") diff --git a/sd/qa/uitest/impress_tests/autocorrectOptions.py b/sd/qa/uitest/impress_tests/autocorrectOptions.py index a8135bca4831..c91ba95b0fa2 100644 --- a/sd/qa/uitest/impress_tests/autocorrectOptions.py +++ b/sd/qa/uitest/impress_tests/autocorrectOptions.py @@ -14,88 +14,86 @@ from uitest.uihelper.common import select_pos class autocorrectOptions(UITestCase): def test_autocorrect_options_impress(self): - self.ui_test.create_doc_in_start_center("impress") - xTemplateDlg = self.xUITest.getTopFocusWindow() - xCancelBtn = xTemplateDlg.getChild("close") - self.ui_test.close_dialog_through_button(xCancelBtn) - document = self.ui_test.get_component() - - with self.ui_test.execute_dialog_through_command(".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() + with self.ui_test.create_doc_in_start_center_guarded("impress"): + xTemplateDlg = self.xUITest.getTopFocusWindow() + xCancelBtn = xTemplateDlg.getChild("close") + self.ui_test.close_dialog_through_button(xCancelBtn) + + with self.ui_test.execute_dialog_through_command(".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 + + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/uitest/impress_tests/customSlideShow.py b/sd/qa/uitest/impress_tests/customSlideShow.py index 6af8ff60a20f..10af7a91648c 100644 --- a/sd/qa/uitest/impress_tests/customSlideShow.py +++ b/sd/qa/uitest/impress_tests/customSlideShow.py @@ -9,55 +9,54 @@ from uitest.uihelper.common import get_state_as_dict, type_text class customSlideShow(UITestCase): def test_customSlideShow(self): - MainDoc = self.ui_test.create_doc_in_start_center("impress") - MainWindow = self.xUITest.getTopFocusWindow() - TemplateDialog = self.xUITest.getTopFocusWindow() - cancel = TemplateDialog.getChild("close") - self.ui_test.close_dialog_through_button(cancel) - with self.ui_test.execute_dialog_through_command(".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()) - - #verify - with self.ui_test.execute_dialog_through_command(".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") + with self.ui_test.create_doc_in_start_center_guarded("impress"): + MainWindow = self.xUITest.getTopFocusWindow() + TemplateDialog = self.xUITest.getTopFocusWindow() + cancel = TemplateDialog.getChild("close") + self.ui_test.close_dialog_through_button(cancel) + with self.ui_test.execute_dialog_through_command(".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()) + + #verify + with self.ui_test.execute_dialog_through_command(".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") - 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") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/uitest/impress_tests/insertSlide.py b/sd/qa/uitest/impress_tests/insertSlide.py index d33f3212cb5a..be65b69e4195 100644 --- a/sd/qa/uitest/impress_tests/insertSlide.py +++ b/sd/qa/uitest/impress_tests/insertSlide.py @@ -15,41 +15,37 @@ from uitest.uihelper.common import select_pos class insertSlide(UITestCase): def test_insert_slide(self): - self.ui_test.create_doc_in_start_center("impress") - xTemplateDlg = self.xUITest.getTopFocusWindow() - xCancelBtn = xTemplateDlg.getChild("close") - self.ui_test.close_dialog_through_button(xCancelBtn) - document = self.ui_test.get_component() - self.assertEqual(document.DrawPages.getCount(), 1) #nr. of pages + with self.ui_test.create_doc_in_start_center_guarded("impress") as document: + xTemplateDlg = self.xUITest.getTopFocusWindow() + xCancelBtn = xTemplateDlg.getChild("close") + self.ui_test.close_dialog_through_button(xCancelBtn) + self.assertEqual(document.DrawPages.getCount(), 1) #nr. of pages - self.xUITest.executeCommand(".uno:InsertPage") + self.xUITest.executeCommand(".uno:InsertPage") - #verify - self.assertEqual(document.DrawPages.getCount(), 2) #nr. of pages - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.DrawPages.getCount(), 1) #nr. of pages - self.ui_test.close_doc() + #verify + self.assertEqual(document.DrawPages.getCount(), 2) #nr. of pages + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.DrawPages.getCount(), 1) #nr. of pages def test_tdf85360_insert_4th_slide(self): - self.ui_test.create_doc_in_start_center("impress") - xTemplateDlg = self.xUITest.getTopFocusWindow() - xCancelBtn = xTemplateDlg.getChild("close") - self.ui_test.close_dialog_through_button(xCancelBtn) - document = self.ui_test.get_component() - self.assertEqual(document.DrawPages.getCount(), 1) #nr. of pages + with self.ui_test.create_doc_in_start_center_guarded("impress") as document: + xTemplateDlg = self.xUITest.getTopFocusWindow() + xCancelBtn = xTemplateDlg.getChild("close") + self.ui_test.close_dialog_through_button(xCancelBtn) + self.assertEqual(document.DrawPages.getCount(), 1) #nr. of pages - self.xUITest.executeCommand(".uno:InsertPage") - self.xUITest.executeCommand(".uno:InsertPage") - self.xUITest.executeCommand(".uno:InsertPage") - self.xUITest.executeCommand(".uno:InsertPage") - #verify - self.assertEqual(document.DrawPages.getCount(), 5) #nr. of pages - #undo - self.xUITest.executeCommand(".uno:Undo") - self.xUITest.executeCommand(".uno:Undo") - self.xUITest.executeCommand(".uno:Undo") - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.DrawPages.getCount(), 1) #nr. of pages - self.ui_test.close_doc() + self.xUITest.executeCommand(".uno:InsertPage") + self.xUITest.executeCommand(".uno:InsertPage") + self.xUITest.executeCommand(".uno:InsertPage") + self.xUITest.executeCommand(".uno:InsertPage") + #verify + self.assertEqual(document.DrawPages.getCount(), 5) #nr. of pages + #undo + self.xUITest.executeCommand(".uno:Undo") + self.xUITest.executeCommand(".uno:Undo") + self.xUITest.executeCommand(".uno:Undo") + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.DrawPages.getCount(), 1) #nr. of pages # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/uitest/impress_tests/masterElements.py b/sd/qa/uitest/impress_tests/masterElements.py index 3ed174c47f20..09d685f53898 100644 --- a/sd/qa/uitest/impress_tests/masterElements.py +++ b/sd/qa/uitest/impress_tests/masterElements.py @@ -14,33 +14,31 @@ from uitest.uihelper.common import select_pos class masterElements(UITestCase): def test_master_elements(self): - self.ui_test.create_doc_in_start_center("impress") - xTemplateDlg = self.xUITest.getTopFocusWindow() - xCancelBtn = xTemplateDlg.getChild("close") - self.ui_test.close_dialog_through_button(xCancelBtn) - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("impress"): + xTemplateDlg = self.xUITest.getTopFocusWindow() + xCancelBtn = xTemplateDlg.getChild("close") + self.ui_test.close_dialog_through_button(xCancelBtn) - with self.ui_test.execute_dialog_through_command(".uno:MasterLayouts") as xDialog: + with self.ui_test.execute_dialog_through_command(".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()) - #verify - with self.ui_test.execute_dialog_through_command(".uno:MasterLayouts") as xDialog: - xfooter = xDialog.getChild("footer") - datetime = xDialog.getChild("datetime") - xpagenumber = xDialog.getChild("pagenumber") + #verify + with self.ui_test.execute_dialog_through_command(".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.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() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/uitest/impress_tests/masterSlides.py b/sd/qa/uitest/impress_tests/masterSlides.py index da4e3e949f4b..fe0ef9c8b0a2 100644 --- a/sd/qa/uitest/impress_tests/masterSlides.py +++ b/sd/qa/uitest/impress_tests/masterSlides.py @@ -13,34 +13,33 @@ class masterSlides(UITestCase): def test_change_master_slide_from_dialog(self): - self.ui_test.create_doc_in_start_center("impress") + with self.ui_test.create_doc_in_start_center_guarded("impress"): - xTemplateDlg = self.xUITest.getTopFocusWindow() - xCancelBtn = xTemplateDlg.getChild("close") - self.ui_test.close_dialog_through_button(xCancelBtn) + xTemplateDlg = self.xUITest.getTopFocusWindow() + xCancelBtn = xTemplateDlg.getChild("close") + self.ui_test.close_dialog_through_button(xCancelBtn) - xImpress = self.xUITest.getTopFocusWindow() - xMasterSlide = xImpress.getChild("masterslide") - self.assertEqual("Default", get_state_as_dict(xMasterSlide)['SelectEntryText']) + xImpress = self.xUITest.getTopFocusWindow() + xMasterSlide = xImpress.getChild("masterslide") + self.assertEqual("Default", get_state_as_dict(xMasterSlide)['SelectEntryText']) - xMasterButton = xImpress.getChild("masterslidebutton") - xMasterButton.executeAction("CLICK", tuple()) + xMasterButton = xImpress.getChild("masterslidebutton") + xMasterButton.executeAction("CLICK", tuple()) - self.xUITest.executeCommand(".uno:InsertMasterPage") + self.xUITest.executeCommand(".uno:InsertMasterPage") - xCloseMasterButton = xImpress.getChild("closemasterslide") - xCloseMasterButton.executeAction("CLICK", tuple()) + xCloseMasterButton = xImpress.getChild("closemasterslide") + xCloseMasterButton.executeAction("CLICK", tuple()) - with self.ui_test.execute_dialog_through_command(".uno:PresentationLayout") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:PresentationLayout") as xDialog: - xSelect = xDialog.getChild('select') - xSelect.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + xSelect = xDialog.getChild('select') + xSelect.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) - xMasterSlide = xImpress.getChild("masterslide") - self.assertEqual("Default 1", get_state_as_dict(xMasterSlide)['SelectEntryText']) + xMasterSlide = xImpress.getChild("masterslide") + self.assertEqual("Default 1", get_state_as_dict(xMasterSlide)['SelectEntryText']) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/uitest/impress_tests/renameSlide.py b/sd/qa/uitest/impress_tests/renameSlide.py index bd082aa91055..8dffbc7e5350 100644 --- a/sd/qa/uitest/impress_tests/renameSlide.py +++ b/sd/qa/uitest/impress_tests/renameSlide.py @@ -11,35 +11,34 @@ from uitest.uihelper.common import get_state_as_dict class renameSlide(UITestCase): def test_rename_slide(self): - self.ui_test.create_doc_in_start_center("impress") - xTemplateDlg = self.xUITest.getTopFocusWindow() - xCancelBtn = xTemplateDlg.getChild("close") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.create_doc_in_start_center_guarded("impress"): + xTemplateDlg = self.xUITest.getTopFocusWindow() + xCancelBtn = xTemplateDlg.getChild("close") + self.ui_test.close_dialog_through_button(xCancelBtn) - with self.ui_test.execute_dialog_through_command(".uno:RenamePage") as xDialog: + with self.ui_test.execute_dialog_through_command(".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"})) - #verify - with self.ui_test.execute_dialog_through_command(".uno:RenamePage") as xDialog: + #verify + with self.ui_test.execute_dialog_through_command(".uno:RenamePage") as xDialog: - name_entry = xDialog.getChild("name_entry") - self.assertEqual(get_state_as_dict(name_entry)["Text"], "NewName") + name_entry = xDialog.getChild("name_entry") + self.assertEqual(get_state_as_dict(name_entry)["Text"], "NewName") - self.xUITest.executeCommand(".uno:InsertPage") + self.xUITest.executeCommand(".uno:InsertPage") - with self.ui_test.execute_dialog_through_command(".uno:RenamePage", close_button="cancel") as xDialog: + with self.ui_test.execute_dialog_through_command(".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']) - 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 73f840beabbd..9ec66d4634a2 100644 --- a/sd/qa/uitest/impress_tests/slideShowSettings.py +++ b/sd/qa/uitest/impress_tests/slideShowSettings.py @@ -8,49 +8,48 @@ from uitest.uihelper.common import get_state_as_dict, type_text class slideShowSettings(UITestCase): def test_slideShowSettings(self): - MainDoc = self.ui_test.create_doc_in_start_center("impress") - MainWindow = self.xUITest.getTopFocusWindow() - TemplateDialog = self.xUITest.getTopFocusWindow() - cancel = TemplateDialog.getChild("close") - self.ui_test.close_dialog_through_button(cancel) - self.xUITest.executeCommand(".uno:InsertPage") - with self.ui_test.execute_dialog_through_command(".uno:PresentationDialog") as PresentationDialog: + with self.ui_test.create_doc_in_start_center_guarded("impress"): + MainWindow = self.xUITest.getTopFocusWindow() + TemplateDialog = self.xUITest.getTopFocusWindow() + cancel = TemplateDialog.getChild("close") + self.ui_test.close_dialog_through_button(cancel) + self.xUITest.executeCommand(".uno:InsertPage") + with self.ui_test.execute_dialog_through_command(".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()) - #verify - with self.ui_test.execute_dialog_through_command(".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") + #verify + with self.ui_test.execute_dialog_through_command(".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") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/uitest/impress_tests/tdf106612.py b/sd/qa/uitest/impress_tests/tdf106612.py index ac3b717820d7..4473603d6bf2 100644 --- a/sd/qa/uitest/impress_tests/tdf106612.py +++ b/sd/qa/uitest/impress_tests/tdf106612.py @@ -11,35 +11,34 @@ from uitest.uihelper.common import get_state_as_dict class Tdf106612(UITestCase): def test_tdf106612(self): - self.ui_test.create_doc_in_start_center("impress") - xTemplateDlg = self.xUITest.getTopFocusWindow() - xCancelBtn = xTemplateDlg.getChild("close") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.create_doc_in_start_center_guarded("impress"): + xTemplateDlg = self.xUITest.getTopFocusWindow() + xCancelBtn = xTemplateDlg.getChild("close") + self.ui_test.close_dialog_through_button(xCancelBtn) - xImpressDoc = self.xUITest.getTopFocusWindow() + xImpressDoc = self.xUITest.getTopFocusWindow() - xEditWin = xImpressDoc.getChild("impress_win") + xEditWin = xImpressDoc.getChild("impress_win") - self.xUITest.executeCommand(".uno:DuplicatePage") + self.xUITest.executeCommand(".uno:DuplicatePage") - self.assertEqual("2", get_state_as_dict(xEditWin)["CurrentSlide"]) + self.assertEqual("2", get_state_as_dict(xEditWin)["CurrentSlide"]) - xEditWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SdNavigatorPanel"})) + xEditWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SdNavigatorPanel"})) - xTree = xImpressDoc.getChild("tree") - self.assertEqual(2, len(xTree.getChildren())) + xTree = xImpressDoc.getChild("tree") + self.assertEqual(2, len(xTree.getChildren())) - self.assertEqual("Slide 1", get_state_as_dict(xTree.getChild('0'))['Text']) - self.assertEqual(2, len(xTree.getChild('0').getChildren())) + self.assertEqual("Slide 1", get_state_as_dict(xTree.getChild('0'))['Text']) + self.assertEqual(2, len(xTree.getChild('0').getChildren())) - self.assertEqual("Slide 2", get_state_as_dict(xTree.getChild('1'))['Text']) - self.assertEqual(2, len(xTree.getChild('1').getChildren())) + self.assertEqual("Slide 2", get_state_as_dict(xTree.getChild('1'))['Text']) + self.assertEqual(2, len(xTree.getChild('1').getChildren())) - xTree.getChild('0').executeAction("DOUBLECLICK", tuple()) + xTree.getChild('0').executeAction("DOUBLECLICK", tuple()) - # Without the fix in place, this test would have failed with - # AssertionError: '1' != '2' - self.assertEqual("1", get_state_as_dict(xEditWin)["CurrentSlide"]) + # Without the fix in place, this test would have failed with + # AssertionError: '1' != '2' + self.assertEqual("1", get_state_as_dict(xEditWin)["CurrentSlide"]) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/uitest/impress_tests/tdf125449.py b/sd/qa/uitest/impress_tests/tdf125449.py index 2ec26db5b907..0b2f7616814c 100644 --- a/sd/qa/uitest/impress_tests/tdf125449.py +++ b/sd/qa/uitest/impress_tests/tdf125449.py @@ -12,47 +12,45 @@ class tdf125449(UITestCase): def test_tdf125449(self): - self.ui_test.create_doc_in_start_center("impress") - - xTemplateDlg = self.xUITest.getTopFocusWindow() - xCancelBtn = xTemplateDlg.getChild("close") - self.ui_test.close_dialog_through_button(xCancelBtn) - - with self.ui_test.execute_dialog_through_command(".uno:PageSetup") as xPageSetupDlg: - - tabcontrol = xPageSetupDlg.getChild("tabcontrol") - select_pos(tabcontrol, "1") - - xBtn = xPageSetupDlg.getChild('btngradient') - xBtn.executeAction("CLICK", tuple()) - - xAngle = xPageSetupDlg.getChild('anglemtr') - xAngle.executeAction("UP", tuple()) - - - document = self.ui_test.get_component() - self.assertEqual( - document.DrawPages.getByIndex(0).Background.FillGradient.Style, LINEAR) - self.assertEqual( - hex(document.DrawPages.getByIndex(0).Background.FillGradient.StartColor), '0xdde8cb') - self.assertEqual( - document.DrawPages.getByIndex(0).Background.FillGradient.Angle, 450) - self.assertEqual( - document.DrawPages.getByIndex(0).Background.FillGradient.Border, 0) - self.assertEqual( - document.DrawPages.getByIndex(0).Background.FillGradient.XOffset, 0) - self.assertEqual( - document.DrawPages.getByIndex(0).Background.FillGradient.YOffset, 0) - self.assertEqual( - document.DrawPages.getByIndex(0).Background.FillGradient.StartIntensity, 100) - self.assertEqual( - document.DrawPages.getByIndex(0).Background.FillGradient.EndIntensity, 100) - - # Without the patch in place, this test would have failed with - # AssertionError: '' != 'gradient' - self.assertEqual( - document.DrawPages.getByIndex(0).Background.FillGradientName, 'gradient') - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("impress") as document: + + xTemplateDlg = self.xUITest.getTopFocusWindow() + xCancelBtn = xTemplateDlg.getChild("close") + self.ui_test.close_dialog_through_button(xCancelBtn) + + with self.ui_test.execute_dialog_through_command(".uno:PageSetup") as xPageSetupDlg: + + tabcontrol = xPageSetupDlg.getChild("tabcontrol") + select_pos(tabcontrol, "1") + + xBtn = xPageSetupDlg.getChild('btngradient') + xBtn.executeAction("CLICK", tuple()) + + xAngle = xPageSetupDlg.getChild('anglemtr') + xAngle.executeAction("UP", tuple()) + + + self.assertEqual( + document.DrawPages.getByIndex(0).Background.FillGradient.Style, LINEAR) + self.assertEqual( + hex(document.DrawPages.getByIndex(0).Background.FillGradient.StartColor), '0xdde8cb') + self.assertEqual( + document.DrawPages.getByIndex(0).Background.FillGradient.Angle, 450) + self.assertEqual( + document.DrawPages.getByIndex(0).Background.FillGradient.Border, 0) + self.assertEqual( + document.DrawPages.getByIndex(0).Background.FillGradient.XOffset, 0) + self.assertEqual( + document.DrawPages.getByIndex(0).Background.FillGradient.YOffset, 0) + self.assertEqual( + document.DrawPages.getByIndex(0).Background.FillGradient.StartIntensity, 100) + self.assertEqual( + document.DrawPages.getByIndex(0).Background.FillGradient.EndIntensity, 100) + + # Without the patch in place, this test would have failed with + # AssertionError: '' != 'gradient' + self.assertEqual( + document.DrawPages.getByIndex(0).Background.FillGradientName, 'gradient') + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/uitest/impress_tests/tdf126605.py b/sd/qa/uitest/impress_tests/tdf126605.py index b4a2668a1952..e51359f43361 100644 --- a/sd/qa/uitest/impress_tests/tdf126605.py +++ b/sd/qa/uitest/impress_tests/tdf126605.py @@ -10,19 +10,18 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf126605(UITestCase): def test_run(self): - self.ui_test.create_doc_in_start_center("impress") - xTemplateDlg = self.xUITest.getTopFocusWindow() - xCancelBtn = xTemplateDlg.getChild("close") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.create_doc_in_start_center_guarded("impress"): + xTemplateDlg = self.xUITest.getTopFocusWindow() + xCancelBtn = xTemplateDlg.getChild("close") + self.ui_test.close_dialog_through_button(xCancelBtn) - xDoc = self.xUITest.getTopFocusWindow() - xEdit = xDoc.getChild("impress_win") - xEdit.executeAction("TYPE", mkPropertyValues({"TEXT":"test"})) + xDoc = self.xUITest.getTopFocusWindow() + xEdit = xDoc.getChild("impress_win") + xEdit.executeAction("TYPE", mkPropertyValues({"TEXT":"test"})) - # Without the accompanying fix in place, it would crash at this point - self.xUITest.executeCommand(".uno:ParaRightToLeft") - self.xUITest.executeCommand(".uno:ParaLeftToRight") + # Without the accompanying fix in place, it would crash at this point + self.xUITest.executeCommand(".uno:ParaRightToLeft") + self.xUITest.executeCommand(".uno:ParaLeftToRight") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/uitest/impress_tests/tdf130440.py b/sd/qa/uitest/impress_tests/tdf130440.py index 60ea610206e1..ae68331a94db 100644 --- a/sd/qa/uitest/impress_tests/tdf130440.py +++ b/sd/qa/uitest/impress_tests/tdf130440.py @@ -10,48 +10,46 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf129346(UITestCase): def test_run(self): - self.ui_test.create_doc_in_start_center("impress") - xTemplateDlg = self.xUITest.getTopFocusWindow() - xCancelBtn = xTemplateDlg.getChild("close") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.create_doc_in_start_center_guarded("impress") as document: + xTemplateDlg = self.xUITest.getTopFocusWindow() + xCancelBtn = xTemplateDlg.getChild("close") + self.ui_test.close_dialog_through_button(xCancelBtn) - xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') - document = self.ui_test.get_component() - self.assertEqual(document.CurrentController.getCurrentPage().Number, 1) - self.xUITest.executeCommand(".uno:DuplicatePage") - xToolkit.processEventsToIdle() - self.assertEqual(document.CurrentController.getCurrentPage().Number, 2) + self.assertEqual(document.CurrentController.getCurrentPage().Number, 1) + self.xUITest.executeCommand(".uno:DuplicatePage") + xToolkit.processEventsToIdle() + self.assertEqual(document.CurrentController.getCurrentPage().Number, 2) - xDoc = self.xUITest.getTopFocusWindow() - xEdit = xDoc.getChild("impress_win") - xEdit.executeAction("TYPE", mkPropertyValues({"TEXT":"test"})) + xDoc = self.xUITest.getTopFocusWindow() + xEdit = xDoc.getChild("impress_win") + xEdit.executeAction("TYPE", mkPropertyValues({"TEXT":"test"})) - self.xUITest.executeCommand(".uno:Undo") - xToolkit.processEventsToIdle() - self.assertEqual(document.CurrentController.getCurrentPage().Number, 2) + self.xUITest.executeCommand(".uno:Undo") + xToolkit.processEventsToIdle() + self.assertEqual(document.CurrentController.getCurrentPage().Number, 2) - self.xUITest.executeCommand(".uno:Undo") - xToolkit.processEventsToIdle() - self.assertEqual(document.CurrentController.getCurrentPage().Number, 2) + self.xUITest.executeCommand(".uno:Undo") + xToolkit.processEventsToIdle() + self.assertEqual(document.CurrentController.getCurrentPage().Number, 2) - self.xUITest.executeCommand(".uno:Undo") - xToolkit.processEventsToIdle() - self.assertEqual(document.CurrentController.getCurrentPage().Number, 1) + self.xUITest.executeCommand(".uno:Undo") + xToolkit.processEventsToIdle() + self.assertEqual(document.CurrentController.getCurrentPage().Number, 1) - self.xUITest.executeCommand(".uno:Redo") - xToolkit.processEventsToIdle() - self.assertEqual(document.CurrentController.getCurrentPage().Number, 2) + self.xUITest.executeCommand(".uno:Redo") + xToolkit.processEventsToIdle() + self.assertEqual(document.CurrentController.getCurrentPage().Number, 2) - self.xUITest.executeCommand(".uno:Redo") + self.xUITest.executeCommand(".uno:Redo") - xDoc = self.xUITest.getTopFocusWindow() - xEdit = xDoc.getChild("impress_win") - xEdit.executeAction("TYPE", mkPropertyValues({"TEXT":"test"})) + xDoc = self.xUITest.getTopFocusWindow() + xEdit = xDoc.getChild("impress_win") + xEdit.executeAction("TYPE", mkPropertyValues({"TEXT":"test"})) - xToolkit.processEventsToIdle() - #Without the accompanying fix in place, it would fail with AssertionError: 2 != 1 - self.assertEqual(document.CurrentController.getCurrentPage().Number, 2) - self.ui_test.close_doc() + xToolkit.processEventsToIdle() + #Without the accompanying fix in place, it would fail with AssertionError: 2 != 1 + self.assertEqual(document.CurrentController.getCurrentPage().Number, 2) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/uitest/impress_tests/tdf134734.py b/sd/qa/uitest/impress_tests/tdf134734.py index 0fc0bf85fd7b..b221f76ed05e 100644 --- a/sd/qa/uitest/impress_tests/tdf134734.py +++ b/sd/qa/uitest/impress_tests/tdf134734.py @@ -13,90 +13,88 @@ import importlib class TestClass(UITestCase): def test_master_page_background(self): - self.ui_test.create_doc_in_start_center("impress") - document = self.ui_test.get_component() - TemplateDialog = self.xUITest.getTopFocusWindow() - close = TemplateDialog.getChild("close") - self.ui_test.close_dialog_through_button(close) + with self.ui_test.create_doc_in_start_center_guarded("impress") as document: + TemplateDialog = self.xUITest.getTopFocusWindow() + close = TemplateDialog.getChild("close") + self.ui_test.close_dialog_through_button(close) - # set margins and fill color - with self.ui_test.execute_dialog_through_command(".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()) + # set margins and fill color + with self.ui_test.execute_dialog_through_command(".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) - self.assertEqual( - document.DrawPages.getByIndex(0).BorderLeft, 1016) - self.assertEqual( - document.DrawPages.getByIndex(0).BorderRight, 762) - self.assertEqual( - document.DrawPages.getByIndex(0).BorderTop, 508) - self.assertEqual( - document.DrawPages.getByIndex(0).BorderBottom, 254) - self.assertEqual( - document.MasterPages.getByIndex(0).BackgroundFullSize, False) + self.assertEqual( + document.DrawPages.getByIndex(0).Background.FillStyle, SOLID) + self.assertEqual( + document.DrawPages.getByIndex(0).BorderLeft, 1016) + self.assertEqual( + document.DrawPages.getByIndex(0).BorderRight, 762) + self.assertEqual( + document.DrawPages.getByIndex(0).BorderTop, 508) + self.assertEqual( + document.DrawPages.getByIndex(0).BorderBottom, 254) + self.assertEqual( + document.MasterPages.getByIndex(0).BackgroundFullSize, False) - # check it - with self.ui_test.execute_dialog_through_command(".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()) + # check it + with self.ui_test.execute_dialog_through_command(".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) - self.assertEqual( - document.DrawPages.getByIndex(0).BorderLeft, 1016) - self.assertEqual( - document.DrawPages.getByIndex(0).BorderRight, 762) - self.assertEqual( - document.DrawPages.getByIndex(0).BorderTop, 508) - self.assertEqual( - document.DrawPages.getByIndex(0).BorderBottom, 254) - self.assertEqual( - document.MasterPages.getByIndex(0).BackgroundFullSize, True) + self.assertEqual( + document.DrawPages.getByIndex(0).Background.FillStyle, SOLID) + self.assertEqual( + document.DrawPages.getByIndex(0).BorderLeft, 1016) + self.assertEqual( + document.DrawPages.getByIndex(0).BorderRight, 762) + self.assertEqual( + document.DrawPages.getByIndex(0).BorderTop, 508) + self.assertEqual( + document.DrawPages.getByIndex(0).BorderBottom, 254) + self.assertEqual( + document.MasterPages.getByIndex(0).BackgroundFullSize, True) - # uncheck it again - with self.ui_test.execute_dialog_through_command(".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()) + # uncheck it again + with self.ui_test.execute_dialog_through_command(".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) - self.assertEqual( - document.DrawPages.getByIndex(0).BorderLeft, 1016) - self.assertEqual( - document.DrawPages.getByIndex(0).BorderRight, 762) - self.assertEqual( - document.DrawPages.getByIndex(0).BorderTop, 508) - self.assertEqual( - document.DrawPages.getByIndex(0).BorderBottom, 254) - self.assertEqual( - document.MasterPages.getByIndex(0).BackgroundFullSize, False) + self.assertEqual( + document.DrawPages.getByIndex(0).Background.FillStyle, SOLID) + self.assertEqual( + document.DrawPages.getByIndex(0).BorderLeft, 1016) + self.assertEqual( + document.DrawPages.getByIndex(0).BorderRight, 762) + self.assertEqual( + document.DrawPages.getByIndex(0).BorderTop, 508) + self.assertEqual( + document.DrawPages.getByIndex(0).BorderBottom, 254) + self.assertEqual( + document.MasterPages.getByIndex(0).BackgroundFullSize, False) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/uitest/impress_tests/tdf137729.py b/sd/qa/uitest/impress_tests/tdf137729.py index 3d08734eed5c..08f2a74e9514 100644 --- a/sd/qa/uitest/impress_tests/tdf137729.py +++ b/sd/qa/uitest/impress_tests/tdf137729.py @@ -13,39 +13,37 @@ class tdf137729(UITestCase): def test_tdf137729(self): - self.ui_test.create_doc_in_start_center("impress") + with self.ui_test.create_doc_in_start_center_guarded("impress") as document: - xTemplateDlg = self.xUITest.getTopFocusWindow() - xCancelBtn = xTemplateDlg.getChild("close") - self.ui_test.close_dialog_through_button(xCancelBtn) + xTemplateDlg = self.xUITest.getTopFocusWindow() + xCancelBtn = xTemplateDlg.getChild("close") + self.ui_test.close_dialog_through_button(xCancelBtn) - with self.ui_test.execute_dialog_through_command(".uno:PageSetup") as xPageSetupDlg: + with self.ui_test.execute_dialog_through_command(".uno:PageSetup") as xPageSetupDlg: - 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()) - document = self.ui_test.get_component() - self.assertEqual( - document.DrawPages.getByIndex(0).Background.FillHatch.Style, SINGLE ) - self.assertEqual( - document.DrawPages.getByIndex(0).Background.FillHatch.Color, 0) - self.assertEqual( - document.DrawPages.getByIndex(0).Background.FillHatch.Distance, 152) - self.assertEqual( - document.DrawPages.getByIndex(0).Background.FillHatch.Angle, 0) + self.assertEqual( + document.DrawPages.getByIndex(0).Background.FillHatch.Style, SINGLE ) + self.assertEqual( + document.DrawPages.getByIndex(0).Background.FillHatch.Color, 0) + self.assertEqual( + document.DrawPages.getByIndex(0).Background.FillHatch.Distance, 152) + self.assertEqual( + document.DrawPages.getByIndex(0).Background.FillHatch.Angle, 0) - # Without the patch in place, this test would have failed with - # AssertionError: '' != 'hatch' - self.assertEqual( - document.DrawPages.getByIndex(0).Background.FillHatchName, 'hatch') + # Without the patch in place, this test would have failed with + # AssertionError: '' != 'hatch' + self.assertEqual( + document.DrawPages.getByIndex(0).Background.FillHatchName, 'hatch') - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/uitest/impress_tests/tdf139511.py b/sd/qa/uitest/impress_tests/tdf139511.py index f02ba76b1c40..eb58c2afbf41 100644 --- a/sd/qa/uitest/impress_tests/tdf139511.py +++ b/sd/qa/uitest/impress_tests/tdf139511.py @@ -12,41 +12,38 @@ from uitest.uihelper.common import change_measurement_unit class tdf139511(UITestCase): def test_tdf139511(self): - self.ui_test.create_doc_in_start_center("impress") - xTemplateDlg = self.xUITest.getTopFocusWindow() - xCancelBtn = xTemplateDlg.getChild("close") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.create_doc_in_start_center_guarded("impress") as document: + xTemplateDlg = self.xUITest.getTopFocusWindow() + xCancelBtn = xTemplateDlg.getChild("close") + self.ui_test.close_dialog_through_button(xCancelBtn) - change_measurement_unit(self, "Centimeter") + change_measurement_unit(self, "Centimeter") - self.xUITest.executeCommand(".uno:InsertTable?Columns:short=4&Rows:short=4") + self.xUITest.executeCommand(".uno:InsertTable?Columns:short=4&Rows:short=4") - document = self.ui_test.get_component() - self.assertEqual(8004, document.DrawPages[0].getByIndex(2).BoundRect.Height) - self.assertEqual(14104, document.DrawPages[0].getByIndex(2).BoundRect.Width) + self.assertEqual(8004, document.DrawPages[0].getByIndex(2).BoundRect.Height) + self.assertEqual(14104, document.DrawPages[0].getByIndex(2).BoundRect.Width) - with self.ui_test.execute_dialog_through_command(".uno:TransformDialog") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:TransformDialog") as xDialog: - 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"})) - document = self.ui_test.get_component() - # Without the fix in place, this test would have failed with - # AssertionError: 5005 != 8004 - self.assertEqual(5005, document.DrawPages[0].getByIndex(2).BoundRect.Height) - self.assertEqual(10005, document.DrawPages[0].getByIndex(2).BoundRect.Width) + # Without the fix in place, this test would have failed with + # AssertionError: 5005 != 8004 + self.assertEqual(5005, document.DrawPages[0].getByIndex(2).BoundRect.Height) + self.assertEqual(10005, document.DrawPages[0].getByIndex(2).BoundRect.Width) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/uitest/impress_tests/tdf141297.py b/sd/qa/uitest/impress_tests/tdf141297.py index dd452699364e..355ded1f27ee 100644 --- a/sd/qa/uitest/impress_tests/tdf141297.py +++ b/sd/qa/uitest/impress_tests/tdf141297.py @@ -15,73 +15,72 @@ class tdf141297(UITestCase): def test_tdf141297(self): - self.ui_test.create_doc_in_start_center("impress") + with self.ui_test.create_doc_in_start_center_guarded("impress"): - xTemplateDlg = self.xUITest.getTopFocusWindow() - xCancelBtn = xTemplateDlg.getChild("close") - self.ui_test.close_dialog_through_button(xCancelBtn) + xTemplateDlg = self.xUITest.getTopFocusWindow() + xCancelBtn = xTemplateDlg.getChild("close") + self.ui_test.close_dialog_through_button(xCancelBtn) - with self.ui_test.execute_dialog_through_command(".uno:InsertGraphic", close_button="open") as xOpenDialog: + with self.ui_test.execute_dialog_through_command(".uno:InsertGraphic", close_button="open") as xOpenDialog: - 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()) - #Confirmation dialog is displayed - xWarnDialog = self.xUITest.getTopFocusWindow() - xOK = xWarnDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + #Confirmation dialog is displayed + xWarnDialog = self.xUITest.getTopFocusWindow() + xOK = xWarnDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) - with self.ui_test.execute_dialog_through_command(".uno:ManageLinks", close_button="close") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:ManageLinks", close_button="close") as xDialog: - 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 - with TemporaryDirectory() as tempdir: - xFilePath = os.path.join(tempdir, "tdf141297-tmp.odp") + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, "tdf141297-tmp.odp") - # Save Copy as - with self.ui_test.execute_dialog_through_command(".uno:SaveAs", close_button="open") as xDialog: + # Save Copy as + with self.ui_test.execute_dialog_through_command(".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})) + # Close the Writer document + self.ui_test.close_doc() - # Close the Writer document - self.ui_test.close_doc() + with self.ui_test.load_file(systemPathToFileUrl(xFilePath)): - with self.ui_test.load_file(systemPathToFileUrl(xFilePath)): + self.xUITest.executeCommand(".uno:ManageLinks") - self.xUITest.executeCommand(".uno:ManageLinks") - - # Since the image is no longer linked, the link dialog is not open. - # Without the fix in place, this dialog would have been opened - xMainWin = self.xUITest.getTopFocusWindow() - self.assertTrue(sLinks not in xMainWin.getChildren()) - self.assertTrue(sFileName not in xMainWin.getChildren()) - self.assertTrue(sBreakLink not in xMainWin.getChildren()) - self.assertTrue("impress_win" in xMainWin.getChildren()) + # Since the image is no longer linked, the link dialog is not open. + # Without the fix in place, this dialog would have been opened + xMainWin = self.xUITest.getTopFocusWindow() + self.assertTrue(sLinks not in xMainWin.getChildren()) + self.assertTrue(sFileName not in xMainWin.getChildren()) + self.assertTrue(sBreakLink not in xMainWin.getChildren()) + self.assertTrue("impress_win" in xMainWin.getChildren()) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/uitest/impress_tests/tdf141708.py b/sd/qa/uitest/impress_tests/tdf141708.py index 613cc8938b4d..a819456b899e 100644 --- a/sd/qa/uitest/impress_tests/tdf141708.py +++ b/sd/qa/uitest/impress_tests/tdf141708.py @@ -10,23 +10,22 @@ class tdf141708(UITestCase): def test_tdf141708(self): - self.ui_test.create_doc_in_start_center("impress") + with self.ui_test.create_doc_in_start_center_guarded("impress"): - xTemplateDlg = self.xUITest.getTopFocusWindow() - xCancelBtn = xTemplateDlg.getChild("close") - self.ui_test.close_dialog_through_button(xCancelBtn) + xTemplateDlg = self.xUITest.getTopFocusWindow() + xCancelBtn = xTemplateDlg.getChild("close") + self.ui_test.close_dialog_through_button(xCancelBtn) - self.xUITest.executeCommand(".uno:Navigator") + self.xUITest.executeCommand(".uno:Navigator") - self.xUITest.executeCommand(".uno:CloseDoc") + self.xUITest.executeCommand(".uno:CloseDoc") - self.ui_test.create_doc_in_start_center("impress") + with self.ui_test.create_doc_in_start_center_guarded("impress"): - xTemplateDlg = self.xUITest.getTopFocusWindow() - xCancelBtn = xTemplateDlg.getChild("close") - self.ui_test.close_dialog_through_button(xCancelBtn) + xTemplateDlg = self.xUITest.getTopFocusWindow() + xCancelBtn = xTemplateDlg.getChild("close") + self.ui_test.close_dialog_through_button(xCancelBtn) - # Without the fix in place, this test would have crashed here - self.ui_test.close_doc() + # Without the fix in place, this test would have crashed here # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/uitest/impress_tests/tdf82616.py b/sd/qa/uitest/impress_tests/tdf82616.py index d8c4cb1bdcfc..a156469aa48b 100644 --- a/sd/qa/uitest/impress_tests/tdf82616.py +++ b/sd/qa/uitest/impress_tests/tdf82616.py @@ -13,54 +13,52 @@ from uitest.framework import UITestCase class Tdf82616(UITestCase): def test_tdf82616(self): - self.ui_test.create_doc_in_start_center("impress") + with self.ui_test.create_doc_in_start_center_guarded("impress") as document: - xTemplateDlg = self.xUITest.getTopFocusWindow() - xCancelBtn = xTemplateDlg.getChild("close") - self.ui_test.close_dialog_through_button(xCancelBtn) + xTemplateDlg = self.xUITest.getTopFocusWindow() + xCancelBtn = xTemplateDlg.getChild("close") + self.ui_test.close_dialog_through_button(xCancelBtn) - change_measurement_unit(self, 'Centimeter') + change_measurement_unit(self, 'Centimeter') - xImpressDoc = self.xUITest.getTopFocusWindow() + xImpressDoc = self.xUITest.getTopFocusWindow() - document = self.ui_test.get_component() - self.assertEqual(1400, document.DrawPages[0].getByIndex(0).Position.X) - self.assertEqual(628, document.DrawPages[0].getByIndex(0).Position.Y) - self.assertEqual(1400, document.DrawPages[0].getByIndex(1).Position.X) - self.assertEqual(3685, document.DrawPages[0].getByIndex(1).Position.Y) + self.assertEqual(1400, document.DrawPages[0].getByIndex(0).Position.X) + self.assertEqual(628, document.DrawPages[0].getByIndex(0).Position.Y) + self.assertEqual(1400, document.DrawPages[0].getByIndex(1).Position.X) + self.assertEqual(3685, document.DrawPages[0].getByIndex(1).Position.Y) - self.assertIsNone(document.CurrentSelection) + self.assertIsNone(document.CurrentSelection) - xEditWin = xImpressDoc.getChild("impress_win") - xEditWin.executeAction("SELECT", mkPropertyValues({"OBJECT":"Unnamed Drawinglayer object 1"})) - self.assertEqual("com.sun.star.drawing.SvxShapeCollection", document.CurrentSelection.getImplementationName()) + xEditWin = xImpressDoc.getChild("impress_win") + xEditWin.executeAction("SELECT", mkPropertyValues({"OBJECT":"Unnamed Drawinglayer object 1"})) + self.assertEqual("com.sun.star.drawing.SvxShapeCollection", document.CurrentSelection.getImplementationName()) - xEditWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "PosSizePropertyPanel"})) + xEditWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "PosSizePropertyPanel"})) - xHorizontalPos = xImpressDoc.getChild("horizontalpos") - self.ui_test.wait_until_property_is_updated(xHorizontalPos, "Value", "1.4") - self.assertEqual("1.4", get_state_as_dict(xHorizontalPos)['Value']) + xHorizontalPos = xImpressDoc.getChild("horizontalpos") + self.ui_test.wait_until_property_is_updated(xHorizontalPos, "Value", "1.4") + self.assertEqual("1.4", get_state_as_dict(xHorizontalPos)['Value']) - xVerticalPos = xImpressDoc.getChild("verticalpos") - self.ui_test.wait_until_property_is_updated(xVerticalPos, "Value", "3.69") - self.assertEqual("3.69", get_state_as_dict(xVerticalPos)['Value']) + xVerticalPos = xImpressDoc.getChild("verticalpos") + self.ui_test.wait_until_property_is_updated(xVerticalPos, "Value", "3.69") + self.assertEqual("3.69", get_state_as_dict(xVerticalPos)['Value']) - xDrawinglayerObject = xEditWin.getChild("Unnamed Drawinglayer object 1") - xDrawinglayerObject.executeAction("MOVE", mkPropertyValues({"X": "-5000", "Y":"-10000"})) + xDrawinglayerObject = xEditWin.getChild("Unnamed Drawinglayer object 1") + xDrawinglayerObject.executeAction("MOVE", mkPropertyValues({"X": "-5000", "Y":"-10000"})) - self.assertEqual(1400, document.DrawPages[0].getByIndex(0).Position.X) - self.assertEqual(628, document.DrawPages[0].getByIndex(0).Position.Y) - self.assertEqual(-3600, document.DrawPages[0].getByIndex(1).Position.X) - self.assertEqual(-6315, document.DrawPages[0].getByIndex(1).Position.Y) + self.assertEqual(1400, document.DrawPages[0].getByIndex(0).Position.X) + self.assertEqual(628, document.DrawPages[0].getByIndex(0).Position.Y) + self.assertEqual(-3600, document.DrawPages[0].getByIndex(1).Position.X) + self.assertEqual(-6315, document.DrawPages[0].getByIndex(1).Position.Y) - # Without the fix in place, this test would have failed with - # AssertionError: '-3.6' != '0' - self.ui_test.wait_until_property_is_updated(xHorizontalPos, "Value", "-3.6") - self.assertEqual("-3.6", get_state_as_dict(xHorizontalPos)['Value']) + # Without the fix in place, this test would have failed with + # AssertionError: '-3.6' != '0' + self.ui_test.wait_until_property_is_updated(xHorizontalPos, "Value", "-3.6") + self.assertEqual("-3.6", get_state_as_dict(xHorizontalPos)['Value']) - self.ui_test.wait_until_property_is_updated(xVerticalPos, "Value", "-6.32") - self.assertEqual("-6.32", get_state_as_dict(xVerticalPos)['Value']) + self.ui_test.wait_until_property_is_updated(xVerticalPos, "Value", "-6.32") + self.assertEqual("-6.32", get_state_as_dict(xVerticalPos)['Value']) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/uitest/impress_tests/tdf91762.py b/sd/qa/uitest/impress_tests/tdf91762.py index 897af11908cc..75573982adbf 100644 --- a/sd/qa/uitest/impress_tests/tdf91762.py +++ b/sd/qa/uitest/impress_tests/tdf91762.py @@ -11,35 +11,33 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf91762(UITestCase): def test_tdf91762(self): - self.ui_test.create_doc_in_start_center("impress") - xTemplateDlg = self.xUITest.getTopFocusWindow() - xCancelBtn = xTemplateDlg.getChild("close") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.create_doc_in_start_center_guarded("impress") as document: + xTemplateDlg = self.xUITest.getTopFocusWindow() + xCancelBtn = xTemplateDlg.getChild("close") + self.ui_test.close_dialog_through_button(xCancelBtn) - self.xUITest.executeCommand(".uno:AssignLayout?WhatLayout:long=1") + self.xUITest.executeCommand(".uno:AssignLayout?WhatLayout:long=1") - with self.ui_test.execute_dialog_through_command(".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']) + with self.ui_test.execute_dialog_through_command(".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) - self.assertEqual(25198, document.DrawPages[0].getByIndex(1).Size.Width) - self.assertEqual(1925, document.DrawPages[0].getByIndex(1).Size.Height) + self.assertEqual(1931, document.DrawPages[0].getByIndex(1).BoundRect.Height) + self.assertEqual(25198, document.DrawPages[0].getByIndex(1).Size.Width) + self.assertEqual(1925, document.DrawPages[0].getByIndex(1).Size.Height) - self.assertEqual(1400, document.DrawPages[0].getByIndex(1).Position.X) - self.assertEqual(3685, document.DrawPages[0].getByIndex(1).Position.Y) + self.assertEqual(1400, document.DrawPages[0].getByIndex(1).Position.X) + self.assertEqual(3685, document.DrawPages[0].getByIndex(1).Position.Y) - xDoc = self.xUITest.getTopFocusWindow() - xEdit = xDoc.getChild("impress_win") - for i in range(5): - xEdit.executeAction("TYPE", mkPropertyValues({"TEXT":"test"})) - xEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + xDoc = self.xUITest.getTopFocusWindow() + xEdit = xDoc.getChild("impress_win") + for i in range(5): + xEdit.executeAction("TYPE", mkPropertyValues({"TEXT":"test"})) + xEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) - # tdf#138011: Without the fix in place, this test would have failed with - # AssertionError: 5496 != 3559 - self.assertEqual(5496, document.DrawPages[0].getByIndex(1).BoundRect.Height) + # tdf#138011: Without the fix in place, this test would have failed with + # AssertionError: 5496 != 3559 + self.assertEqual(5496, document.DrawPages[0].getByIndex(1).BoundRect.Height) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/uitest/impress_tests/textColumnsDialog.py b/sd/qa/uitest/impress_tests/textColumnsDialog.py index 7a19f0258327..e989a4e44b85 100644 --- a/sd/qa/uitest/impress_tests/textColumnsDialog.py +++ b/sd/qa/uitest/impress_tests/textColumnsDialog.py @@ -11,12 +11,11 @@ from uitest.uihelper.common import get_state_as_dict from libreoffice.uno.propertyvalue import mkPropertyValues from uitest.uihelper.common import change_measurement_unit, select_pos from uitest.framework import UITestCase -from uitest.uihelper import guarded class textColumnsDialog(UITestCase): def test_textColumnsDialog(self): - with guarded.create_doc_in_start_center(self, "impress") as document: + with self.ui_test.create_doc_in_start_center_guarded("impress") as document: xTemplateDlg = self.xUITest.getTopFocusWindow() xCancelBtn = xTemplateDlg.getChild("close") diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py index 8b7b5a4c98f8..15cdce4654f0 100644 --- a/uitest/uitest/test.py +++ b/uitest/uitest/test.py @@ -175,6 +175,16 @@ class UITest(object): self.close_dialog_through_button(xCancelBtn) return True + # Calls UITest.close_doc at exit + @contextmanager + def create_doc_in_start_center_guarded(self, app): + self.create_doc_in_start_center(app) + component = self.get_component() + try: + yield component + finally: + self.close_doc() + def create_doc_in_start_center(self, app): xStartCenter = self._xUITest.getTopFocusWindow() try: diff --git a/uitest/uitest/uihelper/guarded.py b/uitest/uitest/uihelper/guarded.py deleted file mode 100644 index 67a11137357d..000000000000 --- a/uitest/uitest/uihelper/guarded.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -from contextlib import contextmanager - -# Calls UITest.close_doc at exit -@contextmanager -def create_doc_in_start_center(testCase, app): - testCase.ui_test.create_doc_in_start_center(app) - component = testCase.ui_test.get_component() - try: - yield component - finally: - testCase.ui_test.close_doc() - -# vim: set shiftwidth=4 softtabstop=4 expandtab: |