on xenial help sign in
Fix qml tests after the refactor.
commit41d350016d4c616934ecb09f8a3e7794fa732ac8 authorMichał Sawicz <michal.sawicz@canonical.com> dateThu 10 Jul 2014, 22:36 (12 years ago) parent8317b6e
4 files changed+18−214
tests/autopilot/unity8/shell/emulators/dash.py+1−1 tests/qmltests/CMakeLists.txt−1 tests/qmltests/Components/tst_FilterGrid.qml−190 tests/qmltests/Dash/tst_GenericScopeView.qml+17−22
tests/autopilot/unity8/shell/emulators/dash.py+1−1
@@ -40,7 +40,7 @@ class Dash(emulators.UnityEmulatorBase):
4040
4141 def get_applications_grid(self):
4242 get_grid = self.get_scope('clickscope').wait_select_single(
43− 'CardFilterGrid', objectName='local')
43+ 'CardGrid', objectName='local')
4444 return get_grid
4545
4646 def get_application_icon(self, text):
tests/qmltests/CMakeLists.txt−1
@@ -24,7 +24,6 @@ add_qml_test(. Shell IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_
2424add_qml_test(Components Carousel)
2525add_qml_test(Components DraggingArea)
2626add_qml_test(Components EdgeDemoOverlay)
27−add_qml_test(Components FilterGrid)
2827add_qml_test(Components LazyImage)
2928add_qml_test(Components Rating)
3029add_qml_test(Components ResponsiveFlowView)
tests/qmltests/Components/tst_FilterGrid.qmldeleted−190
@@ -1,190 +0,0 @@
1−/*
2− * Copyright 2013 Canonical Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.0
18−import QtTest 1.0
19−import "../../../qml/Components"
20−import Ubuntu.Components.ListItems 0.1 as ListItem
21−import Ubuntu.Components 0.1
22−import Unity.Test 0.1 as UT
23−import Utils 0.1
24−
25−/*
26− You should see 6 green squares (from "A" to "F") and a button "View all (12)".
27− Once you press that button other 6 green squares (from "G" to "L") should show up.
28−*/
29−Rectangle {
30− width: gridRect.width + controls.width
31− height: units.gu(50)
32− color: "white"
33−
34− Column {
35− id: controls
36− width: units.gu(30)
37− height: parent.height
38− anchors.top: parent.top
39− anchors.right: parent.right
40− ListItem.ValueSelector {
41− id: collapsedRowCountSelector
42− text: "collapsedRowCount"
43− values: [1,2,3,4]
44− selectedIndex: 1
45− }
46− Row {
47− spacing: units.gu(1)
48− Label { anchors.verticalCenter: parent.verticalCenter
49− text: "Filter" }
50− CheckBox {
51− id: filterCheckBox
52− checked: true
53− onCheckedChanged: filterGrid.setFilter(checked, false /*animate*/)
54− }
55− }
56− }
57−
58− ListModel {
59− id: fakeModel
60− ListElement { name: "A" }
61− ListElement { name: "B" }
62− ListElement { name: "C" }
63− ListElement { name: "D" }
64− ListElement { name: "E" }
65− ListElement { name: "F" }
66− ListElement { name: "G" }
67− ListElement { name: "H" }
68− ListElement { name: "I" }
69− ListElement { name: "J" }
70− ListElement { name: "K" }
71− ListElement { name: "L" }
72− }
73−
74− ListModel {
75− id: fakeModelTwoItems
76− ListElement { name: "A" }
77− ListElement { name: "B" }
78− }
79−
80− ListModel {
81− id: fakeModelFourItems
82− ListElement { name: "A" }
83− ListElement { name: "B" }
84− ListElement { name: "C" }
85− ListElement { name: "D" }
86− }
87−
88− Rectangle {
89− id: gridRect
90− width: units.gu(30)
91− height: parent.height
92− color: "grey"
93− anchors.top: parent.top
94− anchors.left: parent.left
95−
96− FilterGrid {
97− id: filterGrid
98− anchors.fill: parent
99− model: fakeModel
100− maximumNumberOfColumns: 3
101− collapsedRowCount:
102− collapsedRowCountSelector.values[collapsedRowCountSelector.selectedIndex]
103− minimumHorizontalSpacing: units.gu(1)
104− delegateWidth: units.gu(6)
105− delegateHeight: units.gu(6)
106− verticalSpacing: units.gu(1)
107−
108− delegate: Rectangle {
109− // So that it can be identified by countVisibleDelegates()
110− property bool isGridDelegate: true
111−
112− color: "green"
113− width: units.gu(6)
114− height: units.gu(6)
115− Text {
116− anchors.centerIn: parent
117− text: name
118− }
119− }
120− }
121− }
122−
123− UT.UnityTestCase {
124− name: "FilterGrid"
125− when: windowShown
126−
127− function init() {
128− filterGrid.model = fakeModel
129− }
130−
131− function cleanup() {
132− filterCheckBox.checked = true
133− collapsedRowCountSelector.selectedIndex = 1
134− }
135−
136− function test_turningFilterOffShowsAllElements() {
137− tryCompareFunction(countVisibleDelegates, 6)
138−
139− filterCheckBox.checked = false
140−
141− tryCompareFunction(countVisibleDelegates, 12)
142− }
143−
144− function test_collapsedRowCount() {
145− for (var i = 0; i < 4; ++i) {
146− collapsedRowCountSelector.selectedIndex = i
147− // We have 3 elements per row.
148− // row count == index + 1
149− tryCompareFunction(countVisibleDelegates, 3*(i+1))
150− }
151− }
152−
153− function test_modelSizeAffectsCollapsedRowCount_data() {
154− return [
155− { tag: "2 items, collapsedRows 1", model: fakeModelTwoItems, collapsedRowCountIndex: 0,
156− rowsWhenCollapsed: 1, visibleDelegates: 2 },
157− { tag: "2 items, collapsedRows 2", model: fakeModelTwoItems, collapsedRowCountIndex: 1,
158− rowsWhenCollapsed: 1, visibleDelegates: 2 },
159− { tag: "4 items, collapsedRows 1", model: fakeModelFourItems, collapsedRowCountIndex: 0,
160− rowsWhenCollapsed: 1, visibleDelegates: 3 },
161− { tag: "4 items, collapsedRows 2", model: fakeModelFourItems, collapsedRowCountIndex: 1,
162− rowsWhenCollapsed: 2, visibleDelegates: 4 },
163− ]
164− }
165−
166− function test_modelSizeAffectsCollapsedRowCount(data) {
167− filterGrid.model = data.model
168− collapsedRowCountSelector.selectedIndex = data.collapsedRowCountIndex
169−
170− tryCompare(filterGrid, "rowsWhenCollapsed", data.rowsWhenCollapsed)
171− tryCompareFunction(countVisibleDelegates, data.visibleDelegates)
172− }
173−
174− function countVisibleDelegates() {
175− return __countVisibleDelegates(filterGrid.visibleChildren, 0)
176− }
177−
178− function __countVisibleDelegates(objList, total) {
179− for (var i = 0; i < objList.length; ++i) {
180− var child = objList[i];
181− if (child.isGridDelegate !== undefined) {
182− ++total;
183− } else {
184− total = __countVisibleDelegates(child.visibleChildren, total)
185− }
186− }
187− return total
188− }
189− }
190−}
tests/qmltests/Dash/tst_GenericScopeView.qml+17−22
@@ -59,6 +59,7 @@ Item {
5959 genericScopeView.scope = scopes.getScope(2)
6060 shell.width = units.gu(120)
6161 genericScopeView.categoryView.positionAtBeginning();
62+ waitForRendering(genericScopeView.categoryView);
6263 tryCompare(genericScopeView.categoryView, "contentY", 0)
6364 }
6465
@@ -105,8 +106,6 @@ Item {
105106 }
106107
107108 function test_filter_expand_collapse() {
108− // wait for the item to be there
109− waitForRendering(genericScopeView);
110109 tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader0") != null; }, true);
111110
112111 var header = findChild(genericScopeView, "dashSectionHeader0")
@@ -114,18 +113,18 @@ Item {
114113
115114 waitForRendering(header);
116115 verify(category.expandable);
117− verify(category.filtered);
116+ verify(!category.expanded);
118117
119118 var initialHeight = category.height;
120119 var middleHeight;
121120 mouseClick(header, header.width / 2, header.height / 2);
122121 tryCompareFunction(function() { middleHeight = category.height; return category.height > initialHeight; }, true);
123− tryCompare(category, "filtered", false);
122+ tryCompare(category, "expanded", true);
124123 tryCompareFunction(function() { return category.height > middleHeight; }, true);
125124
126125 mouseClick(header, header.width / 2, header.height / 2);
127126 verify(category.expandable);
128− tryCompare(category, "filtered", true);
127+ tryCompare(category, "expanded", false);
129128 }
130129
131130 function test_filter_expand_expand_collapse() {
@@ -137,51 +136,47 @@ Item {
137136
138137 var header2 = findChild(genericScopeView, "dashSectionHeader2")
139138 var category2 = findChild(genericScopeView, "dashCategory2")
140− var category2FilterGrid = category2.children[1].children[2];
141− verify(UT.Util.isInstanceOf(category2FilterGrid, "CardFilterGrid"));
142139
143140 waitForRendering(header2);
144141 verify(category2.expandable);
145− verify(category2.filtered);
142+ verify(!category2.expanded);
146143
147144 mouseClick(header2, header2.width / 2, header2.height / 2);
148− tryCompare(category2, "filtered", false);
149− tryCompare(category2FilterGrid, "filtered", false);
145+ tryCompare(category2, "expanded", true);
150146
151147 categoryListView.positionAtBeginning();
152148
153149 var header0 = findChild(genericScopeView, "dashSectionHeader0")
154150 var category0 = findChild(genericScopeView, "dashCategory0")
155151 mouseClick(header0, header0.width / 2, header0.height / 2);
156− tryCompare(category0, "filtered", false);
157− tryCompare(category2, "filtered", true);
158− tryCompare(category2FilterGrid, "filtered", true);
152+ tryCompare(category0, "expanded", true);
153+ tryCompare(category2, "expanded", false);
159154 mouseClick(header0, header0.width / 2, header0.height / 2);
160− tryCompare(category0, "filtered", true);
161− tryCompare(category2, "filtered", true);
155+ tryCompare(category0, "expanded", false);
156+ tryCompare(category2, "expanded", false);
162157 }
163158
164159 function test_narrow_delegate_ranges_expand() {
165160 tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") != undefined; }, true);
166161 var category = findChild(genericScopeView, "dashCategory0")
167− tryCompare(category, "filtered", true);
162+ tryCompare(category, "expanded", false);
168163
169164 shell.width = units.gu(20)
170165 var categoryListView = findChild(genericScopeView, "categoryListView");
171166 categoryListView.contentY = units.gu(20);
172167 var header0 = findChild(genericScopeView, "dashSectionHeader0")
173168 mouseClick(header0, header0.width / 2, header0.height / 2);
174− tryCompare(category, "filtered", false);
169+ tryCompare(category, "expanded", true);
175170 tryCompareFunction(function() { return category.item.height == genericScopeView.height - category.item.displayMarginBeginning - category.item.displayMarginEnd; }, true);
176171 mouseClick(header0, header0.width / 2, header0.height / 2);
177− tryCompare(category, "filtered", true);
172+ tryCompare(category, "expanded", false);
178173 }
179174
180175 function openPreview() {
181176 tryCompareFunction(function() {
182− var filterGrid = findChild(genericScopeView, "0");
183− if (filterGrid != null) {
184− var tile = findChild(filterGrid, "delegate0");
177+ var cardGrid = findChild(genericScopeView, "0");
178+ if (cardGrid != null) {
179+ var tile = findChild(cardGrid, "delegate0");
185180 return tile != null;
186181 }
187182 return false;
@@ -257,7 +252,7 @@ Item {
257252 closePreview();
258253 }
259254
260− function test_haeder_logo() {
255+ function test_header_logo() {
261256 genericScopeView.scope = scopes.getScope(3);
262257
263258 var image = findChild(genericScopeView, "titleImage");