sc/qa/uitest/conditional_format/tdf117899.py | 45 ++--- sd/qa/uitest/impress_tests/tdf141297.py | 94 +++++------ sw/qa/uitest/writer_tests6/tdf144374.py | 26 +-- sw/qa/uitest/writer_tests7/tdf119661.py | 84 +++++----- sw/qa/uitest/writer_tests7/tdf90401.py | 216 ++++++++++++--------------- 5 files changed, 218 insertions(+), 247 deletions(-)
New commits: commit 1b6839f59b5aa9bf01674862aa320259ee488f63 Author: Xisco Fauli <[email protected]> AuthorDate: Tue Oct 26 12:18:17 2021 +0200 Commit: Xisco Fauli <[email protected]> CommitDate: Tue Oct 26 14:44:14 2021 +0200 uitest: rearrange tests to avoid "close_doc: no active frame" Change-Id: I92bf81801797821c9ec4aa73c005f1d6c6f6da62 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124182 Tested-by: Jenkins Reviewed-by: Xisco Fauli <[email protected]> diff --git a/sc/qa/uitest/conditional_format/tdf117899.py b/sc/qa/uitest/conditional_format/tdf117899.py index 20c3a71e5264..b22b99494c3c 100644 --- a/sc/qa/uitest/conditional_format/tdf117899.py +++ b/sc/qa/uitest/conditional_format/tdf117899.py @@ -25,40 +25,39 @@ class Tdf117899(UITestCase): def test_tdf117899(self): - with self.ui_test.load_file(get_url_for_data_file("tdf117899.ods")): + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, "tdf117899-temp.ods") - self.execute_conditional_format_manager_dialog() + with self.ui_test.load_file(get_url_for_data_file("tdf117899.ods")): - self.xUITest.executeCommand(".uno:SelectAll") + self.execute_conditional_format_manager_dialog() - self.xUITest.executeCommand(".uno:Copy") + self.xUITest.executeCommand(".uno:SelectAll") - with TemporaryDirectory() as tempdir: - xFilePath = os.path.join(tempdir, "tdf117899-temp.ods") + self.xUITest.executeCommand(".uno:Copy") - with self.ui_test.load_empty_file("writer"): + with self.ui_test.load_empty_file("writer"): - self.xUITest.getTopFocusWindow() + self.xUITest.getTopFocusWindow() - # Paste as an OLE spreadsheet - formatProperty = mkPropertyValues({"SelectedFormat": 85}) - self.xUITest.executeCommandWithParameters(".uno:ClipboardFormatItems", formatProperty) + # Paste as an OLE spreadsheet + formatProperty = mkPropertyValues({"SelectedFormat": 85}) + self.xUITest.executeCommandWithParameters(".uno:ClipboardFormatItems", formatProperty) - # Save Copy as - with self.ui_test.execute_dialog_through_command(".uno:ObjectMenue?VerbID:short=-8", close_button="open") as xDialog: + # Save Copy as + with self.ui_test.execute_dialog_through_command(".uno:ObjectMenue?VerbID:short=-8", close_button="open") as xDialog: - xFileName = xDialog.getChild("file_name") - xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) + xFileName = xDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) + with self.ui_test.load_file(systemPathToFileUrl(xFilePath)): - with self.ui_test.load_file(systemPathToFileUrl(xFilePath)): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - - # Without the fix in place, this test would have failed here - self.execute_conditional_format_manager_dialog() + # Without the fix in place, this test would have failed here + self.execute_conditional_format_manager_dialog() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/uitest/impress_tests/tdf141297.py b/sd/qa/uitest/impress_tests/tdf141297.py index 19956e9bcb73..1af3465238d9 100644 --- a/sd/qa/uitest/impress_tests/tdf141297.py +++ b/sd/qa/uitest/impress_tests/tdf141297.py @@ -14,73 +14,65 @@ import os.path class tdf141297(UITestCase): def test_tdf141297(self): + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, "tdf141297-tmp.odp") - with self.ui_test.create_doc_in_start_center("impress"): + with self.ui_test.create_doc_in_start_center("impress"): - xTemplateDlg = self.xUITest.getTopFocusWindow() - xCancelBtn = xTemplateDlg.getChild("close") - self.ui_test.close_dialog_through_button(xCancelBtn) + xTemplateDlg = self.xUITest.getTopFocusWindow() + xCancelBtn = xTemplateDlg.getChild("close") + self.ui_test.close_dialog_through_button(xCancelBtn) - with self.ui_test.execute_dialog_through_command(".uno:InsertGraphic", close_button="open") as xOpenDialog: + with self.ui_test.execute_dialog_through_command(".uno:InsertGraphic", close_button="open") as xOpenDialog: + xFileName = xOpenDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("LibreOffice.jpg")})) - xFileName = xOpenDialog.getChild("file_name") - xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("LibreOffice.jpg")})) + xLink = xOpenDialog.getChild("link") + self.assertEqual("false", get_state_as_dict(xLink)['Selected']) - xLink = xOpenDialog.getChild("link") - self.assertEqual("false", get_state_as_dict(xLink)['Selected']) + xLink.executeAction("CLICK", tuple()) - xLink.executeAction("CLICK", tuple()) + #Confirmation dialog is displayed + xWarnDialog = self.xUITest.getTopFocusWindow() + xOK = xWarnDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_dialog_through_command(".uno:ManageLinks", close_button="close") as xDialog: - #Confirmation dialog is displayed - xWarnDialog = self.xUITest.getTopFocusWindow() - xOK = xWarnDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + sLinks = "TB_LINKS" + xLinks = xDialog.getChild(sLinks) + self.assertEqual(1, len(xLinks.getChildren())) - with self.ui_test.execute_dialog_through_command(".uno:ManageLinks", close_button="close") as xDialog: + sFileName = "FULL_FILE_NAME" + xFileName = xDialog.getChild(sFileName) + self.assertTrue(get_state_as_dict(xFileName)["Text"].endswith("/LibreOffice.jpg")) + sBreakLink = "BREAK_LINK" + xBreakLink = xDialog.getChild(sBreakLink) - sLinks = "TB_LINKS" - xLinks = xDialog.getChild(sLinks) - self.assertEqual(1, len(xLinks.getChildren())) + with self.ui_test.execute_blocking_action(xBreakLink.executeAction, + args=("CLICK", tuple()), close_button="yes"): + pass - sFileName = "FULL_FILE_NAME" - xFileName = xDialog.getChild(sFileName) - self.assertTrue(get_state_as_dict(xFileName)["Text"].endswith("/LibreOffice.jpg")) + # Save Copy as + with self.ui_test.execute_dialog_through_command(".uno:SaveAs", close_button="open") as xDialog: - sBreakLink = "BREAK_LINK" - xBreakLink = xDialog.getChild(sBreakLink) + xFileName = xDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) - with self.ui_test.execute_blocking_action(xBreakLink.executeAction, - args=("CLICK", tuple()), close_button="yes"): - pass + with self.ui_test.load_file(systemPathToFileUrl(xFilePath)): + self.xUITest.executeCommand(".uno:ManageLinks") - with TemporaryDirectory() as tempdir: - xFilePath = os.path.join(tempdir, "tdf141297-tmp.odp") - - # Save Copy as - with self.ui_test.execute_dialog_through_command(".uno:SaveAs", close_button="open") as xDialog: - - xFileName = xDialog.getChild("file_name") - xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) - - # Close the Writer document - self.ui_test.close_doc() - - with self.ui_test.load_file(systemPathToFileUrl(xFilePath)): - - self.xUITest.executeCommand(".uno:ManageLinks") - - # Since the image is no longer linked, the link dialog is not open. - # Without the fix in place, this dialog would have been opened - xMainWin = self.xUITest.getTopFocusWindow() - self.assertTrue(sLinks not in xMainWin.getChildren()) - self.assertTrue(sFileName not in xMainWin.getChildren()) - self.assertTrue(sBreakLink not in xMainWin.getChildren()) - self.assertTrue("impress_win" in xMainWin.getChildren()) + # Since the image is no longer linked, the link dialog is not open. + # Without the fix in place, this dialog would have been opened + xMainWin = self.xUITest.getTopFocusWindow() + self.assertTrue(sLinks not in xMainWin.getChildren()) + self.assertTrue(sFileName not in xMainWin.getChildren()) + self.assertTrue(sBreakLink not in xMainWin.getChildren()) + self.assertTrue("impress_win" in xMainWin.getChildren()) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests6/tdf144374.py b/sw/qa/uitest/writer_tests6/tdf144374.py index c484b79b54cd..bdd0e59f05b2 100644 --- a/sw/qa/uitest/writer_tests6/tdf144374.py +++ b/sw/qa/uitest/writer_tests6/tdf144374.py @@ -16,10 +16,10 @@ import os.path class tdf144374(UITestCase): def test_tdf144374_DOCX(self): - with self.ui_test.create_doc_in_start_center("writer"): - with TemporaryDirectory() as tempdir: - xFilePath = os.path.join(tempdir, "tdf144374-tmp.docx") + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, "tdf144374-tmp.docx") + with self.ui_test.create_doc_in_start_center("writer"): # Save the document with self.ui_test.execute_dialog_through_command(".uno:Save", close_button="") as xSaveDialog: xFileName = xSaveDialog.getChild("file_name") @@ -45,19 +45,17 @@ class tdf144374(UITestCase): xSave = xWarnDialog.getChild("save") self.ui_test.close_dialog_through_button(xSave) - self.ui_test.close_doc() + with self.ui_test.load_file(systemPathToFileUrl(xFilePath)): + xWriterEdit = self.xUITest.getTopFocusWindow().getChild("writer_edit") + document = self.ui_test.get_component() - with self.ui_test.load_file(systemPathToFileUrl(xFilePath)): - xWriterEdit = self.xUITest.getTopFocusWindow().getChild("writer_edit") - document = self.ui_test.get_component() + self.assertTrue(document.isReadonly()) - self.assertTrue(document.isReadonly()) + #Without the fix in place, this dialog wouldn't have been displayed + with self.ui_test.execute_dialog_through_action(xWriterEdit, "TYPE", mkPropertyValues({"KEYCODE": "CTRL+SHIFT+M"})) as xDialog: + xPassword = xDialog.getChild("newpassEntry") + xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"})) - #Without the fix in place, this dialog wouldn't have been displayed - with self.ui_test.execute_dialog_through_action(xWriterEdit, "TYPE", mkPropertyValues({"KEYCODE": "CTRL+SHIFT+M"})) as xDialog: - xPassword = xDialog.getChild("newpassEntry") - xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"})) - - self.assertFalse(document.isReadonly()) + self.assertFalse(document.isReadonly()) # 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 da284add867b..2923128bf830 100644 --- a/sw/qa/uitest/writer_tests7/tdf119661.py +++ b/sw/qa/uitest/writer_tests7/tdf119661.py @@ -14,68 +14,64 @@ import os.path class tdf119661(UITestCase): def test_tdf119661(self): + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, "tdf119661-tmp.odt") - with self.ui_test.create_doc_in_start_center("writer"): + with self.ui_test.create_doc_in_start_center("writer"): - with self.ui_test.execute_dialog_through_command(".uno:InsertGraphic", close_button="") as xOpenDialog: - xFileName = xOpenDialog.getChild("file_name") - xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("LibreOffice.jpg")})) + with self.ui_test.execute_dialog_through_command(".uno:InsertGraphic", close_button="") as xOpenDialog: + xFileName = xOpenDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("LibreOffice.jpg")})) - xLink = xOpenDialog.getChild("link") - self.assertEqual("false", get_state_as_dict(xLink)['Selected']) + xLink = xOpenDialog.getChild("link") + self.assertEqual("false", get_state_as_dict(xLink)['Selected']) - xLink.executeAction("CLICK", tuple()) + xLink.executeAction("CLICK", tuple()) - xOpenBtn = xOpenDialog.getChild("open") + xOpenBtn = xOpenDialog.getChild("open") - #Confirmation dialog is displayed - with self.ui_test.execute_dialog_through_action(xOpenBtn, 'CLICK'): - pass + #Confirmation dialog is displayed + with self.ui_test.execute_dialog_through_action(xOpenBtn, 'CLICK'): + pass - with self.ui_test.execute_dialog_through_command(".uno:LinkDialog", close_button="close") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:LinkDialog", close_button="close") as xDialog: - sLinks = "TB_LINKS" - xLinks = xDialog.getChild(sLinks) - self.assertEqual(1, len(xLinks.getChildren())) + sLinks = "TB_LINKS" + xLinks = xDialog.getChild(sLinks) + self.assertEqual(1, len(xLinks.getChildren())) - sFileName = "FULL_FILE_NAME" - xFileName = xDialog.getChild(sFileName) - self.assertTrue(get_state_as_dict(xFileName)["Text"].endswith("/LibreOffice.jpg")) + sFileName = "FULL_FILE_NAME" + xFileName = xDialog.getChild(sFileName) + self.assertTrue(get_state_as_dict(xFileName)["Text"].endswith("/LibreOffice.jpg")) - sBreakLink = "BREAK_LINK" - xBreakLink = xDialog.getChild(sBreakLink) + sBreakLink = "BREAK_LINK" + xBreakLink = xDialog.getChild(sBreakLink) - with self.ui_test.execute_blocking_action(xBreakLink.executeAction, - args=("CLICK", tuple()), close_button="yes"): - pass + with self.ui_test.execute_blocking_action(xBreakLink.executeAction, + args=("CLICK", tuple()), close_button="yes"): + pass - with TemporaryDirectory() as tempdir: - xFilePath = os.path.join(tempdir, "tdf119661-tmp.odt") - # Save Copy as - with self.ui_test.execute_dialog_through_command(".uno:SaveAs", close_button="open") as xDialog: + # Save Copy as + with self.ui_test.execute_dialog_through_command(".uno:SaveAs", close_button="open") as xDialog: - xFileName = xDialog.getChild("file_name") - xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) + xFileName = xDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) + with self.ui_test.load_file(systemPathToFileUrl(xFilePath)): - # Close the Writer document - self.ui_test.close_doc() + self.xUITest.executeCommand(".uno:LinkDialog") - with self.ui_test.load_file(systemPathToFileUrl(xFilePath)): - - 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()) + # 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/tdf90401.py b/sw/qa/uitest/writer_tests7/tdf90401.py index 5fa131be7839..df71127feb04 100644 --- a/sw/qa/uitest/writer_tests7/tdf90401.py +++ b/sw/qa/uitest/writer_tests7/tdf90401.py @@ -21,39 +21,37 @@ class tdf90401(UITestCase): # load a test document with a tracked change, and add a comment - 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') - - selection = self.xUITest.executeCommand('.uno:SelectAll') - self.xUITest.executeCommand('.uno:InsertAnnotation') - - # enable remove personal info security option - - with self.ui_test.execute_dialog_through_command('.uno:OptionsTreeDialog') as xDialog: - 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') - if get_state_as_dict(xRemovePersonal)['Selected'] == "false": - xRemovePersonal.executeAction('CLICK', tuple()) - self.ui_test.wait_until_property_is_updated(xRemovePersonal, "Selected", "true") - self.assertEqual(get_state_as_dict(xRemovePersonal)["Selected"], "true") - - 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()) - - # 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') + + 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') + + selection = self.xUITest.executeCommand('.uno:SelectAll') + self.xUITest.executeCommand('.uno:InsertAnnotation') + + # enable remove personal info security option + + with self.ui_test.execute_dialog_through_command('.uno:OptionsTreeDialog') as xDialog: + 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') + if get_state_as_dict(xRemovePersonal)['Selected'] == "false": + xRemovePersonal.executeAction('CLICK', tuple()) + self.ui_test.wait_until_property_is_updated(xRemovePersonal, "Selected", "true") + self.assertEqual(get_state_as_dict(xRemovePersonal)["Selected"], "true") + + 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()) # Save Copy as with self.ui_test.execute_dialog_through_command('.uno:SaveAs', close_button="open") as xDialog: @@ -62,72 +60,64 @@ class tdf90401(UITestCase): xFileName.executeAction('TYPE', mkPropertyValues({'KEYCODE':'BACKSPACE'})) xFileName.executeAction('TYPE', mkPropertyValues({'TEXT': xFilePath})) - # Close the Writer document - self.ui_test.close_doc() - - with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as writer_doc2: - - # check removed personal info on comments - - textfields = writer_doc2.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 - with self.ui_test.execute_modeless_dialog_through_command('.uno:AcceptTrackedChanges', close_button="close") as xTrackDlg: - 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') - - + with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as writer_doc2: + + # check removed personal info on comments + + textfields = writer_doc2.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 + with self.ui_test.execute_modeless_dialog_through_command('.uno:AcceptTrackedChanges', close_button="close") as xTrackDlg: + 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') def test_tdf142902_remove_personal_info_in_DOCX(self): # load a test document with a tracked change, and add a comment + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, 'redline-para-join-tmp.docx') - with self.ui_test.load_file(get_url_for_data_file('redline-para-join.docx')) as writer_doc: - - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild('writer_edit') + with self.ui_test.load_file(get_url_for_data_file('redline-para-join.docx')) as writer_doc: - selection = self.xUITest.executeCommand('.uno:SelectAll') - self.xUITest.executeCommand('.uno:InsertAnnotation') + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild('writer_edit') - # enable remove personal info security option + selection = self.xUITest.executeCommand('.uno:SelectAll') + self.xUITest.executeCommand('.uno:InsertAnnotation') - with self.ui_test.execute_dialog_through_command('.uno:OptionsTreeDialog') as xDialog: - xPages = xDialog.getChild('pages') - xGenEntry = xPages.getChild('0') - xSecurityPage = xGenEntry.getChild('6') - xSecurityPage.executeAction('SELECT', tuple()) - # Click Button Options... - xOptions = xDialog.getChild('options') + # enable remove personal info security option - with self.ui_test.execute_blocking_action(xOptions.executeAction, args=('CLICK', ()), close_button="") as dialog: - xRemovePersonal = dialog.getChild('removepersonal') - if get_state_as_dict(xRemovePersonal)['Selected'] == "false": - xRemovePersonal.executeAction('CLICK', tuple()) - self.ui_test.wait_until_property_is_updated(xRemovePersonal, "Selected", "true") - self.assertEqual(get_state_as_dict(xRemovePersonal)["Selected"], "true") + with self.ui_test.execute_dialog_through_command('.uno:OptionsTreeDialog') as xDialog: + xPages = xDialog.getChild('pages') + xGenEntry = xPages.getChild('0') + xSecurityPage = xGenEntry.getChild('6') + xSecurityPage.executeAction('SELECT', tuple()) + # Click Button Options... + xOptions = xDialog.getChild('options') - 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') + if get_state_as_dict(xRemovePersonal)['Selected'] == "false": + xRemovePersonal.executeAction('CLICK', tuple()) + self.ui_test.wait_until_property_is_updated(xRemovePersonal, "Selected", "true") + self.assertEqual(get_state_as_dict(xRemovePersonal)["Selected"], "true") - # save and reload the document to remove personal info - - with TemporaryDirectory() as tempdir: - xFilePath = os.path.join(tempdir, 'redline-para-join-tmp.docx') + 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()) # Save Copy as with self.ui_test.execute_dialog_through_command('.uno:SaveAs', close_button="open") as xDialog: @@ -141,32 +131,28 @@ class tdf90401(UITestCase): xOK = xWarnDialog.getChild("save") self.ui_test.close_dialog_through_button(xOK) - # Close the Writer document - self.ui_test.close_doc() - - with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as writer_doc2: - - # check removed personal info on comments - - textfields = writer_doc2.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 - - with self.ui_test.execute_modeless_dialog_through_command('.uno:AcceptTrackedChanges', close_button="close") as xTrackDlg: - 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') - + with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as writer_doc2: + + # check removed personal info on comments + + textfields = writer_doc2.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 + + with self.ui_test.execute_modeless_dialog_through_command('.uno:AcceptTrackedChanges', close_button="close") as xTrackDlg: + 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') # vim: set shiftwidth=4 softtabstop=4 expandtab:
