Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / autofilter2 / tdf46062.py
blobf5cd82d2d1b82719b9389dbba055098a1c553da7
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.calc import enter_text_to_cell
11 from libreoffice.uno.propertyvalue import mkPropertyValues
12 from uitest.uihelper.common import get_state_as_dict
14 class tdf46062(UITestCase):
16 def test_tdf46062(self):
18 with self.ui_test.create_doc_in_start_center("calc"):
19 calcDoc = self.xUITest.getTopFocusWindow()
20 gridwin = calcDoc.getChild("grid_window")
22 enter_text_to_cell(gridwin, "A1", "spaces")
23 enter_text_to_cell(gridwin, "A2", " ")
24 enter_text_to_cell(gridwin, "A3", " ")
25 enter_text_to_cell(gridwin, "A4", " ")
27 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"}))
29 with self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter", close_button="yes"):
30 pass
32 gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
33 xFloatWindow = self.xUITest.getFloatWindow()
34 xCheckListMenu = xFloatWindow.getChild("FilterDropDown")
35 xList = xCheckListMenu.getChild("check_list_box")
36 self.assertEqual(3, len(xList.getChildren()))
38 # Without the fix in place, this test would have failed with
39 # AssertionError: '" "' != ' '
40 self.assertEqual('" "', get_state_as_dict(xList.getChild("0"))['Text'])
41 self.assertEqual('" "', get_state_as_dict(xList.getChild("1"))['Text'])
42 self.assertEqual('" "', get_state_as_dict(xList.getChild("2"))['Text'])
44 xOkButton = xFloatWindow.getChild("ok")
45 xOkButton.executeAction("CLICK", tuple())
48 # vim: set shiftwidth=4 softtabstop=4 expandtab: