Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / autofilter2 / tdf68113.py
blob2f10d16ad70baa662ae094b8c7fd3087c04e8a36
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 uitest.uihelper.common import get_state_as_dict
12 from libreoffice.uno.propertyvalue import mkPropertyValues
14 #Bug 68113 - UI Selecting "Not empty" unchecks all entries
16 class tdf68113(UITestCase):
17 def test_tdf68113_empty_notempty_button(self):
18 with self.ui_test.create_doc_in_start_center("calc"):
19 calcDoc = self.xUITest.getTopFocusWindow()
20 xGridWin = calcDoc.getChild("grid_window")
22 enter_text_to_cell(xGridWin, "A1", "A")
23 enter_text_to_cell(xGridWin, "A2", "1")
24 enter_text_to_cell(xGridWin, "A3", "2")
25 enter_text_to_cell(xGridWin, "A5", "4")
26 enter_text_to_cell(xGridWin, "A7", "6")
28 xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A7"}))
30 self.xUITest.executeCommand(".uno:DataFilterAutoFilter")
32 # Empty button
33 xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
34 xFloatWindow = self.xUITest.getFloatWindow()
35 xMenu = xFloatWindow.getChild("menu")
36 xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
37 xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
38 xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
39 xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
40 xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
41 xSubFloatWindow = self.xUITest.getFloatWindow()
42 xSubMenu = xSubFloatWindow.getChild("menu")
43 xSubMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
45 # Checkbox elements
46 xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
47 xFloatWindow = self.xUITest.getFloatWindow()
48 xCheckListMenu = xFloatWindow.getChild("FilterDropDown")
49 xTreeList = xCheckListMenu.getChild("check_list_box")
50 self.assertEqual(5, len(xTreeList.getChildren()))
51 self.assertEqual('true', get_state_as_dict(xTreeList.getChild('0'))['IsChecked'])
52 self.assertEqual('false', get_state_as_dict(xTreeList.getChild('2'))['IsChecked'])
53 self.assertEqual('false', get_state_as_dict(xTreeList.getChild('4'))['IsChecked'])
54 xCancelBtn = xFloatWindow.getChild("cancel")
55 xCancelBtn.executeAction("CLICK", tuple())
57 # Not Empty button
58 xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
59 xFloatWindow = self.xUITest.getFloatWindow()
60 xMenu = xFloatWindow.getChild("menu")
61 xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
62 xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
63 xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
64 xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
65 xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
66 xSubFloatWindow = self.xUITest.getFloatWindow()
67 xSubMenu = xSubFloatWindow.getChild("menu")
68 xSubMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
69 xSubMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
71 # Checkbox elements
72 xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
73 xFloatWindow = self.xUITest.getFloatWindow()
74 xCheckListMenu = xFloatWindow.getChild("FilterDropDown")
75 xTreeList = xCheckListMenu.getChild("check_list_box")
76 self.assertEqual(5, len(xTreeList.getChildren()))
77 self.assertEqual('false', get_state_as_dict(xTreeList.getChild('0'))['IsChecked'])
78 self.assertEqual('true', get_state_as_dict(xTreeList.getChild('2'))['IsChecked'])
79 self.assertEqual('true', get_state_as_dict(xTreeList.getChild('4'))['IsChecked'])
80 xCancelBtn = xFloatWindow.getChild("cancel")
81 xCancelBtn.executeAction("CLICK", tuple())
84 # vim: set shiftwidth=4 softtabstop=4 expandtab: