Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / calc_tests7 / tdf150044.py
blobffa0077879ea8c5d135ff78eb3a0d037a4d16839
1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 from uitest.framework import UITestCase
10 from libreoffice.uno.propertyvalue import mkPropertyValues
11 from tempfile import TemporaryDirectory
12 import os.path
14 class save_shared_readonly_with_password(UITestCase):
16 def test_save_to_shared_ods(self):
18 with TemporaryDirectory() as tempdir:
19 xFilePath = os.path.join(tempdir, "shared_readonly_with_password_tmp.ods")
21 with self.ui_test.create_doc_in_start_center("calc"):
22 with self.ui_test.execute_dialog_through_command(".uno:ShareDocument", close_button="") as xShareDocumentDialog:
23 xShareCheckButton = xShareDocumentDialog.getChild("share")
24 xShareCheckButton.executeAction("CLICK", tuple())
25 xOk = xShareDocumentDialog.getChild("ok")
26 # Save the document
27 with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="") as xSaveDialog:
28 xFileName = xSaveDialog.getChild("file_name")
29 xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
30 xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
31 xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath}))
32 xPasswordCheckButton = xSaveDialog.getChild("password")
33 xPasswordCheckButton.executeAction("CLICK", tuple())
34 xOpen = xSaveDialog.getChild("open")
36 with self.ui_test.execute_dialog_through_action(xOpen, "CLICK") as xPasswordDialog:
37 xReadonly = xPasswordDialog.getChild("readonly")
38 xReadonly.executeAction("CLICK", tuple())
39 xNewPassword = xPasswordDialog.getChild("newpassroEntry")
40 xNewPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"}))
41 xConfirmPassword = xPasswordDialog.getChild("confirmropassEntry")
42 xConfirmPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"}))
44 with self.ui_test.execute_dialog_through_command(".uno:Open", close_button="") as xOpenDialog:
45 # Open document
46 xFileName = xOpenDialog.getChild("file_name")
47 xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath}))
48 xOpenBtn = xOpenDialog.getChild("open")
49 xOpenBtn.executeAction("CLICK", tuple())
51 xDialog = self.ui_test.wait_for_top_focus_window('SharedWarningDialog')
52 xOk = xDialog.getChild("ok")
53 xOk.executeAction("CLICK", tuple())
55 document = self.ui_test.get_component()
56 self.assertTrue(document.isReadonly())
58 with self.ui_test.execute_dialog_through_command(".uno:EditDoc") as xDialog:
59 # check that we have a password dialog for editing the shared document
60 xPassword = xDialog.getChild("newpassEntry")
61 xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"}))
63 self.assertFalse(document.isReadonly())
65 # vim: set shiftwidth=4 softtabstop=4 expandtab: