tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / qa / uitest / autofilter / autofilterBugs.py
blob849351861d7f2d16930acb3563717ac2600400d3
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/.
10 from uitest.framework import UITestCase
11 from libreoffice.uno.propertyvalue import mkPropertyValues
12 from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
13 from uitest.uihelper.calc import enter_text_to_cell
15 class autofilter(UITestCase):
17 def test_tdf115046(self):
18 with self.ui_test.load_file(get_url_for_data_file("tdf115046.ods")) as calc_doc:
19 #autofilter exist
20 self.assertEqual(calc_doc.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True)
22 with self.ui_test.execute_dialog_through_command(".uno:DataSort", close_button="cancel"):
23 pass
25 #autofilter still exist
26 self.assertEqual(calc_doc.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True)
28 def test_tdf123095(self):
29 with self.ui_test.create_doc_in_start_center("calc"):
30 calcDoc = self.xUITest.getTopFocusWindow()
31 xGridWindow = calcDoc.getChild("grid_window")
32 enter_text_to_cell(xGridWindow, "A1", "乙二醇(进口料件)")
33 enter_text_to_cell(xGridWindow, "A2", "乙二醇(进口料件)")
34 xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"}))
36 with self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter", close_button="no"):
37 pass
39 xGridWindow.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
40 xFloatWindow = self.xUITest.getFloatWindow()
41 xTreeList = xFloatWindow.getChild("check_list_box")
43 # Without the fix in place, the second entry would not exist
44 self.assertEqual(2, len(xTreeList.getChildren()))
45 self.assertEqual(get_state_as_dict(xTreeList.getChild("0"))["Text"], "乙二醇(进口料件)")
46 self.assertEqual(get_state_as_dict(xTreeList.getChild("1"))["Text"], "乙二醇(进口料件)")
48 def test_tdf125363(self):
49 with self.ui_test.create_doc_in_start_center("calc"):
50 calcDoc = self.xUITest.getTopFocusWindow()
51 xGridWindow = calcDoc.getChild("grid_window")
52 enter_text_to_cell(xGridWindow, "A1", "guet")
53 enter_text_to_cell(xGridWindow, "A2", "guͤt")
54 enter_text_to_cell(xGridWindow, "A3", "tuon")
55 enter_text_to_cell(xGridWindow, "A4", "tuͦn")
56 enter_text_to_cell(xGridWindow, "A5", "vröude")
57 enter_text_to_cell(xGridWindow, "A6", "vröudᵉ")
58 xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A6"}))
60 with self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter", close_button="no"):
61 pass
63 xGridWindow.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
64 xFloatWindow = self.xUITest.getFloatWindow()
65 xTreeList = xFloatWindow.getChild("check_list_box")
67 # Without the fix in place, the entries with superscript/modifier letters would not exist
68 self.assertEqual(6, len(xTreeList.getChildren()))
69 self.assertEqual(get_state_as_dict(xTreeList.getChild("0"))["Text"], "guet")
70 self.assertEqual(get_state_as_dict(xTreeList.getChild("1"))["Text"], "guͤt")
71 self.assertEqual(get_state_as_dict(xTreeList.getChild("2"))["Text"], "tuon")
72 self.assertEqual(get_state_as_dict(xTreeList.getChild("3"))["Text"], "tuͦn")
73 self.assertEqual(get_state_as_dict(xTreeList.getChild("4"))["Text"], "vröude")
74 self.assertEqual(get_state_as_dict(xTreeList.getChild("5"))["Text"], "vröudᵉ")
76 def test_tdf158326(self):
77 with self.ui_test.create_doc_in_start_center("calc"):
78 calcDoc = self.xUITest.getTopFocusWindow()
79 xGridWindow = calcDoc.getChild("grid_window")
80 enter_text_to_cell(xGridWindow, "A1", "vröude")
81 enter_text_to_cell(xGridWindow, "A2", "vröudᵉ")
82 enter_text_to_cell(xGridWindow, "A3", "vröude")
83 enter_text_to_cell(xGridWindow, "A4", "vröudᵉ")
84 enter_text_to_cell(xGridWindow, "A5", "vröude")
85 enter_text_to_cell(xGridWindow, "A6", "vröudᵉ")
86 xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A6"}))
88 with self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter", close_button="no"):
89 pass
91 xGridWindow.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
92 xFloatWindow = self.xUITest.getFloatWindow()
93 xTreeList = xFloatWindow.getChild("check_list_box")
95 # Without the fix in place, there would be 5 items since they will not be removed
96 self.assertEqual(2, len(xTreeList.getChildren()))
97 self.assertEqual(get_state_as_dict(xTreeList.getChild("0"))["Text"], "vröude")
98 self.assertEqual(get_state_as_dict(xTreeList.getChild("1"))["Text"], "vröudᵉ")
100 def test_tdf94055(self):
101 with self.ui_test.create_doc_in_start_center("calc") as document:
102 calcDoc = self.xUITest.getTopFocusWindow()
103 xGridWindow = calcDoc.getChild("grid_window")
104 enter_text_to_cell(xGridWindow, "A1", "X")
105 enter_text_to_cell(xGridWindow, "B1", "Y")
106 enter_text_to_cell(xGridWindow, "A2", "a")
107 enter_text_to_cell(xGridWindow, "B2", "b")
108 enter_text_to_cell(xGridWindow, "A3", "c")
109 enter_text_to_cell(xGridWindow, "B3", "d")
110 xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B1"}))
112 with self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter", close_button="yes"):
113 pass
115 xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:A3"}))
116 self.xUITest.executeCommand(".uno:SelectRow") #select two rows
118 with self.ui_test.execute_dialog_through_command(".uno:DataSort"):
119 pass
121 #autofilter still exist
122 self.assertEqual(document.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True)
125 #tdf77479.ods
126 def test_tdf77479(self):
127 with self.ui_test.load_file(get_url_for_data_file("tdf77479.ods")) as calc_doc:
128 calcDoc = self.xUITest.getTopFocusWindow()
129 xGridWindow = calcDoc.getChild("grid_window")
130 #autofilter exist
131 self.assertEqual(calc_doc.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True)
133 xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:E6"}))
135 with self.ui_test.execute_dialog_through_command(".uno:DataSort"):
136 pass
138 #autofilter still exist
139 self.assertEqual(calc_doc.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True)
141 #112656
142 def test_tdf112656(self):
143 with self.ui_test.load_file(get_url_for_data_file("tdf112656.ods")):
144 calcDoc = self.xUITest.getTopFocusWindow()
145 xGridWindow = calcDoc.getChild("grid_window")
147 xGridWindow.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "2", "ROW": "0"}))
148 xFloatWindow = self.xUITest.getFloatWindow()
149 xTreeList = xFloatWindow.getChild("check_list_box")
150 xFirstEntry = xTreeList.getChild("0")
151 xSecondEntry = xTreeList.getChild("1")
152 self.assertEqual(get_state_as_dict(xFirstEntry)["Text"], "Fruit")
153 self.assertEqual(get_state_as_dict(xSecondEntry)["Text"], "Vegetables")
155 #tdf81124
156 def test_tdf81124(self):
157 with self.ui_test.load_file(get_url_for_data_file("tdf81124.ods")):
158 calcDoc = self.xUITest.getTopFocusWindow()
159 xGridWindow = calcDoc.getChild("grid_window")
161 xGridWindow.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
162 xFloatWindow = self.xUITest.getFloatWindow()
164 xUnselect = xFloatWindow.getChild("unselect_current")
165 xUnselect.executeAction("CLICK", tuple())
166 xokBtn = xFloatWindow.getChild("ok")
167 self.assertEqual(get_state_as_dict(xokBtn)["Enabled"], "false")
169 xSelect = xFloatWindow.getChild("select_current")
170 xSelect.executeAction("CLICK", tuple())
171 xokBtn = xFloatWindow.getChild("ok")
172 self.assertEqual(get_state_as_dict(xokBtn)["Enabled"], "true")
174 xCancel = xFloatWindow.getChild("cancel")
175 xCancel.executeAction("CLICK", tuple())
177 #tdf73565
178 def test_tdf73565(self):
179 with self.ui_test.load_file(get_url_for_data_file("tdf73565.ods")):
180 calcDoc = self.xUITest.getTopFocusWindow()
181 xGridWindow = calcDoc.getChild("grid_window")
183 xGridWindow.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
184 xFloatWindow = self.xUITest.getFloatWindow()
185 xTreeList = xFloatWindow.getChild("check_tree_box")
186 xFirstEntry = xTreeList.getChild("0")
187 self.assertEqual(get_state_as_dict(xFirstEntry)["Text"], "2014")
189 xCancel = xFloatWindow.getChild("cancel")
190 xCancel.executeAction("CLICK", tuple())
192 #tdf65505
193 def test_tdf65505(self):
194 with self.ui_test.load_file(get_url_for_data_file("tdf81124.ods")):
195 calcDoc = self.xUITest.getTopFocusWindow()
196 xGridWindow = calcDoc.getChild("grid_window")
198 xGridWindow.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
199 xFloatWindow = self.xUITest.getFloatWindow()
200 xTreeList = xFloatWindow.getChild("check_list_box")
201 xFirstEntry = xTreeList.getChild("0")
202 self.assertEqual(get_state_as_dict(xFirstEntry)["Text"], "(empty)")
204 xCancel = xFloatWindow.getChild("cancel")
205 xCancel.executeAction("CLICK", tuple())
207 #tdf74857
208 def test_tdf74857(self):
209 with self.ui_test.load_file(get_url_for_data_file("tdf74857.ods")):
210 calcDoc = self.xUITest.getTopFocusWindow()
211 xGridWindow = calcDoc.getChild("grid_window")
213 xGridWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"SHIFT+CTRL+DOWN"}))
214 # Assert that the correct range has been selected
215 gridWinState = get_state_as_dict(xGridWindow)
216 self.assertEqual(gridWinState["MarkedArea"], "Sheet1.A1:Sheet1.A25")
218 #tdf35294
219 def test_tdf35294(self):
220 with self.ui_test.load_file(get_url_for_data_file("tdf35294.ods")):
221 calcDoc = self.xUITest.getTopFocusWindow()
222 xGridWindow = calcDoc.getChild("grid_window")
224 xGridWindow.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
225 xFloatWindow = self.xUITest.getFloatWindow()
226 xTreeList = xFloatWindow.getChild("check_list_box")
227 x1Entry = xTreeList.getChild("0")
228 x2Entry = xTreeList.getChild("1")
229 x3Entry = xTreeList.getChild("2")
230 x4Entry = xTreeList.getChild("3")
231 x5Entry = xTreeList.getChild("4")
232 x6Entry = xTreeList.getChild("5")
233 x7Entry = xTreeList.getChild("6")
235 self.assertEqual(get_state_as_dict(x1Entry)["Text"], "a")
236 self.assertEqual(get_state_as_dict(x2Entry)["Text"], "á")
237 self.assertEqual(get_state_as_dict(x3Entry)["Text"], "b")
238 self.assertEqual(get_state_as_dict(x4Entry)["Text"], "č")
239 self.assertEqual(get_state_as_dict(x5Entry)["Text"], "é")
240 self.assertEqual(get_state_as_dict(x6Entry)["Text"], "ř")
241 self.assertEqual(get_state_as_dict(x7Entry)["Text"], "ž")
243 xCancel = xFloatWindow.getChild("cancel")
244 xCancel.executeAction("CLICK", tuple())
246 #tdf55712
247 def test_tdf55712(self):
248 with self.ui_test.load_file(get_url_for_data_file("tdf55712.ods")):
249 calcDoc = self.xUITest.getTopFocusWindow()
250 xGridWindow = calcDoc.getChild("grid_window")
252 xGridWindow.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
253 xFloatWindow = self.xUITest.getFloatWindow()
254 xTreeList = xFloatWindow.getChild("check_list_box")
255 x1Entry = xTreeList.getChild("0")
256 x2Entry = xTreeList.getChild("1")
257 x3Entry = xTreeList.getChild("2")
258 x4Entry = xTreeList.getChild("3")
259 x5Entry = xTreeList.getChild("4")
260 x6Entry = xTreeList.getChild("5")
261 x7Entry = xTreeList.getChild("6")
262 x8Entry = xTreeList.getChild("7")
263 x9Entry = xTreeList.getChild("8")
265 self.assertEqual(get_state_as_dict(x1Entry)["Text"], "(empty)")
266 self.assertEqual(get_state_as_dict(x2Entry)["Text"], "0")
267 self.assertEqual(get_state_as_dict(x3Entry)["Text"], "0.1")
268 self.assertEqual(get_state_as_dict(x4Entry)["Text"], "0.2")
269 self.assertEqual(get_state_as_dict(x5Entry)["Text"], "0.3")
270 self.assertEqual(get_state_as_dict(x6Entry)["Text"], "0.5")
271 self.assertEqual(get_state_as_dict(x7Entry)["Text"], "0.8")
272 self.assertEqual(get_state_as_dict(x8Entry)["Text"], "0.9")
273 self.assertEqual(get_state_as_dict(x9Entry)["Text"], "1")
274 self.assertEqual(get_state_as_dict(xTreeList)["Children"], "9")
276 xCancel = xFloatWindow.getChild("cancel")
277 xCancel.executeAction("CLICK", tuple())
279 #tdf152082
280 def test_tdf152082(self):
281 with self.ui_test.load_file(get_url_for_data_file("tdf152082.ods")):
282 xCalcDoc = self.xUITest.getTopFocusWindow()
283 gridwin = xCalcDoc.getChild("grid_window")
285 gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
286 xFloatWindow = self.xUITest.getFloatWindow()
287 xCheckListMenu = xFloatWindow.getChild("FilterDropDown")
288 xTreeList = xCheckListMenu.getChild("check_list_box")
289 self.assertEqual(4, len(xTreeList.getChildren()))
290 self.assertEqual('true', get_state_as_dict(xTreeList.getChild('0'))['IsChecked'])
291 self.assertEqual('true', get_state_as_dict(xTreeList.getChild('1'))['IsChecked'])
292 self.assertEqual('true', get_state_as_dict(xTreeList.getChild('2'))['IsChecked'])
293 self.assertEqual('false', get_state_as_dict(xTreeList.getChild('3'))['IsChecked'])
294 xCancelBtn = xFloatWindow.getChild("cancel")
295 xCancelBtn.executeAction("CLICK", tuple())
297 # vim: set shiftwidth=4 softtabstop=4 expandtab: