tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / qa / uitest / calc_tests / rows.py
bloba9e34c67347b6d1743bc3afecf9c306fda754bd8
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 change_measurement_unit
12 from libreoffice.uno.propertyvalue import mkPropertyValues
14 class CalcRows(UITestCase):
15 def test_row_height(self):
16 with self.ui_test.create_doc_in_start_center("calc"):
18 with change_measurement_unit(self, "Centimeter"):
19 xCalcDoc = self.xUITest.getTopFocusWindow()
20 gridwin = xCalcDoc.getChild("grid_window")
22 #select A1
23 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
24 #row height
25 with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog:
26 xvalue = xDialog.getChild("value")
27 xdefault = xDialog.getChild("default")
28 self.assertEqual(get_state_as_dict(xdefault)["Selected"], "true") #default selected
30 # tdf#144247: Without the fix in place, this test would have failed with
31 # AssertionError: '0.45 cm' != '0.4516 cm'
32 self.assertEqual("0.45 cm", get_state_as_dict(xvalue)["Text"])
33 xvalue.executeAction("UP", tuple())
34 self.assertEqual("0.50 cm", get_state_as_dict(xvalue)["Text"])
36 self.assertEqual(get_state_as_dict(xdefault)["Selected"], "false") #default not selected
37 xdefault.executeAction("CLICK", tuple()) #click default
38 self.assertEqual("0.45 cm", get_state_as_dict(xvalue)["Text"])
40 #write your own value
41 xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
42 xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
43 xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"}))
44 # Click Ok
45 #verify
46 with self.ui_test.execute_dialog_through_command(".uno:RowHeight", close_button="cancel") as xDialog:
47 xvalue = xDialog.getChild("value")
48 self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm")
51 def test_row_height_two_rows(self):
52 with self.ui_test.create_doc_in_start_center("calc"):
54 with change_measurement_unit(self, "Centimeter"):
55 xCalcDoc = self.xUITest.getTopFocusWindow()
56 gridwin = xCalcDoc.getChild("grid_window")
59 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
60 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3", "EXTEND":"1"}))
62 with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog:
63 xvalue = xDialog.getChild("value")
64 #write your own value
65 xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
66 xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
67 xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"}))
68 # Click Ok
69 #verify
70 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
71 with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog:
72 xvalue = xDialog.getChild("value")
73 self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm")
75 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"}))
76 with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog:
77 xvalue = xDialog.getChild("value")
78 self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm")
81 def test_tdf89140_row_height_copy(self):
82 #Bug 89140 - Calc row paste doesn't keep row height
83 with self.ui_test.create_doc_in_start_center("calc"):
85 with change_measurement_unit(self, "Centimeter"):
86 xCalcDoc = self.xUITest.getTopFocusWindow()
87 gridwin = xCalcDoc.getChild("grid_window")
90 #select A1
91 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
92 #row height
93 with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog:
94 xvalue = xDialog.getChild("value")
95 xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
96 xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
97 xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"}))
98 # Click Ok
99 #select row 1
100 self.xUITest.executeCommand(".uno:SelectRow")
101 #copy
102 self.xUITest.executeCommand(".uno:Copy")
103 #select A3
104 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"}))
105 #paste
106 self.xUITest.executeCommand(".uno:Paste")
107 #verify
108 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"}))
109 with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog:
110 xvalue = xDialog.getChild("value")
111 self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm")
114 def test_row_hide_show(self):
115 with self.ui_test.create_doc_in_start_center("calc"):
116 xCalcDoc = self.xUITest.getTopFocusWindow()
117 gridwin = xCalcDoc.getChild("grid_window")
118 #select A3
119 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"}))
120 self.xUITest.executeCommand(".uno:HideRow") #uno command moves focus one cell down
121 #verify A4
122 gridWinState = get_state_as_dict(gridwin)
123 self.assertEqual(gridWinState["CurrentRow"], "3")
124 gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"UP"}))
125 #verify A2 (row 3 is hidden)
126 gridWinState = get_state_as_dict(gridwin)
127 self.assertEqual(gridWinState["CurrentRow"], "1")
128 #Show hidden row: select A2:A4
129 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:A4"}))
130 self.xUITest.executeCommand(".uno:ShowRow")
131 #verify
132 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A4"}))
133 gridWinState = get_state_as_dict(gridwin)
134 self.assertEqual(gridWinState["CurrentRow"], "3")
135 gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"UP"}))
136 #verify A3 (row 3 is not hidden)
137 gridWinState = get_state_as_dict(gridwin)
138 self.assertEqual(gridWinState["CurrentRow"], "2")
141 def test_row_test_move(self):
142 with self.ui_test.create_doc_in_start_center("calc"):
143 xCalcDoc = self.xUITest.getTopFocusWindow()
144 gridwin = xCalcDoc.getChild("grid_window")
145 #select A3
146 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"}))
147 gridWinState = get_state_as_dict(gridwin)
148 self.assertEqual(gridWinState["CurrentRow"], "2")
149 #down
150 gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
151 #verify A4
152 gridWinState = get_state_as_dict(gridwin)
153 self.assertEqual(gridWinState["CurrentRow"], "3")
154 gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"UP"}))
155 #verify A2
156 gridWinState = get_state_as_dict(gridwin)
157 self.assertEqual(gridWinState["CurrentRow"], "2")
160 def test_row_height_insert_below(self):
161 with self.ui_test.create_doc_in_start_center("calc"):
163 with change_measurement_unit(self, "Centimeter"):
164 xCalcDoc = self.xUITest.getTopFocusWindow()
165 gridwin = xCalcDoc.getChild("grid_window")
167 #select A3
168 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"}))
169 #row height
170 with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog:
171 xvalue = xDialog.getChild("value")
172 xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
173 xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
174 xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"}))
175 # Click Ok
176 #select row 3
177 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"}))
178 self.xUITest.executeCommand(".uno:SelectRow")
179 #insert rows below
180 self.xUITest.executeCommand(".uno:InsertRowsAfter")
182 #verify
183 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"}))
184 with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog:
185 xvalue = xDialog.getChild("value")
186 self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm")
188 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A4"}))
189 with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog:
190 xvalue = xDialog.getChild("value")
191 self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm")
194 # vim: set shiftwidth=4 softtabstop=4 expandtab: