Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / validity / tdf96698.py
blobd25a5378f5beb31d001a52777615a7d1f32d602d
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
11 from uitest.uihelper.common import select_by_text, select_pos
13 from libreoffice.uno.propertyvalue import mkPropertyValues
16 # Bug 96698 - Data => Validity => Custom (like Excel) is missing
17 class tdf96698(UITestCase):
18 def test_tdf96698_validity_custom_formula(self):
19 with self.ui_test.create_doc_in_start_center("calc"):
20 xCalcDoc = self.xUITest.getTopFocusWindow()
21 gridwin = xCalcDoc.getChild("grid_window")
23 #A general validity check for the entered new content of the active cell - especially for text
24 #with a custom formula like in Excel is not possible.
25 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"}))
26 with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog:
27 xTabs = xDialog.getChild("tabcontrol")
28 select_pos(xTabs, "0")
29 xallow = xDialog.getChild("allow")
30 xmin = xDialog.getChild("min")
32 select_by_text(xallow, "Custom")
33 xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"ISERROR(FIND(\",\",B2))"}))
34 #verify
35 with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog:
36 xallow = xDialog.getChild("allow")
37 xmin = xDialog.getChild("min")
39 self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Custom")
40 self.assertEqual(get_state_as_dict(xmin)["Text"], "ISERROR(FIND(\",\",B2))")
43 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"}))
44 with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog:
45 xTabs = xDialog.getChild("tabcontrol")
46 select_pos(xTabs, "0")
47 xallow = xDialog.getChild("allow")
48 xmin = xDialog.getChild("min")
50 select_by_text(xallow, "Custom")
51 xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"NOT(ISERROR(B3))"}))
52 #verify
53 with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog:
54 xallow = xDialog.getChild("allow")
55 xmin = xDialog.getChild("min")
57 self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Custom")
58 self.assertEqual(get_state_as_dict(xmin)["Text"], "NOT(ISERROR(B3))")
61 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A7"}))
62 with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog:
63 xTabs = xDialog.getChild("tabcontrol")
64 select_pos(xTabs, "0")
65 xallow = xDialog.getChild("allow")
66 xmin = xDialog.getChild("min")
68 select_by_text(xallow, "Custom")
69 xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"ISERROR(FIND(\",\",A7))"}))
70 #verify
71 with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog:
72 xallow = xDialog.getChild("allow")
73 xmin = xDialog.getChild("min")
75 self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Custom")
76 self.assertEqual(get_state_as_dict(xmin)["Text"], "ISERROR(FIND(\",\",A7))")
79 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A8"}))
80 with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog:
81 xTabs = xDialog.getChild("tabcontrol")
82 select_pos(xTabs, "0")
83 xallow = xDialog.getChild("allow")
84 xmin = xDialog.getChild("min")
86 select_by_text(xallow, "Custom")
87 xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"NOT(ISERROR(A8))"}))
88 #verify
89 with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog:
90 xallow = xDialog.getChild("allow")
91 xmin = xDialog.getChild("min")
93 self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Custom")
94 self.assertEqual(get_state_as_dict(xmin)["Text"], "NOT(ISERROR(A8))")
98 # vim: set shiftwidth=4 softtabstop=4 expandtab: