Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / calc_tests9 / tdf144996.py
blobfcfb366feb8ac27a5512f401f8fce0250d3c2e16
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 uitest.uihelper.common import get_url_for_data_file
12 from libreoffice.uno.propertyvalue import mkPropertyValues
13 from com.sun.star.beans import PropertyValue
15 class tdf144996(UITestCase):
17 def test_tdf144996(self):
19 # get_url_for_data_file calls makeCopyFromTDOC
20 # so using save doesn't affect the original file
21 xFilePath = get_url_for_data_file("tdf144996.xlsx")
23 with self.ui_test.load_file(xFilePath, [PropertyValue(Name="Silent", Value=True)]) as document:
25 self.assertTrue(document.isReadonly())
27 with self.ui_test.execute_dialog_through_command(".uno:EditDoc") as xDialog:
28 xPassword = xDialog.getChild("newpassEntry")
29 xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"}))
31 self.assertFalse(document.isReadonly())
33 with self.ui_test.execute_dialog_through_command(".uno:Save", close_button="save"):
34 # Confirm file format popup
35 pass
37 with self.ui_test.load_file(xFilePath, [PropertyValue(Name="Silent", Value=True)]) as document:
39 self.assertTrue(document.isReadonly())
41 # Without the fix in place, this test would have failed here because the saved document
42 # doesn't need a password to edit it
43 with self.ui_test.execute_dialog_through_command(".uno:EditDoc") as xDialog:
44 xPassword = xDialog.getChild("newpassEntry")
45 xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"}))
47 self.assertFalse(document.isReadonly())
49 # vim: set shiftwidth=4 softtabstop=4 expandtab: