diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-06-21 16:21:30 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-06-22 14:46:39 +0200 |
commit | be0a41679fea524e0935dc6617b5e65349812dd1 (patch) | |
tree | f14372226d5054c045f954e38ea09da5c412215b /sw/qa/uitest | |
parent | 14069d84174ca7a4e60db4d75912903e9679b643 (diff) |
uitest: guard load_file
Mostly done by a script
for motivation, see 89aaa17a0a4413f07da2bc5084b0164f15dc01ac
< UITest: introduce guarded context managers >
Change-Id: Ia924293dc2a12230fd13f69fd734875ced86be8a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117593
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw/qa/uitest')
59 files changed, 2932 insertions, 3072 deletions
diff --git a/sw/qa/uitest/chapterNumbering/tdf123547.py b/sw/qa/uitest/chapterNumbering/tdf123547.py index 4b2cdf0a5f06..135db13fe927 100644 --- a/sw/qa/uitest/chapterNumbering/tdf123547.py +++ b/sw/qa/uitest/chapterNumbering/tdf123547.py @@ -12,18 +12,17 @@ from uitest.uihelper.common import select_pos class tdf123547(UITestCase): def test_tdf123547_numbering_dialog_crash(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf123547.docx")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() + with self.ui_test.load_file(get_url_for_data_file("tdf123547.docx")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() - self.ui_test.execute_dialog_through_command(".uno:ChapterNumberingDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - xokbtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xokbtn) - #verify we didn't crash - self.assertEqual(document.CurrentController.PageCount, 1) + self.ui_test.execute_dialog_through_command(".uno:ChapterNumberingDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xokbtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xokbtn) + #verify we didn't crash + self.assertEqual(document.CurrentController.PageCount, 1) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/findReplace/findReplace.py b/sw/qa/uitest/findReplace/findReplace.py index 30e0c0e63006..0ef4f22ac1d9 100644 --- a/sw/qa/uitest/findReplace/findReplace.py +++ b/sw/qa/uitest/findReplace/findReplace.py @@ -11,89 +11,87 @@ from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file, typ class findReplace(UITestCase): def test_find_writer(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("findReplace.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") - xDialog = self.xUITest.getTopFocusWindow() - - searchterm = xDialog.getChild("searchterm") - searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"second"})) #2nd page - xsearch = xDialog.getChild("search") - xsearch.executeAction("CLICK", tuple()) - #verify - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "2") - - searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"third"})) - xsearch.executeAction("CLICK", tuple()) - #verify - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "3") #3rd page - - xcloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xcloseBtn) - - #now open dialog and verify find="third" (remember last value); replace value with "First" ( click match case) with word "Replace" - click twice Replace button, check "Replace first first" - self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") - xDialog = self.xUITest.getTopFocusWindow() - searchterm = xDialog.getChild("searchterm") - self.assertEqual(get_state_as_dict(searchterm)["Text"], "third") - searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"First"})) - matchcase = xDialog.getChild("matchcase") - matchcase.executeAction("CLICK", tuple()) #click match case - replaceterm = xDialog.getChild("replaceterm") - replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"Replace"})) #replace textbox - replace = xDialog.getChild("replace") - replace.executeAction("CLICK", tuple()) - replace.executeAction("CLICK", tuple()) #click twice Replace button - #verify - self.assertEqual(document.Text.String[0:19], "Replace first first") - - #now replace first (uncheck match case) with word "aaa" - click once Replace All button, check "Replace aaa aaa" - replaceterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - replaceterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"aaa"})) - matchcase.executeAction("CLICK", tuple()) #uncheck match case - replaceall = xDialog.getChild("replaceall") - replaceall.executeAction("CLICK", tuple()) - #verify - self.assertEqual(document.Text.String[0:15], "Replace aaa aaa") - - #now delete strings in textbox Find and textbox Replace, click button Format, select Size=16 pt, Close OK, Find Next; verify Page=2; - #click No format button; close dialog - replaceterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - replaceterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - - format = xDialog.getChild("format") - with self.ui_test.execute_blocking_action(format.executeAction, args=('CLICK', ())) as dialog: - xTabs = dialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xSizeFont = dialog.getChild("westsizelb-cjk") - xSizeFont.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xSizeFont.executeAction("TYPE", mkPropertyValues({"TEXT":"16"})) #set font size 16 - - # Verify these didn't get set again through SvxSearchController::StateChanged, timer- - # triggered from SfxBindings::NextJob while executing the Format dialog above: - self.assertEqual(get_state_as_dict(searchterm)["Text"], "") - self.assertEqual(get_state_as_dict(replaceterm)["Text"], "") - - xsearch = xDialog.getChild("search") - xsearch.executeAction("CLICK", tuple()) - #verify - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "2") - noformat = xDialog.getChild("noformat") - noformat.executeAction("CLICK", tuple()) #click No format button - - xcloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xcloseBtn) - - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("findReplace.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") + xDialog = self.xUITest.getTopFocusWindow() + + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"second"})) #2nd page + xsearch = xDialog.getChild("search") + xsearch.executeAction("CLICK", tuple()) + #verify + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "2") + + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"third"})) + xsearch.executeAction("CLICK", tuple()) + #verify + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "3") #3rd page + + xcloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xcloseBtn) + + #now open dialog and verify find="third" (remember last value); replace value with "First" ( click match case) with word "Replace" - click twice Replace button, check "Replace first first" + self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") + xDialog = self.xUITest.getTopFocusWindow() + searchterm = xDialog.getChild("searchterm") + self.assertEqual(get_state_as_dict(searchterm)["Text"], "third") + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"First"})) + matchcase = xDialog.getChild("matchcase") + matchcase.executeAction("CLICK", tuple()) #click match case + replaceterm = xDialog.getChild("replaceterm") + replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"Replace"})) #replace textbox + replace = xDialog.getChild("replace") + replace.executeAction("CLICK", tuple()) + replace.executeAction("CLICK", tuple()) #click twice Replace button + #verify + self.assertEqual(document.Text.String[0:19], "Replace first first") + + #now replace first (uncheck match case) with word "aaa" - click once Replace All button, check "Replace aaa aaa" + replaceterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + replaceterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"aaa"})) + matchcase.executeAction("CLICK", tuple()) #uncheck match case + replaceall = xDialog.getChild("replaceall") + replaceall.executeAction("CLICK", tuple()) + #verify + self.assertEqual(document.Text.String[0:15], "Replace aaa aaa") + + #now delete strings in textbox Find and textbox Replace, click button Format, select Size=16 pt, Close OK, Find Next; verify Page=2; + #click No format button; close dialog + replaceterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + replaceterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + + format = xDialog.getChild("format") + with self.ui_test.execute_blocking_action(format.executeAction, args=('CLICK', ())) as dialog: + xTabs = dialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xSizeFont = dialog.getChild("westsizelb-cjk") + xSizeFont.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xSizeFont.executeAction("TYPE", mkPropertyValues({"TEXT":"16"})) #set font size 16 + + # Verify these didn't get set again through SvxSearchController::StateChanged, timer- + # triggered from SfxBindings::NextJob while executing the Format dialog above: + self.assertEqual(get_state_as_dict(searchterm)["Text"], "") + self.assertEqual(get_state_as_dict(replaceterm)["Text"], "") + + xsearch = xDialog.getChild("search") + xsearch.executeAction("CLICK", tuple()) + #verify + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "2") + noformat = xDialog.getChild("noformat") + noformat.executeAction("CLICK", tuple()) #click No format button + + xcloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xcloseBtn) #Bug 39022 - find-replace->$1, not pattern def test_tdf39022_replace_regexp(self): @@ -124,56 +122,52 @@ class findReplace(UITestCase): #tdf116242 ţ ț def test_tdf116242_replace_t_with_cedilla(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf116242.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - - self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") - xDialog = self.xUITest.getTopFocusWindow() - searchterm = xDialog.getChild("searchterm") - searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"ţ"})) #find - replaceterm = xDialog.getChild("replaceterm") - replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"ț"})) #replace - includediacritics = xDialog.getChild("includediacritics") - if (get_state_as_dict(includediacritics)["Selected"]) == "false": - includediacritics.executeAction("CLICK", tuple()) - replaceall = xDialog.getChild("replaceall") - replaceall.executeAction("CLICK", tuple()) - #verify - self.assertEqual(document.Text.String[0:13], "țoootdf116242") - - xcloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xcloseBtn) - - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("tdf116242.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + + self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") + xDialog = self.xUITest.getTopFocusWindow() + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"ţ"})) #find + replaceterm = xDialog.getChild("replaceterm") + replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"ț"})) #replace + includediacritics = xDialog.getChild("includediacritics") + if (get_state_as_dict(includediacritics)["Selected"]) == "false": + includediacritics.executeAction("CLICK", tuple()) + replaceall = xDialog.getChild("replaceall") + replaceall.executeAction("CLICK", tuple()) + #verify + self.assertEqual(document.Text.String[0:13], "țoootdf116242") + + xcloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xcloseBtn) #Bug 98417 - FIND & REPLACE: Add 'Find Previous' button def test_tdf98417_find_previous_writer(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("findReplace.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") - xDialog = self.xUITest.getTopFocusWindow() - - searchterm = xDialog.getChild("searchterm") - searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"third"})) - xsearch = xDialog.getChild("search") - xsearch.executeAction("CLICK", tuple()) - #verify - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "3") - xsearch.executeAction("CLICK", tuple()) - #verify - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "4") #page 4 - backsearch = xDialog.getChild("backsearch") - backsearch.executeAction("CLICK", tuple()) - #verify - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "3") - - xcloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xcloseBtn) - - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("findReplace.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") + xDialog = self.xUITest.getTopFocusWindow() + + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"third"})) + xsearch = xDialog.getChild("search") + xsearch.executeAction("CLICK", tuple()) + #verify + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "3") + xsearch.executeAction("CLICK", tuple()) + #verify + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "4") #page 4 + backsearch = xDialog.getChild("backsearch") + backsearch.executeAction("CLICK", tuple()) + #verify + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "3") + + xcloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xcloseBtn) def test_tdf136577(self): self.ui_test.create_doc_in_start_center("writer") diff --git a/sw/qa/uitest/findReplace/tdf118208.py b/sw/qa/uitest/findReplace/tdf118208.py index 17cd71fc9923..79c38315898f 100644 --- a/sw/qa/uitest/findReplace/tdf118208.py +++ b/sw/qa/uitest/findReplace/tdf118208.py @@ -14,64 +14,62 @@ from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file class tdf118208(UITestCase): def test_tdf118208_search_dialog_format_crash(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf118208.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - # 1. Open the attached file. - # 2. Press ctrl-H to show the search and replace dialog. - # 3. Press the "Format..." button. - #Libreoffice immediately crashed. - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.load_file(get_url_for_data_file("tdf118208.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + # 1. Open the attached file. + # 2. Press ctrl-H to show the search and replace dialog. + # 3. Press the "Format..." button. + #Libreoffice immediately crashed. + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialog = self.xUITest.getTopFocusWindow() - xPages = xDialog.getChild("pages") - xLanguageEntry = xPages.getChild('2') # Language Settings - xLanguageEntry.executeAction("EXPAND", tuple()) - xxLanguageEntryGeneralEntry = xLanguageEntry.getChild('0') - xxLanguageEntryGeneralEntry.executeAction("SELECT", tuple()) #Language + xPages = xDialog.getChild("pages") + xLanguageEntry = xPages.getChild('2') # Language Settings + xLanguageEntry.executeAction("EXPAND", tuple()) + xxLanguageEntryGeneralEntry = xLanguageEntry.getChild('0') + xxLanguageEntryGeneralEntry.executeAction("SELECT", tuple()) #Language - asianlanguage = xDialog.getChild("asiansupport") - complexlanguage = xDialog.getChild("ctlsupport") - if (get_state_as_dict(asianlanguage)["Selected"]) == "true": - asianlanguage.executeAction("CLICK", tuple()) - if (get_state_as_dict(complexlanguage)["Selected"]) == "true": - complexlanguage.executeAction("CLICK", tuple()) + asianlanguage = xDialog.getChild("asiansupport") + complexlanguage = xDialog.getChild("ctlsupport") + if (get_state_as_dict(asianlanguage)["Selected"]) == "true": + asianlanguage.executeAction("CLICK", tuple()) + if (get_state_as_dict(complexlanguage)["Selected"]) == "true": + complexlanguage.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) - self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") - xDialog = self.xUITest.getTopFocusWindow() + self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") + xDialog = self.xUITest.getTopFocusWindow() - format = xDialog.getChild("format") + format = xDialog.getChild("format") - with self.ui_test.execute_blocking_action(format.executeAction, args=('CLICK', ())): - pass + with self.ui_test.execute_blocking_action(format.executeAction, args=('CLICK', ())): + pass - #verify - self.assertEqual(document.Text.String[0:14], "Aaaaaaaaaaaaaa") - xcloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xcloseBtn) + #verify + self.assertEqual(document.Text.String[0:14], "Aaaaaaaaaaaaaa") + xcloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xcloseBtn) - #enable lang support again - self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog - xDialog = self.xUITest.getTopFocusWindow() + #enable lang support again + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialog = self.xUITest.getTopFocusWindow() - xPages = xDialog.getChild("pages") - xLanguageEntry = xPages.getChild('2') # Language Settings - xLanguageEntry.executeAction("EXPAND", tuple()) - xxLanguageEntryGeneralEntry = xLanguageEntry.getChild('0') - xxLanguageEntryGeneralEntry.executeAction("SELECT", tuple()) #Language + xPages = xDialog.getChild("pages") + xLanguageEntry = xPages.getChild('2') # Language Settings + xLanguageEntry.executeAction("EXPAND", tuple()) + xxLanguageEntryGeneralEntry = xLanguageEntry.getChild('0') + xxLanguageEntryGeneralEntry.executeAction("SELECT", tuple()) #Language - asianlanguage = xDialog.getChild("asiansupport") - complexlanguage = xDialog.getChild("ctlsupport") - if (get_state_as_dict(asianlanguage)["Selected"]) == "false": - asianlanguage.executeAction("CLICK", tuple()) - if (get_state_as_dict(complexlanguage)["Selected"]) == "false": - complexlanguage.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - self.ui_test.close_doc() + asianlanguage = xDialog.getChild("asiansupport") + complexlanguage = xDialog.getChild("ctlsupport") + if (get_state_as_dict(asianlanguage)["Selected"]) == "false": + asianlanguage.executeAction("CLICK", tuple()) + if (get_state_as_dict(complexlanguage)["Selected"]) == "false": + complexlanguage.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/findSimilarity/findSimilarity.py b/sw/qa/uitest/findSimilarity/findSimilarity.py index 8328dedbe191..da5066e8ec91 100644 --- a/sw/qa/uitest/findSimilarity/findSimilarity.py +++ b/sw/qa/uitest/findSimilarity/findSimilarity.py @@ -12,60 +12,58 @@ from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file class findSimilarities(UITestCase): def test_find_similarities(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("findReplace.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - #verify: we are on page 1 - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1") - # search and replace dialog - #find = seco - self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") - xDialog = self.xUITest.getTopFocusWindow() - searchterm = xDialog.getChild("searchterm") - searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"seco"})) #seco - # check similarities, button similarities, set values = 1; close dialog with OK - similarity = xDialog.getChild("similarity") - similaritybtn = xDialog.getChild("similaritybtn") - similarity.executeAction("CLICK", tuple()) - with self.ui_test.execute_blocking_action(similaritybtn.executeAction, args=('CLICK', ())) as dialog: - otherfld = dialog.getChild("otherfld") - longerfld = dialog.getChild("longerfld") - shorterfld = dialog.getChild("shorterfld") - otherfld.executeAction("DOWN", tuple()) - longerfld.executeAction("DOWN", tuple()) - shorterfld.executeAction("DOWN", tuple()) + with self.ui_test.load_file(get_url_for_data_file("findReplace.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + #verify: we are on page 1 + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1") + # search and replace dialog + #find = seco + self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") + xDialog = self.xUITest.getTopFocusWindow() + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"seco"})) #seco + # check similarities, button similarities, set values = 1; close dialog with OK + similarity = xDialog.getChild("similarity") + similaritybtn = xDialog.getChild("similaritybtn") + similarity.executeAction("CLICK", tuple()) + with self.ui_test.execute_blocking_action(similaritybtn.executeAction, args=('CLICK', ())) as dialog: + otherfld = dialog.getChild("otherfld") + longerfld = dialog.getChild("longerfld") + shorterfld = dialog.getChild("shorterfld") + otherfld.executeAction("DOWN", tuple()) + longerfld.executeAction("DOWN", tuple()) + shorterfld.executeAction("DOWN", tuple()) - #open dialog again, verify values = 1; close dialog with cancel - with self.ui_test.execute_blocking_action(similaritybtn.executeAction, args=('CLICK', ()), close_button="cancel") as dialog: - otherfld = dialog.getChild("otherfld") - longerfld = dialog.getChild("longerfld") - shorterfld = dialog.getChild("shorterfld") - self.assertEqual(get_state_as_dict(otherfld)["Text"], "1") - self.assertEqual(get_state_as_dict(longerfld)["Text"], "1") - self.assertEqual(get_state_as_dict(shorterfld)["Text"], "1") + #open dialog again, verify values = 1; close dialog with cancel + with self.ui_test.execute_blocking_action(similaritybtn.executeAction, args=('CLICK', ()), close_button="cancel") as dialog: + otherfld = dialog.getChild("otherfld") + longerfld = dialog.getChild("longerfld") + shorterfld = dialog.getChild("shorterfld") + self.assertEqual(get_state_as_dict(otherfld)["Text"], "1") + self.assertEqual(get_state_as_dict(longerfld)["Text"], "1") + self.assertEqual(get_state_as_dict(shorterfld)["Text"], "1") - xsearch = xDialog.getChild("search") - xsearch.executeAction("CLICK", tuple()) - # Find next - not found - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1") - #find = secon - searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"secon"})) - # Find next - verify: we are on page 2 - xsearch = xDialog.getChild("search") - xsearch.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "2") - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"})) #word "second" is selected - #find = irst - searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"irst"})) - # Find next - verify: we are on page 1 - xsearch.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1") - - self.ui_test.close_doc() + xsearch = xDialog.getChild("search") + xsearch.executeAction("CLICK", tuple()) + # Find next - not found + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1") + #find = secon + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"secon"})) + # Find next - verify: we are on page 2 + xsearch = xDialog.getChild("search") + xsearch.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "2") + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"})) #word "second" is selected + #find = irst + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"irst"})) + # Find next - verify: we are on page 1 + xsearch.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/navigator/tdf114724.py b/sw/qa/uitest/navigator/tdf114724.py index fc220f530202..ebb354bf37b2 100644 --- a/sw/qa/uitest/navigator/tdf114724.py +++ b/sw/qa/uitest/navigator/tdf114724.py @@ -13,39 +13,38 @@ from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file class tdf114724(UITestCase): def test_track_headings_outline(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf114724.odt")) - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") + with self.ui_test.load_file(get_url_for_data_file("tdf114724.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") - self.xUITest.executeCommand(".uno:Sidebar") - xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"})) + self.xUITest.executeCommand(".uno:Sidebar") + xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"})) - xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") - xToolBar = xNavigatorPanel.getChild("content5") - xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "0"})) # 'root' button + xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") + xToolBar = xNavigatorPanel.getChild("content5") + xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "0"})) # 'root' button - xWriterEdit.executeAction("FOCUS", tuple()) + xWriterEdit.executeAction("FOCUS", tuple()) - xContentTree = xNavigatorPanel.getChild("contenttree") + xContentTree = xNavigatorPanel.getChild("contenttree") - self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "HEADING 1") - self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "HEADING 1") - self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") - for _ in range(0,3): - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "HEADING 1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "HEADING 1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") + for _ in range(0,3): + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "HEADING 4") - self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "HEADING 4") - self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") + self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "HEADING 4") + self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "HEADING 4") + self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") - for _ in range(0,3): - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + for _ in range(0,3): + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) - self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "HEADING 1") - self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "HEADING 1") - self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") + self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "HEADING 1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "HEADING 1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") - self.xUITest.executeCommand(".uno:Sidebar") - self.ui_test.close_doc() + self.xUITest.executeCommand(".uno:Sidebar") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/navigator/tdf140661.py b/sw/qa/uitest/navigator/tdf140661.py index 3991105ee78b..75b496b027f9 100644 --- a/sw/qa/uitest/navigator/tdf140661.py +++ b/sw/qa/uitest/navigator/tdf140661.py @@ -41,21 +41,19 @@ class tdf140661(UITestCase): def test_tdf140661(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf140661.odt")) + with self.ui_test.load_file(get_url_for_data_file("tdf140661.odt")) as writer_doc: - self.launch_navigator(True) + self.launch_navigator(True) - # Select the shape and ungroup it - self.xUITest.executeCommand(".uno:JumpToNextFrame") + # Select the shape and ungroup it + self.xUITest.executeCommand(".uno:JumpToNextFrame") - self.ui_test.wait_until_child_is_available('metricfield') + self.ui_test.wait_until_child_is_available('metricfield') - self.xUITest.executeCommand(".uno:FormatUngroup") + self.xUITest.executeCommand(".uno:FormatUngroup") - # Without the fix in place, this test would have failed with - # AssertionError: 12 != 0 - self.launch_navigator(False) - - self.ui_test.close_doc() + # Without the fix in place, this test would have failed with + # AssertionError: 12 != 0 + self.launch_navigator(False) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/navigator/tdf40427.py b/sw/qa/uitest/navigator/tdf40427.py index 9b125ff941ec..a3aa1dfa8d10 100644 --- a/sw/qa/uitest/navigator/tdf40427.py +++ b/sw/qa/uitest/navigator/tdf40427.py @@ -14,68 +14,67 @@ from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file class tdf40427(UITestCase): def test_tdf40427(self): - self.ui_test.load_file(get_url_for_data_file("tdf40427_SectionPositions.odt")) - xMainWindow = self.xUITest.getTopFocusWindow() - xWriterEdit = xMainWindow.getChild("writer_edit") + with self.ui_test.load_file(get_url_for_data_file("tdf40427_SectionPositions.odt")): + xMainWindow = self.xUITest.getTopFocusWindow() + xWriterEdit = xMainWindow.getChild("writer_edit") - self.assertEqual(2, self.ui_test.get_component().CurrentController.PageCount) + self.assertEqual(2, self.ui_test.get_component().CurrentController.PageCount) - # Make sure that the view is 2 pages side-by-side - look at dialog View-Zoom-Zoom - self.ui_test.execute_dialog_through_command(".uno:Zoom") - xDialog = self.xUITest.getTopFocusWindow() + # Make sure that the view is 2 pages side-by-side - look at dialog View-Zoom-Zoom + self.ui_test.execute_dialog_through_command(".uno:Zoom") + xDialog = self.xUITest.getTopFocusWindow() - columnssb = xDialog.getChild("columnssb") - columns = xDialog.getChild("columns") - bookmode = xDialog.getChild("bookmode") - self.assertEqual("true", get_state_as_dict(columns)["Checked"]) - self.assertEqual("2", get_state_as_dict(columnssb)["Text"]) - self.assertEqual("false", get_state_as_dict(bookmode)["Selected"]) + columnssb = xDialog.getChild("columnssb") + columns = xDialog.getChild("columns") + bookmode = xDialog.getChild("bookmode") + self.assertEqual("true", get_state_as_dict(columns)["Checked"]) + self.assertEqual("2", get_state_as_dict(columnssb)["Text"]) + self.assertEqual("false", get_state_as_dict(bookmode)["Selected"]) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) - # In this view, the sections "SectionB" and "SectionC" on second page are positioned on screen - # higher than "SectionY" and "SectionA" respectively; there are nested and anchored sections. - # Make sure that order in Navigator follows their relative position in document, not vertical - # position on screen, nor sorted alphabetically. Sections in flying frames are sorted by their - # anchor position in the document. + # In this view, the sections "SectionB" and "SectionC" on second page are positioned on screen + # higher than "SectionY" and "SectionA" respectively; there are nested and anchored sections. + # Make sure that order in Navigator follows their relative position in document, not vertical + # position on screen, nor sorted alphabetically. Sections in flying frames are sorted by their + # anchor position in the document. - self.xUITest.executeCommand(".uno:Sidebar") - xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"})) + self.xUITest.executeCommand(".uno:Sidebar") + xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"})) - # wait until the navigator panel is available - xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') + # wait until the navigator panel is available + xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') - xContentTree = xNavigatorPanel.getChild("contenttree") - xSections = xContentTree.getChild('6') - self.assertEqual('Sections', get_state_as_dict(xSections)['Text']) - xSections.executeAction("EXPAND", ()) + xContentTree = xNavigatorPanel.getChild("contenttree") + xSections = xContentTree.getChild('6') + self.assertEqual('Sections', get_state_as_dict(xSections)['Text']) + xSections.executeAction("EXPAND", ()) - refSectionNames = [ - 'SectionZ', - 'SectionY', # SectionB should not get before this, despite its Y position on screen is higher - 'SectionT3', # Sections in tables go in rows, then across rows - 'SectionT1', - 'SectionT2', - 'SectionT0', - 'SectionF2', # Goes before SectionF1, because their fly anchors go in that order - 'SectionF3', # Same as SectionF1, but anchor section is in fly itself - 'SectionFinF3', # Check order of nested sections inside fly - 'SectionA', - 'SectionF1', # Section in fly anchored in a section goes immediately after its anchor section - 'SectionB', # High on screen, but late in list because it's on second page - 'SectionC', - ] - self.assertEqual(len(refSectionNames), len(xSections.getChildren())) + refSectionNames = [ + 'SectionZ', + 'SectionY', # SectionB should not get before this, despite its Y position on screen is higher + 'SectionT3', # Sections in tables go in rows, then across rows + 'SectionT1', + 'SectionT2', + 'SectionT0', + 'SectionF2', # Goes before SectionF1, because their fly anchors go in that order + 'SectionF3', # Same as SectionF1, but anchor section is in fly itself + 'SectionFinF3', # Check order of nested sections inside fly + 'SectionA', + 'SectionF1', # Section in fly anchored in a section goes immediately after its anchor section + 'SectionB', # High on screen, but late in list because it's on second page + 'SectionC', + ] + self.assertEqual(len(refSectionNames), len(xSections.getChildren())) - actSectionNames = [] - for i in range(len(refSectionNames)): - actSectionNames.append(get_state_as_dict(xSections.getChild(str(i)))['Text']) - # Without the fix in place, this would fail with - # AssertionError: Lists differ: ['SectionZ', 'SectionY', 'SectionT3', 'SectionT1', 'SectionT2'[100 chars]onC'] != ['SectionZ', 'SectionB', 'SectionF3', 'SectionFinF3', 'Section[100 chars]onA'] - self.assertEqual(refSectionNames, actSectionNames) + actSectionNames = [] + for i in range(len(refSectionNames)): + actSectionNames.append(get_state_as_dict(xSections.getChild(str(i)))['Text']) + # Without the fix in place, this would fail with + # AssertionError: Lists differ: ['SectionZ', 'SectionY', 'SectionT3', 'SectionT1', 'SectionT2'[100 chars]onC'] != ['SectionZ', 'SectionB', 'SectionF3', 'SectionFinF3', 'Section[100 chars]onA'] + self.assertEqual(refSectionNames, actSectionNames) - self.xUITest.executeCommand(".uno:Sidebar") - self.ui_test.close_doc() + self.xUITest.executeCommand(".uno:Sidebar") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/sidebar/tdf99711.py b/sw/qa/uitest/sidebar/tdf99711.py index 1cc899f42cc1..7ffea85ab157 100644 --- a/sw/qa/uitest/sidebar/tdf99711.py +++ b/sw/qa/uitest/sidebar/tdf99711.py @@ -12,29 +12,27 @@ from uitest.uihelper.common import change_measurement_unit class tdf99711(UITestCase): def test_tdf99711(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("shape.odt")) + with self.ui_test.load_file(get_url_for_data_file("shape.odt")) as writer_doc: - #set measurement to millimeters - change_measurement_unit(self, "Millimeter") + #set measurement to millimeters + change_measurement_unit(self, "Millimeter") - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") - self.xUITest.executeCommand(".uno:JumpToNextFrame") + self.xUITest.executeCommand(".uno:JumpToNextFrame") - self.xUITest.executeCommand(".uno:Sidebar") - xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "TextPropertyPanel"})) + self.xUITest.executeCommand(".uno:Sidebar") + xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "TextPropertyPanel"})) - #wait until the sidebar is available - xChild = self.ui_test.wait_until_child_is_available('selectwidth') - self.assertEqual(get_state_as_dict(xChild)['Text'], '10.00 mm') + #wait until the sidebar is available + xChild = self.ui_test.wait_until_child_is_available('selectwidth') + self.assertEqual(get_state_as_dict(xChild)['Text'], '10.00 mm') - xChild = self.ui_test.wait_until_child_is_available('selectheight') - self.assertEqual(get_state_as_dict(xChild)['Text'], '10.00 mm') + xChild = self.ui_test.wait_until_child_is_available('selectheight') + self.assertEqual(get_state_as_dict(xChild)['Text'], '10.00 mm') - self.xUITest.executeCommand(".uno:Sidebar") - - self.ui_test.close_doc() + self.xUITest.executeCommand(".uno:Sidebar") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/styleInspector/styleInspector.py b/sw/qa/uitest/styleInspector/styleInspector.py index 9c4abaf7191f..b734cb624970 100644 --- a/sw/qa/uitest/styleInspector/styleInspector.py +++ b/sw/qa/uitest/styleInspector/styleInspector.py @@ -12,344 +12,340 @@ from com.sun.star.rdf.URIs import RDF_TYPE, RDFS_COMMENT, RDFS_LABEL, ODF_PREFIX class styleNavigator(UITestCase): def test_listbox_is_updated(self): - self.ui_test.load_file(get_url_for_data_file("styles.odt")) - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - - self.xUITest.executeCommand(".uno:Sidebar") - xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "InspectorTextPanel"})) - - xListBox = xWriterEdit.getChild('listbox_fonts') - - # The cursor is on text without formatting and default style - self.assertEqual(1, len(xListBox.getChild('0').getChildren())) - self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) - self.assertEqual(136, len(xListBox.getChild('0').getChild('0').getChildren())) - self.assertEqual(0, len(xListBox.getChild('1').getChildren())) - self.assertEqual(0, len(xListBox.getChild('2').getChildren())) - self.assertEqual(0, len(xListBox.getChild('3').getChildren())) - - self.xUITest.executeCommand(".uno:GoDown") - - # The cursor is on text with direct formatting - self.assertEqual(1, len(xListBox.getChild('0').getChildren())) - self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) - self.assertEqual(136, len(xListBox.getChild('0').getChild('0').getChildren())) - self.assertEqual(0, len(xListBox.getChild('1').getChildren())) - self.assertEqual(0, len(xListBox.getChild('2').getChildren())) - - xDirFormatting = xListBox.getChild('3') - self.assertEqual(5, len(xDirFormatting.getChildren())) - self.assertEqual("Char Back Color\t0xffff00", get_state_as_dict(xDirFormatting.getChild('0'))['Text']) - self.assertEqual("Char Back Transparent\tFalse", get_state_as_dict(xDirFormatting.getChild('1'))['Text']) - self.assertEqual("Char Color\t0xc9211e", get_state_as_dict(xDirFormatting.getChild('2'))['Text']) - self.assertEqual("Char Shading Value\t0", get_state_as_dict(xDirFormatting.getChild('3'))['Text']) - self.assertEqual("Char Transparence\t0", get_state_as_dict(xDirFormatting.getChild('4'))['Text']) - - - self.xUITest.executeCommand(".uno:GoDown") - - # The cursor is on text with paragraph direct formatting - self.assertEqual(1, len(xListBox.getChild('0').getChildren())) - self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) - self.assertEqual(136, len(xListBox.getChild('0').getChild('0').getChildren())) - - xParDirFormatting = xListBox.getChild('1') - self.assertEqual(7, len(xParDirFormatting.getChildren())) - self.assertEqual("Fill Color\t0xff0000", get_state_as_dict(xParDirFormatting.getChild('0'))['Text']) - self.assertEqual("Para Back Color\t0xff0000", get_state_as_dict(xParDirFormatting.getChild('1'))['Text']) - self.assertEqual("Para Back Transparent\tFalse", get_state_as_dict(xParDirFormatting.getChild('2'))['Text']) - self.assertEqual("Para First Line Indent\t0", get_state_as_dict(xParDirFormatting.getChild('3'))['Text']) - self.assertEqual("Para is Auto First Line Indent\tFalse", get_state_as_dict(xParDirFormatting.getChild('4'))['Text']) - self.assertEqual("Para Left Margin\t1482", get_state_as_dict(xParDirFormatting.getChild('5'))['Text']) - self.assertEqual("Para Right Margin\t0", get_state_as_dict(xParDirFormatting.getChild('6'))['Text']) - - self.assertEqual(0, len(xListBox.getChild('2').getChildren())) - self.assertEqual(0, len(xListBox.getChild('3').getChildren())) - - self.xUITest.executeCommand(".uno:GoDown") - - # The cursor is on text with 'Title' style - xParStyle = xListBox.getChild('0') - self.assertEqual(3, len(xParStyle.getChildren())) - self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xParStyle.getChild('0'))['Text']) - self.assertEqual(136, len(xParStyle.getChild('0').getChildren())) - self.assertEqual("Heading\t", get_state_as_dict(xParStyle.getChild('1'))['Text']) - self.assertEqual(28, len(xParStyle.getChild('1').getChildren())) - - xTitleStyle = xParStyle.getChild('2') - self.assertEqual("Title\t", get_state_as_dict(xTitleStyle)['Text']) - self.assertEqual(16, len(xTitleStyle.getChildren())) - self.assertEqual("Char Difference Height\t0", get_state_as_dict(xTitleStyle.getChild('0'))['Text']) - self.assertEqual("Char Difference Height Asian\t0", get_state_as_dict(xTitleStyle.getChild('1'))['Text']) - self.assertEqual("Char Difference Height Complex\t0", get_state_as_dict(xTitleStyle.getChild('2'))['Text']) - self.assertEqual("Char Height\t28", get_state_as_dict(xTitleStyle.getChild('3'))['Text']) - self.assertEqual("Char Height Asian\t28", get_state_as_dict(xTitleStyle.getChild('4'))['Text']) - self.assertEqual("Char Height Complex\t28", get_state_as_dict(xTitleStyle.getChild('5'))['Text']) - self.assertEqual("Char Property Height\t100", get_state_as_dict(xTitleStyle.getChild('6'))['Text']) - self.assertEqual("Char Property Height Asian\t100", get_state_as_dict(xTitleStyle.getChild('7'))['Text']) - self.assertEqual("Char Property Height Complex\t100", get_state_as_dict(xTitleStyle.getChild('8'))['Text']) - self.assertEqual("Char Weight\tBold", get_state_as_dict(xTitleStyle.getChild('9'))['Text']) - self.assertEqual("Char Weight Asian\tBold", get_state_as_dict(xTitleStyle.getChild('10'))['Text']) - self.assertEqual("Char Weight Complex\tBold", get_state_as_dict(xTitleStyle.getChild('11'))['Text']) - self.assertEqual("Follow Style\tText body", get_state_as_dict(xTitleStyle.getChild('12'))['Text']) - self.assertEqual("Para Adjust\t3", get_state_as_dict(xTitleStyle.getChild('13'))['Text']) - self.assertEqual("Para Expand Single Word\tFalse", get_state_as_dict(xTitleStyle.getChild('14'))['Text']) - self.assertEqual("Para Last Line Adjust\t0", get_state_as_dict(xTitleStyle.getChild('15'))['Text']) - - self.assertEqual(0, len(xListBox.getChild('1').getChildren())) - self.assertEqual(0, len(xListBox.getChild('2').getChildren())) - self.assertEqual(0, len(xListBox.getChild('3').getChildren())) - - self.xUITest.executeCommand(".uno:GoDown") - - # The cursor is on text with custom style - xParStyle = xListBox.getChild('0') - self.assertEqual(3, len(xParStyle.getChildren())) - self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xParStyle.getChild('0'))['Text']) - self.assertEqual(136, len(xParStyle.getChild('0').getChildren())) - self.assertEqual("Text Body\t", get_state_as_dict(xParStyle.getChild('1'))['Text']) - self.assertEqual(6, len(xParStyle.getChild('1').getChildren())) - - xCustomStyle = xParStyle.getChild('2') - self.assertEqual("Custom_Style\t", get_state_as_dict(xCustomStyle)['Text']) - self.assertEqual(7, len(xCustomStyle.getChildren())) - self.assertEqual("Char Color\t0xff5429", get_state_as_dict(xCustomStyle.getChild('0'))['Text']) - self.assertEqual("Char Difference Height\t0", get_state_as_dict(xCustomStyle.getChild('1'))['Text']) - self.assertEqual("Char Height\t20", get_state_as_dict(xCustomStyle.getChild('2'))['Text']) - self.assertEqual("Char Property Height\t100", get_state_as_dict(xCustomStyle.getChild('3'))['Text']) - self.assertEqual("Char Transparence\t0", get_state_as_dict(xCustomStyle.getChild('4'))['Text']) - self.assertEqual("Char Weight\tBold", get_state_as_dict(xCustomStyle.getChild('5'))['Text']) - self.assertEqual("Follow Style\tCustom_Style", get_state_as_dict(xCustomStyle.getChild('6'))['Text']) - - self.assertEqual(7, len(xListBox.getChild('0').getChild('2').getChildren())) - self.assertEqual(0, len(xListBox.getChild('1').getChildren())) - self.assertEqual(0, len(xListBox.getChild('2').getChildren())) - self.assertEqual(0, len(xListBox.getChild('3').getChildren())) - - self.xUITest.executeCommand(".uno:Sidebar") - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("styles.odt")): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + self.xUITest.executeCommand(".uno:Sidebar") + xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "InspectorTextPanel"})) + + xListBox = xWriterEdit.getChild('listbox_fonts') + + # The cursor is on text without formatting and default style + self.assertEqual(1, len(xListBox.getChild('0').getChildren())) + self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) + self.assertEqual(136, len(xListBox.getChild('0').getChild('0').getChildren())) + self.assertEqual(0, len(xListBox.getChild('1').getChildren())) + self.assertEqual(0, len(xListBox.getChild('2').getChildren())) + self.assertEqual(0, len(xListBox.getChild('3').getChildren())) + + self.xUITest.executeCommand(".uno:GoDown") + + # The cursor is on text with direct formatting + self.assertEqual(1, len(xListBox.getChild('0').getChildren())) + self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) + self.assertEqual(136, len(xListBox.getChild('0').getChild('0').getChildren())) + self.assertEqual(0, len(xListBox.getChild('1').getChildren())) + self.assertEqual(0, len(xListBox.getChild('2').getChildren())) + + xDirFormatting = xListBox.getChild('3') + self.assertEqual(5, len(xDirFormatting.getChildren())) + self.assertEqual("Char Back Color\t0xffff00", get_state_as_dict(xDirFormatting.getChild('0'))['Text']) + self.assertEqual("Char Back Transparent\tFalse", get_state_as_dict(xDirFormatting.getChild('1'))['Text']) + self.assertEqual("Char Color\t0xc9211e", get_state_as_dict(xDirFormatting.getChild('2'))['Text']) + self.assertEqual("Char Shading Value\t0", get_state_as_dict(xDirFormatting.getChild('3'))['Text']) + self.assertEqual("Char Transparence\t0", get_state_as_dict(xDirFormatting.getChild('4'))['Text']) + + + self.xUITest.executeCommand(".uno:GoDown") + + # The cursor is on text with paragraph direct formatting + self.assertEqual(1, len(xListBox.getChild('0').getChildren())) + self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) + self.assertEqual(136, len(xListBox.getChild('0').getChild('0').getChildren())) + + xParDirFormatting = xListBox.getChild('1') + self.assertEqual(7, len(xParDirFormatting.getChildren())) + self.assertEqual("Fill Color\t0xff0000", get_state_as_dict(xParDirFormatting.getChild('0'))['Text']) + self.assertEqual("Para Back Color\t0xff0000", get_state_as_dict(xParDirFormatting.getChild('1'))['Text']) + self.assertEqual("Para Back Transparent\tFalse", get_state_as_dict(xParDirFormatting.getChild('2'))['Text']) + self.assertEqual("Para First Line Indent\t0", get_state_as_dict(xParDirFormatting.getChild('3'))['Text']) + self.assertEqual("Para is Auto First Line Indent\tFalse", get_state_as_dict(xParDirFormatting.getChild('4'))['Text']) + self.assertEqual("Para Left Margin\t1482", get_state_as_dict(xParDirFormatting.getChild('5'))['Text']) + self.assertEqual("Para Right Margin\t0", get_state_as_dict(xParDirFormatting.getChild('6'))['Text']) + + self.assertEqual(0, len(xListBox.getChild('2').getChildren())) + self.assertEqual(0, len(xListBox.getChild('3').getChildren())) + + self.xUITest.executeCommand(".uno:GoDown") + + # The cursor is on text with 'Title' style + xParStyle = xListBox.getChild('0') + self.assertEqual(3, len(xParStyle.getChildren())) + self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xParStyle.getChild('0'))['Text']) + self.assertEqual(136, len(xParStyle.getChild('0').getChildren())) + self.assertEqual("Heading\t", get_state_as_dict(xParStyle.getChild('1'))['Text']) + self.assertEqual(28, len(xParStyle.getChild('1').getChildren())) + + xTitleStyle = xParStyle.getChild('2') + self.assertEqual("Title\t", get_state_as_dict(xTitleStyle)['Text']) + self.assertEqual(16, len(xTitleStyle.getChildren())) + self.assertEqual("Char Difference Height\t0", get_state_as_dict(xTitleStyle.getChild('0'))['Text']) + self.assertEqual("Char Difference Height Asian\t0", get_state_as_dict(xTitleStyle.getChild('1'))['Text']) + self.assertEqual("Char Difference Height Complex\t0", get_state_as_dict(xTitleStyle.getChild('2'))['Text']) + self.assertEqual("Char Height\t28", get_state_as_dict(xTitleStyle.getChild('3'))['Text']) + self.assertEqual("Char Height Asian\t28", get_state_as_dict(xTitleStyle.getChild('4'))['Text']) + self.assertEqual("Char Height Complex\t28", get_state_as_dict(xTitleStyle.getChild('5'))['Text']) + self.assertEqual("Char Property Height\t100", get_state_as_dict(xTitleStyle.getChild('6'))['Text']) + self.assertEqual("Char Property Height Asian\t100", get_state_as_dict(xTitleStyle.getChild('7'))['Text']) + self.assertEqual("Char Property Height Complex\t100", get_state_as_dict(xTitleStyle.getChild('8'))['Text']) + self.assertEqual("Char Weight\tBold", get_state_as_dict(xTitleStyle.getChild('9'))['Text']) + self.assertEqual("Char Weight Asian\tBold", get_state_as_dict(xTitleStyle.getChild('10'))['Text']) + self.assertEqual("Char Weight Complex\tBold", get_state_as_dict(xTitleStyle.getChild('11'))['Text']) + self.assertEqual("Follow Style\tText body", get_state_as_dict(xTitleStyle.getChild('12'))['Text']) + self.assertEqual("Para Adjust\t3", get_state_as_dict(xTitleStyle.getChild('13'))['Text']) + self.assertEqual("Para Expand Single Word\tFalse", get_state_as_dict(xTitleStyle.getChild('14'))['Text']) + self.assertEqual("Para Last Line Adjust\t0", get_state_as_dict(xTitleStyle.getChild('15'))['Text']) + + self.assertEqual(0, len(xListBox.getChild('1').getChildren())) + self.assertEqual(0, len(xListBox.getChild('2').getChildren())) + self.assertEqual(0, len(xListBox.getChild('3').getChildren())) + + self.xUITest.executeCommand(".uno:GoDown") + + # The cursor is on text with custom style + xParStyle = xListBox.getChild('0') + self.assertEqual(3, len(xParStyle.getChildren())) + self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xParStyle.getChild('0'))['Text']) + self.assertEqual(136, len(xParStyle.getChild('0').getChildren())) + self.assertEqual("Text Body\t", get_state_as_dict(xParStyle.getChild('1'))['Text']) + self.assertEqual(6, len(xParStyle.getChild('1').getChildren())) + + xCustomStyle = xParStyle.getChild('2') + self.assertEqual("Custom_Style\t", get_state_as_dict(xCustomStyle)['Text']) + self.assertEqual(7, len(xCustomStyle.getChildren())) + self.assertEqual("Char Color\t0xff5429", get_state_as_dict(xCustomStyle.getChild('0'))['Text']) + self.assertEqual("Char Difference Height\t0", get_state_as_dict(xCustomStyle.getChild('1'))['Text']) + self.assertEqual("Char Height\t20", get_state_as_dict(xCustomStyle.getChild('2'))['Text']) + self.assertEqual("Char Property Height\t100", get_state_as_dict(xCustomStyle.getChild('3'))['Text']) + self.assertEqual("Char Transparence\t0", get_state_as_dict(xCustomStyle.getChild('4'))['Text']) + self.assertEqual("Char Weight\tBold", get_state_as_dict(xCustomStyle.getChild('5'))['Text']) + self.assertEqual("Follow Style\tCustom_Style", get_state_as_dict(xCustomStyle.getChild('6'))['Text']) + + self.assertEqual(7, len(xListBox.getChild('0').getChild('2').getChildren())) + self.assertEqual(0, len(xListBox.getChild('1').getChildren())) + self.assertEqual(0, len(xListBox.getChild('2').getChildren())) + self.assertEqual(0, len(xListBox.getChild('3').getChildren())) + + self.xUITest.executeCommand(".uno:Sidebar") def test_metadata(self): - self.ui_test.load_file(get_url_for_data_file("metadata.odt")) - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - - self.xUITest.executeCommand(".uno:Sidebar") - xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "InspectorTextPanel"})) - - xListBox = xWriterEdit.getChild('listbox_fonts') - - # The cursor is on text without metadata - self.assertEqual(1, len(xListBox.getChild('0').getChildren())) - self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) - self.assertEqual(136, len(xListBox.getChild('0').getChild('0').getChildren())) - self.assertEqual(0, len(xListBox.getChild('1').getChildren())) - self.assertEqual(0, len(xListBox.getChild('2').getChildren())) - self.assertEqual(0, len(xListBox.getChild('3').getChildren())) - - self.xUITest.executeCommand(".uno:GoDown") - - # The cursor is on text with paragraph metadata showed under direct paragraph formatting - self.assertEqual(1, len(xListBox.getChild('0').getChildren())) - self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) - self.assertEqual(136, len(xListBox.getChild('0').getChild('0').getChildren())) - - xParDirFormatting = xListBox.getChild('1') - self.assertEqual(1, len(xParDirFormatting.getChildren())) - self.assertEqual("Metadata Reference\t", get_state_as_dict(xParDirFormatting.getChild('0'))['Text']) - - xMetadata = xParDirFormatting.getChild('0') - self.assertEqual(4, len(xMetadata.getChildren())) - self.assertEqual("xml:id\tpara1", get_state_as_dict(xMetadata.getChild('0'))['Text']) - self.assertEqual("http://www.w3.org/1999/02/22-rdf-syntax-ns#type\tParagraph", get_state_as_dict(xMetadata.getChild('1'))['Text']) - self.assertEqual("http://www.w3.org/2000/01/rdf-schema#comment\tAbout this paragraph...", get_state_as_dict(xMetadata.getChild('2'))['Text']) - self.assertEqual("http://www.w3.org/2000/01/rdf-schema#label\tAnnotated paragraph", get_state_as_dict(xMetadata.getChild('3'))['Text']) - - self.xUITest.executeCommand(".uno:GoDown") - # FIXME jump over the control character (not visible in getString(), but it affects - # cursor position and availability of NestedTextContent) - self.xUITest.executeCommand(".uno:GoRight") - - # The cursor is on text with annotated text range - xDirFormatting = xListBox.getChild('3') - self.assertEqual(2, len(xDirFormatting.getChildren())) - self.assertEqual("Metadata Reference\t", get_state_as_dict(xDirFormatting.getChild('0'))['Text']) - self.assertEqual("Nested Text Content\tAnnotated text range", get_state_as_dict(xDirFormatting.getChild('1'))['Text']) - - xMetadata = xDirFormatting.getChild('0') - self.assertEqual(4, len(xMetadata.getChildren())) - self.assertEqual("xml:id\tid2758386667", get_state_as_dict(xMetadata.getChild('0'))['Text']) - self.assertEqual("http://www.w3.org/1999/02/22-rdf-syntax-ns#type\tText span", get_state_as_dict(xMetadata.getChild('1'))['Text']) - self.assertEqual("http://www.w3.org/2000/01/rdf-schema#comment\tComment...", get_state_as_dict(xMetadata.getChild('2'))['Text']) - self.assertEqual("http://www.w3.org/2000/01/rdf-schema#label\tAnnotated paragraph portion", get_state_as_dict(xMetadata.getChild('3'))['Text']) - - self.assertEqual(0, len(xListBox.getChild('1').getChildren())) - self.assertEqual(0, len(xListBox.getChild('2').getChildren())) - - self.xUITest.executeCommand(".uno:Sidebar") - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("metadata.odt")): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + self.xUITest.executeCommand(".uno:Sidebar") + xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "InspectorTextPanel"})) + + xListBox = xWriterEdit.getChild('listbox_fonts') + + # The cursor is on text without metadata + self.assertEqual(1, len(xListBox.getChild('0').getChildren())) + self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) + self.assertEqual(136, len(xListBox.getChild('0').getChild('0').getChildren())) + self.assertEqual(0, len(xListBox.getChild('1').getChildren())) + self.assertEqual(0, len(xListBox.getChild('2').getChildren())) + self.assertEqual(0, len(xListBox.getChild('3').getChildren())) + + self.xUITest.executeCommand(".uno:GoDown") + + # The cursor is on text with paragraph metadata showed under direct paragraph formatting + self.assertEqual(1, len(xListBox.getChild('0').getChildren())) + self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) + self.assertEqual(136, len(xListBox.getChild('0').getChild('0').getChildren())) + + xParDirFormatting = xListBox.getChild('1') + self.assertEqual(1, len(xParDirFormatting.getChildren())) + self.assertEqual("Metadata Reference\t", get_state_as_dict(xParDirFormatting.getChild('0'))['Text']) + + xMetadata = xParDirFormatting.getChild('0') + self.assertEqual(4, len(xMetadata.getChildren())) + self.assertEqual("xml:id\tpara1", get_state_as_dict(xMetadata.getChild('0'))['Text']) + self.assertEqual("http://www.w3.org/1999/02/22-rdf-syntax-ns#type\tParagraph", get_state_as_dict(xMetadata.getChild('1'))['Text']) + self.assertEqual("http://www.w3.org/2000/01/rdf-schema#comment\tAbout this paragraph...", get_state_as_dict(xMetadata.getChild('2'))['Text']) + self.assertEqual("http://www.w3.org/2000/01/rdf-schema#label\tAnnotated paragraph", get_state_as_dict(xMetadata.getChild('3'))['Text']) + + self.xUITest.executeCommand(".uno:GoDown") + # FIXME jump over the control character (not visible in getString(), but it affects + # cursor position and availability of NestedTextContent) + self.xUITest.executeCommand(".uno:GoRight") + + # The cursor is on text with annotated text range + xDirFormatting = xListBox.getChild('3') + self.assertEqual(2, len(xDirFormatting.getChildren())) + self.assertEqual("Metadata Reference\t", get_state_as_dict(xDirFormatting.getChild('0'))['Text']) + self.assertEqual("Nested Text Content\tAnnotated text range", get_state_as_dict(xDirFormatting.getChild('1'))['Text']) + + xMetadata = xDirFormatting.getChild('0') + self.assertEqual(4, len(xMetadata.getChildren())) + self.assertEqual("xml:id\tid2758386667", get_state_as_dict(xMetadata.getChild('0'))['Text']) + self.assertEqual("http://www.w3.org/1999/02/22-rdf-syntax-ns#type\tText span", get_state_as_dict(xMetadata.getChild('1'))['Text']) + self.assertEqual("http://www.w3.org/2000/01/rdf-schema#comment\tComment...", get_state_as_dict(xMetadata.getChild('2'))['Text']) + self.assertEqual("http://www.w3.org/2000/01/rdf-schema#label\tAnnotated paragraph portion", get_state_as_dict(xMetadata.getChild('3'))['Text']) + + self.assertEqual(0, len(xListBox.getChild('1').getChildren())) + self.assertEqual(0, len(xListBox.getChild('2').getChildren())) + + self.xUITest.executeCommand(".uno:Sidebar") def test_bookmark_metadata(self): - self.ui_test.load_file(get_url_for_data_file("bookmark-metadata.odt")) - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - - self.xUITest.executeCommand(".uno:Sidebar") - xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "InspectorTextPanel"})) - - xListBox = xWriterEdit.getChild('listbox_fonts') - - # The cursor is on text without metadata - self.assertEqual(1, len(xListBox.getChild('0').getChildren())) - self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) - self.assertEqual(136, len(xListBox.getChild('0').getChild('0').getChildren())) - self.assertEqual(0, len(xListBox.getChild('1').getChildren())) - self.assertEqual(0, len(xListBox.getChild('2').getChildren())) - self.assertEqual(0, len(xListBox.getChild('3').getChildren())) - - self.xUITest.executeCommand(".uno:GoDown") - - # The cursor is on text with paragraph metadata showed under direct paragraph formatting - self.assertEqual(1, len(xListBox.getChild('0').getChildren())) - self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) - self.assertEqual(136, len(xListBox.getChild('0').getChild('0').getChildren())) - - # Outer bookmark - xBookmarkFormatting = xListBox.getChild('4') - self.assertEqual(1, len(xBookmarkFormatting.getChildren())) - self.assertEqual("Bookmark 1\t", get_state_as_dict(xBookmarkFormatting.getChild('0'))['Text']) - - self.xUITest.executeCommand(".uno:GoDown") - - # Inner bookmark - xBookmarkFormatting = xListBox.getChild('4') - self.assertEqual(2, len(xBookmarkFormatting.getChildren())) - - self.assertEqual("Bookmark 1\t", get_state_as_dict(xBookmarkFormatting.getChild('0'))['Text']) - xMetadata = xBookmarkFormatting.getChild('0').getChild('0') - self.assertEqual(2, len(xMetadata.getChildren())) - self.assertEqual("xml:id\tID-566430c5-9857-4ff2-be6d-57d127368d88", get_state_as_dict(xMetadata.getChild('0'))['Text']) - self.assertEqual("http://www.w3.org/1999/02/22-rdf-syntax-ns#type\tBookmark", get_state_as_dict(xMetadata.getChild('1'))['Text']) - - self.assertEqual("Bookmark 2\t", get_state_as_dict(xBookmarkFormatting.getChild('1'))['Text']) - xMetadata = xBookmarkFormatting.getChild('1').getChild('0') - self.assertEqual(2, len(xMetadata.getChildren())) - self.assertEqual("xml:id\tID-941142c3-924d-4884-a521-cb6a2dd26f04", get_state_as_dict(xMetadata.getChild('0'))['Text']) - self.assertEqual("http://www.w3.org/1999/02/22-rdf-syntax-ns#type\tBookmark", get_state_as_dict(xMetadata.getChild('1'))['Text']) - - # Only in outer bookmark again - self.xUITest.executeCommand(".uno:GoDown") - xBookmarkFormatting = xListBox.getChild('4') - self.assertEqual(1, len(xBookmarkFormatting.getChildren())) - self.assertEqual("Bookmark 1\t", get_state_as_dict(xBookmarkFormatting.getChild('0'))['Text']) - - self.xUITest.executeCommand(".uno:Sidebar") - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("bookmark-metadata.odt")): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + self.xUITest.executeCommand(".uno:Sidebar") + xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "InspectorTextPanel"})) + + xListBox = xWriterEdit.getChild('listbox_fonts') + + # The cursor is on text without metadata + self.assertEqual(1, len(xListBox.getChild('0').getChildren())) + self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) + self.assertEqual(136, len(xListBox.getChild('0').getChild('0').getChildren())) + self.assertEqual(0, len(xListBox.getChild('1').getChildren())) + self.assertEqual(0, len(xListBox.getChild('2').getChildren())) + self.assertEqual(0, len(xListBox.getChild('3').getChildren())) + + self.xUITest.executeCommand(".uno:GoDown") + + # The cursor is on text with paragraph metadata showed under direct paragraph formatting + self.assertEqual(1, len(xListBox.getChild('0').getChildren())) + self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) + self.assertEqual(136, len(xListBox.getChild('0').getChild('0').getChildren())) + + # Outer bookmark + xBookmarkFormatting = xListBox.getChild('4') + self.assertEqual(1, len(xBookmarkFormatting.getChildren())) + self.assertEqual("Bookmark 1\t", get_state_as_dict(xBookmarkFormatting.getChild('0'))['Text']) + + self.xUITest.executeCommand(".uno:GoDown") + + # Inner bookmark + xBookmarkFormatting = xListBox.getChild('4') + self.assertEqual(2, len(xBookmarkFormatting.getChildren())) + + self.assertEqual("Bookmark 1\t", get_state_as_dict(xBookmarkFormatting.getChild('0'))['Text']) + xMetadata = xBookmarkFormatting.getChild('0').getChild('0') + self.assertEqual(2, len(xMetadata.getChildren())) + self.assertEqual("xml:id\tID-566430c5-9857-4ff2-be6d-57d127368d88", get_state_as_dict(xMetadata.getChild('0'))['Text']) + self.assertEqual("http://www.w3.org/1999/02/22-rdf-syntax-ns#type\tBookmark", get_state_as_dict(xMetadata.getChild('1'))['Text']) + + self.assertEqual("Bookmark 2\t", get_state_as_dict(xBookmarkFormatting.getChild('1'))['Text']) + xMetadata = xBookmarkFormatting.getChild('1').getChild('0') + self.assertEqual(2, len(xMetadata.getChildren())) + self.assertEqual("xml:id\tID-941142c3-924d-4884-a521-cb6a2dd26f04", get_state_as_dict(xMetadata.getChild('0'))['Text']) + self.assertEqual("http://www.w3.org/1999/02/22-rdf-syntax-ns#type\tBookmark", get_state_as_dict(xMetadata.getChild('1'))['Text']) + + # Only in outer bookmark again + self.xUITest.executeCommand(".uno:GoDown") + xBookmarkFormatting = xListBox.getChild('4') + self.assertEqual(1, len(xBookmarkFormatting.getChildren())) + self.assertEqual("Bookmark 1\t", get_state_as_dict(xBookmarkFormatting.getChild('0'))['Text']) + + self.xUITest.executeCommand(".uno:Sidebar") def test_metadata_shading_color(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("metacolor.odt")) - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - - self.xUITest.executeCommand(".uno:Sidebar") - xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "InspectorTextPanel"})) - - xListBox = xWriterEdit.getChild('listbox_fonts') - - # The cursor is on text without metadata - self.assertEqual(1, len(xListBox.getChild('0').getChildren())) - self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) - self.assertEqual(136, len(xListBox.getChild('0').getChild('0').getChildren())) - self.assertEqual(0, len(xListBox.getChild('1').getChildren())) - self.assertEqual(0, len(xListBox.getChild('2').getChildren())) - - # go to next word with RDF annotation - self.xUITest.executeCommand(".uno:GoToNextWord") - self.xUITest.executeCommand(".uno:GoRight") - - # FIXME jump over the control character (not visible in getString(), but it affects - # cursor position and availability of NestedTextContent) - self.xUITest.executeCommand(".uno:GoRight") - - # The cursor is on text with annotated text range - xDirFormatting = xListBox.getChild('3') - self.assertEqual(2, len(xDirFormatting.getChildren())) - self.assertEqual("Metadata Reference\t", get_state_as_dict(xDirFormatting.getChild('0'))['Text']) - self.assertEqual("Nested Text Content\tipsum", get_state_as_dict(xDirFormatting.getChild('1'))['Text']) - - xMetadata = xDirFormatting.getChild('0') - self.assertEqual(2, len(xMetadata.getChildren())) - self.assertEqual("xml:id\tID-f1a8a096-7a43-4bda-a462-d73c2800dd9a", get_state_as_dict(xMetadata.getChild('0'))['Text']) - # RGB code of the custom shading color of the annotated text range is FFB7E9 - self.assertEqual("urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0odf#shading\tFFB7E9", get_state_as_dict(xMetadata.getChild('1'))['Text']) - - self.assertEqual(0, len(xListBox.getChild('1').getChildren())) - self.assertEqual(0, len(xListBox.getChild('2').getChildren())) - - # go to next word with RDF annotation - self.xUITest.executeCommand(".uno:GoToNextWord") - self.xUITest.executeCommand(".uno:GoToNextWord") - self.xUITest.executeCommand(".uno:GoToNextWord") - self.xUITest.executeCommand(".uno:GoRight") - - # The cursor is on text with annotated text range - xDirFormatting = xListBox.getChild('3') - self.assertEqual(2, len(xDirFormatting.getChildren())) - self.assertEqual("Metadata Reference\t", get_state_as_dict(xDirFormatting.getChild('0'))['Text']) - self.assertEqual("Nested Text Content\tames", get_state_as_dict(xDirFormatting.getChild('1'))['Text']) - - xMetadata = xDirFormatting.getChild('0') - print(get_state_as_dict(xMetadata)) - self.assertEqual(2, len(xMetadata.getChildren())) - self.assertEqual("xml:id\tID-24478193-9630-4d03-8976-9e097c843a0b", get_state_as_dict(xMetadata.getChild('0'))['Text']) - # RGB code of the custom shading color of the annotated text range is 97E1E9 (the code can be lower case, see STRtoRGB) - self.assertEqual("urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0odf#shading\t97e1e9", get_state_as_dict(xMetadata.getChild('1'))['Text']) - - self.assertEqual(0, len(xListBox.getChild('1').getChildren())) - self.assertEqual(0, len(xListBox.getChild('2').getChildren())) - - # add a new annotated text range and check it in the Style Inspector - self.xUITest.executeCommand(".uno:GoToStartOfDoc") - - # create annotated text range on "Lorem" - viewCursor = writer_doc.CurrentController.getViewCursor() - viewCursor.goRight(5, True) - rdf = writer_doc.createInstance("com.sun.star.text.InContentMetadata") - writer_doc.Text.insertTextContent(viewCursor, rdf, True) - - # set its custom shading color using the new URI const LO_EXT_SHADING - repository = writer_doc.getRDFRepository() - # get metadata graph of file "custom.rdf" stored in the test document - xCustomGraph = [repository.getGraph(i) for i in repository.getGraphNames() if i.LocalName == "custom.rdf"] - self.assertEqual(1, len(xCustomGraph)) - - smgr = self.xContext.ServiceManager - xShadingURI = smgr.createInstance('com.sun.star.rdf.URI') - xShadingURI.initialize((LO_EXT_SHADING,)) - xShadingColor = smgr.createInstance('com.sun.star.rdf.Literal') - xShadingColor.initialize(('BBFF88',)) - xCustomGraph[0].addStatement(rdf, xShadingURI, xShadingColor) - - # remove the selection - self.xUITest.executeCommand(".uno:GoLeft") - - # FIXME: neither LO_EXT_SHADING, nor odf:prefix/odf:suffix changes update the View, - # so add a temporary bookmark to the text range to trigger the color change immediately - self.ui_test.execute_dialog_through_command(".uno:InsertBookmark") - xBookDlg = self.xUITest.getTopFocusWindow() - xInsertBtn = xBookDlg.getChild("insert") - xInsertBtn.executeAction("CLICK", tuple()) # first bookmark - self.xUITest.executeCommand(".uno:Undo") - - xDirFormatting = xListBox.getChild('3') - xMetadata = xDirFormatting.getChild('0') - self.assertEqual(2, len(xMetadata.getChildren())) - # RGB code of the custom shading color of the annotated text range is BBFF88 - self.assertEqual("urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0odf#shading\tBBFF88", get_state_as_dict(xMetadata.getChild('1'))['Text']) - - self.xUITest.executeCommand(".uno:Sidebar") - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("metacolor.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + self.xUITest.executeCommand(".uno:Sidebar") + xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "InspectorTextPanel"})) + + xListBox = xWriterEdit.getChild('listbox_fonts') + + # The cursor is on text without metadata + self.assertEqual(1, len(xListBox.getChild('0').getChildren())) + self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) + self.assertEqual(136, len(xListBox.getChild('0').getChild('0').getChildren())) + self.assertEqual(0, len(xListBox.getChild('1').getChildren())) + self.assertEqual(0, len(xListBox.getChild('2').getChildren())) + + # go to next word with RDF annotation + self.xUITest.executeCommand(".uno:GoToNextWord") + self.xUITest.executeCommand(".uno:GoRight") + + # FIXME jump over the control character (not visible in getString(), but it affects + # cursor position and availability of NestedTextContent) + self.xUITest.executeCommand(".uno:GoRight") + + # The cursor is on text with annotated text range + xDirFormatting = xListBox.getChild('3') + self.assertEqual(2, len(xDirFormatting.getChildren())) + self.assertEqual("Metadata Reference\t", get_state_as_dict(xDirFormatting.getChild('0'))['Text']) + self.assertEqual("Nested Text Content\tipsum", get_state_as_dict(xDirFormatting.getChild('1'))['Text']) + + xMetadata = xDirFormatting.getChild('0') + self.assertEqual(2, len(xMetadata.getChildren())) + self.assertEqual("xml:id\tID-f1a8a096-7a43-4bda-a462-d73c2800dd9a", get_state_as_dict(xMetadata.getChild('0'))['Text']) + # RGB code of the custom shading color of the annotated text range is FFB7E9 + self.assertEqual("urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0odf#shading\tFFB7E9", get_state_as_dict(xMetadata.getChild('1'))['Text']) + + self.assertEqual(0, len(xListBox.getChild('1').getChildren())) + self.assertEqual(0, len(xListBox.getChild('2').getChildren())) + + # go to next word with RDF annotation + self.xUITest.executeCommand(".uno:GoToNextWord") + self.xUITest.executeCommand(".uno:GoToNextWord") + self.xUITest.executeCommand(".uno:GoToNextWord") + self.xUITest.executeCommand(".uno:GoRight") + + # The cursor is on text with annotated text range + xDirFormatting = xListBox.getChild('3') + self.assertEqual(2, len(xDirFormatting.getChildren())) + self.assertEqual("Metadata Reference\t", get_state_as_dict(xDirFormatting.getChild('0'))['Text']) + self.assertEqual("Nested Text Content\tames", get_state_as_dict(xDirFormatting.getChild('1'))['Text']) + + xMetadata = xDirFormatting.getChild('0') + print(get_state_as_dict(xMetadata)) + self.assertEqual(2, len(xMetadata.getChildren())) + self.assertEqual("xml:id\tID-24478193-9630-4d03-8976-9e097c843a0b", get_state_as_dict(xMetadata.getChild('0'))['Text']) + # RGB code of the custom shading color of the annotated text range is 97E1E9 (the code can be lower case, see STRtoRGB) + self.assertEqual("urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0odf#shading\t97e1e9", get_state_as_dict(xMetadata.getChild('1'))['Text']) + + self.assertEqual(0, len(xListBox.getChild('1').getChildren())) + self.assertEqual(0, len(xListBox.getChild('2').getChildren())) + + # add a new annotated text range and check it in the Style Inspector + self.xUITest.executeCommand(".uno:GoToStartOfDoc") + + # create annotated text range on "Lorem" + viewCursor = writer_doc.CurrentController.getViewCursor() + viewCursor.goRight(5, True) + rdf = writer_doc.createInstance("com.sun.star.text.InContentMetadata") + writer_doc.Text.insertTextContent(viewCursor, rdf, True) + + # set its custom shading color using the new URI const LO_EXT_SHADING + repository = writer_doc.getRDFRepository() + # get metadata graph of file "custom.rdf" stored in the test document + xCustomGraph = [repository.getGraph(i) for i in repository.getGraphNames() if i.LocalName == "custom.rdf"] + self.assertEqual(1, len(xCustomGraph)) + + smgr = self.xContext.ServiceManager + xShadingURI = smgr.createInstance('com.sun.star.rdf.URI') + xShadingURI.initialize((LO_EXT_SHADING,)) + xShadingColor = smgr.createInstance('com.sun.star.rdf.Literal') + xShadingColor.initialize(('BBFF88',)) + xCustomGraph[0].addStatement(rdf, xShadingURI, xShadingColor) + + # remove the selection + self.xUITest.executeCommand(".uno:GoLeft") + + # FIXME: neither LO_EXT_SHADING, nor odf:prefix/odf:suffix changes update the View, + # so add a temporary bookmark to the text range to trigger the color change immediately + self.ui_test.execute_dialog_through_command(".uno:InsertBookmark") + xBookDlg = self.xUITest.getTopFocusWindow() + xInsertBtn = xBookDlg.getChild("insert") + xInsertBtn.executeAction("CLICK", tuple()) # first bookmark + self.xUITest.executeCommand(".uno:Undo") + + xDirFormatting = xListBox.getChild('3') + xMetadata = xDirFormatting.getChild('0') + self.assertEqual(2, len(xMetadata.getChildren())) + # RGB code of the custom shading color of the annotated text range is BBFF88 + self.assertEqual("urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0odf#shading\tBBFF88", get_state_as_dict(xMetadata.getChild('1'))['Text']) + + self.xUITest.executeCommand(".uno:Sidebar") diff --git a/sw/qa/uitest/table/sheetToTable.py b/sw/qa/uitest/table/sheetToTable.py index 7beff37c6c8d..4f48eeb644db 100644 --- a/sw/qa/uitest/table/sheetToTable.py +++ b/sw/qa/uitest/table/sheetToTable.py @@ -13,58 +13,52 @@ from uitest.uihelper.calc import enter_text_to_cell class sheetToTable(UITestCase): def test_sheet_to_table_without_hidden_rows(self): - calc_doc = self.ui_test.load_file(get_url_for_data_file("hiddenRow.ods")) - xCalcDoc = self.xUITest.getTopFocusWindow() - self.xUITest.executeCommand(".uno:SelectAll") - self.xUITest.executeCommand(".uno:Copy") - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - self.ui_test.close_doc() - writer_doc = self.ui_test.load_file(get_url_for_data_file("tableToText.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - self.xUITest.executeCommand(".uno:Paste") - #verify (don't copy hidden cells) - self.assertEqual(document.TextTables.getCount(), 1) - table = document.getTextTables()[0] - # This was 3 (copied hidden row) - self.assertEqual(len(table.getRows()), 2) - self.assertEqual(table.getCellByName("A1").getString(), "1") - # This was "2 (hidden)" (copied hidden row) - self.assertEqual(table.getCellByName("A2").getString(), "3") - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("hiddenRow.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + self.xUITest.executeCommand(".uno:SelectAll") + self.xUITest.executeCommand(".uno:Copy") + + with self.ui_test.load_file(get_url_for_data_file("tableToText.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + self.xUITest.executeCommand(".uno:Paste") + #verify (don't copy hidden cells) + self.assertEqual(document.TextTables.getCount(), 1) + table = document.getTextTables()[0] + # This was 3 (copied hidden row) + self.assertEqual(len(table.getRows()), 2) + self.assertEqual(table.getCellByName("A1").getString(), "1") + # This was "2 (hidden)" (copied hidden row) + self.assertEqual(table.getCellByName("A2").getString(), "3") def test_tdf138688(self): - calc_doc = self.ui_test.load_file(get_url_for_data_file("hiddenRow.ods")) - xCalcDoc = self.xUITest.getTopFocusWindow() - self.xUITest.executeCommand(".uno:SelectAll") - self.xUITest.executeCommand(".uno:Copy") - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - self.ui_test.close_doc() - writer_doc = self.ui_test.load_file(get_url_for_data_file("tableToText.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - - # set numbering in the paragraph after the table - self.xUITest.executeCommand(".uno:GoDown") - self.xUITest.executeCommand(".uno:GoDown") - self.xUITest.executeCommand(".uno:DefaultNumbering") - self.xUITest.executeCommand(".uno:GoUp") - self.xUITest.executeCommand(".uno:GoUp") - - #verify (this was a freezing/crash) - self.xUITest.executeCommand(".uno:Paste") - - #verify also tdf#124646 (don't copy hidden cells) - self.assertEqual(document.TextTables.getCount(), 1) - table = document.getTextTables()[0] - # This was 3 (copied hidden row) - self.assertEqual(len(table.getRows()), 2) - self.assertEqual(table.getCellByName("A1").getString(), "1") - # This was "2 (hidden)" (copied hidden row) - self.assertEqual(table.getCellByName("A2").getString(), "3") - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("hiddenRow.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + self.xUITest.executeCommand(".uno:SelectAll") + self.xUITest.executeCommand(".uno:Copy") + + with self.ui_test.load_file(get_url_for_data_file("tableToText.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + + # set numbering in the paragraph after the table + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:DefaultNumbering") + self.xUITest.executeCommand(".uno:GoUp") + self.xUITest.executeCommand(".uno:GoUp") + + #verify (this was a freezing/crash) + self.xUITest.executeCommand(".uno:Paste") + + #verify also tdf#124646 (don't copy hidden cells) + self.assertEqual(document.TextTables.getCount(), 1) + table = document.getTextTables()[0] + # This was 3 (copied hidden row) + self.assertEqual(len(table.getRows()), 2) + self.assertEqual(table.getCellByName("A1").getString(), "1") + # This was "2 (hidden)" (copied hidden row) + self.assertEqual(table.getCellByName("A2").getString(), "3") def test_tdf129083(self): calc_doc = self.ui_test.create_doc_in_start_center("calc") @@ -84,17 +78,16 @@ class sheetToTable(UITestCase): self.ui_test.close_doc() - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf129083.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() + with self.ui_test.load_file(get_url_for_data_file("tdf129083.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() - self.xUITest.executeCommand(".uno:Paste") + self.xUITest.executeCommand(".uno:Paste") - self.assertEqual(document.TextTables.getCount(), 1) - table = document.getTextTables()[0] - self.assertEqual(len(table.getRows()), 4) - self.assertEqual(table.getCellByName("A1").getString(), "Test 1") - self.assertEqual(table.getCellByName("A2").getString(), "Test 2") - self.assertEqual(table.getCellByName("A3").getString(), "Test 3") - self.assertEqual(table.getCellByName("A4").getString(), "Test 4") - self.ui_test.close_doc() + self.assertEqual(document.TextTables.getCount(), 1) + table = document.getTextTables()[0] + self.assertEqual(len(table.getRows()), 4) + self.assertEqual(table.getCellByName("A1").getString(), "Test 1") + self.assertEqual(table.getCellByName("A2").getString(), "Test 2") + self.assertEqual(table.getCellByName("A3").getString(), "Test 3") + self.assertEqual(table.getCellByName("A4").getString(), "Test 4") diff --git a/sw/qa/uitest/table/splitTable.py b/sw/qa/uitest/table/splitTable.py index 402aab45d543..e4fdecac6fa0 100644 --- a/sw/qa/uitest/table/splitTable.py +++ b/sw/qa/uitest/table/splitTable.py @@ -11,74 +11,70 @@ from uitest.uihelper.common import get_url_for_data_file class splitTable(UITestCase): def test_split_table(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("splitTable.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - #go to row 2 - self.xUITest.executeCommand(".uno:GoDown") - self.xUITest.executeCommand(".uno:GoDown") - #dialog Split table, check Copy heading, OK -> verify 2 tables, 1st has 2 rows, second has 5 rows - self.ui_test.execute_dialog_through_command(".uno:SplitTable") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.load_file(get_url_for_data_file("splitTable.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + #go to row 2 + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:GoDown") + #dialog Split table, check Copy heading, OK -> verify 2 tables, 1st has 2 rows, second has 5 rows + self.ui_test.execute_dialog_through_command(".uno:SplitTable") + xDialog = self.xUITest.getTopFocusWindow() - copyheading = xDialog.getChild("copyheading") - copyheading.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - self.assertEqual(document.TextTables.getCount(), 2) - tables = document.getTextTables() - self.assertEqual(len(tables[0].getRows()), 2) - self.assertEqual(len(tables[1].getRows()), 5) - #undo -> verify 1 tables - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.TextTables.getCount(), 1) - - self.ui_test.close_doc() + copyheading = xDialog.getChild("copyheading") + copyheading.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + self.assertEqual(document.TextTables.getCount(), 2) + tables = document.getTextTables() + self.assertEqual(len(tables[0].getRows()), 2) + self.assertEqual(len(tables[1].getRows()), 5) + #undo -> verify 1 tables + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.TextTables.getCount(), 1) #dialog Split table, check Custom heading, OK -> verify 2 tables, 1st has 2 rows, second has 4 rows - writer_doc = self.ui_test.load_file(get_url_for_data_file("splitTable.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - #go to row 2 - self.xUITest.executeCommand(".uno:GoDown") - self.xUITest.executeCommand(".uno:GoDown") - self.ui_test.execute_dialog_through_command(".uno:SplitTable") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.load_file(get_url_for_data_file("splitTable.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + #go to row 2 + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:GoDown") + self.ui_test.execute_dialog_through_command(".uno:SplitTable") + xDialog = self.xUITest.getTopFocusWindow() - customheading = xDialog.getChild("customheading") - customheading.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - self.assertEqual(document.TextTables.getCount(), 2) - tables = document.getTextTables() - self.assertEqual(len(tables[0].getRows()), 2) - self.assertEqual(len(tables[1].getRows()), 4) - #undo -> verify 1 tables - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.TextTables.getCount(), 1) + customheading = xDialog.getChild("customheading") + customheading.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + self.assertEqual(document.TextTables.getCount(), 2) + tables = document.getTextTables() + self.assertEqual(len(tables[0].getRows()), 2) + self.assertEqual(len(tables[1].getRows()), 4) + #undo -> verify 1 tables + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.TextTables.getCount(), 1) - self.ui_test.close_doc() #dialog Split table, check No heading, OK -> verify 2 tables, 1st has 2 rows, second has 4 rows - writer_doc = self.ui_test.load_file(get_url_for_data_file("splitTable.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - #go to row 2 - self.xUITest.executeCommand(".uno:GoDown") - self.xUITest.executeCommand(".uno:GoDown") - self.ui_test.execute_dialog_through_command(".uno:SplitTable") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.load_file(get_url_for_data_file("splitTable.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + #go to row 2 + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:GoDown") + self.ui_test.execute_dialog_through_command(".uno:SplitTable") + xDialog = self.xUITest.getTopFocusWindow() - noheading = xDialog.getChild("noheading") - noheading.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - self.assertEqual(document.TextTables.getCount(), 2) - tables = document.getTextTables() - self.assertEqual(len(tables[0].getRows()), 2) - self.assertEqual(len(tables[1].getRows()), 4) - #undo -> verify 1 tables - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.TextTables.getCount(), 1) + noheading = xDialog.getChild("noheading") + noheading.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + self.assertEqual(document.TextTables.getCount(), 2) + tables = document.getTextTables() + self.assertEqual(len(tables[0].getRows()), 2) + self.assertEqual(len(tables[1].getRows()), 4) + #undo -> verify 1 tables + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.TextTables.getCount(), 1) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tableProperties.py b/sw/qa/uitest/table/tableProperties.py index da75f2218255..4c2b34ab0a16 100644 --- a/sw/qa/uitest/table/tableProperties.py +++ b/sw/qa/uitest/table/tableProperties.py @@ -15,208 +15,207 @@ from uitest.uihelper.common import change_measurement_unit class tableProperties(UITestCase): def test_table_properties(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tableToText.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - - change_measurement_unit(self, "Centimeter") - - #dialog Table Properties - Table - self.ui_test.execute_dialog_through_command(".uno:TableDialog") - xDialog = self.xUITest.getTopFocusWindow() - tabcontrol = xDialog.getChild("tabcontrol") - select_pos(tabcontrol, "0") - - name = xDialog.getChild("name") - free = xDialog.getChild("free") - widthmf = xDialog.getChild("widthmf") - leftmf = xDialog.getChild("leftmf") - rightmf = xDialog.getChild("rightmf") - abovemf = xDialog.getChild("abovemf") - belowmf = xDialog.getChild("belowmf") - textdirection = xDialog.getChild("textdirection") - - name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - name.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName"})) - free.executeAction("CLICK", tuple()) - widthmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - widthmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - widthmf.executeAction("TYPE", mkPropertyValues({"TEXT":"15"})) - leftmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - leftmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - leftmf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) - rightmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - rightmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - rightmf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) - abovemf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - abovemf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - abovemf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) - belowmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - belowmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - belowmf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) - select_by_text(textdirection, "Left-to-right (LTR)") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #verify - self.ui_test.execute_dialog_through_command(".uno:TableDialog") - xDialog = self.xUITest.getTopFocusWindow() - tabcontrol = xDialog.getChild("tabcontrol") - select_pos(tabcontrol, "0") - - name = xDialog.getChild("name") - free = xDialog.getChild("free") - widthmf = xDialog.getChild("widthmf") - leftmf = xDialog.getChild("leftmf") - rightmf = xDialog.getChild("rightmf") - abovemf = xDialog.getChild("abovemf") - belowmf = xDialog.getChild("belowmf") - textdirection = xDialog.getChild("textdirection") - - self.assertEqual(get_state_as_dict(name)["Text"], "NewName") - self.assertEqual(get_state_as_dict(free)["Checked"], "true") - self.assertEqual(get_state_as_dict(widthmf)["Text"], "15.00 cm") - self.assertEqual(get_state_as_dict(leftmf)["Text"], "1.00 cm") - self.assertEqual(get_state_as_dict(rightmf)["Text"], "1.00 cm") - self.assertEqual(get_state_as_dict(abovemf)["Text"], "1.00 cm") - self.assertEqual(get_state_as_dict(belowmf)["Text"], "1.00 cm") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - #dialog Table Properties - Text flow - self.ui_test.execute_dialog_through_command(".uno:TableDialog") - xDialog = self.xUITest.getTopFocusWindow() - tabcontrol = xDialog.getChild("tabcontrol") - select_pos(tabcontrol, "1") - - xbreak = xDialog.getChild("break") - xbreak.executeAction("CLICK", tuple()) - column = xDialog.getChild("column") - column.executeAction("CLICK", tuple()) - after = xDialog.getChild("after") - after.executeAction("CLICK", tuple()) - keep = xDialog.getChild("keep") - keep.executeAction("CLICK", tuple()) - headline = xDialog.getChild("headline") - headline.executeAction("CLICK", tuple()) - textdirection = xDialog.getChild("textorientation") - select_by_text(textdirection, "Vertical (bottom to top)") - vertorient = xDialog.getChild("vertorient") - select_by_text(vertorient, "Bottom") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #verify - self.ui_test.execute_dialog_through_command(".uno:TableDialog") - xDialog = self.xUITest.getTopFocusWindow() - tabcontrol = xDialog.getChild("tabcontrol") - select_pos(tabcontrol, "1") - - xbreak = xDialog.getChild("break") - self.assertEqual(get_state_as_dict(xbreak)["Selected"], "true") - column = xDialog.getChild("column") - self.assertEqual(get_state_as_dict(column)["Checked"], "true") - after = xDialog.getChild("column") - self.assertEqual(get_state_as_dict(after)["Checked"], "true") - keep = xDialog.getChild("keep") - self.assertEqual(get_state_as_dict(keep)["Selected"], "true") - headline = xDialog.getChild("headline") - self.assertEqual(get_state_as_dict(headline)["Selected"], "true") - textdirection = xDialog.getChild("textorientation") - self.assertEqual(get_state_as_dict(textdirection)["SelectEntryText"], "Vertical (bottom to top)") - vertorient = xDialog.getChild("vertorient") - self.assertEqual(get_state_as_dict(vertorient)["SelectEntryText"], "Bottom") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - #dialog Table Properties - Columns - self.ui_test.execute_dialog_through_command(".uno:TableDialog") - xDialog = self.xUITest.getTopFocusWindow() - tabcontrol = xDialog.getChild("tabcontrol") - select_pos(tabcontrol, "2") - - adaptwidth = xDialog.getChild("adaptwidth") - adaptwidth.executeAction("CLICK", tuple()) - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #verify - #doesn't work / probably Bug 100537 - Width and relative checkboxes disabled in Table - #dialog by default with automatic alignment -# self.ui_test.execute_dialog_through_command(".uno:TableDialog") -# xDialog = self.xUITest.getTopFocusWindow() -# tabcontrol = xDialog.getChild("tabcontrol") -# select_pos(tabcontrol, "2") -# adaptwidth = xDialog.getChild("adaptwidth") -# self.assertEqual(get_state_as_dict(adaptwidth)["Selected"], "true") -# xOKBtn = xDialog.getChild("ok") -# self.ui_test.close_dialog_through_button(xOKBtn) - - #dialog Table Properties - Borders - self.ui_test.execute_dialog_through_command(".uno:TableDialog") - xDialog = self.xUITest.getTopFocusWindow() - tabcontrol = xDialog.getChild("tabcontrol") - select_pos(tabcontrol, "3") - - sync = xDialog.getChild("sync") - mergeadjacent = xDialog.getChild("mergeadjacent") - sync.executeAction("CLICK", tuple()) - mergeadjacent.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - #verify - self.ui_test.execute_dialog_through_command(".uno:TableDialog") - xDialog = self.xUITest.getTopFocusWindow() - tabcontrol = xDialog.getChild("tabcontrol") - select_pos(tabcontrol, "3") - sync = xDialog.getChild("sync") - mergeadjacent = xDialog.getChild("mergeadjacent") -# self.assertEqual(get_state_as_dict(sync)["Selected"], "false") #need change spacing, but ui names are not unique - self.assertEqual(get_state_as_dict(mergeadjacent)["Selected"], "false") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - #dialog Table Properties - Background - self.ui_test.execute_dialog_through_command(".uno:TableDialog") - xDialog = self.xUITest.getTopFocusWindow() - tabcontrol = xDialog.getChild("tabcontrol") - select_pos(tabcontrol, "4") - - btncolor = xDialog.getChild("btncolor") - btncolor.executeAction("CLICK", tuple()) - R_custom = xDialog.getChild("R_custom") - G_custom = xDialog.getChild("G_custom") - B_custom = xDialog.getChild("B_custom") - R_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - R_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - R_custom.executeAction("TYPE", mkPropertyValues({"TEXT":"100"})) - G_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - G_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - G_custom.executeAction("TYPE", mkPropertyValues({"TEXT":"100"})) - B_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - B_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - B_custom.executeAction("TYPE", mkPropertyValues({"TEXT":"100"})) - B_custom.executeAction("UP", tuple()) - B_custom.executeAction("DOWN", tuple()) #need to refresh HEX value... - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - #verify - self.ui_test.execute_dialog_through_command(".uno:TableDialog") - xDialog = self.xUITest.getTopFocusWindow() - tabcontrol = xDialog.getChild("tabcontrol") - select_pos(tabcontrol, "4") - btncolor = xDialog.getChild("btncolor") - btncolor.executeAction("CLICK", tuple()) - R_custom = xDialog.getChild("R_custom") - G_custom = xDialog.getChild("G_custom") - B_custom = xDialog.getChild("B_custom") - - self.assertEqual(get_state_as_dict(R_custom)["Text"], "100") - self.assertEqual(get_state_as_dict(B_custom)["Text"], "100") - self.assertEqual(get_state_as_dict(G_custom)["Text"], "100") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("tableToText.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + + change_measurement_unit(self, "Centimeter") + + #dialog Table Properties - Table + self.ui_test.execute_dialog_through_command(".uno:TableDialog") + xDialog = self.xUITest.getTopFocusWindow() + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "0") + + name = xDialog.getChild("name") + free = xDialog.getChild("free") + widthmf = xDialog.getChild("widthmf") + leftmf = xDialog.getChild("leftmf") + rightmf = xDialog.getChild("rightmf") + abovemf = xDialog.getChild("abovemf") + belowmf = xDialog.getChild("belowmf") + textdirection = xDialog.getChild("textdirection") + + name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + name.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName"})) + free.executeAction("CLICK", tuple()) + widthmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + widthmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + widthmf.executeAction("TYPE", mkPropertyValues({"TEXT":"15"})) + leftmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + leftmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + leftmf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + rightmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + rightmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + rightmf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + abovemf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + abovemf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + abovemf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + belowmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + belowmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + belowmf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + select_by_text(textdirection, "Left-to-right (LTR)") + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #verify + self.ui_test.execute_dialog_through_command(".uno:TableDialog") + xDialog = self.xUITest.getTopFocusWindow() + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "0") + + name = xDialog.getChild("name") + free = xDialog.getChild("free") + widthmf = xDialog.getChild("widthmf") + leftmf = xDialog.getChild("leftmf") + rightmf = xDialog.getChild("rightmf") + abovemf = xDialog.getChild("abovemf") + belowmf = xDialog.getChild("belowmf") + textdirection = xDialog.getChild("textdirection") + + self.assertEqual(get_state_as_dict(name)["Text"], "NewName") + self.assertEqual(get_state_as_dict(free)["Checked"], "true") + self.assertEqual(get_state_as_dict(widthmf)["Text"], "15.00 cm") + self.assertEqual(get_state_as_dict(leftmf)["Text"], "1.00 cm") + self.assertEqual(get_state_as_dict(rightmf)["Text"], "1.00 cm") + self.assertEqual(get_state_as_dict(abovemf)["Text"], "1.00 cm") + self.assertEqual(get_state_as_dict(belowmf)["Text"], "1.00 cm") + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #dialog Table Properties - Text flow + self.ui_test.execute_dialog_through_command(".uno:TableDialog") + xDialog = self.xUITest.getTopFocusWindow() + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "1") + + xbreak = xDialog.getChild("break") + xbreak.executeAction("CLICK", tuple()) + column = xDialog.getChild("column") + column.executeAction("CLICK", tuple()) + after = xDialog.getChild("after") + after.executeAction("CLICK", tuple()) + keep = xDialog.getChild("keep") + keep.executeAction("CLICK", tuple()) + headline = xDialog.getChild("headline") + headline.executeAction("CLICK", tuple()) + textdirection = xDialog.getChild("textorientation") + select_by_text(textdirection, "Vertical (bottom to top)") + vertorient = xDialog.getChild("vertorient") + select_by_text(vertorient, "Bottom") + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #verify + self.ui_test.execute_dialog_through_command(".uno:TableDialog") + xDialog = self.xUITest.getTopFocusWindow() + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "1") + + xbreak = xDialog.getChild("break") + self.assertEqual(get_state_as_dict(xbreak)["Selected"], "true") + column = xDialog.getChild("column") + self.assertEqual(get_state_as_dict(column)["Checked"], "true") + after = xDialog.getChild("column") + self.assertEqual(get_state_as_dict(after)["Checked"], "true") + keep = xDialog.getChild("keep") + self.assertEqual(get_state_as_dict(keep)["Selected"], "true") + headline = xDialog.getChild("headline") + self.assertEqual(get_state_as_dict(headline)["Selected"], "true") + textdirection = xDialog.getChild("textorientation") + self.assertEqual(get_state_as_dict(textdirection)["SelectEntryText"], "Vertical (bottom to top)") + vertorient = xDialog.getChild("vertorient") + self.assertEqual(get_state_as_dict(vertorient)["SelectEntryText"], "Bottom") + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #dialog Table Properties - Columns + self.ui_test.execute_dialog_through_command(".uno:TableDialog") + xDialog = self.xUITest.getTopFocusWindow() + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "2") + + adaptwidth = xDialog.getChild("adaptwidth") + adaptwidth.executeAction("CLICK", tuple()) + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #verify + #doesn't work / probably Bug 100537 - Width and relative checkboxes disabled in Table + #dialog by default with automatic alignment + # self.ui_test.execute_dialog_through_command(".uno:TableDialog") + # xDialog = self.xUITest.getTopFocusWindow() + # tabcontrol = xDialog.getChild("tabcontrol") + # select_pos(tabcontrol, "2") + # adaptwidth = xDialog.getChild("adaptwidth") + # self.assertEqual(get_state_as_dict(adaptwidth)["Selected"], "true") + # xOKBtn = xDialog.getChild("ok") + # self.ui_test.close_dialog_through_button(xOKBtn) + + #dialog Table Properties - Borders + self.ui_test.execute_dialog_through_command(".uno:TableDialog") + xDialog = self.xUITest.getTopFocusWindow() + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "3") + + sync = xDialog.getChild("sync") + mergeadjacent = xDialog.getChild("mergeadjacent") + sync.executeAction("CLICK", tuple()) + mergeadjacent.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #verify + self.ui_test.execute_dialog_through_command(".uno:TableDialog") + xDialog = self.xUITest.getTopFocusWindow() + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "3") + sync = xDialog.getChild("sync") + mergeadjacent = xDialog.getChild("mergeadjacent") + # self.assertEqual(get_state_as_dict(sync)["Selected"], "false") #need change spacing, but ui names are not unique + self.assertEqual(get_state_as_dict(mergeadjacent)["Selected"], "false") + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #dialog Table Properties - Background + self.ui_test.execute_dialog_through_command(".uno:TableDialog") + xDialog = self.xUITest.getTopFocusWindow() + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "4") + + btncolor = xDialog.getChild("btncolor") + btncolor.executeAction("CLICK", tuple()) + R_custom = xDialog.getChild("R_custom") + G_custom = xDialog.getChild("G_custom") + B_custom = xDialog.getChild("B_custom") + R_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + R_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + R_custom.executeAction("TYPE", mkPropertyValues({"TEXT":"100"})) + G_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + G_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + G_custom.executeAction("TYPE", mkPropertyValues({"TEXT":"100"})) + B_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + B_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + B_custom.executeAction("TYPE", mkPropertyValues({"TEXT":"100"})) + B_custom.executeAction("UP", tuple()) + B_custom.executeAction("DOWN", tuple()) #need to refresh HEX value... + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #verify + self.ui_test.execute_dialog_through_command(".uno:TableDialog") + xDialog = self.xUITest.getTopFocusWindow() + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "4") + btncolor = xDialog.getChild("btncolor") + btncolor.executeAction("CLICK", tuple()) + R_custom = xDialog.getChild("R_custom") + G_custom = xDialog.getChild("G_custom") + B_custom = xDialog.getChild("B_custom") + + self.assertEqual(get_state_as_dict(R_custom)["Text"], "100") + self.assertEqual(get_state_as_dict(B_custom)["Text"], "100") + self.assertEqual(get_state_as_dict(G_custom)["Text"], "100") + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tableToText.py b/sw/qa/uitest/table/tableToText.py index f131f914c93e..110a3e0837d6 100644 --- a/sw/qa/uitest/table/tableToText.py +++ b/sw/qa/uitest/table/tableToText.py @@ -12,68 +12,67 @@ from uitest.uihelper.common import get_url_for_data_file class tableToText(UITestCase): def test_table_to_text(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tableToText.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - #dialog Table to text - Tabs; verify - self.ui_test.execute_dialog_through_command(".uno:ConvertTableToText") - xDialog = self.xUITest.getTopFocusWindow() - tabs = xDialog.getChild("tabs") - tabs.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #verify - self.assertEqual(document.Text.String[0:3], "a\ta") - self.assertEqual(document.TextTables.getCount(), 0) - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.TextTables.getCount(), 1) + with self.ui_test.load_file(get_url_for_data_file("tableToText.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + #dialog Table to text - Tabs; verify + self.ui_test.execute_dialog_through_command(".uno:ConvertTableToText") + xDialog = self.xUITest.getTopFocusWindow() + tabs = xDialog.getChild("tabs") + tabs.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #verify + self.assertEqual(document.Text.String[0:3], "a\ta") + self.assertEqual(document.TextTables.getCount(), 0) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.TextTables.getCount(), 1) - #dialog Table to text - Paragraph; verify - self.ui_test.execute_dialog_through_command(".uno:ConvertTableToText") - xDialog = self.xUITest.getTopFocusWindow() - paragraph = xDialog.getChild("paragraph") - paragraph.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #verify - self.assertEqual(document.Text.String.replace('\r\n', '\n')[0:4], "a\na\n") - self.assertEqual(document.TextTables.getCount(), 0) - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.TextTables.getCount(), 1) + #dialog Table to text - Paragraph; verify + self.ui_test.execute_dialog_through_command(".uno:ConvertTableToText") + xDialog = self.xUITest.getTopFocusWindow() + paragraph = xDialog.getChild("paragraph") + paragraph.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #verify + self.assertEqual(document.Text.String.replace('\r\n', '\n')[0:4], "a\na\n") + self.assertEqual(document.TextTables.getCount(), 0) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.TextTables.getCount(), 1) - #dialog Table to text - Semicolons; verify - self.ui_test.execute_dialog_through_command(".uno:ConvertTableToText") - xDialog = self.xUITest.getTopFocusWindow() - semicolons = xDialog.getChild("semicolons") - semicolons.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #verify - self.assertEqual(document.Text.String.replace('\r\n', '\n')[0:6], "a;a\n;\n") - self.assertEqual(document.TextTables.getCount(), 0) - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.TextTables.getCount(), 1) + #dialog Table to text - Semicolons; verify + self.ui_test.execute_dialog_through_command(".uno:ConvertTableToText") + xDialog = self.xUITest.getTopFocusWindow() + semicolons = xDialog.getChild("semicolons") + semicolons.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #verify + self.assertEqual(document.Text.String.replace('\r\n', '\n')[0:6], "a;a\n;\n") + self.assertEqual(document.TextTables.getCount(), 0) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.TextTables.getCount(), 1) - #dialog Table to text - other; verify - self.ui_test.execute_dialog_through_command(".uno:ConvertTableToText") - xDialog = self.xUITest.getTopFocusWindow() - other = xDialog.getChild("other") - other.executeAction("CLICK", tuple()) - othered = xDialog.getChild("othered") - othered.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - othered.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - othered.executeAction("TYPE", mkPropertyValues({"TEXT":":"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #verify - self.assertEqual(document.Text.String.replace('\r\n', '\n')[0:6], "a:a\n:\n") - self.assertEqual(document.TextTables.getCount(), 0) - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.TextTables.getCount(), 1) + #dialog Table to text - other; verify + self.ui_test.execute_dialog_through_command(".uno:ConvertTableToText") + xDialog = self.xUITest.getTopFocusWindow() + other = xDialog.getChild("other") + other.executeAction("CLICK", tuple()) + othered = xDialog.getChild("othered") + othered.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + othered.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + othered.executeAction("TYPE", mkPropertyValues({"TEXT":":"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #verify + self.assertEqual(document.Text.String.replace('\r\n', '\n')[0:6], "a:a\n:\n") + self.assertEqual(document.TextTables.getCount(), 0) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.TextTables.getCount(), 1) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tdf134881_colProportionalAdjust.py b/sw/qa/uitest/table/tdf134881_colProportionalAdjust.py index 019c492374a1..ff34dd75e9d0 100644 --- a/sw/qa/uitest/table/tdf134881_colProportionalAdjust.py +++ b/sw/qa/uitest/table/tdf134881_colProportionalAdjust.py @@ -14,38 +14,36 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf134881(UITestCase): def test_tdf134881(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf134881_colProportionalAdjust.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - - change_measurement_unit(self, "Centimeter") - - #dialog Table Properties - self.ui_test.execute_dialog_through_command(".uno:TableDialog") - xDialog = self.xUITest.getTopFocusWindow() - tabcontrol = xDialog.getChild("tabcontrol") - select_pos(tabcontrol, "2") #columns - - adaptcolumns = xDialog.getChild("adaptcolumns") - width1 = xDialog.getChild("width1") - width2 = xDialog.getChild("width2") - # Get the baseline. The first column is much shorter than the second. - self.assertEqual((get_state_as_dict(width1)["Text"])[0:3], "3.0") - self.assertEqual((get_state_as_dict(width2)["Text"])[0:4], "14.0") - # Set proportional adjust - so all columns are affected. - adaptcolumns.executeAction("CLICK", tuple()) - # Cut the second column in half. - width2.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - width2.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - width2.executeAction("TYPE", mkPropertyValues({"TEXT":"7"})) - width2.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) - - # The first column should now be half it's original value, not zero (not 3 - 7) - self.assertEqual((get_state_as_dict(width1)["Text"])[0:2], "1.") #1.5 - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("tdf134881_colProportionalAdjust.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + + change_measurement_unit(self, "Centimeter") + + #dialog Table Properties + self.ui_test.execute_dialog_through_command(".uno:TableDialog") + xDialog = self.xUITest.getTopFocusWindow() + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "2") #columns + + adaptcolumns = xDialog.getChild("adaptcolumns") + width1 = xDialog.getChild("width1") + width2 = xDialog.getChild("width2") + # Get the baseline. The first column is much shorter than the second. + self.assertEqual((get_state_as_dict(width1)["Text"])[0:3], "3.0") + self.assertEqual((get_state_as_dict(width2)["Text"])[0:4], "14.0") + # Set proportional adjust - so all columns are affected. + adaptcolumns.executeAction("CLICK", tuple()) + # Cut the second column in half. + width2.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + width2.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + width2.executeAction("TYPE", mkPropertyValues({"TEXT":"7"})) + width2.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + + # The first column should now be half it's original value, not zero (not 3 - 7) + self.assertEqual((get_state_as_dict(width1)["Text"])[0:2], "1.") #1.5 + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tdf135693.py b/sw/qa/uitest/table/tdf135693.py index 39026fcbfd27..f4a0a7b8cfa3 100644 --- a/sw/qa/uitest/table/tdf135693.py +++ b/sw/qa/uitest/table/tdf135693.py @@ -11,27 +11,25 @@ from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file class tdf135693(UITestCase): def test_tdf135693(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf135693.odt")) + with self.ui_test.load_file(get_url_for_data_file("tdf135693.odt")) as writer_doc: - self.xUITest.getTopFocusWindow() + self.xUITest.getTopFocusWindow() - self.xUITest.executeCommand(".uno:GoRight") - self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:GoRight") + self.xUITest.executeCommand(".uno:GoDown") - # Without the fix in place, this would have crashed here - self.ui_test.execute_dialog_through_command(".uno:TableDialog") + # Without the fix in place, this would have crashed here + self.ui_test.execute_dialog_through_command(".uno:TableDialog") - xTableDlg = self.xUITest.getTopFocusWindow() + xTableDlg = self.xUITest.getTopFocusWindow() - xTabs = xTableDlg.getChild("tabcontrol") - select_pos(xTabs, "0") + xTabs = xTableDlg.getChild("tabcontrol") + select_pos(xTabs, "0") - # Check we are in the right table - self.assertEqual("Table1", get_state_as_dict(xTabs.getChild('name'))['Text']) + # Check we are in the right table + self.assertEqual("Table1", get_state_as_dict(xTabs.getChild('name'))['Text']) - xok = xTableDlg.getChild("ok") - self.ui_test.close_dialog_through_button(xok) - - self.ui_test.close_doc() + xok = xTableDlg.getChild("ok") + self.ui_test.close_dialog_through_button(xok) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tdf81292.py b/sw/qa/uitest/table/tdf81292.py index 343b1a89bb13..50996861d6ac 100644 --- a/sw/qa/uitest/table/tdf81292.py +++ b/sw/qa/uitest/table/tdf81292.py @@ -12,30 +12,29 @@ from uitest.uihelper.common import get_url_for_data_file class tdf81292(UITestCase): def test_tdf81292_table_sort(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf81292.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - #select whole table - self.xUITest.executeCommand(".uno:SelectTable") - #Tools - Sort - self.ui_test.execute_dialog_through_command(".uno:SortDialog") - xDialog = self.xUITest.getTopFocusWindow() - xDown = xDialog.getChild("down1") - xDown.executeAction("CLICK", tuple()) - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) - #verify - tables = document.getTextTables() - table = tables[0] - tableText = table.getCellByName("B3") - b3 = tableText.getString() - tableTextc1 = table.getCellByName("C1").getString() - self.assertEqual(b3, "https://www.hightail.com/") - self.assertEqual(tableTextc1, "inlognaam") - #undo - self.xUITest.executeCommand(".uno:Undo") - b3 = tableText.getString() - self.assertEqual(b3, "www.comicstripshop.com") + with self.ui_test.load_file(get_url_for_data_file("tdf81292.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + #select whole table + self.xUITest.executeCommand(".uno:SelectTable") + #Tools - Sort + self.ui_test.execute_dialog_through_command(".uno:SortDialog") + xDialog = self.xUITest.getTopFocusWindow() + xDown = xDialog.getChild("down1") + xDown.executeAction("CLICK", tuple()) + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #verify + tables = document.getTextTables() + table = tables[0] + tableText = table.getCellByName("B3") + b3 = tableText.getString() + tableTextc1 = table.getCellByName("C1").getString() + self.assertEqual(b3, "https://www.hightail.com/") + self.assertEqual(tableTextc1, "inlognaam") + #undo + self.xUITest.executeCommand(".uno:Undo") + b3 = tableText.getString() + self.assertEqual(b3, "www.comicstripshop.com") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tdf99334.py b/sw/qa/uitest/table/tdf99334.py index e87226a0c485..9e1b649becbe 100644 --- a/sw/qa/uitest/table/tdf99334.py +++ b/sw/qa/uitest/table/tdf99334.py @@ -12,28 +12,27 @@ from uitest.uihelper.common import get_url_for_data_file class tdf99334(UITestCase): def test_tdf99334_table_sort_umlauts(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf99334.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - #select whole table - self.xUITest.executeCommand(".uno:SelectTable") - #Tools - Sort - self.ui_test.execute_dialog_through_command(".uno:SortDialog") - xDialog = self.xUITest.getTopFocusWindow() - # xDown = xDialog.getChild("down1") - # xDown.executeAction("CLICK", tuple()) - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) - #verify - tables = document.getTextTables() - table = tables[0] - tableText = table.getCellByName("B1") - b1 = tableText.getString() - self.assertEqual(b1, "two") - #undo - self.xUITest.executeCommand(".uno:Undo") - b1 = tableText.getString() - self.assertEqual(b1, "one") + with self.ui_test.load_file(get_url_for_data_file("tdf99334.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + #select whole table + self.xUITest.executeCommand(".uno:SelectTable") + #Tools - Sort + self.ui_test.execute_dialog_through_command(".uno:SortDialog") + xDialog = self.xUITest.getTopFocusWindow() + # xDown = xDialog.getChild("down1") + # xDown.executeAction("CLICK", tuple()) + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #verify + tables = document.getTextTables() + table = tables[0] + tableText = table.getCellByName("B1") + b1 = tableText.getString() + self.assertEqual(b1, "two") + #undo + self.xUITest.executeCommand(".uno:Undo") + b1 = tableText.getString() + self.assertEqual(b1, "one") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/textToTable.py b/sw/qa/uitest/table/textToTable.py index d901ae6d2c04..2b820b360653 100644 --- a/sw/qa/uitest/table/textToTable.py +++ b/sw/qa/uitest/table/textToTable.py @@ -38,33 +38,32 @@ class textToTable(UITestCase): self.ui_test.close_doc() def test_text_to_table_header(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("textToTable.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - #open file; select all text ; dialog Text to table - other ":"; verify - self.xUITest.executeCommand(".uno:SelectAll") - self.ui_test.execute_dialog_through_command(".uno:ConvertTextToTable") - xDialog = self.xUITest.getTopFocusWindow() - other = xDialog.getChild("other") - other.executeAction("CLICK", tuple()) - othered = xDialog.getChild("othered") - othered.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - othered.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - othered.executeAction("TYPE", mkPropertyValues({"TEXT":":"})) - headingcb = xDialog.getChild("headingcb") - headingcb.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #verify - self.assertEqual(document.TextTables.getCount(), 1) - tables = document.getTextTables() - self.assertEqual(len(tables[0].getRows()), 4) - self.assertEqual(len(tables[0].getColumns()), 3) - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.TextTables.getCount(), 0) - self.assertEqual(document.Text.String[0:5], "A:B:C") + with self.ui_test.load_file(get_url_for_data_file("textToTable.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + #open file; select all text ; dialog Text to table - other ":"; verify + self.xUITest.executeCommand(".uno:SelectAll") + self.ui_test.execute_dialog_through_command(".uno:ConvertTextToTable") + xDialog = self.xUITest.getTopFocusWindow() + other = xDialog.getChild("other") + other.executeAction("CLICK", tuple()) + othered = xDialog.getChild("othered") + othered.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + othered.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + othered.executeAction("TYPE", mkPropertyValues({"TEXT":":"})) + headingcb = xDialog.getChild("headingcb") + headingcb.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #verify + self.assertEqual(document.TextTables.getCount(), 1) + tables = document.getTextTables() + self.assertEqual(len(tables[0].getRows()), 4) + self.assertEqual(len(tables[0].getColumns()), 3) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.TextTables.getCount(), 0) + self.assertEqual(document.Text.String[0:5], "A:B:C") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests/compareDocuments.py b/sw/qa/uitest/writer_tests/compareDocuments.py index 6cb90bf99466..ba308974d79f 100644 --- a/sw/qa/uitest/writer_tests/compareDocuments.py +++ b/sw/qa/uitest/writer_tests/compareDocuments.py @@ -16,76 +16,72 @@ class compareDocuments(UITestCase): def test_tdf130960(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf130960.odt")) + with self.ui_test.load_file(get_url_for_data_file("tdf130960.odt")) as writer_doc: - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() - self.ui_test.execute_dialog_through_command(".uno:CompareDocuments") + self.ui_test.execute_dialog_through_command(".uno:CompareDocuments") - xOpenDialog = self.xUITest.getTopFocusWindow() - xFileName = xOpenDialog.getChild("file_name") - xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf130960_2.odt")})) + xOpenDialog = self.xUITest.getTopFocusWindow() + xFileName = xOpenDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf130960_2.odt")})) - xOpenBtn = xOpenDialog.getChild("open") - xOpenBtn.executeAction("CLICK", tuple()) + xOpenBtn = xOpenDialog.getChild("open") + xOpenBtn.executeAction("CLICK", tuple()) - # Close the dialog and open it again so the list of changes is updated - xTrackDlg = self.xUITest.getTopFocusWindow() - xcloseBtn = xTrackDlg.getChild("close") - xcloseBtn.executeAction("CLICK", tuple()) + # Close the dialog and open it again so the list of changes is updated + xTrackDlg = self.xUITest.getTopFocusWindow() + xcloseBtn = xTrackDlg.getChild("close") + xcloseBtn.executeAction("CLICK", tuple()) - self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges") - xTrackDlg = self.xUITest.getTopFocusWindow() - changesList = xTrackDlg.getChild("writerchanges") + self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges") + xTrackDlg = self.xUITest.getTopFocusWindow() + changesList = xTrackDlg.getChild("writerchanges") - text = "Unknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y") - self.assertEqual(2, len(changesList.getChildren())) - self.assertTrue(get_state_as_dict(changesList.getChild('0'))["Text"].startswith(text)) - self.assertTrue(get_state_as_dict(changesList.getChild('1'))["Text"].startswith(text)) + text = "Unknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y") + self.assertEqual(2, len(changesList.getChildren())) + self.assertTrue(get_state_as_dict(changesList.getChild('0'))["Text"].startswith(text)) + self.assertTrue(get_state_as_dict(changesList.getChild('1'))["Text"].startswith(text)) - xcloseBtn = xTrackDlg.getChild("close") - xcloseBtn.executeAction("CLICK", tuple()) - - self.ui_test.close_doc() + xcloseBtn = xTrackDlg.getChild("close") + xcloseBtn.executeAction("CLICK", tuple()) def test_tdf137855(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf137855.odt")) - - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() + with self.ui_test.load_file(get_url_for_data_file("tdf137855.odt")) as writer_doc: - self.ui_test.execute_dialog_through_command(".uno:CompareDocuments") + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() - xOpenDialog = self.xUITest.getTopFocusWindow() - xFileName = xOpenDialog.getChild("file_name") - xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf137855_2.odt")})) + self.ui_test.execute_dialog_through_command(".uno:CompareDocuments") - xOpenBtn = xOpenDialog.getChild("open") - xOpenBtn.executeAction("CLICK", tuple()) + xOpenDialog = self.xUITest.getTopFocusWindow() + xFileName = xOpenDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf137855_2.odt")})) - # Close the dialog and open it again so the list of changes is updated - xTrackDlg = self.xUITest.getTopFocusWindow() - xcloseBtn = xTrackDlg.getChild("close") - xcloseBtn.executeAction("CLICK", tuple()) + xOpenBtn = xOpenDialog.getChild("open") + xOpenBtn.executeAction("CLICK", tuple()) - self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges") - xTrackDlg = self.xUITest.getTopFocusWindow() - changesList = xTrackDlg.getChild("writerchanges") + # Close the dialog and open it again so the list of changes is updated + xTrackDlg = self.xUITest.getTopFocusWindow() + xcloseBtn = xTrackDlg.getChild("close") + xcloseBtn.executeAction("CLICK", tuple()) - # Check the number of changes - self.assertEqual(263, len(changesList.getChildren())) + self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges") + xTrackDlg = self.xUITest.getTopFocusWindow() + changesList = xTrackDlg.getChild("writerchanges") - # Without the fix in place, this test would have crashed here - xAccBtn = xTrackDlg.getChild("acceptall") - xAccBtn.executeAction("CLICK", tuple()) + # Check the number of changes + self.assertEqual(263, len(changesList.getChildren())) - self.assertEqual(0, len(changesList.getChildren())) + # Without the fix in place, this test would have crashed here + xAccBtn = xTrackDlg.getChild("acceptall") + xAccBtn.executeAction("CLICK", tuple()) - xcloseBtn = xTrackDlg.getChild("close") - xcloseBtn.executeAction("CLICK", tuple()) + self.assertEqual(0, len(changesList.getChildren())) - self.ui_test.close_doc() + xcloseBtn = xTrackDlg.getChild("close") + xcloseBtn.executeAction("CLICK", tuple()) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests/tdf81457.py b/sw/qa/uitest/writer_tests/tdf81457.py index bf615f99c2b0..7a15327a45bc 100644 --- a/sw/qa/uitest/writer_tests/tdf81457.py +++ b/sw/qa/uitest/writer_tests/tdf81457.py @@ -15,29 +15,27 @@ class tdf81457(UITestCase): #tdf 81457 def test_open_documentProperties_tdf81457(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf81457.odt")) - self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "2") #tab Custom properties - - aExpectedNames = ['BookMarkCount', 'BookMarkInfo1', 'BookMarkInfo10', 'BookMarkInfo11', - 'BookMarkInfo12', 'BookMarkInfo13'] - aExpectedValues = ['78', '00FF0000FF010', '00FF0000FF1E0', '00FF0000FF1E0', - '00FF0000FF210', '00FF0000FF230'] - - for i in range(6): - xNameBox = xDialog.getChild("namebox" + str(i + 1)) - xTypeBox = xDialog.getChild("typebox" + str(i + 1)) - xValueEdit = xDialog.getChild("valueedit" + str(i + 1)) - self.assertEqual(aExpectedNames[i], get_state_as_dict(xNameBox)['Text']) - self.assertEqual('Text', get_state_as_dict(xTypeBox)['DisplayText']) - self.assertEqual(aExpectedValues[i], get_state_as_dict(xValueEdit)['Text'][:13]) - - - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) - - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("tdf81457.odt")) as writer_doc: + self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "2") #tab Custom properties + + aExpectedNames = ['BookMarkCount', 'BookMarkInfo1', 'BookMarkInfo10', 'BookMarkInfo11', + 'BookMarkInfo12', 'BookMarkInfo13'] + aExpectedValues = ['78', '00FF0000FF010', '00FF0000FF1E0', '00FF0000FF1E0', + '00FF0000FF210', '00FF0000FF230'] + + for i in range(6): + xNameBox = xDialog.getChild("namebox" + str(i + 1)) + xTypeBox = xDialog.getChild("typebox" + str(i + 1)) + xValueEdit = xDialog.getChild("valueedit" + str(i + 1)) + self.assertEqual(aExpectedNames[i], get_state_as_dict(xNameBox)['Text']) + self.assertEqual('Text', get_state_as_dict(xTypeBox)['DisplayText']) + self.assertEqual(aExpectedValues[i], get_state_as_dict(xValueEdit)['Text'][:13]) + + + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests/trackedChanges.py b/sw/qa/uitest/writer_tests/trackedChanges.py index a3ea2671c6c6..366954d76d16 100644 --- a/sw/qa/uitest/writer_tests/trackedChanges.py +++ b/sw/qa/uitest/writer_tests/trackedChanges.py @@ -151,105 +151,101 @@ class trackedchanges(UITestCase): self.ui_test.close_doc() def test_list_of_changes(self): - self.ui_test.load_file(get_url_for_data_file("trackedChanges.odt")) - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - document = self.ui_test.get_component() + with self.ui_test.load_file(get_url_for_data_file("trackedChanges.odt")): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + document = self.ui_test.get_component() + + listText = [ + "Unknown Author\t01/24/2020 16:19:32\t", + "Unknown Author\t01/24/2020 16:19:35\t", + "Unknown Author\t01/24/2020 16:19:39\t", + "Unknown Author\t01/24/2020 16:19:39\t", + "Xisco Fauli\t01/27/2020 17:42:55\t"] + + self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges") + xTrackDlg = self.xUITest.getTopFocusWindow() + changesList = xTrackDlg.getChild("writerchanges") + + resultsAccept = [ + "The tennis ball is a small ball. The baskedtball is much bigger.", + "The tennis ball is a small ball. The baskedtball is much bigger.", + "The tennis ball is a small ball. The baskedtball is much bigger.", + "The tennis ball is a small ball. The basketball is much bigger.", + "The tennis ball is a small ball. The basketball is much bigger.", + "The tennis ball is a small ball. The basketball is much bigger."] + + for i in range(len(listText)): + self.assertEqual(document.Text.String.strip(), resultsAccept[i]) + self.assertEqual(get_state_as_dict(changesList.getChild('0'))["Text"], listText[i] ) + xAccBtn = xTrackDlg.getChild("accept") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(document.Text.String.strip(), resultsAccept[5]) + #List is empty + self.assertFalse('0' in changesList.getChildren()) + + for i in reversed(range(len(listText))): + xUndoBtn = xTrackDlg.getChild("undo") + xUndoBtn.executeAction("CLICK", tuple()) + self.assertEqual(document.Text.String.strip(), resultsAccept[i]) + self.assertEqual(get_state_as_dict(changesList.getChild('0'))["Text"], listText[i] ) + + resultsReject = [ + "The tennis ball is a small ball. The baskedtball is much bigger.", + "The tenis ball is a small ball. The baskedtball is much bigger.", + "The tenis ball is a small bal. The baskedtball is much bigger.", + "The tenis ball is a small bal. The baskedtball is much bigger.", + "The tenis ball is a small bal. The baskedball is much bigger.", + "The tenis ball is a small bal. The baskedball is much biger."] + + for i in range(len(listText)): + self.assertEqual(document.Text.String.strip(), resultsReject[i]) + self.assertEqual(get_state_as_dict(changesList.getChild('0'))["Text"], listText[i] ) + xAccBtn = xTrackDlg.getChild("reject") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(document.Text.String.strip(), resultsReject[5]) + #List is empty + self.assertFalse('0' in changesList.getChildren()) + + for i in reversed(range(len(listText))): + xUndoBtn = xTrackDlg.getChild("undo") + xUndoBtn.executeAction("CLICK", tuple()) + self.assertEqual(document.Text.String.strip(), resultsReject[i]) + self.assertEqual(get_state_as_dict(changesList.getChild('0'))["Text"], listText[i] ) + + xcloseBtn = xTrackDlg.getChild("close") + xcloseBtn.executeAction("CLICK", tuple()) - listText = [ - "Unknown Author\t01/24/2020 16:19:32\t", - "Unknown Author\t01/24/2020 16:19:35\t", - "Unknown Author\t01/24/2020 16:19:39\t", - "Unknown Author\t01/24/2020 16:19:39\t", - "Xisco Fauli\t01/27/2020 17:42:55\t"] + def test_tdf135018(self): + with self.ui_test.load_file(get_url_for_data_file("tdf135018.odt")): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + document = self.ui_test.get_component() - self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges") - xTrackDlg = self.xUITest.getTopFocusWindow() - changesList = xTrackDlg.getChild("writerchanges") - - resultsAccept = [ - "The tennis ball is a small ball. The baskedtball is much bigger.", - "The tennis ball is a small ball. The baskedtball is much bigger.", - "The tennis ball is a small ball. The baskedtball is much bigger.", - "The tennis ball is a small ball. The basketball is much bigger.", - "The tennis ball is a small ball. The basketball is much bigger.", - "The tennis ball is a small ball. The basketball is much bigger."] - - for i in range(len(listText)): - self.assertEqual(document.Text.String.strip(), resultsAccept[i]) - self.assertEqual(get_state_as_dict(changesList.getChild('0'))["Text"], listText[i] ) - xAccBtn = xTrackDlg.getChild("accept") - xAccBtn.executeAction("CLICK", tuple()) + self.assertEqual(5, document.CurrentController.PageCount) - self.assertEqual(document.Text.String.strip(), resultsAccept[5]) - #List is empty - self.assertFalse('0' in changesList.getChildren()) + self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges") + xTrackDlg = self.xUITest.getTopFocusWindow() + changesList = xTrackDlg.getChild("writerchanges") + self.assertEqual(147, len(changesList.getChildren())) - for i in reversed(range(len(listText))): - xUndoBtn = xTrackDlg.getChild("undo") - xUndoBtn.executeAction("CLICK", tuple()) - self.assertEqual(document.Text.String.strip(), resultsAccept[i]) - self.assertEqual(get_state_as_dict(changesList.getChild('0'))["Text"], listText[i] ) - - resultsReject = [ - "The tennis ball is a small ball. The baskedtball is much bigger.", - "The tenis ball is a small ball. The baskedtball is much bigger.", - "The tenis ball is a small bal. The baskedtball is much bigger.", - "The tenis ball is a small bal. The baskedtball is much bigger.", - "The tenis ball is a small bal. The baskedball is much bigger.", - "The tenis ball is a small bal. The baskedball is much biger."] - - for i in range(len(listText)): - self.assertEqual(document.Text.String.strip(), resultsReject[i]) - self.assertEqual(get_state_as_dict(changesList.getChild('0'))["Text"], listText[i] ) - xAccBtn = xTrackDlg.getChild("reject") + # Without the fix in place, it would have crashed here + xAccBtn = xTrackDlg.getChild("acceptall") xAccBtn.executeAction("CLICK", tuple()) - self.assertEqual(document.Text.String.strip(), resultsReject[5]) - #List is empty - self.assertFalse('0' in changesList.getChildren()) + self.assertEqual(0, len(changesList.getChildren())) - for i in reversed(range(len(listText))): xUndoBtn = xTrackDlg.getChild("undo") xUndoBtn.executeAction("CLICK", tuple()) - self.assertEqual(document.Text.String.strip(), resultsReject[i]) - self.assertEqual(get_state_as_dict(changesList.getChild('0'))["Text"], listText[i] ) - - xcloseBtn = xTrackDlg.getChild("close") - xcloseBtn.executeAction("CLICK", tuple()) - - self.ui_test.close_doc() - - def test_tdf135018(self): - self.ui_test.load_file(get_url_for_data_file("tdf135018.odt")) - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - document = self.ui_test.get_component() - - self.assertEqual(5, document.CurrentController.PageCount) - - self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges") - xTrackDlg = self.xUITest.getTopFocusWindow() - changesList = xTrackDlg.getChild("writerchanges") - self.assertEqual(147, len(changesList.getChildren())) - # Without the fix in place, it would have crashed here - xAccBtn = xTrackDlg.getChild("acceptall") - xAccBtn.executeAction("CLICK", tuple()) - - self.assertEqual(0, len(changesList.getChildren())) - - xUndoBtn = xTrackDlg.getChild("undo") - xUndoBtn.executeAction("CLICK", tuple()) + self.assertEqual(147, len(changesList.getChildren())) - self.assertEqual(147, len(changesList.getChildren())) + xcloseBtn = xTrackDlg.getChild("close") + xcloseBtn.executeAction("CLICK", tuple()) - xcloseBtn = xTrackDlg.getChild("close") - xcloseBtn.executeAction("CLICK", tuple()) - - # Check the changes are shown after opening the Manage Tracked Changes dialog - self.assertGreater(document.CurrentController.PageCount, 5) - - self.ui_test.close_doc() + # Check the changes are shown after opening the Manage Tracked Changes dialog + self.assertGreater(document.CurrentController.PageCount, 5) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests/versionDialog.py b/sw/qa/uitest/writer_tests/versionDialog.py index 5d0e3c120b4e..6ab12611c2bc 100644 --- a/sw/qa/uitest/writer_tests/versionDialog.py +++ b/sw/qa/uitest/writer_tests/versionDialog.py @@ -14,29 +14,27 @@ class versionDialog(UITestCase): def test_tdf131931(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf131931.odt")) + with self.ui_test.load_file(get_url_for_data_file("tdf131931.odt")) as writer_doc: - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() - self.ui_test.execute_dialog_through_command(".uno:VersionDialog") + self.ui_test.execute_dialog_through_command(".uno:VersionDialog") - xVersionDialog = self.xUITest.getTopFocusWindow() + xVersionDialog = self.xUITest.getTopFocusWindow() - versiondList = xVersionDialog.getChild("versions") + versiondList = xVersionDialog.getChild("versions") - text = "04/06/2020 15:18\t\tHELLO" - self.assertEqual(1, len(versiondList.getChildren())) - self.assertEqual(get_state_as_dict(versiondList.getChild('0'))["Text"].strip(), text) + text = "04/06/2020 15:18\t\tHELLO" + self.assertEqual(1, len(versiondList.getChildren())) + self.assertEqual(get_state_as_dict(versiondList.getChild('0'))["Text"].strip(), text) - xDeleteBtn = xVersionDialog.getChild("delete") - xDeleteBtn.executeAction("CLICK", tuple()) + xDeleteBtn = xVersionDialog.getChild("delete") + xDeleteBtn.executeAction("CLICK", tuple()) - self.assertEqual(0, len(versiondList.getChildren())) + self.assertEqual(0, len(versiondList.getChildren())) - xCloseBtn = xVersionDialog.getChild("close") - xCloseBtn.executeAction("CLICK", tuple()) - - self.ui_test.close_doc() + xCloseBtn = xVersionDialog.getChild("close") + xCloseBtn.executeAction("CLICK", tuple()) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests/wordCount.py b/sw/qa/uitest/writer_tests/wordCount.py index b7b88dcb4f74..3260e9c03309 100644 --- a/sw/qa/uitest/writer_tests/wordCount.py +++ b/sw/qa/uitest/writer_tests/wordCount.py @@ -48,37 +48,35 @@ class writerWordCount(UITestCase): def test_tdf68347(self): #Bug 68347 - Incorrect word count in a document with recorded changes - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf68347.odt")) - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - document = self.ui_test.get_component() - - xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "24", "END_POS": "39"})) #select two words - - self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog") - xDialog = self.xUITest.getTopFocusWindow() - xselectwords = xDialog.getChild("selectwords") - xdocwords = xDialog.getChild("docwords") - xselectchars = xDialog.getChild("selectchars") - xdocchars = xDialog.getChild("docchars") - xselectcharsnospaces = xDialog.getChild("selectcharsnospaces") - xdoccharsnospaces = xDialog.getChild("doccharsnospaces") - xselectcjkchars = xDialog.getChild("selectcjkchars") - xdoccjkchars = xDialog.getChild("doccjkchars") - - self.assertEqual(get_state_as_dict(xselectwords)["Text"], "4") - self.assertEqual(get_state_as_dict(xdocwords)["Text"], "12") - self.assertEqual(get_state_as_dict(xselectchars)["Text"], "15") - self.assertEqual(get_state_as_dict(xdocchars)["Text"], "54") - self.assertEqual(get_state_as_dict(xselectcharsnospaces)["Text"], "12") - #bug Bug 117703 Word Count: Wrong result for "Characters excluding spaces" - #self.assertEqual(get_state_as_dict(xdoccharsnospaces)["Text"], "44") - self.assertEqual(get_state_as_dict(xselectcjkchars)["Text"], "0") - self.assertEqual(get_state_as_dict(xdoccjkchars)["Text"], "0") - xCloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xCloseBtn) - - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("tdf68347.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + document = self.ui_test.get_component() + + xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "24", "END_POS": "39"})) #select two words + + self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog") + xDialog = self.xUITest.getTopFocusWindow() + xselectwords = xDialog.getChild("selectwords") + xdocwords = xDialog.getChild("docwords") + xselectchars = xDialog.getChild("selectchars") + xdocchars = xDialog.getChild("docchars") + xselectcharsnospaces = xDialog.getChild("selectcharsnospaces") + xdoccharsnospaces = xDialog.getChild("doccharsnospaces") + xselectcjkchars = xDialog.getChild("selectcjkchars") + xdoccjkchars = xDialog.getChild("doccjkchars") + + self.assertEqual(get_state_as_dict(xselectwords)["Text"], "4") + self.assertEqual(get_state_as_dict(xdocwords)["Text"], "12") + self.assertEqual(get_state_as_dict(xselectchars)["Text"], "15") + self.assertEqual(get_state_as_dict(xdocchars)["Text"], "54") + self.assertEqual(get_state_as_dict(xselectcharsnospaces)["Text"], "12") + #bug Bug 117703 Word Count: Wrong result for "Characters excluding spaces" + #self.assertEqual(get_state_as_dict(xdoccharsnospaces)["Text"], "44") + self.assertEqual(get_state_as_dict(xselectcjkchars)["Text"], "0") + self.assertEqual(get_state_as_dict(xdoccjkchars)["Text"], "0") + xCloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xCloseBtn) def test_tdf91100(self): self.ui_test.create_doc_in_start_center("writer") @@ -93,32 +91,30 @@ class writerWordCount(UITestCase): self.ui_test.close_doc() def test_tdf58050(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf58050.html")) - - self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog") - xDialog = self.xUITest.getTopFocusWindow() - - xselectwords = xDialog.getChild("selectwords") - xdocwords = xDialog.getChild("docwords") - xselectchars = xDialog.getChild("selectchars") - xdocchars = xDialog.getChild("docchars") - xselectcharsnospaces = xDialog.getChild("selectcharsnospaces") - xdoccharsnospaces = xDialog.getChild("doccharsnospaces") - xselectcjkchars = xDialog.getChild("selectcjkchars") - xdoccjkchars = xDialog.getChild("doccjkchars") - - self.assertEqual(get_state_as_dict(xselectwords)["Text"], "0") - self.assertEqual(get_state_as_dict(xdocwords)["Text"], "3") - self.assertEqual(get_state_as_dict(xselectchars)["Text"], "0") - self.assertEqual(get_state_as_dict(xdocchars)["Text"], "14") - self.assertEqual(get_state_as_dict(xselectcharsnospaces)["Text"], "0") - self.assertEqual(get_state_as_dict(xdoccharsnospaces)["Text"], "12") - self.assertEqual(get_state_as_dict(xselectcjkchars)["Text"], "0") - self.assertEqual(get_state_as_dict(xdoccjkchars)["Text"], "0") - xCloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xCloseBtn) - - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("tdf58050.html")) as writer_doc: + + self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog") + xDialog = self.xUITest.getTopFocusWindow() + + xselectwords = xDialog.getChild("selectwords") + xdocwords = xDialog.getChild("docwords") + xselectchars = xDialog.getChild("selectchars") + xdocchars = xDialog.getChild("docchars") + xselectcharsnospaces = xDialog.getChild("selectcharsnospaces") + xdoccharsnospaces = xDialog.getChild("doccharsnospaces") + xselectcjkchars = xDialog.getChild("selectcjkchars") + xdoccjkchars = xDialog.getChild("doccjkchars") + + self.assertEqual(get_state_as_dict(xselectwords)["Text"], "0") + self.assertEqual(get_state_as_dict(xdocwords)["Text"], "3") + self.assertEqual(get_state_as_dict(xselectchars)["Text"], "0") + self.assertEqual(get_state_as_dict(xdocchars)["Text"], "14") + self.assertEqual(get_state_as_dict(xselectcharsnospaces)["Text"], "0") + self.assertEqual(get_state_as_dict(xdoccharsnospaces)["Text"], "12") + self.assertEqual(get_state_as_dict(xselectcjkchars)["Text"], "0") + self.assertEqual(get_state_as_dict(xdoccjkchars)["Text"], "0") + xCloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xCloseBtn) def test_word_count_interpunction_counted_tdf56975_a(self): @@ -243,84 +239,82 @@ class writerWordCount(UITestCase): self.ui_test.close_doc() def test_tdf51816(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf51816.odt")) - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - document = self.ui_test.get_component() - #1. Open attached document - #2. Tools> Word count - self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog") - xDialog = self.xUITest.getTopFocusWindow() - xselectwords = xDialog.getChild("selectwords") - xdocwords = xDialog.getChild("docwords") - xselectchars = xDialog.getChild("selectchars") - xdocchars = xDialog.getChild("docchars") - xselectcharsnospaces = xDialog.getChild("selectcharsnospaces") - xdoccharsnospaces = xDialog.getChild("doccharsnospaces") - xselectcjkchars = xDialog.getChild("selectcjkchars") - xdoccjkchars = xDialog.getChild("doccjkchars") - - #3. Click after "At nunc" then <Ctrl><Shift><Left> - self.xUITest.executeCommand(".uno:GoRight") - self.xUITest.executeCommand(".uno:GoRight") - self.xUITest.executeCommand(".uno:GoRight") - self.xUITest.executeCommand(".uno:GoRight") - self.xUITest.executeCommand(".uno:GoRight") - self.xUITest.executeCommand(".uno:GoRight") - self.xUITest.executeCommand(".uno:GoRight") - self.xUITest.executeCommand(".uno:WordLeftSel") - - #needs to wait, because Word count dialog is already open and it takes time to refresh the counter - #Expected result : Words 1 & Characters 4 #Actual result : Words 0 & Characters 0 - self.ui_test.wait_until_property_is_updated(xselectwords, "Text", "1") - self.assertEqual(get_state_as_dict(xselectwords)["Text"], "1") - self.assertEqual(get_state_as_dict(xselectchars)["Text"], "4") - - #4. Click after "At nunc" then <Shift><Home> - self.xUITest.executeCommand(".uno:StartOfParaSel") - - #needs to wait, because Word count dialog is already open and it takes time to refresh the counter - #Expected result : Words 2 & Characters 7 & excluding space 6 #Actual result : Words 0 & Characters 0 - self.ui_test.wait_until_property_is_updated(xselectwords, "Text", "2") - self.assertEqual(get_state_as_dict(xselectwords)["Text"], "2") - self.assertEqual(get_state_as_dict(xselectchars)["Text"], "7") - - self.assertEqual(get_state_as_dict(xselectcharsnospaces)["Text"], "6") - - xCloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xCloseBtn) - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("tdf51816.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + document = self.ui_test.get_component() + #1. Open attached document + #2. Tools> Word count + self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog") + xDialog = self.xUITest.getTopFocusWindow() + xselectwords = xDialog.getChild("selectwords") + xdocwords = xDialog.getChild("docwords") + xselectchars = xDialog.getChild("selectchars") + xdocchars = xDialog.getChild("docchars") + xselectcharsnospaces = xDialog.getChild("selectcharsnospaces") + xdoccharsnospaces = xDialog.getChild("doccharsnospaces") + xselectcjkchars = xDialog.getChild("selectcjkchars") + xdoccjkchars = xDialog.getChild("doccjkchars") + + #3. Click after "At nunc" then <Ctrl><Shift><Left> + self.xUITest.executeCommand(".uno:GoRight") + self.xUITest.executeCommand(".uno:GoRight") + self.xUITest.executeCommand(".uno:GoRight") + self.xUITest.executeCommand(".uno:GoRight") + self.xUITest.executeCommand(".uno:GoRight") + self.xUITest.executeCommand(".uno:GoRight") + self.xUITest.executeCommand(".uno:GoRight") + self.xUITest.executeCommand(".uno:WordLeftSel") + + #needs to wait, because Word count dialog is already open and it takes time to refresh the counter + #Expected result : Words 1 & Characters 4 #Actual result : Words 0 & Characters 0 + self.ui_test.wait_until_property_is_updated(xselectwords, "Text", "1") + self.assertEqual(get_state_as_dict(xselectwords)["Text"], "1") + self.assertEqual(get_state_as_dict(xselectchars)["Text"], "4") + + #4. Click after "At nunc" then <Shift><Home> + self.xUITest.executeCommand(".uno:StartOfParaSel") + + #needs to wait, because Word count dialog is already open and it takes time to refresh the counter + #Expected result : Words 2 & Characters 7 & excluding space 6 #Actual result : Words 0 & Characters 0 + self.ui_test.wait_until_property_is_updated(xselectwords, "Text", "2") + self.assertEqual(get_state_as_dict(xselectwords)["Text"], "2") + self.assertEqual(get_state_as_dict(xselectchars)["Text"], "7") + + self.assertEqual(get_state_as_dict(xselectcharsnospaces)["Text"], "6") + + xCloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xCloseBtn) def test_tdf117703(self): - self.ui_test.load_file(get_url_for_data_file("tdf117703.odt")) - self.xUITest.getTopFocusWindow() - - self.xUITest.executeCommand(".uno:SelectAll") - - self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.load_file(get_url_for_data_file("tdf117703.odt")): + self.xUITest.getTopFocusWindow() + + self.xUITest.executeCommand(".uno:SelectAll") + + self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog") + xDialog = self.xUITest.getTopFocusWindow() + + xselectwords = xDialog.getChild("selectwords") + xdocwords = xDialog.getChild("docwords") + xselectchars = xDialog.getChild("selectchars") + xdocchars = xDialog.getChild("docchars") + xselectcharsnospaces = xDialog.getChild("selectcharsnospaces") + xdoccharsnospaces = xDialog.getChild("doccharsnospaces") + xselectcjkchars = xDialog.getChild("selectcjkchars") + xdoccjkchars = xDialog.getChild("doccjkchars") + + self.assertEqual(get_state_as_dict(xselectwords)["Text"], "12") + self.assertEqual(get_state_as_dict(xdocwords)["Text"], "12") + self.assertEqual(get_state_as_dict(xselectchars)["Text"], "54") + self.assertEqual(get_state_as_dict(xdocchars)["Text"], "54") + + # Without the fix in place it would have failed with: AssertionError: '0' != '44' + self.assertEqual(get_state_as_dict(xselectcharsnospaces)["Text"], "44") + self.assertEqual(get_state_as_dict(xdoccharsnospaces)["Text"], "44") + self.assertEqual(get_state_as_dict(xselectcjkchars)["Text"], "0") + self.assertEqual(get_state_as_dict(xdoccjkchars)["Text"], "0") + xCloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xCloseBtn) - xselectwords = xDialog.getChild("selectwords") - xdocwords = xDialog.getChild("docwords") - xselectchars = xDialog.getChild("selectchars") - xdocchars = xDialog.getChild("docchars") - xselectcharsnospaces = xDialog.getChild("selectcharsnospaces") - xdoccharsnospaces = xDialog.getChild("doccharsnospaces") - xselectcjkchars = xDialog.getChild("selectcjkchars") - xdoccjkchars = xDialog.getChild("doccjkchars") - - self.assertEqual(get_state_as_dict(xselectwords)["Text"], "12") - self.assertEqual(get_state_as_dict(xdocwords)["Text"], "12") - self.assertEqual(get_state_as_dict(xselectchars)["Text"], "54") - self.assertEqual(get_state_as_dict(xdocchars)["Text"], "54") - - # Without the fix in place it would have failed with: AssertionError: '0' != '44' - self.assertEqual(get_state_as_dict(xselectcharsnospaces)["Text"], "44") - self.assertEqual(get_state_as_dict(xdoccharsnospaces)["Text"], "44") - self.assertEqual(get_state_as_dict(xselectcjkchars)["Text"], "0") - self.assertEqual(get_state_as_dict(xdoccjkchars)["Text"], "0") - xCloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xCloseBtn) - - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests3/goToPage.py b/sw/qa/uitest/writer_tests3/goToPage.py index e8c0c6486a38..4d46a0740c53 100644 --- a/sw/qa/uitest/writer_tests3/goToPage.py +++ b/sw/qa/uitest/writer_tests3/goToPage.py @@ -10,34 +10,33 @@ from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file class GoToPage_dialog(UITestCase): def test_go_to_page(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("3pages.odt")) - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") + with self.ui_test.load_file(get_url_for_data_file("3pages.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") - self.ui_test.execute_dialog_through_command(".uno:GotoPage") - xDialog = self.xUITest.getTopFocusWindow() - xPageText = xDialog.getChild("page") - xPageText.executeAction("TYPE", mkPropertyValues({"TEXT":"2"})) - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) + self.ui_test.execute_dialog_through_command(".uno:GotoPage") + xDialog = self.xUITest.getTopFocusWindow() + xPageText = xDialog.getChild("page") + xPageText.executeAction("TYPE", mkPropertyValues({"TEXT":"2"})) + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "2") + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "2") - self.ui_test.execute_dialog_through_command(".uno:GotoPage") - xDialog = self.xUITest.getTopFocusWindow() - xPageText = xDialog.getChild("page") - xPageText.executeAction("TYPE", mkPropertyValues({"TEXT":"3a"})) - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) + self.ui_test.execute_dialog_through_command(".uno:GotoPage") + xDialog = self.xUITest.getTopFocusWindow() + xPageText = xDialog.getChild("page") + xPageText.executeAction("TYPE", mkPropertyValues({"TEXT":"3a"})) + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "3") + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "3") - # check cancel button - self.ui_test.execute_dialog_through_command(".uno:GotoPage") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + # check cancel button + self.ui_test.execute_dialog_through_command(".uno:GotoPage") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "3") + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "3") - self.ui_test.close_doc() diff --git a/sw/qa/uitest/writer_tests4/spellDialog.py b/sw/qa/uitest/writer_tests4/spellDialog.py index fe329ab344c3..fea337bd2c3f 100644 --- a/sw/qa/uitest/writer_tests4/spellDialog.py +++ b/sw/qa/uitest/writer_tests4/spellDialog.py @@ -104,28 +104,28 @@ frog, dogg, catt""" supported_locale = self.is_supported_locale("en", "US") if not supported_locale: self.skipTest("no dictionary support for en_US available") - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf66043.fodt")) - document = self.ui_test.get_component() - # Step 1: Initiate spellchecking, and make sure "Check grammar" is - # unchecked - spell_dialog = self.launch_dialog() - checkgrammar = spell_dialog.getChild('checkgrammar') - if get_state_as_dict(checkgrammar)['Selected'] == 'true': - checkgrammar.executeAction('CLICK', ()) - self.assertTrue(get_state_as_dict(checkgrammar)['Selected'] == 'false') - - # Step 2: Click on "Correct all" for each misspelling - # prompt until end of document is reached. - changeall = spell_dialog.getChild('changeall') - changeall.executeAction("CLICK", ()) - - xCloseBtn = spell_dialog.getChild("close") - xCloseBtn.executeAction("CLICK", tuple()) - - output_text = document.Text.getString().replace('\r\n', '\n') - # This was "gooodgood baaad eeend" ("goood" is a deletion, - # "good" is an insertion by fixing the first misspelling), - # but now "goood" is not a misspelling because it is accepted - # correctly without the redline containing a deleted "o" - self.assertEqual(output_text, 'goood baaadbaaed eeend') + with self.ui_test.load_file(get_url_for_data_file("tdf66043.fodt")) as writer_doc: + document = self.ui_test.get_component() + # Step 1: Initiate spellchecking, and make sure "Check grammar" is + # unchecked + spell_dialog = self.launch_dialog() + checkgrammar = spell_dialog.getChild('checkgrammar') + if get_state_as_dict(checkgrammar)['Selected'] == 'true': + checkgrammar.executeAction('CLICK', ()) + self.assertTrue(get_state_as_dict(checkgrammar)['Selected'] == 'false') + + # Step 2: Click on "Correct all" for each misspelling + # prompt until end of document is reached. + changeall = spell_dialog.getChild('changeall') + changeall.executeAction("CLICK", ()) + + xCloseBtn = spell_dialog.getChild("close") + xCloseBtn.executeAction("CLICK", tuple()) + + output_text = document.Text.getString().replace('\r\n', '\n') + # This was "gooodgood baaad eeend" ("goood" is a deletion, + # "good" is an insertion by fixing the first misspelling), + # but now "goood" is not a misspelling because it is accepted + # correctly without the redline containing a deleted "o" + self.assertEqual(output_text, 'goood baaadbaaed eeend') diff --git a/sw/qa/uitest/writer_tests4/tdf113284.py b/sw/qa/uitest/writer_tests4/tdf113284.py index 8bb43962d8fb..70bacd60ac77 100644 --- a/sw/qa/uitest/writer_tests4/tdf113284.py +++ b/sw/qa/uitest/writer_tests4/tdf113284.py @@ -10,34 +10,33 @@ from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file class tdf113284(UITestCase): def test_tdf113284(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf113284.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - - xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') - xToolkit.processEventsToIdle() - - xPageCount = document.CurrentController.PageCount - self.ui_test.execute_dialog_through_command(".uno:GotoPage") - xDialog = self.xUITest.getTopFocusWindow() - xPageText = xDialog.getChild("page") - xPageText.executeAction("TYPE", mkPropertyValues({"TEXT":str(xPageCount)})) # goto last page - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) - - xToolkit.processEventsToIdle() - - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], str(xPageCount)) - self.ui_test.execute_dialog_through_command(".uno:EditCurIndex") #open index dialog - xDiagIndex = self.xUITest.getTopFocusWindow() - xCancBtn = xDiagIndex.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancBtn) # close dialog - - #page count is not constant - #self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "66") #page 66 start of the Index - #pagecount unchanged - self.assertEqual(document.CurrentController.PageCount, xPageCount) - - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("tdf113284.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.processEventsToIdle() + + xPageCount = document.CurrentController.PageCount + self.ui_test.execute_dialog_through_command(".uno:GotoPage") + xDialog = self.xUITest.getTopFocusWindow() + xPageText = xDialog.getChild("page") + xPageText.executeAction("TYPE", mkPropertyValues({"TEXT":str(xPageCount)})) # goto last page + xOkBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) + + xToolkit.processEventsToIdle() + + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], str(xPageCount)) + self.ui_test.execute_dialog_through_command(".uno:EditCurIndex") #open index dialog + xDiagIndex = self.xUITest.getTopFocusWindow() + xCancBtn = xDiagIndex.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancBtn) # close dialog + + #page count is not constant + #self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "66") #page 66 start of the Index + #pagecount unchanged + self.assertEqual(document.CurrentController.PageCount, xPageCount) + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests4/tdf122449.py b/sw/qa/uitest/writer_tests4/tdf122449.py index 1fc69909a978..b893f4f643e1 100644 --- a/sw/qa/uitest/writer_tests4/tdf122449.py +++ b/sw/qa/uitest/writer_tests4/tdf122449.py @@ -14,38 +14,37 @@ from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file class tdf122449(UITestCase): def test_tdf122449_crash_edit_index_entry(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf122449.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - #search word Autocorrect (second find) .uno:SearchDialog - self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.load_file(get_url_for_data_file("tdf122449.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + #search word Autocorrect (second find) .uno:SearchDialog + self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") + xDialog = self.xUITest.getTopFocusWindow() - searchterm = xDialog.getChild("searchterm") - searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"Autocorrection"})) - xsearch = xDialog.getChild("search") - xsearch.executeAction("CLICK", tuple()) #first search - xsearch.executeAction("CLICK", tuple()) #2nd search - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "6") - xcloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xcloseBtn) - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "HOME"})) - # invoke Index dialog Index entry .uno:IndexEntryDialog - self.ui_test.execute_dialog_through_command(".uno:IndexEntryDialog") - xDialog = self.xUITest.getTopFocusWindow() - xcloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xcloseBtn) - # close - # Go to page 2 - self.ui_test.execute_dialog_through_command(".uno:GotoPage") - xDialog = self.xUITest.getTopFocusWindow() - xPageText = xDialog.getChild("page") - xPageText.executeAction("TYPE", mkPropertyValues({"TEXT":"2"})) - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) - # verify - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "2") + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"Autocorrection"})) + xsearch = xDialog.getChild("search") + xsearch.executeAction("CLICK", tuple()) #first search + xsearch.executeAction("CLICK", tuple()) #2nd search + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "6") + xcloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xcloseBtn) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "HOME"})) + # invoke Index dialog Index entry .uno:IndexEntryDialog + self.ui_test.execute_dialog_through_command(".uno:IndexEntryDialog") + xDialog = self.xUITest.getTopFocusWindow() + xcloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xcloseBtn) + # close + # Go to page 2 + self.ui_test.execute_dialog_through_command(".uno:GotoPage") + xDialog = self.xUITest.getTopFocusWindow() + xPageText = xDialog.getChild("page") + xPageText.executeAction("TYPE", mkPropertyValues({"TEXT":"2"})) + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) + # verify + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "2") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests4/tdf134439.py b/sw/qa/uitest/writer_tests4/tdf134439.py index 07f4db79c934..6086ae289a12 100644 --- a/sw/qa/uitest/writer_tests4/tdf134439.py +++ b/sw/qa/uitest/writer_tests4/tdf134439.py @@ -13,47 +13,45 @@ class tdf134439(UITestCase): def test_tdf134439(self): - self.ui_test.load_file(get_url_for_data_file("tdf134439.odt")) + with self.ui_test.load_file(get_url_for_data_file("tdf134439.odt")): - document = self.ui_test.get_component() + document = self.ui_test.get_component() - self.assertEqual(document.CurrentController.PageCount, 3) + self.assertEqual(document.CurrentController.PageCount, 3) - xCursor = document.CurrentController.ViewCursor - self.assertEqual("Chap 1", xCursor.PageStyleName) + xCursor = document.CurrentController.ViewCursor + self.assertEqual("Chap 1", xCursor.PageStyleName) - xPageBreak = self.ui_test.wait_until_child_is_available('PageBreak') - self.ui_test.execute_dialog_through_action(xPageBreak, "EDIT") + xPageBreak = self.ui_test.wait_until_child_is_available('PageBreak') + self.ui_test.execute_dialog_through_action(xPageBreak, "EDIT") - xDialog = self.xUITest.getTopFocusWindow() + xDialog = self.xUITest.getTopFocusWindow() - self.assertEqual("Page", get_state_as_dict(xDialog.getChild("comboBreakType"))["SelectEntryText"]) - self.assertEqual("Before", get_state_as_dict(xDialog.getChild("comboBreakPosition"))["SelectEntryText"]) + self.assertEqual("Page", get_state_as_dict(xDialog.getChild("comboBreakType"))["SelectEntryText"]) + self.assertEqual("Before", get_state_as_dict(xDialog.getChild("comboBreakPosition"))["SelectEntryText"]) - xPageStyle = xDialog.getChild("comboPageStyle") - self.assertEqual("Chap 2", get_state_as_dict(xPageStyle)["SelectEntryText"]) + xPageStyle = xDialog.getChild("comboPageStyle") + self.assertEqual("Chap 2", get_state_as_dict(xPageStyle)["SelectEntryText"]) - select_by_text(xPageStyle, "Chap 3") + select_by_text(xPageStyle, "Chap 3") - self.assertEqual("Chap 3", get_state_as_dict(xPageStyle)["SelectEntryText"]) + self.assertEqual("Chap 3", get_state_as_dict(xPageStyle)["SelectEntryText"]) - # tdf#116070: Without the fix in place, this test would have crashed here - okBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(okBtn) + # tdf#116070: Without the fix in place, this test would have crashed here + okBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(okBtn) - # Without the fix in place, this test would have failed with - # AssertionError: 'Chap 1' != 'Chap 3' - self.assertEqual("Chap 1", xCursor.PageStyleName) + # Without the fix in place, this test would have failed with + # AssertionError: 'Chap 1' != 'Chap 3' + self.assertEqual("Chap 1", xCursor.PageStyleName) - self.assertEqual(document.CurrentController.PageCount, 3) + self.assertEqual(document.CurrentController.PageCount, 3) - xCursor.jumpToNextPage() - self.assertEqual("Chap 3", xCursor.PageStyleName) + xCursor.jumpToNextPage() + self.assertEqual("Chap 3", xCursor.PageStyleName) - self.xUITest.executeCommand(".uno:Undo") + self.xUITest.executeCommand(".uno:Undo") - self.assertEqual("Chap 2", xCursor.PageStyleName) - - self.ui_test.close_doc() + self.assertEqual("Chap 2", xCursor.PageStyleName) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests4/tdf135636.py b/sw/qa/uitest/writer_tests4/tdf135636.py index 3347a4404722..f4efcddb3c2e 100644 --- a/sw/qa/uitest/writer_tests4/tdf135636.py +++ b/sw/qa/uitest/writer_tests4/tdf135636.py @@ -11,35 +11,33 @@ class tdf135636(UITestCase): def test_tdf135636(self): - self.ui_test.load_file(get_url_for_data_file("tdf135636.odt")) + with self.ui_test.load_file(get_url_for_data_file("tdf135636.odt")): - document = self.ui_test.get_component() + document = self.ui_test.get_component() - self.assertEqual(document.CurrentController.PageCount, 2) + self.assertEqual(document.CurrentController.PageCount, 2) - xPageBreak = self.ui_test.wait_until_child_is_available('PageBreak') - self.ui_test.execute_dialog_through_action(xPageBreak, "EDIT") + xPageBreak = self.ui_test.wait_until_child_is_available('PageBreak') + self.ui_test.execute_dialog_through_action(xPageBreak, "EDIT") - xDialog = self.xUITest.getTopFocusWindow() + xDialog = self.xUITest.getTopFocusWindow() - xBreak = xDialog.getChild("break") - self.assertEqual("true", get_state_as_dict(xBreak)["Selected"]) + xBreak = xDialog.getChild("break") + self.assertEqual("true", get_state_as_dict(xBreak)["Selected"]) - xBreak.executeAction("CLICK", tuple()) + xBreak.executeAction("CLICK", tuple()) - self.assertEqual("false", get_state_as_dict(xBreak)["Selected"]) + self.assertEqual("false", get_state_as_dict(xBreak)["Selected"]) - okBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(okBtn) + okBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(okBtn) - # Without the fix in place, this test would have failed with - # AssertionError: 2 != 1 - self.assertEqual(document.CurrentController.PageCount, 1) + # Without the fix in place, this test would have failed with + # AssertionError: 2 != 1 + self.assertEqual(document.CurrentController.PageCount, 1) - self.xUITest.executeCommand(".uno:Undo") + self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.CurrentController.PageCount, 2) - - self.ui_test.close_doc() + self.assertEqual(document.CurrentController.PageCount, 2) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests4/tdf136578.py b/sw/qa/uitest/writer_tests4/tdf136578.py index 3de6e019ec41..4380a394a11e 100644 --- a/sw/qa/uitest/writer_tests4/tdf136578.py +++ b/sw/qa/uitest/writer_tests4/tdf136578.py @@ -11,22 +11,20 @@ class tdf136578(UITestCase): def test_tdf136578(self): - self.ui_test.load_file(get_url_for_data_file("tdf136578.odt")) + with self.ui_test.load_file(get_url_for_data_file("tdf136578.odt")): - document = self.ui_test.get_component() - self.assertEqual(document.CurrentController.PageCount, 2) + document = self.ui_test.get_component() + self.assertEqual(document.CurrentController.PageCount, 2) - xPageBreak = self.ui_test.wait_until_child_is_available('PageBreak') - xPageBreak.executeAction("DELETE", tuple()) + xPageBreak = self.ui_test.wait_until_child_is_available('PageBreak') + xPageBreak.executeAction("DELETE", tuple()) - # Without the fix in place, this test would have failed with - # AssertionError: 1 != 2 - self.assertEqual(document.CurrentController.PageCount, 1) + # Without the fix in place, this test would have failed with + # AssertionError: 1 != 2 + self.assertEqual(document.CurrentController.PageCount, 1) - self.xUITest.executeCommand(".uno:Undo") + self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.CurrentController.PageCount, 2) - - self.ui_test.close_doc() + self.assertEqual(document.CurrentController.PageCount, 2) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests4/tdf138546.py b/sw/qa/uitest/writer_tests4/tdf138546.py index b57c5748baf9..528fcda84911 100644 --- a/sw/qa/uitest/writer_tests4/tdf138546.py +++ b/sw/qa/uitest/writer_tests4/tdf138546.py @@ -12,33 +12,31 @@ from uitest.uihelper.common import get_url_for_data_file class tdf138546(UITestCase): def test_tdf138546(self): - self.ui_test.load_file(get_url_for_data_file("tdf138546.odt")) - xWriterDoc = self.xUITest.getTopFocusWindow() + with self.ui_test.load_file(get_url_for_data_file("tdf138546.odt")): + xWriterDoc = self.xUITest.getTopFocusWindow() - change_measurement_unit(self, "Centimeter") + change_measurement_unit(self, "Centimeter") - #dialog Columns - self.ui_test.execute_dialog_through_command(".uno:FormatColumns") - xDialog = self.xUITest.getTopFocusWindow() + #dialog Columns + self.ui_test.execute_dialog_through_command(".uno:FormatColumns") + xDialog = self.xUITest.getTopFocusWindow() - colsnf = xDialog.getChild("colsnf") - width1mf = xDialog.getChild("width1mf") - self.assertEqual(get_state_as_dict(colsnf)["Text"], "2") - self.assertEqual((get_state_as_dict(width1mf)["Text"])[0:3], "2.0") #2.00 cm - xOKBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xOKBtn) + colsnf = xDialog.getChild("colsnf") + width1mf = xDialog.getChild("width1mf") + self.assertEqual(get_state_as_dict(colsnf)["Text"], "2") + self.assertEqual((get_state_as_dict(width1mf)["Text"])[0:3], "2.0") #2.00 cm + xOKBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xOKBtn) - self.ui_test.execute_dialog_through_command(".uno:PageDialog") - xDialog = self.xUITest.getTopFocusWindow() - tabcontrol = xDialog.getChild("tabcontrol") - select_pos(tabcontrol, "7") #Columns - colsnf = xDialog.getChild("colsnf") - width1mf = xDialog.getChild("width1mf") - self.assertEqual(get_state_as_dict(colsnf)["Text"], "2") - self.assertEqual((get_state_as_dict(width1mf)["Text"])[0:3], "2.0") #2.00 cm - xOKBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xOKBtn) - - self.ui_test.close_doc() + self.ui_test.execute_dialog_through_command(".uno:PageDialog") + xDialog = self.xUITest.getTopFocusWindow() + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "7") #Columns + colsnf = xDialog.getChild("colsnf") + width1mf = xDialog.getChild("width1mf") + self.assertEqual(get_state_as_dict(colsnf)["Text"], "2") + self.assertEqual((get_state_as_dict(width1mf)["Text"])[0:3], "2.0") #2.00 cm + xOKBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xOKBtn) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/DateFormFieldPropertiesDialog.py b/sw/qa/uitest/writer_tests5/DateFormFieldPropertiesDialog.py index 0d110d315a21..021084932f9a 100644 --- a/sw/qa/uitest/writer_tests5/DateFormFieldPropertiesDialog.py +++ b/sw/qa/uitest/writer_tests5/DateFormFieldPropertiesDialog.py @@ -11,147 +11,137 @@ class dateFormFieldDialog(UITestCase): def test_setting_date_format(self): # open a file with a date form field - writer_doc = self.ui_test.load_file(get_url_for_data_file("date_form_field.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() + with self.ui_test.load_file(get_url_for_data_file("date_form_field.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() - # open the dialog (cursor is at the field) - self.ui_test.execute_dialog_through_command(".uno:ControlProperties") - xDialog = self.xUITest.getTopFocusWindow() + # open the dialog (cursor is at the field) + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() - itemsList = xDialog.getChild("date_formats_treeview") + itemsList = xDialog.getChild("date_formats_treeview") - # check whether we have the right format selected - self.assertEqual(get_state_as_dict(itemsList)["Children"], "20") - self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12/31/99") + # check whether we have the right format selected + self.assertEqual(get_state_as_dict(itemsList)["Children"], "20") + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12/31/99") - # select a new format - itemsList.getChild("11").executeAction("SELECT", tuple()); - self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12-31") + # select a new format + itemsList.getChild("11").executeAction("SELECT", tuple()); + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12-31") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) - # open the dialog again - self.ui_test.execute_dialog_through_command(".uno:ControlProperties") - xDialog = self.xUITest.getTopFocusWindow() - itemsList = xDialog.getChild("date_formats_treeview") - self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12-31") + # open the dialog again + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() + itemsList = xDialog.getChild("date_formats_treeview") + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12-31") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - self.ui_test.close_doc() + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) def test_date_field_with_custom_format(self): # open a file with a date form field - writer_doc = self.ui_test.load_file(get_url_for_data_file("date_form_field_custom_format.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - - # open the dialog (cursor is at the field) - self.ui_test.execute_dialog_through_command(".uno:ControlProperties") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.load_file(get_url_for_data_file("date_form_field_custom_format.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() - itemsList = xDialog.getChild("date_formats_treeview") + # open the dialog (cursor is at the field) + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() - # check whether we have the right format selected - self.assertEqual(get_state_as_dict(itemsList)["Children"], "20") - self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "1999. december 31., péntek") + itemsList = xDialog.getChild("date_formats_treeview") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + # check whether we have the right format selected + self.assertEqual(get_state_as_dict(itemsList)["Children"], "20") + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "1999. december 31., péntek") - self.ui_test.close_doc() + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) def test_date_reformat(self): # open a file with a date form field - writer_doc = self.ui_test.load_file(get_url_for_data_file("date_form_field.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - self.assertEqual(writer_doc.getText().getString(), "07/17/19") - - # open the dialog (cursor is at the field) - self.ui_test.execute_dialog_through_command(".uno:ControlProperties") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.load_file(get_url_for_data_file("date_form_field.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + self.assertEqual(writer_doc.getText().getString(), "07/17/19") - itemsList = xDialog.getChild("date_formats_treeview") + # open the dialog (cursor is at the field) + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() - # check whether we have the right format selected - self.assertEqual(get_state_as_dict(itemsList)["Children"], "20") - self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12/31/99") + itemsList = xDialog.getChild("date_formats_treeview") - # select a new format - itemsList.getChild("11").executeAction("SELECT", tuple()); - self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12-31") + # check whether we have the right format selected + self.assertEqual(get_state_as_dict(itemsList)["Children"], "20") + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12/31/99") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + # select a new format + itemsList.getChild("11").executeAction("SELECT", tuple()); + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12-31") - # after applying the new format, the field content should be updated - self.assertEqual(writer_doc.getText().getString(), "07-17") + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) - self.ui_test.close_doc() + # after applying the new format, the field content should be updated + self.assertEqual(writer_doc.getText().getString(), "07-17") def test_date_field_with_placeholder(self): # open a file with a date form field - writer_doc = self.ui_test.load_file(get_url_for_data_file("date_form_field_with_placeholder.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - self.assertEqual(writer_doc.getText().getString(), "[select date]") + with self.ui_test.load_file(get_url_for_data_file("date_form_field_with_placeholder.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + self.assertEqual(writer_doc.getText().getString(), "[select date]") - # open the dialog (cursor is at the field) - self.ui_test.execute_dialog_through_command(".uno:ControlProperties") - xDialog = self.xUITest.getTopFocusWindow() + # open the dialog (cursor is at the field) + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() - itemsList = xDialog.getChild("date_formats_treeview") + itemsList = xDialog.getChild("date_formats_treeview") - # check whether we have the right format selected - self.assertEqual(get_state_as_dict(itemsList)["Children"], "20") - self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "Fri 31/Dec 99") + # check whether we have the right format selected + self.assertEqual(get_state_as_dict(itemsList)["Children"], "20") + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "Fri 31/Dec 99") - # select a new format - itemsList.getChild("11").executeAction("SELECT", tuple()); - self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12-31") + # select a new format + itemsList.getChild("11").executeAction("SELECT", tuple()); + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12-31") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) - # a placeholder text is not changed by format change - self.assertEqual(writer_doc.getText().getString(), "[select date]") - - self.ui_test.close_doc() + # a placeholder text is not changed by format change + self.assertEqual(writer_doc.getText().getString(), "[select date]") def test_date_field_without_current_date(self): # current date means the current date fieldmark parameter which contains the current date in YYYY-MM-DD format # when this parameter is missing LO tries to parse the content string to find out the set date # open a file with a date form field - writer_doc = self.ui_test.load_file(get_url_for_data_file("date_form_field_without_current_date.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - self.assertEqual(writer_doc.getText().getString(), "07/17/19") - - # open the dialog (cursor is at the field) - self.ui_test.execute_dialog_through_command(".uno:ControlProperties") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.load_file(get_url_for_data_file("date_form_field_without_current_date.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + self.assertEqual(writer_doc.getText().getString(), "07/17/19") - itemsList = xDialog.getChild("date_formats_treeview") + # open the dialog (cursor is at the field) + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() - # check whether we have the right format selected - self.assertEqual(get_state_as_dict(itemsList)["Children"], "20") - self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12/31/99") + itemsList = xDialog.getChild("date_formats_treeview") - # select a new format - itemsList.getChild("3").executeAction("SELECT", tuple()); - self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "Dec 31, 1999") + # check whether we have the right format selected + self.assertEqual(get_state_as_dict(itemsList)["Children"], "20") + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12/31/99") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + # select a new format + itemsList.getChild("3").executeAction("SELECT", tuple()); + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "Dec 31, 1999") - # a placeholder text is not changed by format change - self.assertEqual(writer_doc.getText().getString(), "Jul 17, 2019") + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) - self.ui_test.close_doc() + # a placeholder text is not changed by format change + self.assertEqual(writer_doc.getText().getString(), "Jul 17, 2019") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/DropDownFormFieldPropertiesDialog.py b/sw/qa/uitest/writer_tests5/DropDownFormFieldPropertiesDialog.py index 48608e3ee95d..b3274b124dac 100644 --- a/sw/qa/uitest/writer_tests5/DropDownFormFieldPropertiesDialog.py +++ b/sw/qa/uitest/writer_tests5/DropDownFormFieldPropertiesDialog.py @@ -13,236 +13,140 @@ class dropDownFormFieldDialog(UITestCase): def test_add_new_items(self): # open a file with an empty form field - writer_doc = self.ui_test.load_file(get_url_for_data_file("empty_drop_down_form_field.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - - # open the dialog (cursor is at the field) - self.ui_test.execute_dialog_through_command(".uno:ControlProperties") - xDialog = self.xUITest.getTopFocusWindow() - - itemEntry = xDialog.getChild("item_entry") - addButton = xDialog.getChild("add_button") - itemsList = xDialog.getChild("items_treeview") - - # initial state - self.assertEqual(get_state_as_dict(itemEntry)["Text"], "") - self.assertEqual(get_state_as_dict(addButton)["Enabled"], "false") - self.assertEqual(get_state_as_dict(itemsList)["Children"], "0") - - # add some new items - itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"1000"})) - self.assertEqual(get_state_as_dict(addButton)["Enabled"], "true") - addButton.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(addButton)["Enabled"], "false") - itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"2000"})) - addButton.executeAction("CLICK", tuple()) - itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"3000"})) - addButton.executeAction("CLICK", tuple()) - itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"4000"})) - addButton.executeAction("CLICK", tuple()) - - # check whether the items are there in the list - self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") - self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") - self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "2000") - self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "3000") - self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "4000") - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - # check whether items are the same after reopening - self.ui_test.execute_dialog_through_command(".uno:ControlProperties") - xDialog = self.xUITest.getTopFocusWindow() - - itemsList = xDialog.getChild("items_treeview") - self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") - self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") - self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "2000") - self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "3000") - self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "4000") - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("empty_drop_down_form_field.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + + # open the dialog (cursor is at the field) + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() + + itemEntry = xDialog.getChild("item_entry") + addButton = xDialog.getChild("add_button") + itemsList = xDialog.getChild("items_treeview") + + # initial state + self.assertEqual(get_state_as_dict(itemEntry)["Text"], "") + self.assertEqual(get_state_as_dict(addButton)["Enabled"], "false") + self.assertEqual(get_state_as_dict(itemsList)["Children"], "0") + + # add some new items + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"1000"})) + self.assertEqual(get_state_as_dict(addButton)["Enabled"], "true") + addButton.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(addButton)["Enabled"], "false") + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"2000"})) + addButton.executeAction("CLICK", tuple()) + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"3000"})) + addButton.executeAction("CLICK", tuple()) + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"4000"})) + addButton.executeAction("CLICK", tuple()) + + # check whether the items are there in the list + self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") + self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") + self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "2000") + self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "3000") + self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "4000") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # check whether items are the same after reopening + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() + + itemsList = xDialog.getChild("items_treeview") + self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") + self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") + self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "2000") + self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "3000") + self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "4000") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) def test_remove_items(self): # open a file with an empty form field - writer_doc = self.ui_test.load_file(get_url_for_data_file("empty_drop_down_form_field.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - - # open the dialog (cursor is at the field) - self.ui_test.execute_dialog_through_command(".uno:ControlProperties") - xDialog = self.xUITest.getTopFocusWindow() - - itemEntry = xDialog.getChild("item_entry") - addButton = xDialog.getChild("add_button") - itemsList = xDialog.getChild("items_treeview") - removeButton = xDialog.getChild("remove_button") - - # initial state - self.assertEqual(get_state_as_dict(itemEntry)["Text"], "") - self.assertEqual(get_state_as_dict(addButton)["Enabled"], "false") - self.assertEqual(get_state_as_dict(itemsList)["Children"], "0") - self.assertEqual(get_state_as_dict(removeButton)["Enabled"], "false") - - # add some new items - itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"1000"})) - self.assertEqual(get_state_as_dict(addButton)["Enabled"], "true") - addButton.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(removeButton)["Enabled"], "true") - itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"2000"})) - addButton.executeAction("CLICK", tuple()) - itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"3000"})) - addButton.executeAction("CLICK", tuple()) - itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"4000"})) - addButton.executeAction("CLICK", tuple()) - - # check whether the items are there in the list - self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") - self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") - self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "2000") - self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "3000") - self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "4000") - - # select an item from the list and remove it - itemsList.getChild("1").executeAction("SELECT", tuple()); - removeButton.executeAction("CLICK", tuple()) - - # check whether the right item was removed - self.assertEqual(get_state_as_dict(itemsList)["Children"], "3") - self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") - self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "3000") - self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "4000") - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - # check whether items are the same after reopening - self.ui_test.execute_dialog_through_command(".uno:ControlProperties") - xDialog = self.xUITest.getTopFocusWindow() - - itemsList = xDialog.getChild("items_treeview") - removeButton = xDialog.getChild("remove_button") - self.assertEqual(get_state_as_dict(itemsList)["Children"], "3") - self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") - self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "3000") - self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "4000") - - # remove all items - itemsList.getChild("1").executeAction("SELECT", tuple()); - removeButton.executeAction("CLICK", tuple()) - removeButton.executeAction("CLICK", tuple()) - removeButton.executeAction("CLICK", tuple()) - - self.assertEqual(get_state_as_dict(removeButton)["Enabled"], "false") - self.assertEqual(get_state_as_dict(itemsList)["Children"], "0") - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("empty_drop_down_form_field.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() - def test_move_items(self): + # open the dialog (cursor is at the field) + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() - # open a file with an empty form field - writer_doc = self.ui_test.load_file(get_url_for_data_file("empty_drop_down_form_field.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - - # open the dialog (cursor is at the field) - self.ui_test.execute_dialog_through_command(".uno:ControlProperties") - xDialog = self.xUITest.getTopFocusWindow() - - itemEntry = xDialog.getChild("item_entry") - addButton = xDialog.getChild("add_button") - itemsList = xDialog.getChild("items_treeview") - upButton = xDialog.getChild("up_button") - downButton = xDialog.getChild("down_button") - - # initial state - self.assertEqual(get_state_as_dict(itemEntry)["Text"], "") - self.assertEqual(get_state_as_dict(addButton)["Enabled"], "false") - self.assertEqual(get_state_as_dict(itemsList)["Children"], "0") - self.assertEqual(get_state_as_dict(upButton)["Enabled"], "false") - self.assertEqual(get_state_as_dict(downButton)["Enabled"], "false") - - # add some new items - itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"1000"})) - self.assertEqual(get_state_as_dict(addButton)["Enabled"], "true") - addButton.executeAction("CLICK", tuple()) - itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"2000"})) - addButton.executeAction("CLICK", tuple()) - itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"3000"})) - addButton.executeAction("CLICK", tuple()) - itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"4000"})) - addButton.executeAction("CLICK", tuple()) - - # check whether the items are there in the list - self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") - self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") - self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "2000") - self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "3000") - self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "4000") - - # select an item from the list and move it up - itemsList.getChild("1").executeAction("SELECT", tuple()) - self.assertEqual(get_state_as_dict(upButton)["Enabled"], "true") - self.assertEqual(get_state_as_dict(downButton)["Enabled"], "true") - upButton.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(upButton)["Enabled"], "false") - self.assertEqual(get_state_as_dict(downButton)["Enabled"], "true") - - # check whether the item was correctly moved - self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") - self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "2000") - self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "1000") - self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "3000") - self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "4000") - - # move down the selected item - downButton.executeAction("CLICK", tuple()) - downButton.executeAction("CLICK", tuple()) - downButton.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(upButton)["Enabled"], "true") - self.assertEqual(get_state_as_dict(downButton)["Enabled"], "false") - - # check whether the item was correctly moved - self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") - self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") - self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "3000") - self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "4000") - self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "2000") - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - # check whether items are the same after reopening - self.ui_test.execute_dialog_through_command(".uno:ControlProperties") - xDialog = self.xUITest.getTopFocusWindow() - - itemsList = xDialog.getChild("items_treeview") - self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") - self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") - self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "3000") - self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "4000") - self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "2000") - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - self.ui_test.close_doc() + itemEntry = xDialog.getChild("item_entry") + addButton = xDialog.getChild("add_button") + itemsList = xDialog.getChild("items_treeview") + removeButton = xDialog.getChild("remove_button") + + # initial state + self.assertEqual(get_state_as_dict(itemEntry)["Text"], "") + self.assertEqual(get_state_as_dict(addButton)["Enabled"], "false") + self.assertEqual(get_state_as_dict(itemsList)["Children"], "0") + self.assertEqual(get_state_as_dict(removeButton)["Enabled"], "false") + + # add some new items + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"1000"})) + self.assertEqual(get_state_as_dict(addButton)["Enabled"], "true") + addButton.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(removeButton)["Enabled"], "true") + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"2000"})) + addButton.executeAction("CLICK", tuple()) + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"3000"})) + addButton.executeAction("CLICK", tuple()) + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"4000"})) + addButton.executeAction("CLICK", tuple()) - def test_drop_down_after_import(self): + # check whether the items are there in the list + self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") + self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") + self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "2000") + self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "3000") + self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "4000") - files = ["drop_down_form_field.odt", "drop_down_form_field.doc", "drop_down_form_field.docx"] - for file in files: - # open a file with a drop-down for field with items and selection - writer_doc = self.ui_test.load_file(get_url_for_data_file(file)) + # select an item from the list and remove it + itemsList.getChild("1").executeAction("SELECT", tuple()); + removeButton.executeAction("CLICK", tuple()) + + # check whether the right item was removed + self.assertEqual(get_state_as_dict(itemsList)["Children"], "3") + self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") + self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "3000") + self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "4000") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # check whether items are the same after reopening + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() + + itemsList = xDialog.getChild("items_treeview") + removeButton = xDialog.getChild("remove_button") + self.assertEqual(get_state_as_dict(itemsList)["Children"], "3") + self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") + self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "3000") + self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "4000") + + # remove all items + itemsList.getChild("1").executeAction("SELECT", tuple()); + removeButton.executeAction("CLICK", tuple()) + removeButton.executeAction("CLICK", tuple()) + removeButton.executeAction("CLICK", tuple()) + + self.assertEqual(get_state_as_dict(removeButton)["Enabled"], "false") + self.assertEqual(get_state_as_dict(itemsList)["Children"], "0") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + def test_move_items(self): + + # open a file with an empty form field + with self.ui_test.load_file(get_url_for_data_file("empty_drop_down_form_field.odt")) as writer_doc: document = self.ui_test.get_component() xWriterDoc = self.xUITest.getTopFocusWindow() @@ -250,7 +154,29 @@ class dropDownFormFieldDialog(UITestCase): self.ui_test.execute_dialog_through_command(".uno:ControlProperties") xDialog = self.xUITest.getTopFocusWindow() + itemEntry = xDialog.getChild("item_entry") + addButton = xDialog.getChild("add_button") itemsList = xDialog.getChild("items_treeview") + upButton = xDialog.getChild("up_button") + downButton = xDialog.getChild("down_button") + + # initial state + self.assertEqual(get_state_as_dict(itemEntry)["Text"], "") + self.assertEqual(get_state_as_dict(addButton)["Enabled"], "false") + self.assertEqual(get_state_as_dict(itemsList)["Children"], "0") + self.assertEqual(get_state_as_dict(upButton)["Enabled"], "false") + self.assertEqual(get_state_as_dict(downButton)["Enabled"], "false") + + # add some new items + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"1000"})) + self.assertEqual(get_state_as_dict(addButton)["Enabled"], "true") + addButton.executeAction("CLICK", tuple()) + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"2000"})) + addButton.executeAction("CLICK", tuple()) + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"3000"})) + addButton.executeAction("CLICK", tuple()) + itemEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"4000"})) + addButton.executeAction("CLICK", tuple()) # check whether the items are there in the list self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") @@ -259,11 +185,77 @@ class dropDownFormFieldDialog(UITestCase): self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "3000") self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "4000") - self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "3000") + # select an item from the list and move it up + itemsList.getChild("1").executeAction("SELECT", tuple()) + self.assertEqual(get_state_as_dict(upButton)["Enabled"], "true") + self.assertEqual(get_state_as_dict(downButton)["Enabled"], "true") + upButton.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(upButton)["Enabled"], "false") + self.assertEqual(get_state_as_dict(downButton)["Enabled"], "true") + + # check whether the item was correctly moved + self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") + self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "2000") + self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "1000") + self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "3000") + self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "4000") + + # move down the selected item + downButton.executeAction("CLICK", tuple()) + downButton.executeAction("CLICK", tuple()) + downButton.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(upButton)["Enabled"], "true") + self.assertEqual(get_state_as_dict(downButton)["Enabled"], "false") + + # check whether the item was correctly moved + self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") + self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") + self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "3000") + self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "4000") + self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "2000") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # check whether items are the same after reopening + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() + + itemsList = xDialog.getChild("items_treeview") + self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") + self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") + self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "3000") + self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "4000") + self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "2000") xOKBtn = xDialog.getChild("ok") self.ui_test.close_dialog_through_button(xOKBtn) - self.ui_test.close_doc() + def test_drop_down_after_import(self): + + files = ["drop_down_form_field.odt", "drop_down_form_field.doc", "drop_down_form_field.docx"] + for file in files: + # open a file with a drop-down for field with items and selection + with self.ui_test.load_file(get_url_for_data_file(file)) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + + # open the dialog (cursor is at the field) + self.ui_test.execute_dialog_through_command(".uno:ControlProperties") + xDialog = self.xUITest.getTopFocusWindow() + + itemsList = xDialog.getChild("items_treeview") + + # check whether the items are there in the list + self.assertEqual(get_state_as_dict(itemsList)["Children"], "4") + self.assertEqual(get_state_as_dict(itemsList.getChild("0"))["Text"], "1000") + self.assertEqual(get_state_as_dict(itemsList.getChild("1"))["Text"], "2000") + self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "3000") + self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "4000") + + self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "3000") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/tdf117039.py b/sw/qa/uitest/writer_tests5/tdf117039.py index b640ab65266a..49de2b42efaf 100644 --- a/sw/qa/uitest/writer_tests5/tdf117039.py +++ b/sw/qa/uitest/writer_tests5/tdf117039.py @@ -14,15 +14,14 @@ from uitest.uihelper.common import get_url_for_data_file class tdf117039(UITestCase): def test_tdf117039_preview_signed_document(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf117039.odt")) - document = self.ui_test.get_component() - self.xUITest.executeCommand(".uno:PrintPreview") #open print preview - self.xUITest.executeCommand(".uno:ClosePreview") # close print preview + with self.ui_test.load_file(get_url_for_data_file("tdf117039.odt")) as writer_doc: + document = self.ui_test.get_component() + self.xUITest.executeCommand(".uno:PrintPreview") #open print preview + self.xUITest.executeCommand(".uno:ClosePreview") # close print preview - self.xUITest.getTopFocusWindow() #Get focus after closing preview + self.xUITest.getTopFocusWindow() #Get focus after closing preview - #verify - self.assertEqual(document.Text.String[0:22], "Test digital signature") - self.ui_test.close_doc() + #verify + self.assertEqual(document.Text.String[0:22], "Test digital signature") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/tdf118540.py b/sw/qa/uitest/writer_tests5/tdf118540.py index 2959f2491b64..56dae2d761b1 100644 --- a/sw/qa/uitest/writer_tests5/tdf118540.py +++ b/sw/qa/uitest/writer_tests5/tdf118540.py @@ -14,19 +14,18 @@ from uitest.uihelper.common import get_url_for_data_file class tdf118540(UITestCase): def test_tdf118540_preview_document_properties(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf118540.docx")) - document = self.ui_test.get_component() - self.xUITest.executeCommand(".uno:PrintPreview") #open print preview - self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties") #open properties dialog - xDialog = self.xUITest.getTopFocusWindow() - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) - self.xUITest.executeCommand(".uno:ClosePreview") # close print preview + with self.ui_test.load_file(get_url_for_data_file("tdf118540.docx")) as writer_doc: + document = self.ui_test.get_component() + self.xUITest.executeCommand(".uno:PrintPreview") #open print preview + self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties") #open properties dialog + xDialog = self.xUITest.getTopFocusWindow() + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) + self.xUITest.executeCommand(".uno:ClosePreview") # close print preview - self.xUITest.getTopFocusWindow() #Get focus after closing preview + self.xUITest.getTopFocusWindow() #Get focus after closing preview - #verify - self.assertEqual(document.Text.String[0:4], "Test") - self.ui_test.close_doc() + #verify + self.assertEqual(document.Text.String[0:4], "Test") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/titlePageWizard.py b/sw/qa/uitest/writer_tests5/titlePageWizard.py index bc5f275e8cfa..a69658ec9260 100644 --- a/sw/qa/uitest/writer_tests5/titlePageWizard.py +++ b/sw/qa/uitest/writer_tests5/titlePageWizard.py @@ -13,202 +13,200 @@ from uitest.uihelper.common import get_url_for_data_file # and inserting at the very end of the document. class tdf138907(UITestCase): def test_tdf138907(self): - self.ui_test.load_file(get_url_for_data_file("tdf138907_titlePageDialog.odt")) - document = self.ui_test.get_component() - - # Confirm the starting state. Just a page break, without a valid restart page number on page 2 - self.assertEqual(document.CurrentController.PageCount, 5) - Paragraphs = document.Text.createEnumeration() - Para1 = Paragraphs.nextElement() - self.assertEqual(Para1.String, "6") - self.assertEqual(Para1.PageDescName, "First Page") - Para2 = Paragraphs.nextElement() - self.assertEqual(Para2.String, "7") - self.assertEqual(Para2.PageDescName, None) - Para3 = Paragraphs.nextElement() - self.assertEqual(Para3.String, "8") - self.assertEqual(Para3.PageDescName, None) - Para4 = Paragraphs.nextElement() - self.assertEqual(Para4.String, "9") - self.assertEqual(Para4.PageDescName, None) - Para5 = Paragraphs.nextElement() - self.assertEqual(Para5.String, "10") - self.assertEqual(Para5.PageDescName, None) - - - #dialog Title Page - self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") - xDialog = self.xUITest.getTopFocusWindow() - #set restart page number to 2. With this doc, it defaults to resetting to 1. - xRestartNumbering = xDialog.getChild("NF_RESTART_NUMBERING") - xRestartNumbering.executeAction("UP", tuple()) # restart numbering at 2 - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - Paragraphs = document.Text.createEnumeration() - Para1 = Paragraphs.nextElement() - self.assertEqual(Para1.String, "6") - self.assertEqual(Para1.PageDescName, "First Page") - self.assertEqual(Para2.String, "2") - Para2 = Paragraphs.nextElement() - # Without this fix, there was no PageDescName specified, just Landscape as default. - self.assertEqual(Para2.PageDescName, "Landscape") - - #re-run dialog Title Page - self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") - xDialog = self.xUITest.getTopFocusWindow() - #accept defaults and OK without making any changes. - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - # Without this fix, re-running the wizard was failing with the title page restarting at page 2. - Paragraphs = document.Text.createEnumeration() - Para1 = Paragraphs.nextElement() - self.assertEqual(Para1.String, "6") - self.assertEqual(Para1.PageDescName, "First Page") - Para2 = Paragraphs.nextElement() - self.assertEqual(Para2.String, "2") - self.assertEqual(Para2.PageDescName, "Landscape") - - #Note: 6 virtual pages, including blank, even page seen in book view - self.assertEqual(document.CurrentController.PageCount, 6) - - #Now test replacing several pages with title and index styles - - #dialog Title Page - self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") - xDialog = self.xUITest.getTopFocusWindow() - print(xDialog.getChildren()) - #Convert three pages to title/index pages starting at page two. - xPageCount = xDialog.getChild("NF_PAGE_COUNT") - for _ in range(0,2): - xPageCount.executeAction("UP", tuple()) - xUseStartingPage = xDialog.getChild("RB_PAGE_START") - xUseStartingPage.executeAction("CLICK", tuple()) - xStartingPage = xDialog.getChild("NF_PAGE_START") - xStartingPage.executeAction("UP", tuple()) #Start at page 2. - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - Paragraphs = document.Text.createEnumeration() - Para1 = Paragraphs.nextElement() - self.assertEqual(Para1.String, "6") - self.assertEqual(Para1.PageDescName, "First Page") - # Without the fix, the following results are all off by one. - Para2 = Paragraphs.nextElement() - self.assertEqual(Para2.String, "6") - self.assertEqual(Para2.PageDescName, "First Page") - Para3 = Paragraphs.nextElement() - self.assertEqual(Para3.String, "7") - self.assertEqual(Para3.PageDescName, "Index") - Para4 = Paragraphs.nextElement() - self.assertEqual(Para4.String, "8") - self.assertEqual(Para4.PageDescName, "Index") - Para5 = Paragraphs.nextElement() - self.assertEqual(Para5.String, "2") - self.assertEqual(Para5.PageDescName, "Landscape") - - #Now test inserting at the end of the document - - #dialog Title Page - self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") - xDialog = self.xUITest.getTopFocusWindow() - print(xDialog.getChildren()) - #Insert three title/index pages at the end of the document (plus a content page). - newPages = xDialog.getChild("RB_INSERT_NEW_PAGES") - newPages.executeAction("CLICK", tuple()) - xPageCount = xDialog.getChild("NF_PAGE_COUNT") - for _ in range(0,2): - xPageCount.executeAction("UP", tuple()) - xUseStartingPage = xDialog.getChild("RB_PAGE_START") - xUseStartingPage.executeAction("CLICK", tuple()) - xStartingPage = xDialog.getChild("NF_PAGE_START") - for _ in range(0,18): - xStartingPage.executeAction("UP", tuple()) #Start at mythical page 20. - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - # Without the fix, the pages were being inserted before the last page. - text = document.Text.String.replace('\r\n', '\n') - self.assertEqual(text[0:1], "6") - self.assertEqual(text[2:3], "6") - self.assertEqual(text[4:5], "7") - self.assertEqual(text[6:7], "8") - # Without the fix, the new pages were inserted before the last page. - self.assertFalse("\n" in text[8:9]) - #Note: 13 total virtual pages, including four blanks, as seen in book view - self.assertEqual(document.CurrentController.PageCount, 13) - - #Now test inserting in the middle of the document - - #dialog Title Page - self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") - xDialog = self.xUITest.getTopFocusWindow() - print(xDialog.getChildren()) - #Insert three title/index pages starting at page 2. - newPages = xDialog.getChild("RB_INSERT_NEW_PAGES") - newPages.executeAction("CLICK", tuple()) - xPageCount = xDialog.getChild("NF_PAGE_COUNT") - for _ in range(0,2): - xPageCount.executeAction("UP", tuple()) - xUseStartingPage = xDialog.getChild("RB_PAGE_START") - xUseStartingPage.executeAction("CLICK", tuple()) - xStartingPage = xDialog.getChild("NF_PAGE_START") - for _ in range(0,10): - xStartingPage.executeAction("DOWN", tuple()) #Reset to page 1 - xStartingPage.executeAction("UP", tuple()) #Start at page 2. - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - # Without first re-calculating the layout, the styles were applied to the wrong pages. - Paragraphs = document.Text.createEnumeration() - Para1 = Paragraphs.nextElement() - self.assertEqual(Para1.String, "6") - self.assertEqual(Para1.PageDescName, "First Page") - # The next three pages are the ones that were just inserted. - Para2 = Paragraphs.nextElement() - self.assertEqual(Para2.String, "") - self.assertEqual(Para2.PageDescName, "First Page") - Para3 = Paragraphs.nextElement() - self.assertEqual(Para3.String, "") - self.assertEqual(Para3.PageDescName, "Index") - Para4 = Paragraphs.nextElement() - self.assertEqual(Para4.String, "") - self.assertEqual(Para4.PageDescName, "Index") - # A bit of a quirk is that the style of the first page after the - # title page is still First Page - so that is used as the Normal page style. - # OK - this is a bit of a strange workflow, so just accept that. - Para5 = Paragraphs.nextElement() - self.assertEqual(Para5.String, "6") - self.assertEqual(Para5.PageDescName, "First Page") - Para6 = Paragraphs.nextElement() - self.assertEqual(Para6.String, "7") - self.assertEqual(Para6.PageDescName, "Index") - Para7 = Paragraphs.nextElement() - self.assertEqual(Para7.String, "8") - self.assertEqual(Para7.PageDescName, "Index") - Para8 = Paragraphs.nextElement() - self.assertEqual(Para8.String, "2") - self.assertEqual(Para8.PageDescName, "Landscape") - Para9 = Paragraphs.nextElement() - self.assertEqual(Para9.String, "") - self.assertEqual(Para9.PageDescName, "First Page") - Para10 = Paragraphs.nextElement() - self.assertEqual(Para10.String, "") - self.assertEqual(Para10.PageDescName, "Index") - Para11 = Paragraphs.nextElement() - self.assertEqual(Para11.String, "") - self.assertEqual(Para11.PageDescName, "Index") - # The quirk resets this extra content page to the "style after First page == First Page" - Para12 = Paragraphs.nextElement() - self.assertEqual(Para12.String, "") - self.assertEqual(Para12.PageDescName, "First Page") - #Note: 17 total virtual pages, including five blanks, as seen in book view - self.assertEqual(document.CurrentController.PageCount, 17) - - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("tdf138907_titlePageDialog.odt")): + document = self.ui_test.get_component() + + # Confirm the starting state. Just a page break, without a valid restart page number on page 2 + self.assertEqual(document.CurrentController.PageCount, 5) + Paragraphs = document.Text.createEnumeration() + Para1 = Paragraphs.nextElement() + self.assertEqual(Para1.String, "6") + self.assertEqual(Para1.PageDescName, "First Page") + Para2 = Paragraphs.nextElement() + self.assertEqual(Para2.String, "7") + self.assertEqual(Para2.PageDescName, None) + Para3 = Paragraphs.nextElement() + self.assertEqual(Para3.String, "8") + self.assertEqual(Para3.PageDescName, None) + Para4 = Paragraphs.nextElement() + self.assertEqual(Para4.String, "9") + self.assertEqual(Para4.PageDescName, None) + Para5 = Paragraphs.nextElement() + self.assertEqual(Para5.String, "10") + self.assertEqual(Para5.PageDescName, None) + + + #dialog Title Page + self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") + xDialog = self.xUITest.getTopFocusWindow() + #set restart page number to 2. With this doc, it defaults to resetting to 1. + xRestartNumbering = xDialog.getChild("NF_RESTART_NUMBERING") + xRestartNumbering.executeAction("UP", tuple()) # restart numbering at 2 + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + Paragraphs = document.Text.createEnumeration() + Para1 = Paragraphs.nextElement() + self.assertEqual(Para1.String, "6") + self.assertEqual(Para1.PageDescName, "First Page") + self.assertEqual(Para2.String, "2") + Para2 = Paragraphs.nextElement() + # Without this fix, there was no PageDescName specified, just Landscape as default. + self.assertEqual(Para2.PageDescName, "Landscape") + + #re-run dialog Title Page + self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") + xDialog = self.xUITest.getTopFocusWindow() + #accept defaults and OK without making any changes. + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # Without this fix, re-running the wizard was failing with the title page restarting at page 2. + Paragraphs = document.Text.createEnumeration() + Para1 = Paragraphs.nextElement() + self.assertEqual(Para1.String, "6") + self.assertEqual(Para1.PageDescName, "First Page") + Para2 = Paragraphs.nextElement() + self.assertEqual(Para2.String, "2") + self.assertEqual(Para2.PageDescName, "Landscape") + + #Note: 6 virtual pages, including blank, even page seen in book view + self.assertEqual(document.CurrentController.PageCount, 6) + + #Now test replacing several pages with title and index styles + + #dialog Title Page + self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") + xDialog = self.xUITest.getTopFocusWindow() + print(xDialog.getChildren()) + #Convert three pages to title/index pages starting at page two. + xPageCount = xDialog.getChild("NF_PAGE_COUNT") + for _ in range(0,2): + xPageCount.executeAction("UP", tuple()) + xUseStartingPage = xDialog.getChild("RB_PAGE_START") + xUseStartingPage.executeAction("CLICK", tuple()) + xStartingPage = xDialog.getChild("NF_PAGE_START") + xStartingPage.executeAction("UP", tuple()) #Start at page 2. + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + Paragraphs = document.Text.createEnumeration() + Para1 = Paragraphs.nextElement() + self.assertEqual(Para1.String, "6") + self.assertEqual(Para1.PageDescName, "First Page") + # Without the fix, the following results are all off by one. + Para2 = Paragraphs.nextElement() + self.assertEqual(Para2.String, "6") + self.assertEqual(Para2.PageDescName, "First Page") + Para3 = Paragraphs.nextElement() + self.assertEqual(Para3.String, "7") + self.assertEqual(Para3.PageDescName, "Index") + Para4 = Paragraphs.nextElement() + self.assertEqual(Para4.String, "8") + self.assertEqual(Para4.PageDescName, "Index") + Para5 = Paragraphs.nextElement() + self.assertEqual(Para5.String, "2") + self.assertEqual(Para5.PageDescName, "Landscape") + + #Now test inserting at the end of the document + + #dialog Title Page + self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") + xDialog = self.xUITest.getTopFocusWindow() + print(xDialog.getChildren()) + #Insert three title/index pages at the end of the document (plus a content page). + newPages = xDialog.getChild("RB_INSERT_NEW_PAGES") + newPages.executeAction("CLICK", tuple()) + xPageCount = xDialog.getChild("NF_PAGE_COUNT") + for _ in range(0,2): + xPageCount.executeAction("UP", tuple()) + xUseStartingPage = xDialog.getChild("RB_PAGE_START") + xUseStartingPage.executeAction("CLICK", tuple()) + xStartingPage = xDialog.getChild("NF_PAGE_START") + for _ in range(0,18): + xStartingPage.executeAction("UP", tuple()) #Start at mythical page 20. + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # Without the fix, the pages were being inserted before the last page. + text = document.Text.String.replace('\r\n', '\n') + self.assertEqual(text[0:1], "6") + self.assertEqual(text[2:3], "6") + self.assertEqual(text[4:5], "7") + self.assertEqual(text[6:7], "8") + # Without the fix, the new pages were inserted before the last page. + self.assertFalse("\n" in text[8:9]) + #Note: 13 total virtual pages, including four blanks, as seen in book view + self.assertEqual(document.CurrentController.PageCount, 13) + + #Now test inserting in the middle of the document + + #dialog Title Page + self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") + xDialog = self.xUITest.getTopFocusWindow() + print(xDialog.getChildren()) + #Insert three title/index pages starting at page 2. + newPages = xDialog.getChild("RB_INSERT_NEW_PAGES") + newPages.executeAction("CLICK", tuple()) + xPageCount = xDialog.getChild("NF_PAGE_COUNT") + for _ in range(0,2): + xPageCount.executeAction("UP", tuple()) + xUseStartingPage = xDialog.getChild("RB_PAGE_START") + xUseStartingPage.executeAction("CLICK", tuple()) + xStartingPage = xDialog.getChild("NF_PAGE_START") + for _ in range(0,10): + xStartingPage.executeAction("DOWN", tuple()) #Reset to page 1 + xStartingPage.executeAction("UP", tuple()) #Start at page 2. + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # Without first re-calculating the layout, the styles were applied to the wrong pages. + Paragraphs = document.Text.createEnumeration() + Para1 = Paragraphs.nextElement() + self.assertEqual(Para1.String, "6") + self.assertEqual(Para1.PageDescName, "First Page") + # The next three pages are the ones that were just inserted. + Para2 = Paragraphs.nextElement() + self.assertEqual(Para2.String, "") + self.assertEqual(Para2.PageDescName, "First Page") + Para3 = Paragraphs.nextElement() + self.assertEqual(Para3.String, "") + self.assertEqual(Para3.PageDescName, "Index") + Para4 = Paragraphs.nextElement() + self.assertEqual(Para4.String, "") + self.assertEqual(Para4.PageDescName, "Index") + # A bit of a quirk is that the style of the first page after the + # title page is still First Page - so that is used as the Normal page style. + # OK - this is a bit of a strange workflow, so just accept that. + Para5 = Paragraphs.nextElement() + self.assertEqual(Para5.String, "6") + self.assertEqual(Para5.PageDescName, "First Page") + Para6 = Paragraphs.nextElement() + self.assertEqual(Para6.String, "7") + self.assertEqual(Para6.PageDescName, "Index") + Para7 = Paragraphs.nextElement() + self.assertEqual(Para7.String, "8") + self.assertEqual(Para7.PageDescName, "Index") + Para8 = Paragraphs.nextElement() + self.assertEqual(Para8.String, "2") + self.assertEqual(Para8.PageDescName, "Landscape") + Para9 = Paragraphs.nextElement() + self.assertEqual(Para9.String, "") + self.assertEqual(Para9.PageDescName, "First Page") + Para10 = Paragraphs.nextElement() + self.assertEqual(Para10.String, "") + self.assertEqual(Para10.PageDescName, "Index") + Para11 = Paragraphs.nextElement() + self.assertEqual(Para11.String, "") + self.assertEqual(Para11.PageDescName, "Index") + # The quirk resets this extra content page to the "style after First page == First Page" + Para12 = Paragraphs.nextElement() + self.assertEqual(Para12.String, "") + self.assertEqual(Para12.PageDescName, "First Page") + #Note: 17 total virtual pages, including five blanks, as seen in book view + self.assertEqual(document.CurrentController.PageCount, 17) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests5/titlePageWizard2.py b/sw/qa/uitest/writer_tests5/titlePageWizard2.py index 9c57a7fa5054..2838c7ae2343 100644 --- a/sw/qa/uitest/writer_tests5/titlePageWizard2.py +++ b/sw/qa/uitest/writer_tests5/titlePageWizard2.py @@ -10,127 +10,125 @@ from uitest.uihelper.common import get_url_for_data_file # This tests both an edge cases, and some more realistic situations. class tdf138907(UITestCase): def test_tdf138907(self): - self.ui_test.load_file(get_url_for_data_file("tdf138907_titlePageDialog.odt")) - document = self.ui_test.get_component() - - # Test an undefined situation - try to modify pages beyond the end of the document. - - #dialog Title Page - self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") - xDialog = self.xUITest.getTopFocusWindow() - #set restart page number to 2. With this doc, it defaults to resetting to 1. - xRestartNumbering = xDialog.getChild("NF_RESTART_NUMBERING") - xRestartNumbering.executeAction("UP", tuple()) # restart numbering at 2 - - #Convert three pages to title/index pages starting at non-existing page twenty. - xPageCount = xDialog.getChild("NF_PAGE_COUNT") - for _ in range(0,2): - xPageCount.executeAction("UP", tuple()) - xUseStartingPage = xDialog.getChild("RB_PAGE_START") - xUseStartingPage.executeAction("CLICK", tuple()) - xStartingPage = xDialog.getChild("NF_PAGE_START") - for _ in range(0,19): - xStartingPage.executeAction("UP", tuple()) #Start at mythical page 20. - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - # Nothing should happen when modifying pages that don't exist. - # Just a page break, without a valid restart page number on page 2 - self.assertEqual(document.CurrentController.PageCount, 5) - Paragraphs = document.Text.createEnumeration() - Para1 = Paragraphs.nextElement() - self.assertEqual(Para1.String, "6") - self.assertEqual(Para1.PageDescName, "First Page") - Para2 = Paragraphs.nextElement() - self.assertEqual(Para2.String, "7") - self.assertEqual(Para2.PageDescName, None) - Para3 = Paragraphs.nextElement() - self.assertEqual(Para3.String, "8") - self.assertEqual(Para3.PageDescName, None) - Para4 = Paragraphs.nextElement() - self.assertEqual(Para4.String, "9") - self.assertEqual(Para4.PageDescName, None) - Para5 = Paragraphs.nextElement() - self.assertEqual(Para5.String, "10") - self.assertEqual(Para5.PageDescName, None) - - - #dialog Title Page - self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") - xDialog = self.xUITest.getTopFocusWindow() - #set restart page number to 1 - which is the default. - #set restart title page to 1 - the current value for this document is 6. - xRestartNumbering = xDialog.getChild("NF_SET_PAGE_NUMBER") - print(xDialog.getChildren()) - for _ in range(0,5): - xRestartNumbering.executeAction("DOWN", tuple()) # restart title numbering at 1 - #Insert two title/index pages at beginning of the document. - newPages = xDialog.getChild("RB_INSERT_NEW_PAGES") - newPages.executeAction("CLICK", tuple()) - xPageCount = xDialog.getChild("NF_PAGE_COUNT") - for _ in range(0,1): - xPageCount.executeAction("UP", tuple()) - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - Paragraphs = document.Text.createEnumeration() - Para1 = Paragraphs.nextElement() - self.assertEqual(Para1.String, "") - self.assertEqual(Para1.PageDescName, "First Page") - Para2 = Paragraphs.nextElement() - self.assertEqual(Para2.String, "") - self.assertEqual(Para2.PageDescName, "Index") - Para3 = Paragraphs.nextElement() - self.assertEqual(Para3.String, "1") - self.assertEqual(Para3.PageDescName, "Landscape") - Para4 = Paragraphs.nextElement() - self.assertEqual(Para4.String, "2") - Para5 = Paragraphs.nextElement() - self.assertEqual(Para5.String, "3") - Para6 = Paragraphs.nextElement() - self.assertEqual(Para6.String, "4") - Para7 = Paragraphs.nextElement() - self.assertEqual(Para7.String, "5") - - #Now test replacing several pages with title and index styles - - #dialog Title Page - self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") - xDialog = self.xUITest.getTopFocusWindow() - print(xDialog.getChildren()) - #Convert four pages to title/index pages starting at page one. - xPageCount = xDialog.getChild("NF_PAGE_COUNT") - for _ in range(0,3): - xPageCount.executeAction("DOWN", tuple()) #reset to 1 first - for _ in range(0,3): - xPageCount.executeAction("UP", tuple()) - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - Paragraphs = document.Text.createEnumeration() - Para1 = Paragraphs.nextElement() - self.assertEqual(Para1.String, "") - self.assertEqual(Para1.PageDescName, "First Page") - Para2 = Paragraphs.nextElement() - self.assertEqual(Para2.String, "") - self.assertEqual(Para2.PageDescName, "Index") - Para3 = Paragraphs.nextElement() - self.assertEqual(Para3.String, "3") - self.assertEqual(Para3.PageDescName, "Index") - Para4 = Paragraphs.nextElement() - self.assertEqual(Para4.String, "4") - self.assertEqual(Para4.PageDescName, "Index") - Para5 = Paragraphs.nextElement() - self.assertEqual(Para5.String, "1") - self.assertEqual(Para5.PageDescName, "Landscape") - Para6 = Paragraphs.nextElement() - self.assertEqual(Para6.String, "2") - Para7 = Paragraphs.nextElement() - self.assertEqual(Para7.String, "3") - - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("tdf138907_titlePageDialog.odt")): + document = self.ui_test.get_component() + + # Test an undefined situation - try to modify pages beyond the end of the document. + + #dialog Title Page + self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") + xDialog = self.xUITest.getTopFocusWindow() + #set restart page number to 2. With this doc, it defaults to resetting to 1. + xRestartNumbering = xDialog.getChild("NF_RESTART_NUMBERING") + xRestartNumbering.executeAction("UP", tuple()) # restart numbering at 2 + + #Convert three pages to title/index pages starting at non-existing page twenty. + xPageCount = xDialog.getChild("NF_PAGE_COUNT") + for _ in range(0,2): + xPageCount.executeAction("UP", tuple()) + xUseStartingPage = xDialog.getChild("RB_PAGE_START") + xUseStartingPage.executeAction("CLICK", tuple()) + xStartingPage = xDialog.getChild("NF_PAGE_START") + for _ in range(0,19): + xStartingPage.executeAction("UP", tuple()) #Start at mythical page 20. + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # Nothing should happen when modifying pages that don't exist. + # Just a page break, without a valid restart page number on page 2 + self.assertEqual(document.CurrentController.PageCount, 5) + Paragraphs = document.Text.createEnumeration() + Para1 = Paragraphs.nextElement() + self.assertEqual(Para1.String, "6") + self.assertEqual(Para1.PageDescName, "First Page") + Para2 = Paragraphs.nextElement() + self.assertEqual(Para2.String, "7") + self.assertEqual(Para2.PageDescName, None) + Para3 = Paragraphs.nextElement() + self.assertEqual(Para3.String, "8") + self.assertEqual(Para3.PageDescName, None) + Para4 = Paragraphs.nextElement() + self.assertEqual(Para4.String, "9") + self.assertEqual(Para4.PageDescName, None) + Para5 = Paragraphs.nextElement() + self.assertEqual(Para5.String, "10") + self.assertEqual(Para5.PageDescName, None) + + + #dialog Title Page + self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") + xDialog = self.xUITest.getTopFocusWindow() + #set restart page number to 1 - which is the default. + #set restart title page to 1 - the current value for this document is 6. + xRestartNumbering = xDialog.getChild("NF_SET_PAGE_NUMBER") + print(xDialog.getChildren()) + for _ in range(0,5): + xRestartNumbering.executeAction("DOWN", tuple()) # restart title numbering at 1 + #Insert two title/index pages at beginning of the document. + newPages = xDialog.getChild("RB_INSERT_NEW_PAGES") + newPages.executeAction("CLICK", tuple()) + xPageCount = xDialog.getChild("NF_PAGE_COUNT") + for _ in range(0,1): + xPageCount.executeAction("UP", tuple()) + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + Paragraphs = document.Text.createEnumeration() + Para1 = Paragraphs.nextElement() + self.assertEqual(Para1.String, "") + self.assertEqual(Para1.PageDescName, "First Page") + Para2 = Paragraphs.nextElement() + self.assertEqual(Para2.String, "") + self.assertEqual(Para2.PageDescName, "Index") + Para3 = Paragraphs.nextElement() + self.assertEqual(Para3.String, "1") + self.assertEqual(Para3.PageDescName, "Landscape") + Para4 = Paragraphs.nextElement() + self.assertEqual(Para4.String, "2") + Para5 = Paragraphs.nextElement() + self.assertEqual(Para5.String, "3") + Para6 = Paragraphs.nextElement() + self.assertEqual(Para6.String, "4") + Para7 = Paragraphs.nextElement() + self.assertEqual(Para7.String, "5") + + #Now test replacing several pages with title and index styles + + #dialog Title Page + self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") + xDialog = self.xUITest.getTopFocusWindow() + print(xDialog.getChildren()) + #Convert four pages to title/index pages starting at page one. + xPageCount = xDialog.getChild("NF_PAGE_COUNT") + for _ in range(0,3): + xPageCount.executeAction("DOWN", tuple()) #reset to 1 first + for _ in range(0,3): + xPageCount.executeAction("UP", tuple()) + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + Paragraphs = document.Text.createEnumeration() + Para1 = Paragraphs.nextElement() + self.assertEqual(Para1.String, "") + self.assertEqual(Para1.PageDescName, "First Page") + Para2 = Paragraphs.nextElement() + self.assertEqual(Para2.String, "") + self.assertEqual(Para2.PageDescName, "Index") + Para3 = Paragraphs.nextElement() + self.assertEqual(Para3.String, "3") + self.assertEqual(Para3.PageDescName, "Index") + Para4 = Paragraphs.nextElement() + self.assertEqual(Para4.String, "4") + self.assertEqual(Para4.PageDescName, "Index") + Para5 = Paragraphs.nextElement() + self.assertEqual(Para5.String, "1") + self.assertEqual(Para5.PageDescName, "Landscape") + Para6 = Paragraphs.nextElement() + self.assertEqual(Para6.String, "2") + Para7 = Paragraphs.nextElement() + self.assertEqual(Para7.String, "3") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests6/tdf120731.py b/sw/qa/uitest/writer_tests6/tdf120731.py index c7177922ad92..d9415d9aa7e8 100644 --- a/sw/qa/uitest/writer_tests6/tdf120731.py +++ b/sw/qa/uitest/writer_tests6/tdf120731.py @@ -11,15 +11,14 @@ from uitest.uihelper.common import get_url_for_data_file class tdf120731(UITestCase): def test_tdf120731_crash_open_char_dialog(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf120731.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() + with self.ui_test.load_file(get_url_for_data_file("tdf120731.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() - self.xUITest.executeCommand(".uno:SelectAll") - self.ui_test.execute_dialog_through_command(".uno:FontDialog") - xDialog = self.xUITest.getTopFocusWindow() - xOK = xDialog.getChild("ok") - xOK.executeAction("CLICK", tuple()) - self.assertEqual(document.Text.String[0:5], "Lorem") - self.ui_test.close_doc() + self.xUITest.executeCommand(".uno:SelectAll") + self.ui_test.execute_dialog_through_command(".uno:FontDialog") + xDialog = self.xUITest.getTopFocusWindow() + xOK = xDialog.getChild("ok") + xOK.executeAction("CLICK", tuple()) + self.assertEqual(document.Text.String[0:5], "Lorem") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests6/tdf124586.py b/sw/qa/uitest/writer_tests6/tdf124586.py index 612824ee740e..35e255c0cd39 100644 --- a/sw/qa/uitest/writer_tests6/tdf124586.py +++ b/sw/qa/uitest/writer_tests6/tdf124586.py @@ -12,25 +12,24 @@ from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file class tdf124586(UITestCase): def test_tdf124586_crash_switch_outline_numbering(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf124586.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() + with self.ui_test.load_file(get_url_for_data_file("tdf124586.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() - #Goto Tools > Chapter Numbering. - self.ui_test.execute_dialog_through_command(".uno:ChapterNumberingDialog") - xDialog = self.xUITest.getTopFocusWindow() - xstyle = xDialog.getChild("style") - select_by_text(xstyle, "MyHeading") - xOK = xDialog.getChild("ok") - xOK.executeAction("CLICK", tuple()) + #Goto Tools > Chapter Numbering. + self.ui_test.execute_dialog_through_command(".uno:ChapterNumberingDialog") + xDialog = self.xUITest.getTopFocusWindow() + xstyle = xDialog.getChild("style") + select_by_text(xstyle, "MyHeading") + xOK = xDialog.getChild("ok") + xOK.executeAction("CLICK", tuple()) - self.assertEqual(document.Text.String[0:8], "Schritte") + self.assertEqual(document.Text.String[0:8], "Schritte") - self.ui_test.execute_dialog_through_command(".uno:ChapterNumberingDialog") - xDialog = self.xUITest.getTopFocusWindow() - xstyle = xDialog.getChild("style") - self.assertEqual(get_state_as_dict(xstyle)["SelectEntryText"], "MyHeading") - xOK = xDialog.getChild("ok") - xOK.executeAction("CLICK", tuple()) - self.ui_test.close_doc() + self.ui_test.execute_dialog_through_command(".uno:ChapterNumberingDialog") + xDialog = self.xUITest.getTopFocusWindow() + xstyle = xDialog.getChild("style") + self.assertEqual(get_state_as_dict(xstyle)["SelectEntryText"], "MyHeading") + xOK = xDialog.getChild("ok") + xOK.executeAction("CLICK", tuple()) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests6/tdf124675.py b/sw/qa/uitest/writer_tests6/tdf124675.py index 15cc5c462041..200255e159fc 100644 --- a/sw/qa/uitest/writer_tests6/tdf124675.py +++ b/sw/qa/uitest/writer_tests6/tdf124675.py @@ -12,26 +12,24 @@ from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file class tdf124675(UITestCase): def test_tdf124675_crash_moving_SwTextFrame_previous_page(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf124675.docx")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") + with self.ui_test.load_file(get_url_for_data_file("tdf124675.docx")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") - self.assertEqual(document.CurrentController.PageCount, 2) - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1") + self.assertEqual(document.CurrentController.PageCount, 2) + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1") - for i in range(52): - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + for i in range(52): + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) - self.assertEqual(document.CurrentController.PageCount, 4) - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "2") + self.assertEqual(document.CurrentController.PageCount, 4) + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "2") - for i in range(52): - self.xUITest.executeCommand(".uno:Undo") + for i in range(52): + self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.CurrentController.PageCount, 2) - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1") - - self.ui_test.close_doc() + self.assertEqual(document.CurrentController.PageCount, 2) + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests6/tdf126017.py b/sw/qa/uitest/writer_tests6/tdf126017.py index d10a68517429..640c9bf8c236 100644 --- a/sw/qa/uitest/writer_tests6/tdf126017.py +++ b/sw/qa/uitest/writer_tests6/tdf126017.py @@ -12,40 +12,39 @@ from uitest.uihelper.common import get_url_for_data_file class tdf126017(UITestCase): def test_tdf126017_crash_after_undo(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf126017.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - - #go to TOC - self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") - xDialog = self.xUITest.getTopFocusWindow() - searchterm = xDialog.getChild("searchterm") - searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"aasasas"})) - xsearch = xDialog.getChild("search") - xsearch.executeAction("CLICK", tuple()) - xcloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xcloseBtn) - #edit index - self.ui_test.execute_dialog_through_command(".uno:EditCurIndex") #open index dialog - xDiagIndex = self.xUITest.getTopFocusWindow() - xOKBtn = xDiagIndex.getChild("ok") - title = xDiagIndex.getChild("title") - title.executeAction("TYPE", mkPropertyValues({"TEXT":"aaaa"})) - self.ui_test.close_dialog_through_button(xOKBtn) - - self.xUITest.executeCommand(".uno:Undo") - - self.ui_test.execute_dialog_through_command(".uno:EditCurIndex") #open index dialog - xDiagIndex = self.xUITest.getTopFocusWindow() - xOKBtn = xDiagIndex.getChild("ok") - title = xDiagIndex.getChild("title") - title.executeAction("TYPE", mkPropertyValues({"TEXT":"aaaa"})) - self.ui_test.close_dialog_through_button(xOKBtn) - - self.xUITest.executeCommand(".uno:Undo") - self.xUITest.executeCommand(".uno:Undo") - - self.assertEqual(document.Text.String.replace('\r\n', '\n')[1:7], "CRASHY") - - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("tdf126017.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + + #go to TOC + self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") + xDialog = self.xUITest.getTopFocusWindow() + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"aasasas"})) + xsearch = xDialog.getChild("search") + xsearch.executeAction("CLICK", tuple()) + xcloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xcloseBtn) + #edit index + self.ui_test.execute_dialog_through_command(".uno:EditCurIndex") #open index dialog + xDiagIndex = self.xUITest.getTopFocusWindow() + xOKBtn = xDiagIndex.getChild("ok") + title = xDiagIndex.getChild("title") + title.executeAction("TYPE", mkPropertyValues({"TEXT":"aaaa"})) + self.ui_test.close_dialog_through_button(xOKBtn) + + self.xUITest.executeCommand(".uno:Undo") + + self.ui_test.execute_dialog_through_command(".uno:EditCurIndex") #open index dialog + xDiagIndex = self.xUITest.getTopFocusWindow() + xOKBtn = xDiagIndex.getChild("ok") + title = xDiagIndex.getChild("title") + title.executeAction("TYPE", mkPropertyValues({"TEXT":"aaaa"})) + self.ui_test.close_dialog_through_button(xOKBtn) + + self.xUITest.executeCommand(".uno:Undo") + self.xUITest.executeCommand(".uno:Undo") + + self.assertEqual(document.Text.String.replace('\r\n', '\n')[1:7], "CRASHY") + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests6/tdf126226.py b/sw/qa/uitest/writer_tests6/tdf126226.py index e13505fc1f64..9d397a060792 100644 --- a/sw/qa/uitest/writer_tests6/tdf126226.py +++ b/sw/qa/uitest/writer_tests6/tdf126226.py @@ -10,20 +10,19 @@ from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file class Tdf126226(UITestCase): def test_tdf126226(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf126226.odt")) + with self.ui_test.load_file(get_url_for_data_file("tdf126226.odt")) as writer_doc: - self.xUITest.executeCommand(".uno:SelectAll") + self.xUITest.executeCommand(".uno:SelectAll") - # Without the fix in place, this test would have crashed here - self.ui_test.execute_dialog_through_command(".uno:CommentChangeTracking") + # Without the fix in place, this test would have crashed here + self.ui_test.execute_dialog_through_command(".uno:CommentChangeTracking") - xDialog = self.xUITest.getTopFocusWindow() + xDialog = self.xUITest.getTopFocusWindow() - self.assertEqual("Hello\n", get_state_as_dict(xDialog.getChild("edit"))["Text"]) - self.assertEqual("Autor desconocido, 07/04/2019 13:43:52", - get_state_as_dict(xDialog.getChild("lastedit"))["Text"]) + self.assertEqual("Hello\n", get_state_as_dict(xDialog.getChild("edit"))["Text"]) + self.assertEqual("Autor desconocido, 07/04/2019 13:43:52", + get_state_as_dict(xDialog.getChild("lastedit"))["Text"]) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) - self.ui_test.close_doc() diff --git a/sw/qa/uitest/writer_tests6/tdf126627.py b/sw/qa/uitest/writer_tests6/tdf126627.py index d72f3d91416b..2da4c6d89fde 100644 --- a/sw/qa/uitest/writer_tests6/tdf126627.py +++ b/sw/qa/uitest/writer_tests6/tdf126627.py @@ -12,39 +12,38 @@ from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file class tdf126627(UITestCase): def test_tdf126627_crash_undo_deletion(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf126627.odt")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.load_file(get_url_for_data_file("tdf126627.odt")) as writer_doc: + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") + xDialog = self.xUITest.getTopFocusWindow() - searchterm = xDialog.getChild("searchterm") - searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"bar"})) - xsearch = xDialog.getChild("search") - xsearch.executeAction("CLICK", tuple()) + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"bar"})) + xsearch = xDialog.getChild("search") + xsearch.executeAction("CLICK", tuple()) - xcloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xcloseBtn) - #2. Place the cursor before 'bar' - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"})) - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"})) - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"})) - #3. Hit backspace 4 times -> Foo and bar are together - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) - self.assertEqual(document.Text.String[0:6], "foobar") - #4. Undo once-> Crash - self.xUITest.executeCommand(".uno:Undo") - #verify that we have now two words - self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog") - xDialog = self.xUITest.getTopFocusWindow() - xselectwords = xDialog.getChild("selectwords") - self.assertEqual(get_state_as_dict(xselectwords)["Text"], "2") - xCloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xCloseBtn) + xcloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xcloseBtn) + #2. Place the cursor before 'bar' + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"})) + #3. Hit backspace 4 times -> Foo and bar are together + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) + self.assertEqual(document.Text.String[0:6], "foobar") + #4. Undo once-> Crash + self.xUITest.executeCommand(".uno:Undo") + #verify that we have now two words + self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog") + xDialog = self.xUITest.getTopFocusWindow() + xselectwords = xDialog.getChild("selectwords") + self.assertEqual(get_state_as_dict(xselectwords)["Text"], "2") + xCloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xCloseBtn) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests7/apply_line_cap.py b/sw/qa/uitest/writer_tests7/apply_line_cap.py index 5e7b42ca9a2f..2813c997ad1e 100644 --- a/sw/qa/uitest/writer_tests7/apply_line_cap.py +++ b/sw/qa/uitest/writer_tests7/apply_line_cap.py @@ -11,92 +11,90 @@ from uitest.uihelper.common import select_pos class apply_line_cap(UITestCase): def test_apply_line_cap(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf127166_prstDash_Word97.docx")) + with self.ui_test.load_file(get_url_for_data_file("tdf127166_prstDash_Word97.docx")) as writer_doc: - # check FLAT -> ROUND cap style change by selecting the new 'Rounded' preset line styles + # check FLAT -> ROUND cap style change by selecting the new 'Rounded' preset line styles - # select second line shape (dashDot) - writer_doc.getCurrentController().select(writer_doc.getDrawPage()[1]) + # select second line shape (dashDot) + writer_doc.getCurrentController().select(writer_doc.getDrawPage()[1]) - # wait for available line style setting - self.ui_test.wait_until_child_is_available('metricfield') + # wait for available line style setting + self.ui_test.wait_until_child_is_available('metricfield') - # line setting dialog window - self.ui_test.execute_dialog_through_command(".uno:FormatLine") - xFormatLineDlg = self.xUITest.getTopFocusWindow() + # line setting dialog window + self.ui_test.execute_dialog_through_command(".uno:FormatLine") + xFormatLineDlg = self.xUITest.getTopFocusWindow() - # get cap style combo box - xCapStyle = xFormatLineDlg.getChild("LB_CAP_STYLE") - cap_style = get_state_as_dict(xCapStyle)['SelectEntryText'] + # get cap style combo box + xCapStyle = xFormatLineDlg.getChild("LB_CAP_STYLE") + cap_style = get_state_as_dict(xCapStyle)['SelectEntryText'] - # get line style combo box - xLineStyle = xFormatLineDlg.getChild("LB_LINE_STYLE") + # get line style combo box + xLineStyle = xFormatLineDlg.getChild("LB_LINE_STYLE") - # select 'Dot (Rounded)', but store the previous value - style = get_state_as_dict(xLineStyle)['SelectEntryText'] - select_pos(xLineStyle, "3") + # select 'Dot (Rounded)', but store the previous value + style = get_state_as_dict(xLineStyle)['SelectEntryText'] + select_pos(xLineStyle, "3") - xOKBtn = xFormatLineDlg.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + xOKBtn = xFormatLineDlg.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) - self.assertEqual(cap_style, 'Flat') - self.assertEqual(style, 'Long Dash Dot') + self.assertEqual(cap_style, 'Flat') + self.assertEqual(style, 'Long Dash Dot') - # check round cap setting, opening the line style dialog again - writer_doc.getCurrentController().select(writer_doc.getDrawPage()[1]) + # check round cap setting, opening the line style dialog again + writer_doc.getCurrentController().select(writer_doc.getDrawPage()[1]) - # wait for available line style setting - self.ui_test.wait_until_child_is_available('metricfield') + # wait for available line style setting + self.ui_test.wait_until_child_is_available('metricfield') - # line setting dialog window - self.ui_test.execute_dialog_through_command(".uno:FormatLine") - xFormatLineDlg = self.xUITest.getTopFocusWindow() + # line setting dialog window + self.ui_test.execute_dialog_through_command(".uno:FormatLine") + xFormatLineDlg = self.xUITest.getTopFocusWindow() - # get cap style combo box - xCapStyle = xFormatLineDlg.getChild("LB_CAP_STYLE") - cap_style = get_state_as_dict(xCapStyle)['SelectEntryText'] + # get cap style combo box + xCapStyle = xFormatLineDlg.getChild("LB_CAP_STYLE") + cap_style = get_state_as_dict(xCapStyle)['SelectEntryText'] - # get line style combo box - xLineStyle = xFormatLineDlg.getChild("LB_LINE_STYLE") + # get line style combo box + xLineStyle = xFormatLineDlg.getChild("LB_LINE_STYLE") - # select 'Dot', but store the previous value - style = get_state_as_dict(xLineStyle)['SelectEntryText'] - select_pos(xLineStyle, "2") + # select 'Dot', but store the previous value + style = get_state_as_dict(xLineStyle)['SelectEntryText'] + select_pos(xLineStyle, "2") - xOKBtn = xFormatLineDlg.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + xOKBtn = xFormatLineDlg.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) - # This was 'Flat' (set only dash style of the line style before) - self.assertEqual(cap_style, 'Round') - self.assertEqual(style, 'Dot (Rounded)') + # This was 'Flat' (set only dash style of the line style before) + self.assertEqual(cap_style, 'Round') + self.assertEqual(style, 'Dot (Rounded)') - # 2. check ROUND -> FLAT cap style change - writer_doc.getCurrentController().select(writer_doc.getDrawPage()[1]) + # 2. check ROUND -> FLAT cap style change + writer_doc.getCurrentController().select(writer_doc.getDrawPage()[1]) - # wait for available line style setting - self.ui_test.wait_until_child_is_available('metricfield') + # wait for available line style setting + self.ui_test.wait_until_child_is_available('metricfield') - # line setting dialog window - self.ui_test.execute_dialog_through_command(".uno:FormatLine") - xFormatLineDlg = self.xUITest.getTopFocusWindow() + # line setting dialog window + self.ui_test.execute_dialog_through_command(".uno:FormatLine") + xFormatLineDlg = self.xUITest.getTopFocusWindow() - # get cap style combo box - xCapStyle = xFormatLineDlg.getChild("LB_CAP_STYLE") - cap_style = get_state_as_dict(xCapStyle)['SelectEntryText'] + # get cap style combo box + xCapStyle = xFormatLineDlg.getChild("LB_CAP_STYLE") + cap_style = get_state_as_dict(xCapStyle)['SelectEntryText'] - # get line style combo box - xLineStyle = xFormatLineDlg.getChild("LB_LINE_STYLE") + # get line style combo box + xLineStyle = xFormatLineDlg.getChild("LB_LINE_STYLE") - style = get_state_as_dict(xLineStyle)['SelectEntryText'] + style = get_state_as_dict(xLineStyle)['SelectEntryText'] - xOKBtn = xFormatLineDlg.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + xOKBtn = xFormatLineDlg.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) - # This was 'Flat' (set only dash style of the line style before) - self.assertEqual(cap_style, 'Flat') - self.assertEqual(style, 'Dot') - - self.ui_test.close_doc() + # This was 'Flat' (set only dash style of the line style before) + self.assertEqual(cap_style, 'Flat') + self.assertEqual(style, 'Dot') # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests7/forms.py b/sw/qa/uitest/writer_tests7/forms.py index b931c5d6f3fb..d58d9a15ae91 100644 --- a/sw/qa/uitest/writer_tests7/forms.py +++ b/sw/qa/uitest/writer_tests7/forms.py @@ -14,201 +14,189 @@ class Forms(UITestCase): def test_tdf140486(self): - self.ui_test.load_file(get_url_for_data_file("tdf140486.odt")) + with self.ui_test.load_file(get_url_for_data_file("tdf140486.odt")): - self.xUITest.executeCommand(".uno:JumpToNextFrame") + self.xUITest.executeCommand(".uno:JumpToNextFrame") - self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties") - xChild = self.ui_test.wait_until_child_is_available('listbox-Empty string is NULL') - - # Without the fix in place, this test would have failed with - # AssertionError: 'Yes' != 'No' - self.assertEqual("Yes", get_state_as_dict(xChild)['SelectEntryText']) + self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties") + xChild = self.ui_test.wait_until_child_is_available('listbox-Empty string is NULL') - self.ui_test.close_doc() + # Without the fix in place, this test would have failed with + # AssertionError: 'Yes' != 'No' + self.assertEqual("Yes", get_state_as_dict(xChild)['SelectEntryText']) def test_tdf140198(self): - self.ui_test.load_file(get_url_for_data_file("tdf140198.odt")) + with self.ui_test.load_file(get_url_for_data_file("tdf140198.odt")): - self.xUITest.executeCommand(".uno:JumpToNextFrame") + self.xUITest.executeCommand(".uno:JumpToNextFrame") - self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties") - xChild = self.ui_test.wait_until_child_is_available('listbox-Text type') - - # Without the fix in place, this test would have failed with - # AssertionError: 'Multi-line' != 'Single-line' - self.assertEqual("Multi-line", get_state_as_dict(xChild)['SelectEntryText']) + self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties") + xChild = self.ui_test.wait_until_child_is_available('listbox-Text type') - self.ui_test.close_doc() + # Without the fix in place, this test would have failed with + # AssertionError: 'Multi-line' != 'Single-line' + self.assertEqual("Multi-line", get_state_as_dict(xChild)['SelectEntryText']) def test_tdf141084(self): # Reuse document from tdf#140239 - self.ui_test.load_file(get_url_for_data_file("tdf140239.odt")) + with self.ui_test.load_file(get_url_for_data_file("tdf140239.odt")): - self.xUITest.executeCommand(".uno:JumpToNextFrame") + self.xUITest.executeCommand(".uno:JumpToNextFrame") - self.ui_test.execute_modeless_dialog_through_command(".uno:FormProperties") - xURL = self.ui_test.wait_until_child_is_available('urlcontrol-URL') - xFrame = self.ui_test.wait_until_child_is_available('combobox-Frame') + self.ui_test.execute_modeless_dialog_through_command(".uno:FormProperties") + xURL = self.ui_test.wait_until_child_is_available('urlcontrol-URL') + xFrame = self.ui_test.wait_until_child_is_available('combobox-Frame') - xURL.executeAction("TYPE", mkPropertyValues({"TEXT": "1"})) - xURL.executeAction("TYPE", mkPropertyValues({"TEXT": "2"})) - xURL.executeAction("TYPE", mkPropertyValues({"TEXT": "3"})) - xURL.executeAction("TYPE", mkPropertyValues({"TEXT": "4"})) - xURL.executeAction("TYPE", mkPropertyValues({"TEXT": "5"})) + xURL.executeAction("TYPE", mkPropertyValues({"TEXT": "1"})) + xURL.executeAction("TYPE", mkPropertyValues({"TEXT": "2"})) + xURL.executeAction("TYPE", mkPropertyValues({"TEXT": "3"})) + xURL.executeAction("TYPE", mkPropertyValues({"TEXT": "4"})) + xURL.executeAction("TYPE", mkPropertyValues({"TEXT": "5"})) - # Without the fix in place, this test would have failed with - # AssertionError: '12345' != 'file:///tmp/tmp/5file:///tmp/tmp/4file://[40 chars]mp/1' - self.assertEqual("12345", get_state_as_dict(xURL)['Text']) + # Without the fix in place, this test would have failed with + # AssertionError: '12345' != 'file:///tmp/tmp/5file:///tmp/tmp/4file://[40 chars]mp/1' + self.assertEqual("12345", get_state_as_dict(xURL)['Text']) def test_tdf140239(self): - self.ui_test.load_file(get_url_for_data_file("tdf140239.odt")) + with self.ui_test.load_file(get_url_for_data_file("tdf140239.odt")): - self.xUITest.executeCommand(".uno:JumpToNextFrame") + self.xUITest.executeCommand(".uno:JumpToNextFrame") - self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties") - xAction = self.ui_test.wait_until_child_is_available('listbox-Action') - xURL = self.ui_test.wait_until_child_is_available('urlcontrol-URL') - xEntry = self.ui_test.wait_until_child_is_available('entry') - - self.assertEqual("None", get_state_as_dict(xAction)['SelectEntryText']) - self.assertEqual("false", get_state_as_dict(xURL)['Enabled']) + self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties") + xAction = self.ui_test.wait_until_child_is_available('listbox-Action') + xURL = self.ui_test.wait_until_child_is_available('urlcontrol-URL') + xEntry = self.ui_test.wait_until_child_is_available('entry') - select_by_text(xAction, "Open document/web page") + self.assertEqual("None", get_state_as_dict(xAction)['SelectEntryText']) + self.assertEqual("false", get_state_as_dict(xURL)['Enabled']) - self.assertEqual("Open document/web page", get_state_as_dict(xAction)['SelectEntryText']) - self.assertEqual("true", get_state_as_dict(xURL)['Enabled']) + select_by_text(xAction, "Open document/web page") - xURL.executeAction("TYPE", mkPropertyValues({"TEXT": "1"})) - xURL.executeAction("TYPE", mkPropertyValues({"TEXT": "2"})) - xURL.executeAction("TYPE", mkPropertyValues({"TEXT": "3"})) - xURL.executeAction("TYPE", mkPropertyValues({"TEXT": "4"})) - xURL.executeAction("TYPE", mkPropertyValues({"TEXT": "5"})) + self.assertEqual("Open document/web page", get_state_as_dict(xAction)['SelectEntryText']) + self.assertEqual("true", get_state_as_dict(xURL)['Enabled']) - # Without the fix in place, this test would have failed with - # AssertionError: '12345' != '54321' - self.assertEqual("12345", get_state_as_dict(xURL)['Text']) + xURL.executeAction("TYPE", mkPropertyValues({"TEXT": "1"})) + xURL.executeAction("TYPE", mkPropertyValues({"TEXT": "2"})) + xURL.executeAction("TYPE", mkPropertyValues({"TEXT": "3"})) + xURL.executeAction("TYPE", mkPropertyValues({"TEXT": "4"})) + xURL.executeAction("TYPE", mkPropertyValues({"TEXT": "5"})) - xEntry.executeAction("FOCUS", tuple()) - self.assertEqual("Push Button", get_state_as_dict(xEntry)['Text']) + # Without the fix in place, this test would have failed with + # AssertionError: '12345' != '54321' + self.assertEqual("12345", get_state_as_dict(xURL)['Text']) - xEntry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xEntry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xEntry.executeAction("TYPE", mkPropertyValues({"TEXT": "Push"})) + xEntry.executeAction("FOCUS", tuple()) + self.assertEqual("Push Button", get_state_as_dict(xEntry)['Text']) - # Move the focus to another element so the changes done before will take effect - xAction.executeAction("FOCUS", tuple()) + xEntry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xEntry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xEntry.executeAction("TYPE", mkPropertyValues({"TEXT": "Push"})) - # tdf#131522: Without the fix in place, this test would have failed with - # AssertionError: 'Push' != 'Push Button' - self.assertEqual("Push", get_state_as_dict(xEntry)['Text']) + # Move the focus to another element so the changes done before will take effect + xAction.executeAction("FOCUS", tuple()) - self.ui_test.close_doc() + # tdf#131522: Without the fix in place, this test would have failed with + # AssertionError: 'Push' != 'Push Button' + self.assertEqual("Push", get_state_as_dict(xEntry)['Text']) def test_tdf138701(self): # Reuse file from another test - self.ui_test.load_file(get_url_for_data_file("tdf140198.odt")) - - self.xUITest.executeCommand(".uno:JumpToNextFrame") + with self.ui_test.load_file(get_url_for_data_file("tdf140198.odt")): - self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties") - xChild = self.ui_test.wait_until_child_is_available('combobox-Data field') + self.xUITest.executeCommand(".uno:JumpToNextFrame") - xChild.executeAction("TYPE", mkPropertyValues({"TEXT": "1"})) - xChild.executeAction("TYPE", mkPropertyValues({"TEXT": "2"})) - xChild.executeAction("TYPE", mkPropertyValues({"TEXT": "3"})) - xChild.executeAction("TYPE", mkPropertyValues({"TEXT": "4"})) - xChild.executeAction("TYPE", mkPropertyValues({"TEXT": "5"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties") + xChild = self.ui_test.wait_until_child_is_available('combobox-Data field') - # Without the fix in place, this test would have failed with - # AssertionError: '12345' != '54321' - self.assertEqual("12345", get_state_as_dict(xChild)['Text']) + xChild.executeAction("TYPE", mkPropertyValues({"TEXT": "1"})) + xChild.executeAction("TYPE", mkPropertyValues({"TEXT": "2"})) + xChild.executeAction("TYPE", mkPropertyValues({"TEXT": "3"})) + xChild.executeAction("TYPE", mkPropertyValues({"TEXT": "4"})) + xChild.executeAction("TYPE", mkPropertyValues({"TEXT": "5"})) - self.ui_test.close_doc() + # Without the fix in place, this test would have failed with + # AssertionError: '12345' != '54321' + self.assertEqual("12345", get_state_as_dict(xChild)['Text']) def test_tdf139486(self): # Reuse file from another test - self.ui_test.load_file(get_url_for_data_file("tdf140198.odt")) - - change_measurement_unit(self, "Centimeter") + with self.ui_test.load_file(get_url_for_data_file("tdf140198.odt")): - self.xUITest.executeCommand(".uno:JumpToNextFrame") + change_measurement_unit(self, "Centimeter") - document = self.ui_test.get_component() - drawPage = document.getDrawPages().getByIndex(0) - shape = drawPage.getByIndex(0) - self.assertEqual(13996, shape.getSize().Width) - self.assertEqual(2408, shape.getSize().Height) + self.xUITest.executeCommand(".uno:JumpToNextFrame") - self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties") - xWidth = self.ui_test.wait_until_child_is_available('numericfield-Width') - xHeight = self.ui_test.wait_until_child_is_available('numericfield-Height') + document = self.ui_test.get_component() + drawPage = document.getDrawPages().getByIndex(0) + shape = drawPage.getByIndex(0) + self.assertEqual(13996, shape.getSize().Width) + self.assertEqual(2408, shape.getSize().Height) - self.assertEqual("14.00 cm", get_state_as_dict(xWidth)['Text']) - self.assertEqual("2.41 cm", get_state_as_dict(xHeight)['Text']) + self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties") + xWidth = self.ui_test.wait_until_child_is_available('numericfield-Width') + xHeight = self.ui_test.wait_until_child_is_available('numericfield-Height') - xWidth.executeAction("FOCUS", tuple()) - xWidth.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xWidth.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xWidth.executeAction("TYPE", mkPropertyValues({"TEXT":"20 cm"})) + self.assertEqual("14.00 cm", get_state_as_dict(xWidth)['Text']) + self.assertEqual("2.41 cm", get_state_as_dict(xHeight)['Text']) - self.assertEqual("20 cm", get_state_as_dict(xWidth)['Text']) + xWidth.executeAction("FOCUS", tuple()) + xWidth.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xWidth.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xWidth.executeAction("TYPE", mkPropertyValues({"TEXT":"20 cm"})) - xHeight.executeAction("FOCUS", tuple()) - xHeight.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xHeight.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xHeight.executeAction("TYPE", mkPropertyValues({"TEXT":"5 cm"})) + self.assertEqual("20 cm", get_state_as_dict(xWidth)['Text']) - self.assertEqual("5 cm", get_state_as_dict(xHeight)['Text']) + xHeight.executeAction("FOCUS", tuple()) + xHeight.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xHeight.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xHeight.executeAction("TYPE", mkPropertyValues({"TEXT":"5 cm"})) - # Move the focus to another element so the changes done before take effect on the document - xDialog = self.xUITest.getTopFocusWindow() - xDialog.getChild('numericfield-PositionY').executeAction("FOCUS", tuple()) + self.assertEqual("5 cm", get_state_as_dict(xHeight)['Text']) - # Without the fix in place, the size of the form wouldn't have changed - self.assertEqual(20001, shape.getSize().Width) - self.assertEqual(5001, shape.getSize().Height) + # Move the focus to another element so the changes done before take effect on the document + xDialog = self.xUITest.getTopFocusWindow() + xDialog.getChild('numericfield-PositionY').executeAction("FOCUS", tuple()) - self.ui_test.close_doc() + # Without the fix in place, the size of the form wouldn't have changed + self.assertEqual(20001, shape.getSize().Width) + self.assertEqual(5001, shape.getSize().Height) def test_tdf138271(self): - self.ui_test.load_file(get_url_for_data_file("tdf138271.odt")) + with self.ui_test.load_file(get_url_for_data_file("tdf138271.odt")): - self.xUITest.executeCommand(".uno:JumpToNextFrame") + self.xUITest.executeCommand(".uno:JumpToNextFrame") - aOldValue = ["-1000000.00", "1000000.00"] - aNewValue = ["-100.00", "100.00"] + aOldValue = ["-1000000.00", "1000000.00"] + aNewValue = ["-100.00", "100.00"] - for i, name in enumerate(['formattedcontrol-Value min.', 'formattedcontrol-Value max.']): + for i, name in enumerate(['formattedcontrol-Value min.', 'formattedcontrol-Value max.']): - self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties") - xChild = self.ui_test.wait_until_child_is_available(name) - - self.assertEqual(aOldValue[i], get_state_as_dict(xChild)['Text']) + self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties") + xChild = self.ui_test.wait_until_child_is_available(name) - xChild.executeAction("FOCUS", tuple()) - xChild.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xChild.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xChild.executeAction("TYPE", mkPropertyValues({"TEXT": aNewValue[i]})) + self.assertEqual(aOldValue[i], get_state_as_dict(xChild)['Text']) - #Close the dialog and open it again - self.xUITest.executeCommand(".uno:ControlProperties") + xChild.executeAction("FOCUS", tuple()) + xChild.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xChild.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xChild.executeAction("TYPE", mkPropertyValues({"TEXT": aNewValue[i]})) - self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties") - xChild = self.ui_test.wait_until_child_is_available(name) + #Close the dialog and open it again + self.xUITest.executeCommand(".uno:ControlProperties") - # Without the fix in place, this test would have failed here because - # the values wouldn't have changed - self.assertEqual(aNewValue[i], get_state_as_dict(xChild)['Text']) + self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties") + xChild = self.ui_test.wait_until_child_is_available(name) - self.xUITest.executeCommand(".uno:ControlProperties") + # Without the fix in place, this test would have failed here because + # the values wouldn't have changed + self.assertEqual(aNewValue[i], get_state_as_dict(xChild)['Text']) - self.ui_test.close_doc() + self.xUITest.executeCommand(".uno:ControlProperties") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests7/tdf104795.py b/sw/qa/uitest/writer_tests7/tdf104795.py index 1fcc20f5b013..58316db101b5 100644 --- a/sw/qa/uitest/writer_tests7/tdf104795.py +++ b/sw/qa/uitest/writer_tests7/tdf104795.py @@ -13,19 +13,17 @@ from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file class tdf104795(UITestCase): def test_tdf104795(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf104795.odt")) - self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.load_file(get_url_for_data_file("tdf104795.odt")) as writer_doc: + self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties") + xDialog = self.xUITest.getTopFocusWindow() - sShowSignedText = get_state_as_dict(xDialog.getChild('showsigned'))['Text'] + sShowSignedText = get_state_as_dict(xDialog.getChild('showsigned'))['Text'] - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) - # Without the fix in place, this test would have failed with - # AssertionError: '12/19/2016, 23:06:31, timur.davletshin' != '12/19/2016, 00:00:00, !!br0ken!!' - self.assertEqual("12/19/2016, 23:06:31, timur.davletshin", sShowSignedText.split('@')[0]) - - self.ui_test.close_doc() + # Without the fix in place, this test would have failed with + # AssertionError: '12/19/2016, 23:06:31, timur.davletshin' != '12/19/2016, 00:00:00, !!br0ken!!' + self.assertEqual("12/19/2016, 23:06:31, timur.davletshin", sShowSignedText.split('@')[0]) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests7/tdf119661.py b/sw/qa/uitest/writer_tests7/tdf119661.py index 9d09d25bb3c7..9ad178f8a722 100644 --- a/sw/qa/uitest/writer_tests7/tdf119661.py +++ b/sw/qa/uitest/writer_tests7/tdf119661.py @@ -77,18 +77,16 @@ class tdf119661(UITestCase): # Close the Writer document self.ui_test.close_doc() - self.ui_test.load_file(systemPathToFileUrl(xFilePath)) + with self.ui_test.load_file(systemPathToFileUrl(xFilePath)): - self.xUITest.executeCommand(".uno:LinkDialog") + self.xUITest.executeCommand(".uno:LinkDialog") - # 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("writer_edit" in xMainWin.getChildren()) - - self.ui_test.close_doc() + # 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("writer_edit" in xMainWin.getChildren()) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests7/tdf122780.py b/sw/qa/uitest/writer_tests7/tdf122780.py index 09f881c5c781..45f6a75b5906 100644 --- a/sw/qa/uitest/writer_tests7/tdf122780.py +++ b/sw/qa/uitest/writer_tests7/tdf122780.py @@ -13,16 +13,14 @@ from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file class tdf122780(UITestCase): def test_tdf122780(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf122780.docx")) - self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties") + with self.ui_test.load_file(get_url_for_data_file("tdf122780.docx")) as writer_doc: + self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties") - # Without the fix in place, this test would have hung here - xDialog = self.xUITest.getTopFocusWindow() - self.assertEqual("Normal_x005F", get_state_as_dict(xDialog.getChild('showtemplate'))['Text'][:12]) - self.assertEqual(32767, len(get_state_as_dict(xDialog.getChild('showtemplate'))['Text'])) - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) - - self.ui_test.close_doc() + # Without the fix in place, this test would have hung here + xDialog = self.xUITest.getTopFocusWindow() + self.assertEqual("Normal_x005F", get_state_as_dict(xDialog.getChild('showtemplate'))['Text'][:12]) + self.assertEqual(32767, len(get_state_as_dict(xDialog.getChild('showtemplate'))['Text'])) + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests7/tdf131936.py b/sw/qa/uitest/writer_tests7/tdf131936.py index db0c4ae3b47c..7e147f006326 100644 --- a/sw/qa/uitest/writer_tests7/tdf131936.py +++ b/sw/qa/uitest/writer_tests7/tdf131936.py @@ -10,18 +10,16 @@ import time class tdf131936(UITestCase): def test_tdf131936_saveas_docx_version(self): - self.ui_test.load_file(get_url_for_data_file("tdf131936.docx")) + with self.ui_test.load_file(get_url_for_data_file("tdf131936.docx")): - self.ui_test.execute_dialog_through_command(".uno:SaveAs") - time.sleep(DEFAULT_SLEEP) - xDialog = self.xUITest.getTopFocusWindow() - xFileTypeCombo = xDialog.getChild("file_type") - state = get_state_as_dict(xFileTypeCombo) - self.assertEqual(state["SelectEntryText"], "Office Open XML Text (Transitional) (.docx)") + self.ui_test.execute_dialog_through_command(".uno:SaveAs") + time.sleep(DEFAULT_SLEEP) + xDialog = self.xUITest.getTopFocusWindow() + xFileTypeCombo = xDialog.getChild("file_type") + state = get_state_as_dict(xFileTypeCombo) + self.assertEqual(state["SelectEntryText"], "Office Open XML Text (Transitional) (.docx)") - xCancel = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancel) - - self.ui_test.close_doc() + xCancel = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancel) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests7/tdf132169.py b/sw/qa/uitest/writer_tests7/tdf132169.py index 7914fbf85e15..ef1ec666c029 100644 --- a/sw/qa/uitest/writer_tests7/tdf132169.py +++ b/sw/qa/uitest/writer_tests7/tdf132169.py @@ -11,38 +11,36 @@ from uitest.uihelper.common import change_measurement_unit class tdf132169(UITestCase): def test_tdf132169(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("shape.odt")) + with self.ui_test.load_file(get_url_for_data_file("shape.odt")) as writer_doc: - #set measurement to points - change_measurement_unit(self, "Point") + #set measurement to points + change_measurement_unit(self, "Point") - self.xUITest.executeCommand(".uno:JumpToNextFrame") + self.xUITest.executeCommand(".uno:JumpToNextFrame") - #wait until the toolbar is available - xLineMetric = self.ui_test.wait_until_child_is_available('metricfield') - self.assertEqual(get_state_as_dict(xLineMetric)["Text"], "0.0 pt") + #wait until the toolbar is available + xLineMetric = self.ui_test.wait_until_child_is_available('metricfield') + self.assertEqual(get_state_as_dict(xLineMetric)["Text"], "0.0 pt") - #Check changing value from dialog also works - self.ui_test.execute_dialog_through_command(".uno:FormatLine") - xFormatLineDlg = self.xUITest.getTopFocusWindow() - xWidth = xFormatLineDlg.getChild('MTR_FLD_LINE_WIDTH') - type_text(xWidth, "4.0") - xOKBtn = xFormatLineDlg.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + #Check changing value from dialog also works + self.ui_test.execute_dialog_through_command(".uno:FormatLine") + xFormatLineDlg = self.xUITest.getTopFocusWindow() + xWidth = xFormatLineDlg.getChild('MTR_FLD_LINE_WIDTH') + type_text(xWidth, "4.0") + xOKBtn = xFormatLineDlg.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) - self.ui_test.wait_until_property_is_updated(xLineMetric, "Text", "4.0 pt") - self.assertEqual(get_state_as_dict(xLineMetric)["Text"], "4.0 pt") + self.ui_test.wait_until_property_is_updated(xLineMetric, "Text", "4.0 pt") + self.assertEqual(get_state_as_dict(xLineMetric)["Text"], "4.0 pt") - xLineMetric.executeAction("UP", tuple()) + xLineMetric.executeAction("UP", tuple()) - document = self.ui_test.get_component() - drawPage = document.getDrawPages().getByIndex(0) - shape = drawPage.getByIndex(0) + document = self.ui_test.get_component() + drawPage = document.getDrawPages().getByIndex(0) + shape = drawPage.getByIndex(0) - #Without the fix in place, it would have been 310 - self.assertEqual(shape.LineWidth, 176) - - self.ui_test.close_doc() + #Without the fix in place, it would have been 310 + self.assertEqual(shape.LineWidth, 176) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests7/tdf134243.py b/sw/qa/uitest/writer_tests7/tdf134243.py index 53e9109e22bb..e41cb5ce410c 100644 --- a/sw/qa/uitest/writer_tests7/tdf134243.py +++ b/sw/qa/uitest/writer_tests7/tdf134243.py @@ -10,17 +10,15 @@ from uitest.uihelper.common import get_url_for_data_file class tdf134243(UITestCase): def test_tdf134243(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf134243.odt")) + with self.ui_test.load_file(get_url_for_data_file("tdf134243.odt")) as writer_doc: - # Without the fix in place, it would hung launching the mailmerge wizard - self.ui_test.execute_dialog_through_command(".uno:MailMergeWizard") + # Without the fix in place, it would hung launching the mailmerge wizard + self.ui_test.execute_dialog_through_command(".uno:MailMergeWizard") - xDialog = self.xUITest.getTopFocusWindow() + xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) - - self.ui_test.close_doc() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests7/tdf137802.py b/sw/qa/uitest/writer_tests7/tdf137802.py index a4067410f41c..99c6085f29dd 100644 --- a/sw/qa/uitest/writer_tests7/tdf137802.py +++ b/sw/qa/uitest/writer_tests7/tdf137802.py @@ -13,67 +13,65 @@ class tdf137802(UITestCase): def test_tdf137802(self): - self.ui_test.load_file(get_url_for_data_file("tdf137802.odt")) + with self.ui_test.load_file(get_url_for_data_file("tdf137802.odt")): - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + document = self.ui_test.get_component() - self.assertEqual(document.DrawPage.getCount(), 2) - self.assertEqual(AT_PARAGRAPH, document.DrawPage.getByIndex(0).AnchorType) + self.assertEqual(document.DrawPage.getCount(), 2) + self.assertEqual(AT_PARAGRAPH, document.DrawPage.getByIndex(0).AnchorType) - self.xUITest.executeCommand(".uno:JumpToNextFrame") + self.xUITest.executeCommand(".uno:JumpToNextFrame") - self.ui_test.wait_until_child_is_available('metricfield') + self.ui_test.wait_until_child_is_available('metricfield') - self.ui_test.execute_dialog_through_command(".uno:TransformDialog") + self.ui_test.execute_dialog_through_command(".uno:TransformDialog") - xDialog = self.xUITest.getTopFocusWindow() + xDialog = self.xUITest.getTopFocusWindow() - xDialog.getChild('topage').executeAction("CLICK", tuple()) + xDialog.getChild('topage').executeAction("CLICK", tuple()) - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) - self.assertEqual(AT_PAGE, document.DrawPage.getByIndex(0).AnchorType) + self.assertEqual(AT_PAGE, document.DrawPage.getByIndex(0).AnchorType) - self.assertEqual(document.DrawPage.getCount(), 2) + self.assertEqual(document.DrawPage.getCount(), 2) - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") - # When shape 1 is selected, esc key doesn't put the focus back to the document - # because the shape has a textbox. Move the focus to another shape with tab key - # and then use escape - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ESC"})) + # When shape 1 is selected, esc key doesn't put the focus back to the document + # because the shape has a textbox. Move the focus to another shape with tab key + # and then use escape + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ESC"})) - # Wait until the shape is deselected and the cursor is on the document - self.ui_test.wait_until_child_is_available('FontNameBox') + # Wait until the shape is deselected and the cursor is on the document + self.ui_test.wait_until_child_is_available('FontNameBox') - # Delete the second paragraph. Shape 2 is anchored to this paragraph - # so it should be deleted - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) + # Delete the second paragraph. Shape 2 is anchored to this paragraph + # so it should be deleted + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"})) - self.assertEqual(document.DrawPage.getCount(), 1) + self.assertEqual(document.DrawPage.getCount(), 1) - self.xUITest.executeCommand(".uno:JumpToNextFrame") - self.xUITest.executeCommand(".uno:Delete") + self.xUITest.executeCommand(".uno:JumpToNextFrame") + self.xUITest.executeCommand(".uno:Delete") - self.assertEqual(document.DrawPage.getCount(), 0) + self.assertEqual(document.DrawPage.getCount(), 0) - self.xUITest.executeCommand(".uno:Undo") + self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.DrawPage.getCount(), 1) + self.assertEqual(document.DrawPage.getCount(), 1) - self.xUITest.executeCommand(".uno:Undo") + self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.DrawPage.getCount(), 2) + self.assertEqual(document.DrawPage.getCount(), 2) - self.xUITest.executeCommand(".uno:Undo") + self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(AT_PARAGRAPH, document.DrawPage.getByIndex(0).AnchorType) - - self.ui_test.close_doc() + self.assertEqual(AT_PARAGRAPH, document.DrawPage.getByIndex(0).AnchorType) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests7/tdf137803.py b/sw/qa/uitest/writer_tests7/tdf137803.py index 3e48c267ca55..3549cc9d0b77 100644 --- a/sw/qa/uitest/writer_tests7/tdf137803.py +++ b/sw/qa/uitest/writer_tests7/tdf137803.py @@ -11,42 +11,41 @@ from uitest.uihelper.common import get_url_for_data_file class tdf137803(UITestCase): def test_tdf137803(self): # load the sample file - self.ui_test.load_file(get_url_for_data_file("tdf137803.odt")) - document = self.ui_test.get_component() + with self.ui_test.load_file(get_url_for_data_file("tdf137803.odt")): + document = self.ui_test.get_component() - # select the shape - self.xUITest.executeCommand(".uno:JumpToNextFrame") - self.ui_test.wait_until_child_is_available('metricfield') + # select the shape + self.xUITest.executeCommand(".uno:JumpToNextFrame") + self.ui_test.wait_until_child_is_available('metricfield') - # open textattrs dialog - self.ui_test.execute_dialog_through_command(".uno:TextAttributes") - TextDialog = self.xUITest.getTopFocusWindow(); + # open textattrs dialog + self.ui_test.execute_dialog_through_command(".uno:TextAttributes") + TextDialog = self.xUITest.getTopFocusWindow(); - # check autosize on - TSB_AUTOGROW_SIZE = TextDialog.getChild('TSB_AUTOGROW_SIZE') - TSB_AUTOGROW_SIZE.executeAction("CLICK",tuple()) - ok = TextDialog.getChild("ok") - self.ui_test.close_dialog_through_button(ok) + # check autosize on + TSB_AUTOGROW_SIZE = TextDialog.getChild('TSB_AUTOGROW_SIZE') + TSB_AUTOGROW_SIZE.executeAction("CLICK",tuple()) + ok = TextDialog.getChild("ok") + self.ui_test.close_dialog_through_button(ok) - # get the shape - drawPage = document.getDrawPages().getByIndex(0) - shape = drawPage.getByIndex(0) + # get the shape + drawPage = document.getDrawPages().getByIndex(0) + shape = drawPage.getByIndex(0) - # and the textbox - frame = shape.getText() + # and the textbox + frame = shape.getText() - # get the positions - shapeYPos = shape.getPropertyValue("VertOrientPosition") - frameYPos = frame.getPropertyValue("VertOrientPosition") - shpsize = shape.getSize().Height + # get the positions + shapeYPos = shape.getPropertyValue("VertOrientPosition") + frameYPos = frame.getPropertyValue("VertOrientPosition") + shpsize = shape.getSize().Height - xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') - xToolkit.processEventsToIdle() + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.processEventsToIdle() - # without the fix, at this point the textbox falls apart so this won't be passed - self.assertLess(frameYPos, shapeYPos + shpsize) + # without the fix, at this point the textbox falls apart so this won't be passed + self.assertLess(frameYPos, shapeYPos + shpsize) - # close the doc - self.ui_test.close_doc() + # close the doc # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests7/tdf139301.py b/sw/qa/uitest/writer_tests7/tdf139301.py index 064018889031..7436dce42bda 100644 --- a/sw/qa/uitest/writer_tests7/tdf139301.py +++ b/sw/qa/uitest/writer_tests7/tdf139301.py @@ -12,58 +12,54 @@ class tdf139301(UITestCase): styles = ('Long Dash', 'Long Dash Dot', 'Long Dot', 'Double Dash', 'Double Dash Dot', 'Double Dash Dot Dot', 'Dash', 'Dash Dot', 'Dash Dot Dot', 'Dot') def test_tdf139301(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf127166_prstDash_Word97.docx")) + with self.ui_test.load_file(get_url_for_data_file("tdf127166_prstDash_Word97.docx")) as writer_doc: - for i in range(len(self.styles)): - # select next line shape - writer_doc.getCurrentController().select(writer_doc.getDrawPage()[i]) + for i in range(len(self.styles)): + # select next line shape + writer_doc.getCurrentController().select(writer_doc.getDrawPage()[i]) - # wait for available line style setting - self.ui_test.wait_until_child_is_available('metricfield') + # wait for available line style setting + self.ui_test.wait_until_child_is_available('metricfield') - # line setting dialog window - self.ui_test.execute_dialog_through_command(".uno:FormatLine") - xFormatLineDlg = self.xUITest.getTopFocusWindow() - # get line style combo box - xLineStyle = xFormatLineDlg.getChild("LB_LINE_STYLE") + # line setting dialog window + self.ui_test.execute_dialog_through_command(".uno:FormatLine") + xFormatLineDlg = self.xUITest.getTopFocusWindow() + # get line style combo box + xLineStyle = xFormatLineDlg.getChild("LB_LINE_STYLE") - # check preset line style - style = get_state_as_dict(xLineStyle)['SelectEntryText'] + # check preset line style + style = get_state_as_dict(xLineStyle)['SelectEntryText'] - xOKBtn = xFormatLineDlg.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + xOKBtn = xFormatLineDlg.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) - self.assertEqual(style, self.styles[i]) - - self.ui_test.close_doc() + self.assertEqual(style, self.styles[i]) def test_round_cap(self): - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf127166_prstDash_round_cap.docx")) - - style_name_extension = ' (Rounded)' + with self.ui_test.load_file(get_url_for_data_file("tdf127166_prstDash_round_cap.docx")) as writer_doc: - for i in range(len(self.styles)): - # select next line shape - writer_doc.getCurrentController().select(writer_doc.getDrawPage()[i]) + style_name_extension = ' (Rounded)' - # wait for available line style setting - self.ui_test.wait_until_child_is_available('metricfield') + for i in range(len(self.styles)): + # select next line shape + writer_doc.getCurrentController().select(writer_doc.getDrawPage()[i]) - # line setting dialog window - self.ui_test.execute_dialog_through_command(".uno:FormatLine") - xFormatLineDlg = self.xUITest.getTopFocusWindow() - # get line style combo box - xLineStyle = xFormatLineDlg.getChild("LB_LINE_STYLE") + # wait for available line style setting + self.ui_test.wait_until_child_is_available('metricfield') - # check preset line style - style = get_state_as_dict(xLineStyle)['SelectEntryText'] + # line setting dialog window + self.ui_test.execute_dialog_through_command(".uno:FormatLine") + xFormatLineDlg = self.xUITest.getTopFocusWindow() + # get line style combo box + xLineStyle = xFormatLineDlg.getChild("LB_LINE_STYLE") - xOKBtn = xFormatLineDlg.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + # check preset line style + style = get_state_as_dict(xLineStyle)['SelectEntryText'] - self.assertEqual(style, self.styles[i] + style_name_extension) + xOKBtn = xFormatLineDlg.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) - self.ui_test.close_doc() + self.assertEqual(style, self.styles[i] + style_name_extension) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests7/tdf140117.py b/sw/qa/uitest/writer_tests7/tdf140117.py index c6244841241e..a1790e642a64 100644 --- a/sw/qa/uitest/writer_tests7/tdf140117.py +++ b/sw/qa/uitest/writer_tests7/tdf140117.py @@ -13,51 +13,49 @@ from uitest.uihelper.common import get_url_for_data_file class tdf140117(UITestCase): def test_tdf140117(self): # load the sample file - self.ui_test.load_file(get_url_for_data_file("tdf140117.fodt")) - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - document = self.ui_test.get_component() - - for i in range(3): - xWriterEdit.executeAction("GOTO", mkPropertyValues({"PAGE": "2"})) - - self.xUITest.executeCommand(".uno:JumpToHeader") - - xPageSytle = document.getStyleFamilies().getByIndex(2) - xHeaderText = xPageSytle.getByIndex(0).HeaderText.String - xHeaderFirstText = xPageSytle.getByIndex(0).HeaderTextFirst.String - xHeaderLeftText = xPageSytle.getByIndex(0).HeaderTextLeft.String - xHeaderRightText = xPageSytle.getByIndex(0).HeaderTextRight.String - - # Option "same content on left and right pages" is false, - # insert text "XXXX" before actual header text "left" on page 2 - if i == 0: - type_text(xWriterEdit, "XXXX") - - # Option "same content on left and right pages" is true, - # header of page 2 contains the same text as page 1 - elif i == 1: - self.assertEqual("right", xHeaderText) - self.assertEqual("right", xHeaderRightText) - - # Option "same content on left and right pages" is false again. - # This was "right" instead of keeping the header content disabled - # temporarily for the second interaction of the loop. - elif i == 2: - self.assertEqual("XXXXleft", xHeaderLeftText) - - self.ui_test.execute_dialog_through_command(".uno:PageDialog") - PageDialog = self.xUITest.getTopFocusWindow(); - - xTabs = PageDialog.getChild("tabcontrol") - select_pos(xTabs, "4") - - # Change option "same content on left and right pages" for the next iteration - Button = xTabs.getChild('checkSameLR') - Button.executeAction("CLICK", tuple()) - ok = PageDialog.getChild("ok") - self.ui_test.close_dialog_through_button(ok) - - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("tdf140117.fodt")): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + document = self.ui_test.get_component() + + for i in range(3): + xWriterEdit.executeAction("GOTO", mkPropertyValues({"PAGE": "2"})) + + self.xUITest.executeCommand(".uno:JumpToHeader") + + xPageSytle = document.getStyleFamilies().getByIndex(2) + xHeaderText = xPageSytle.getByIndex(0).HeaderText.String + xHeaderFirstText = xPageSytle.getByIndex(0).HeaderTextFirst.String + xHeaderLeftText = xPageSytle.getByIndex(0).HeaderTextLeft.String + xHeaderRightText = xPageSytle.getByIndex(0).HeaderTextRight.String + + # Option "same content on left and right pages" is false, + # insert text "XXXX" before actual header text "left" on page 2 + if i == 0: + type_text(xWriterEdit, "XXXX") + + # Option "same content on left and right pages" is true, + # header of page 2 contains the same text as page 1 + elif i == 1: + self.assertEqual("right", xHeaderText) + self.assertEqual("right", xHeaderRightText) + + # Option "same content on left and right pages" is false again. + # This was "right" instead of keeping the header content disabled + # temporarily for the second interaction of the loop. + elif i == 2: + self.assertEqual("XXXXleft", xHeaderLeftText) + + self.ui_test.execute_dialog_through_command(".uno:PageDialog") + PageDialog = self.xUITest.getTopFocusWindow(); + + xTabs = PageDialog.getChild("tabcontrol") + select_pos(xTabs, "4") + + # Change option "same content on left and right pages" for the next iteration + Button = xTabs.getChild('checkSameLR') + Button.executeAction("CLICK", tuple()) + ok = PageDialog.getChild("ok") + self.ui_test.close_dialog_through_button(ok) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests7/tdf141158.py b/sw/qa/uitest/writer_tests7/tdf141158.py index e29c36418958..6624530ee3cd 100644 --- a/sw/qa/uitest/writer_tests7/tdf141158.py +++ b/sw/qa/uitest/writer_tests7/tdf141158.py @@ -10,32 +10,31 @@ import time class TestTdf141158(UITestCase): def test_tdf141158(self): # load the desired bugdoc - self.ui_test.load_file(get_url_for_data_file("TestHiddenHeadersFooters.docx")) - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - document = self.ui_test.get_component() - # open the page styles dialog and select the headers tab - self.xUITest.executeCommand(".uno:PageStyleName") - TemplateDialog8 = self.xUITest.getTopFocusWindow() - xTabs = TemplateDialog8.getChild("tabcontrol") - select_pos(xTabs, "4") - # make the same left right page header state to off and apply the setting - checkSameLR = TemplateDialog8.getChild("checkSameLR") - checkSameLR.executeAction("CLICK",tuple()) - ok = TemplateDialog8.getChild("ok") - self.ui_test.close_dialog_through_button(ok) - time.sleep(1) - # go to the left header - xWriterEdit.executeAction("GOTO", mkPropertyValues({"PAGE": "2"})) - self.xUITest.executeCommand(".uno:JumpToHeader") - # get the text of the header - xPageSytle = document.getStyleFamilies().getByIndex(2) - xHeaderText = xPageSytle.getByIndex(0).HeaderText.String - xHeaderLeftText = xPageSytle.getByIndex(0).HeaderTextLeft.String - # without the fix in place it was "Right Header" (lost hidden left header), - # with the fix it should pass... - self.assertEqual("Left Header", xHeaderLeftText) - time.sleep(1) - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("TestHiddenHeadersFooters.docx")): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + document = self.ui_test.get_component() + # open the page styles dialog and select the headers tab + self.xUITest.executeCommand(".uno:PageStyleName") + TemplateDialog8 = self.xUITest.getTopFocusWindow() + xTabs = TemplateDialog8.getChild("tabcontrol") + select_pos(xTabs, "4") + # make the same left right page header state to off and apply the setting + checkSameLR = TemplateDialog8.getChild("checkSameLR") + checkSameLR.executeAction("CLICK",tuple()) + ok = TemplateDialog8.getChild("ok") + self.ui_test.close_dialog_through_button(ok) + time.sleep(1) + # go to the left header + xWriterEdit.executeAction("GOTO", mkPropertyValues({"PAGE": "2"})) + self.xUITest.executeCommand(".uno:JumpToHeader") + # get the text of the header + xPageSytle = document.getStyleFamilies().getByIndex(2) + xHeaderText = xPageSytle.getByIndex(0).HeaderText.String + xHeaderLeftText = xPageSytle.getByIndex(0).HeaderTextLeft.String + # without the fix in place it was "Right Header" (lost hidden left header), + # with the fix it should pass... + self.assertEqual("Left Header", xHeaderLeftText) + time.sleep(1) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests7/tdf141557.py b/sw/qa/uitest/writer_tests7/tdf141557.py index c641cd3e23f3..3d25c7908d99 100644 --- a/sw/qa/uitest/writer_tests7/tdf141557.py +++ b/sw/qa/uitest/writer_tests7/tdf141557.py @@ -12,29 +12,27 @@ from uitest.uihelper.common import get_url_for_data_file class tdf141557(UITestCase): def test_tdf141557(self): # load the sample file - self.ui_test.load_file(get_url_for_data_file("tdf141557.docx")) - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - document = self.ui_test.get_component() + with self.ui_test.load_file(get_url_for_data_file("tdf141557.docx")): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + document = self.ui_test.get_component() - self.assertEqual(AS_CHARACTER, document.DrawPage.getByIndex(0).AnchorType) + self.assertEqual(AS_CHARACTER, document.DrawPage.getByIndex(0).AnchorType) - self.xUITest.executeCommand(".uno:JumpToNextFrame") + self.xUITest.executeCommand(".uno:JumpToNextFrame") - self.ui_test.wait_until_child_is_available('metricfield') + self.ui_test.wait_until_child_is_available('metricfield') - self.ui_test.execute_dialog_through_command(".uno:TransformDialog") + self.ui_test.execute_dialog_through_command(".uno:TransformDialog") - xDialog = self.xUITest.getTopFocusWindow() + xDialog = self.xUITest.getTopFocusWindow() - xDialog.getChild('topara').executeAction("CLICK", tuple()) + xDialog.getChild('topara').executeAction("CLICK", tuple()) - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) - # Without the fix in place, at this point crash occurs. - self.assertEqual(AT_PARAGRAPH, document.DrawPage.getByIndex(0).AnchorType) - - self.ui_test.close_doc() + # Without the fix in place, at this point crash occurs. + self.assertEqual(AT_PARAGRAPH, document.DrawPage.getByIndex(0).AnchorType) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests7/tdf46561.py b/sw/qa/uitest/writer_tests7/tdf46561.py index 1c90dc3c404a..1c34a89a71b4 100644 --- a/sw/qa/uitest/writer_tests7/tdf46561.py +++ b/sw/qa/uitest/writer_tests7/tdf46561.py @@ -26,75 +26,73 @@ class tdf46561(UITestCase): self.assertEqual(right, xHeaderTextRight) def test_tdf46561(self): - self.ui_test.load_file(get_url_for_data_file("tdf46561.odt")) - self.document = self.ui_test.get_component() - self.check_header_texts(master="right", first="1st", left="left", right="right") - - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - xWriterEdit.executeAction("GOTO", mkPropertyValues({"PAGE": "2"})) - self.xUITest.executeCommand(".uno:JumpToHeader") - - # Switch "same left and right page headers" on and off a few times - for _ in range(4): - self.ui_test.execute_dialog_through_command(".uno:PageDialog") - PageDialog = self.xUITest.getTopFocusWindow(); - - xTabs = PageDialog.getChild("tabcontrol") - select_pos(xTabs, "4") - - Button = xTabs.getChild('checkSameLR') - Button.executeAction("CLICK",tuple()) - ok = PageDialog.getChild("ok") - self.ui_test.close_dialog_through_button(ok) - - # We should be back to the starting state after 2*k on/off changes - self.check_header_texts(master="right", first="1st", left="left", right="right") - - # Enter some additional text in the left page header - type_text(xWriterEdit, "XXXX") - self.check_header_texts(master="right", first="1st", left="XXXXleft", right="right") - - # Now go back one change (before entering "XXXX") - self.xUITest.executeCommand(".uno:Undo") - self.check_header_texts(master="right", first="1st", left="left", right="right") - - # Undo the fourth change - self.xUITest.executeCommand(".uno:Undo") - self.check_header_texts(master="right", first="1st", left="right", right="right") - - # Undo the third change - self.xUITest.executeCommand(".uno:Undo") - self.check_header_texts(master="right", first="1st", left="left", right="right") - - # Undo the second change - self.xUITest.executeCommand(".uno:Undo") - self.check_header_texts(master="right", first="1st", left="right", right="right") - - # Undo the first change - self.xUITest.executeCommand(".uno:Undo") - self.check_header_texts(master="right", first="1st", left="left", right="right") - - # Redo the first change - self.xUITest.executeCommand(".uno:Redo") - self.check_header_texts(master="right", first="1st", left="right", right="right") - - # Redo the second change - self.xUITest.executeCommand(".uno:Redo") - self.check_header_texts(master="right", first="1st", left="left", right="right") - - # Redo the third change - self.xUITest.executeCommand(".uno:Redo") - self.check_header_texts(master="right", first="1st", left="right", right="right") - - # Redo the fourth change - self.xUITest.executeCommand(".uno:Redo") - self.check_header_texts(master="right", first="1st", left="left", right="right") - - # Redo the final change - self.xUITest.executeCommand(".uno:Redo") - self.check_header_texts(master="right", first="1st", left="XXXXleft", right="right") - - self.ui_test.close_doc() + with self.ui_test.load_file(get_url_for_data_file("tdf46561.odt")): + self.document = self.ui_test.get_component() + self.check_header_texts(master="right", first="1st", left="left", right="right") + + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + xWriterEdit.executeAction("GOTO", mkPropertyValues({"PAGE": "2"})) + self.xUITest.executeCommand(".uno:JumpToHeader") + + # Switch "same left and right page headers" on and off a few times + for _ in range(4): + self.ui_test.execute_dialog_through_command(".uno:PageDialog") + PageDialog = self.xUITest.getTopFocusWindow(); + + xTabs = PageDialog.getChild("tabcontrol") + select_pos(xTabs, "4") + + Button = xTabs.getChild('checkSameLR') + Button.executeAction("CLICK",tuple()) + ok = PageDialog.getChild("ok") + self.ui_test.close_dialog_through_button(ok) + + # We should be back to the starting state after 2*k on/off changes + self.check_header_texts(master="right", first="1st", left="left", right="right") + + # Enter some additional text in the left page header + type_text(xWriterEdit, "XXXX") + self.check_header_texts(master="right", first="1st", left="XXXXleft", right="right") + + # Now go back one change (before entering "XXXX") + self.xUITest.executeCommand(".uno:Undo") + self.check_header_texts(master="right", first="1st", left="left", right="right") + + # Undo the fourth change + self.xUITest.executeCommand(".uno:Undo") + self.check_header_texts(master="right", first="1st", left="right", right="right") + + # Undo the third change + self.xUITest.executeCommand(".uno:Undo") + self.check_header_texts(master="right", first="1st", left="left", right="right") + + # Undo the second change + self.xUITest.executeCommand(".uno:Undo") + self.check_header_texts(master="right", first="1st", left="right", right="right") + + # Undo the first change + self.xUITest.executeCommand(".uno:Undo") + self.check_header_texts(master="right", first="1st", left="left", right="right") + + # Redo the first change + self.xUITest.executeCommand(".uno:Redo") + self.check_header_texts(master="right", first="1st", left="right", right="right") + + # Redo the second change + self.xUITest.executeCommand(".uno:Redo") + self.check_header_texts(master="right", first="1st", left="left", right="right") + + # Redo the third change + self.xUITest.executeCommand(".uno:Redo") + self.check_header_texts(master="right", first="1st", left="right", right="right") + + # Redo the fourth change + self.xUITest.executeCommand(".uno:Redo") + self.check_header_texts(master="right", first="1st", left="left", right="right") + + # Redo the final change + self.xUITest.executeCommand(".uno:Redo") + self.check_header_texts(master="right", first="1st", left="XXXXleft", right="right") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests7/tdf90401.py b/sw/qa/uitest/writer_tests7/tdf90401.py index e204ef8bb62a..cb70c401b142 100644 --- a/sw/qa/uitest/writer_tests7/tdf90401.py +++ b/sw/qa/uitest/writer_tests7/tdf90401.py @@ -21,82 +21,83 @@ class tdf90401(UITestCase): # load a test document with a tracked change, and add a comment - writer_doc = self.ui_test.load_file(get_url_for_data_file('redline-autocorrect.fodt')) - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild('writer_edit') + with self.ui_test.load_file(get_url_for_data_file('redline-autocorrect.fodt')) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild('writer_edit') - document = self.ui_test.get_component() - selection = self.xUITest.executeCommand('.uno:SelectAll') - self.xUITest.executeCommand('.uno:InsertAnnotation') + document = self.ui_test.get_component() + selection = self.xUITest.executeCommand('.uno:SelectAll') + self.xUITest.executeCommand('.uno:InsertAnnotation') - # enable remove personal info security option + # enable remove personal info security option - self.ui_test.execute_dialog_through_command('.uno:OptionsTreeDialog') #optionsdialog - xDialog = self.xUITest.getTopFocusWindow() + self.ui_test.execute_dialog_through_command('.uno:OptionsTreeDialog') #optionsdialog + xDialog = self.xUITest.getTopFocusWindow() - xPages = xDialog.getChild('pages') - xGenEntry = xPages.getChild('0') - xSecurityPage = xGenEntry.getChild('6') - xSecurityPage.executeAction('SELECT', tuple()) - # Click Button Options... - xOptions = xDialog.getChild('options') + xPages = xDialog.getChild('pages') + xGenEntry = xPages.getChild('0') + xSecurityPage = xGenEntry.getChild('6') + xSecurityPage.executeAction('SELECT', tuple()) + # Click Button Options... + xOptions = xDialog.getChild('options') - with self.ui_test.execute_blocking_action(xOptions.executeAction, args=('CLICK', ()), close_button="") as dialog: - xRemovePersonal = dialog.getChild('removepersonal') - xRemovePersonal.executeAction('CLICK', tuple()) - xOkBtn = dialog.getChild('ok') - # FIXME: we can't use close_dialog_through_button here, the dialog doesn't emit the - # event DialogClosed after closing - xOkBtn.executeAction('CLICK', tuple()) + with self.ui_test.execute_blocking_action(xOptions.executeAction, args=('CLICK', ()), close_button="") as dialog: + xRemovePersonal = dialog.getChild('removepersonal') + xRemovePersonal.executeAction('CLICK', tuple()) + xOkBtn = dialog.getChild('ok') + # FIXME: we can't use close_dialog_through_button here, the dialog doesn't emit the + # event DialogClosed after closing + xOkBtn.executeAction('CLICK', tuple()) - xOKBtn = xDialog.getChild('ok') - self.ui_test.close_dialog_through_button(xOKBtn) + xOKBtn = xDialog.getChild('ok') + self.ui_test.close_dialog_through_button(xOKBtn) - # save and reload the document to remove personal info + # save and reload the document to remove personal info - with TemporaryDirectory() as tempdir: - xFilePath = os.path.join(tempdir, 'tdf90401-tmp.fodt') + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, 'tdf90401-tmp.fodt') - # Save Copy as - self.ui_test.execute_dialog_through_command('.uno:SaveAs') - xDialog = self.xUITest.getTopFocusWindow() + # Save Copy as + self.ui_test.execute_dialog_through_command('.uno:SaveAs') + xDialog = self.xUITest.getTopFocusWindow() - 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) + xOpenBtn = xDialog.getChild('open') + self.ui_test.close_dialog_through_button(xOpenBtn) - # Close the Writer document - self.ui_test.close_doc() + # Close the Writer document + self.ui_test.close_doc() - self.ui_test.load_file(systemPathToFileUrl(xFilePath)) - document = self.ui_test.get_component() + with self.ui_test.load_file(systemPathToFileUrl(xFilePath)): + document = self.ui_test.get_component() + + # check removed personal info on comments + + textfields = document.getTextFields() + author = "" + year = -1 + for textfield in textfields: + if textfield.supportsService("com.sun.star.text.TextField.Annotation"): + author = textfield.Author + year = textfield.Date.Year + # This was 'Unknown Author' + self.assertEqual(author, 'Author2') + # This was 2021 + self.assertEqual(year, 0) + + # check removed personal info on tracked changes + + self.ui_test.execute_modeless_dialog_through_command('.uno:AcceptTrackedChanges') + xTrackDlg = self.xUITest.getTopFocusWindow() + xTreeList = xTrackDlg.getChild('writerchanges') + state = get_state_as_dict(xTreeList) + # This was 'NL\t11/03/2020 19:19:05\t', containing personal info + self.assertEqual(state['SelectEntryText'], 'Author1\t01/01/1970 00:00:00\t') + + self.ui_test.close_doc() - # check removed personal info on comments - - textfields = document.getTextFields() - author = "" - year = -1 - for textfield in textfields: - if textfield.supportsService("com.sun.star.text.TextField.Annotation"): - author = textfield.Author - year = textfield.Date.Year - # This was 'Unknown Author' - self.assertEqual(author, 'Author2') - # This was 2021 - self.assertEqual(year, 0) - - # check removed personal info on tracked changes - - self.ui_test.execute_modeless_dialog_through_command('.uno:AcceptTrackedChanges') - xTrackDlg = self.xUITest.getTopFocusWindow() - xTreeList = xTrackDlg.getChild('writerchanges') - state = get_state_as_dict(xTreeList) - # This was 'NL\t11/03/2020 19:19:05\t', containing personal info - self.assertEqual(state['SelectEntryText'], 'Author1\t01/01/1970 00:00:00\t') - - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: |