Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / calc_tests4 / tdf89958.py
blob6f31939fb82846539f7339d6f748bec712b84016
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 uitest.uihelper.common import select_by_text
12 from libreoffice.uno.propertyvalue import mkPropertyValues
14 #Bug 89958 - Data->Filter->Standard Filter, condition "does not end with" does filter too much
16 class tdf89958(UITestCase):
17 def test_td89958_standard_filter(self):
18 with self.ui_test.load_file(get_url_for_data_file("tdf89958.ods")):
19 xCalcDoc = self.xUITest.getTopFocusWindow()
20 gridwin = xCalcDoc.getChild("grid_window")
21 #select A1-> Column .uno:SelectColumn
22 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
23 self.xUITest.executeCommand(".uno:SelectColumn")
25 #Menu: Data->Filter->Standard Filter ...
26 #Field Name "Column A", Condition "Does not end with", Value: "CTORS"
27 with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog:
28 xfield1 = xDialog.getChild("field1")
29 xval1 = xDialog.getChild("val1")
30 xcond1 = xDialog.getChild("cond1")
32 select_by_text(xfield1, "Column A")
33 select_by_text(xcond1, "Does not end with")
34 xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"CTORS"}))
36 #Expected behaviours: A2 is not filtered as it does not end with "CTORS".
37 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
38 gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
39 gridWinState = get_state_as_dict(gridwin)
40 self.assertEqual(gridWinState["CurrentRow"], "1")
41 gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
42 gridWinState = get_state_as_dict(gridwin)
43 self.assertEqual(gridWinState["CurrentRow"], "3")
44 # #reopen filter and verify - doesn't works
45 # gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"}))
46 # gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"}))
47 # self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter")
48 # xDialog = self.xUITest.getTopFocusWindow()
49 # xfield1 = xDialog.getChild("field1")
50 # xval1 = xDialog.getChild("val1")
51 # xcond1 = xDialog.getChild("cond1")
52 # self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "Column A")
53 # self.assertEqual(get_state_as_dict(xval1)["Text"], "CTORS")
54 # self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Does not end with")
55 # xCancelBtn = xDialog.getChild("cancel")
56 # self.ui_test.close_dialog_through_button(xCancelBtn)
58 # vim: set shiftwidth=4 softtabstop=4 expandtab: