Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / autofilter2 / tdf95520.py
blobc5339c3f8db0e231dd7715f6de057e09fabd5212
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 get_cell_by_position
14 class tdf95520(UITestCase):
15 def test_tdf95520(self):
16 # Reuse existing document
17 with self.ui_test.load_file(get_url_for_data_file("tdf144549.ods")) as doc:
18 calcDoc = self.xUITest.getTopFocusWindow()
19 xGridWin = calcDoc.getChild("grid_window")
21 xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"}))
22 xFloatWindow = self.xUITest.getFloatWindow()
23 xMenu = xFloatWindow.getChild("menu")
25 # Sort by Color
26 xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
27 xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
28 xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
30 xSubFloatWindow = self.xUITest.getFloatWindow()
31 xSubMenu = xSubFloatWindow.getChild("textcolor")
32 self.assertEqual(3, len(xSubMenu.getChildren()))
33 self.assertEqual('false', get_state_as_dict(xSubMenu.getChild('0'))['IsChecked'])
34 self.assertEqual('#00FF00', get_state_as_dict(xSubMenu.getChild('0'))['Text'])
35 self.assertEqual('false', get_state_as_dict(xSubMenu.getChild('1'))['IsChecked'])
36 self.assertEqual('false', get_state_as_dict(xSubMenu.getChild('2'))['IsChecked'])
38 # Choose Red
39 xSubMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
40 xSubMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
42 self.assertEqual("Jan", get_cell_by_position(doc, 0, 0, 1).getString())
43 self.assertEqual("Dez", get_cell_by_position(doc, 0, 0, 2).getString())
44 self.assertEqual("Aug", get_cell_by_position(doc, 0, 0, 3).getString())
45 self.assertEqual("Nov", get_cell_by_position(doc, 0, 0, 4).getString())
46 self.assertEqual("Jun", get_cell_by_position(doc, 0, 0, 5).getString())
47 self.assertEqual("Apr", get_cell_by_position(doc, 0, 0, 6).getString())
48 self.assertEqual("Mai", get_cell_by_position(doc, 0, 0, 7).getString())
49 self.assertEqual("Okt", get_cell_by_position(doc, 0, 0, 8).getString())
50 self.assertEqual("Feb", get_cell_by_position(doc, 0, 0, 9).getString())
51 self.assertEqual("Mär", get_cell_by_position(doc, 0, 0, 10).getString())
52 self.assertEqual("Jul", get_cell_by_position(doc, 0, 0, 11).getString())
53 self.assertEqual("Sep", get_cell_by_position(doc, 0, 0, 12).getString())
55 # vim: set shiftwidth=4 softtabstop=4 expandtab: