diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-10-29 17:53:10 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-10-30 08:41:07 +0200 |
commit | 3797007c2fe143dc3c83c72eeb5cc6d1cb401792 (patch) | |
tree | 45f7d67f511246a12e4ac4ff12f43c418f192a86 /sw/qa/uitest/writer_tests6 | |
parent | 8565e4ef18e96b9a68a4b75d551a80ce52128bd5 (diff) |
sw: uitest: test "save to ODT as read-only with password protection"
Similar to the UItest added in 1b53c1dfc76f08ca7df40a0673aa50eca700d072
< tdf#144374 DOCX: export the password for editing > for the DOCX format
Change-Id: Ifceab6bfb683a42db28e1836b173a850a342515a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124444
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw/qa/uitest/writer_tests6')
-rw-r--r-- | sw/qa/uitest/writer_tests6/save_readonly_with_password.py (renamed from sw/qa/uitest/writer_tests6/tdf144374.py) | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/sw/qa/uitest/writer_tests6/tdf144374.py b/sw/qa/uitest/writer_tests6/save_readonly_with_password.py index bdd0e59f05b2..c61e7d7b0c19 100644 --- a/sw/qa/uitest/writer_tests6/tdf144374.py +++ b/sw/qa/uitest/writer_tests6/save_readonly_with_password.py @@ -11,11 +11,11 @@ from uitest.uihelper.common import select_by_text from tempfile import TemporaryDirectory import os.path -#Bug 144374 - Writer: FILESAVE to DOCX as read-only with additional password protection for editing not working -class tdf144374(UITestCase): +class save_readonly_with_password(UITestCase): - def test_tdf144374_DOCX(self): + #Bug 144374 - Writer: FILESAVE to DOCX as read-only with additional password protection for editing not working + def test_save_to_docx(self): with TemporaryDirectory() as tempdir: xFilePath = os.path.join(tempdir, "tdf144374-tmp.docx") @@ -45,14 +45,48 @@ class tdf144374(UITestCase): xSave = xWarnDialog.getChild("save") self.ui_test.close_dialog_through_button(xSave) - 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)) as document: 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: + with self.ui_test.execute_dialog_through_command(".uno:EditDoc") as xDialog: + xPassword = xDialog.getChild("newpassEntry") + xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"})) + + self.assertFalse(document.isReadonly()) + + def test_save_to_odt(self): + + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, "readonly_with_password_tmp.odt") + + 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") + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) + xPasswordCheckButton = xSaveDialog.getChild("password") + xPasswordCheckButton.executeAction("CLICK", tuple()) + xOpen = xSaveDialog.getChild("open") + + with self.ui_test.execute_dialog_through_action(xOpen, "CLICK") as xPasswordDialog: + xReadonly = xPasswordDialog.getChild("readonly") + xReadonly.executeAction("CLICK", tuple()) + xNewPassword = xPasswordDialog.getChild("newpassroEntry") + xNewPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"})) + xConfirmPassword = xPasswordDialog.getChild("confirmropassEntry") + xConfirmPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"})) + + with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as document: + + xWriterEdit = self.xUITest.getTopFocusWindow().getChild("writer_edit") + + self.assertTrue(document.isReadonly()) + + with self.ui_test.execute_dialog_through_command(".uno:EditDoc") as xDialog: xPassword = xDialog.getChild("newpassEntry") xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"})) |