Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / autofilter2 / tdf97340.py
blob884caa00a5db61c0d6345072ddc9e9815f4bc4b5
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_state_as_dict, get_url_for_data_file
11 from libreoffice.uno.propertyvalue import mkPropertyValues
13 #Bug 97340 - Calc crashes on filtering with select checkbox with space bar
15 class tdf97340(UITestCase):
16 def test_tdf97340_autofilter(self):
17 with self.ui_test.load_file(get_url_for_data_file("autofilter.ods")):
18 xCalcDoc = self.xUITest.getTopFocusWindow()
19 gridwin = xCalcDoc.getChild("grid_window")
21 gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
22 xFloatWindow = self.xUITest.getFloatWindow()
24 xCheckListMenu = xFloatWindow.getChild("FilterDropDown")
25 xTreeList = xCheckListMenu.getChild("check_tree_box")
26 self.assertEqual(2, len(xTreeList.getChildren()))
27 self.assertEqual("2016", get_state_as_dict(xTreeList.getChild('0'))['Text'])
28 self.assertEqual("2017", get_state_as_dict(xTreeList.getChild('1'))['Text'])
30 xsearchEdit = xFloatWindow.getChild("search_edit")
31 xsearchEdit.executeAction("TYPE", mkPropertyValues({"TEXT":" "}))
32 self.ui_test.wait_until_property_is_updated(xTreeList, "Children", str(0))
33 self.assertEqual(0, len(xTreeList.getChildren()))
35 xsearchEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"}))
37 #tdf#133785, without the fix in place, it would have been 0
38 self.ui_test.wait_until_property_is_updated(xTreeList, "Children", str(8))
39 # Number of children differs due to xTreeList.getChildren() returns only direct descendants
40 self.assertEqual(2, len(xTreeList.getChildren()))
41 self.assertEqual("2016", get_state_as_dict(xTreeList.getChild('0'))['Text'])
42 self.assertEqual("2017", get_state_as_dict(xTreeList.getChild('1'))['Text'])
44 # vim: set shiftwidth=4 softtabstop=4 expandtab: