Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / autofilter2 / tdf153972.py
blobfe994ea9057758bfd1cefd6a8bcacd8120ddbd46
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_url_for_data_file, get_state_as_dict
11 from libreoffice.uno.propertyvalue import mkPropertyValues
12 from libreoffice.calc.document import is_row_hidden
14 class tdf153972(UITestCase):
15 def test_tdf153972(self):
17 with self.ui_test.load_file(get_url_for_data_file("tdf153972.ods")) as doc:
18 calcDoc = self.xUITest.getTopFocusWindow()
19 xGridWin = calcDoc.getChild("grid_window")
21 xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
22 xFloatWindow = self.xUITest.getFloatWindow()
23 xMenu = xFloatWindow.getChild("menu")
25 # Filter by Color
26 xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
27 xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
28 xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
29 xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
31 xSubFloatWindow = self.xUITest.getFloatWindow()
32 xSubMenu = xSubFloatWindow.getChild("background")
34 # Without the fix in place, this test would have failed with
35 # AssertionError: 4 != 0
36 self.assertEqual(4, len(xSubMenu.getChildren()))
37 self.assertEqual('#7FD41A', get_state_as_dict(xSubMenu.getChild('0'))['Text'])
38 self.assertEqual('#FE0000', get_state_as_dict(xSubMenu.getChild('1'))['Text'])
39 self.assertEqual('#FEFF00', get_state_as_dict(xSubMenu.getChild('2'))['Text'])
40 self.assertEqual('No Fill', get_state_as_dict(xSubMenu.getChild('3'))['Text'])
42 # Choose Red
43 xSubMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
44 xSubMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
46 self.assertTrue(is_row_hidden(doc, 1))
47 self.assertTrue(is_row_hidden(doc, 2))
48 self.assertTrue(is_row_hidden(doc, 3))
49 self.assertTrue(is_row_hidden(doc, 4))
50 self.assertTrue(is_row_hidden(doc, 5))
51 self.assertFalse(is_row_hidden(doc, 6))
52 self.assertTrue(is_row_hidden(doc, 7))
53 self.assertTrue(is_row_hidden(doc, 8))
54 self.assertFalse(is_row_hidden(doc, 9))
55 self.assertTrue(is_row_hidden(doc, 10))
56 self.assertFalse(is_row_hidden(doc, 11))
57 self.assertTrue(is_row_hidden(doc, 12))
58 self.assertFalse(is_row_hidden(doc, 13))
60 # vim: set shiftwidth=4 softtabstop=4 expandtab: