Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / conditional_format / tdf104026.py
blob2d8c5fc66c5faea340d394c798519eae6070306a
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 uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
13 class Tdf104026(UITestCase):
15 def execute_conditional_format_manager_dialog(self, nCount):
17 with self.ui_test.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog") as xCondFormatMgr:
19 aExpectedResults = ['A2\tCell value != $Sheet1.$B2', 'A3\tCell value != $Sheet1.$B3',
20 'A4\tCell value != $Sheet1.$B4', 'A5\tCell value != $Sheet1.$B5',
21 'A6\tCell value != $Sheet1.$B6', 'A7\tCell value != $Sheet1.$B7']
23 xList = xCondFormatMgr.getChild("CONTAINER")
24 self.assertEqual(nCount, len(xList.getChildren()))
26 for i in range(nCount):
27 self.assertEqual(aExpectedResults[i], get_state_as_dict(xList.getChild(str(i)))['Text'])
30 def test_tdf104026(self):
31 with self.ui_test.load_file(get_url_for_data_file("tdf104026.ods")):
33 self.execute_conditional_format_manager_dialog(6)
35 xCalcDoc = self.xUITest.getTopFocusWindow()
36 gridwin = xCalcDoc.getChild("grid_window")
37 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"}))
39 self.xUITest.executeCommand(".uno:DeleteRows")
41 # Without the fix in place, this test would have failed with
42 # AssertionError: 'A2\tCell value != $Sheet1.$B2' != 'A2\tCell value != $Sheet1.$B#REF!'
43 self.execute_conditional_format_manager_dialog(5)
45 # vim: set shiftwidth=4 softtabstop=4 expandtab: