1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 from uitest
.framework
import UITestCase
8 from uitest
.uihelper
.calc
import enter_text_to_cell
9 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
10 from libreoffice
.calc
.document
import get_cell_by_position
11 from libreoffice
.calc
.document
import get_row
13 class tdf126306(UITestCase
):
14 def check_values(self
, document
, results
):
15 for i
, value
in enumerate(results
, start
=1):
16 self
.assertEqual(get_cell_by_position(document
, 0, 0, i
).getValue(), value
)
18 def check_row_hidden(self
, document
, results
= [True] * 14):
19 for i
, value
in enumerate(results
, start
=1):
20 row
= get_row(document
, i
)
21 bVisible
= row
.getPropertyValue("IsVisible")
22 self
.assertEqual(bVisible
, value
)
25 self
.ui_test
.create_doc_in_start_center("calc")
26 document
= self
.ui_test
.get_component()
27 calcDoc
= self
.xUITest
.getTopFocusWindow()
28 xGridWin
= calcDoc
.getChild("grid_window")
30 default_values
= [25, 1023, 17, 9, 19, 0, 107, 89, 8, 453, 33, 3, 25, 204]
31 document
= self
.ui_test
.get_component()
33 for i
, value
in enumerate(default_values
, start
=2):
34 enter_text_to_cell(xGridWin
, "A" + str(i
), str(value
))
36 xGridWin
.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A15"}))
38 self
.ui_test
.execute_dialog_through_command(".uno:DataFilterAutoFilter")
39 xDialog
= self
.xUITest
.getTopFocusWindow()
40 xYesBtn
= xDialog
.getChild("yes")
41 self
.ui_test
.close_dialog_through_button(xYesBtn
)
43 self
.assertEqual(document
.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter
, True)
45 self
.check_values(document
, default_values
)
46 self
.check_row_hidden(document
)
48 # Sort ascending button
49 xGridWin
.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
50 xFloatWindow
= self
.xUITest
.getFloatWindow()
51 xMenu
= xFloatWindow
.getChild("menu")
52 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"SPACE"}))
53 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
55 sort_asc_values
= [0, 3, 8, 9, 17, 19, 25, 25, 33, 89, 107, 204, 453, 1023]
56 self
.check_values(document
, sort_asc_values
)
57 self
.check_row_hidden(document
)
60 self
.xUITest
.executeCommand(".uno:Undo")
61 self
.check_values(document
, default_values
)
62 self
.check_row_hidden(document
)
64 # Sort descending button
65 xGridWin
.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
66 xFloatWindow
= self
.xUITest
.getFloatWindow()
67 xMenu
= xFloatWindow
.getChild("menu")
68 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
69 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
71 sort_des_values
= [1023, 453, 204, 107, 89, 33, 25, 25, 19, 17, 9, 8, 3, 0]
72 self
.check_values(document
, sort_des_values
)
73 self
.check_row_hidden(document
)
76 self
.xUITest
.executeCommand(".uno:Undo")
77 self
.check_values(document
, default_values
)
78 self
.check_row_hidden(document
)
81 xGridWin
.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
82 xFloatWindow
= self
.xUITest
.getFloatWindow()
83 xMenu
= xFloatWindow
.getChild("menu")
84 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
85 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
86 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
88 top10_hidden_values
= [True, True, True, False, True, False, True,
89 True, False, True, True, False, True, True]
92 self
.check_values(document
, default_values
)
93 self
.check_row_hidden(document
, top10_hidden_values
)
96 self
.xUITest
.executeCommand(".uno:Undo")
97 self
.check_values(document
, default_values
)
98 self
.check_row_hidden(document
)
101 xGridWin
.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
102 xFloatWindow
= self
.xUITest
.getFloatWindow()
103 xMenu
= xFloatWindow
.getChild("menu")
104 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
105 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
106 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
107 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
109 empty_values
= [False] * 14
111 self
.check_values(document
, default_values
)
112 self
.check_row_hidden(document
, empty_values
)
115 self
.xUITest
.executeCommand(".uno:Undo")
116 self
.check_values(document
, default_values
)
117 self
.check_row_hidden(document
)
120 xGridWin
.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
121 xFloatWindow
= self
.xUITest
.getFloatWindow()
122 xMenu
= xFloatWindow
.getChild("menu")
123 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
124 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
125 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
126 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
127 xMenu
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
129 #Nothing should change
130 self
.check_values(document
, default_values
)
131 self
.check_row_hidden(document
)
134 self
.xUITest
.executeCommand(".uno:Undo")
135 self
.check_values(document
, default_values
)
136 self
.check_row_hidden(document
)
139 self
.ui_test
.close_doc()
141 # vim: set shiftwidth=4 softtabstop=4 expandtab: