Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / autofilter2 / tdf92767.py
blobe3a0908d421d1b0d57c25b7aef820b40b629cd01
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 libreoffice.calc.document import is_row_hidden
12 from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
14 class tdf92767(UITestCase):
16 def test_tdf92767(self):
17 with self.ui_test.load_file(get_url_for_data_file("tdf92767.ods")) as calc_doc:
18 xCalcDoc = self.xUITest.getTopFocusWindow()
19 gridwin = xCalcDoc.getChild("grid_window")
21 for i in range(0,25):
22 self.assertFalse(is_row_hidden(calc_doc, i))
24 gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
25 xFloatWindow = self.xUITest.getFloatWindow()
26 xTreeList = xFloatWindow.getChild("check_tree_box")
27 xFirstEntry = xTreeList.getChild("0")
28 self.assertEqual('2015', get_state_as_dict(xFirstEntry)["Text"])
29 self.assertEqual('7', get_state_as_dict(xFirstEntry)["Children"])
31 # Deselect all the options but the last one
32 for i in range(6):
33 xChild = xFirstEntry.getChild(str(i))
34 xChild.executeAction("CLICK", tuple())
35 self.assertEqual('false', get_state_as_dict(xChild)['IsChecked'])
37 xLastChild = xFirstEntry.getChild('6')
38 self.assertEqual('true', get_state_as_dict(xLastChild)['IsChecked'])
39 self.assertEqual('July', get_state_as_dict(xLastChild)['Text'])
41 xOkBtn = xFloatWindow.getChild("ok")
42 xOkBtn.executeAction("CLICK", tuple())
44 for i in range(1,22):
45 self.assertTrue(is_row_hidden(calc_doc, i))
47 # Without the fix in place, this test would have failed here
48 self.assertFalse(is_row_hidden(calc_doc, 23))
49 self.assertFalse(is_row_hidden(calc_doc, 24))
50 self.assertFalse(is_row_hidden(calc_doc, 25))
52 # vim: set shiftwidth=4 softtabstop=4 expandtab: