Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / conditional_format / tdf117899.py
blob81c270cc895fa53da6b100a7014dd5cd7c0bd94f
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 import os.path
10 from tempfile import TemporaryDirectory
12 from uitest.framework import UITestCase
13 from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
14 from libreoffice.uno.propertyvalue import mkPropertyValues
16 from org.libreoffice.unotest import systemPathToFileUrl
19 class Tdf117899(UITestCase):
21 def execute_conditional_format_manager_dialog(self):
23 with self.ui_test.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog") as xCondFormatMgr:
25 aExpectedResult = 'Formula is $E3="нет"'
26 xList = xCondFormatMgr.getChild("CONTAINER")
27 self.assertEqual(1, len(xList.getChildren()))
28 self.assertTrue(get_state_as_dict(xList.getChild('0'))['Text'].endswith(aExpectedResult))
31 def test_tdf117899(self):
32 with TemporaryDirectory() as tempdir:
33 xFilePath = os.path.join(tempdir, "tdf117899-temp.ods")
35 with self.ui_test.load_file(get_url_for_data_file("tdf117899.ods")):
37 self.execute_conditional_format_manager_dialog()
39 self.xUITest.executeCommand(".uno:SelectAll")
41 self.xUITest.executeCommand(".uno:Copy")
43 with self.ui_test.load_empty_file("writer"):
45 self.xUITest.getTopFocusWindow()
47 # Paste as an OLE spreadsheet
48 formatProperty = mkPropertyValues({"SelectedFormat": 85})
49 self.xUITest.executeCommandWithParameters(".uno:ClipboardFormatItems", formatProperty)
51 # Save Copy as
52 with self.ui_test.execute_dialog_through_command(".uno:ObjectMenue?VerbID:short=-8", close_button="open") as xDialog:
54 xFileName = xDialog.getChild("file_name")
55 xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
56 xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
57 xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath}))
59 with self.ui_test.load_file(systemPathToFileUrl(xFilePath)):
60 # Without the fix in place, this test would have failed here
61 self.execute_conditional_format_manager_dialog()
63 # vim: set shiftwidth=4 softtabstop=4 expandtab: