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