Merge lp:~gerboland/unity/lvwph-tests into lp:unity/phablet

Proposed by Gerry Boland
Status: Merged
Approved by: Michael Zanetti
Approved revision: no longer in the source branch.
Merged at revision: 592
Proposed branch: lp:~gerboland/unity/lvwph-tests
Merge into: lp:unity/phablet
Diff against target: 396 lines (+357/-2)
4 files modified
Components/ListViewWithPageHeader.qml (+4/-0)
tests/qmluitests/Components/CMakeLists.txt (+1/-0)
tests/qmluitests/Components/tst_ListViewWithPageHeader.qml (+350/-0)
tests/qmluitests/UnityTestCase.qml (+2/-2)
To merge this branch: bzr merge lp:~gerboland/unity/lvwph-tests
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michael Zanetti (community) Approve
Review via email: mp+158336@code.launchpad.net

Commit message

[tests] Add ListViewWithPageHeader tests

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
MichaƂ Sawicz (saviq) wrote :

The above failure should go away with lp:~saviq/unity/phablet.add-python3-dep

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

looks good to me. Jenkins seems happy too

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Components/ListViewWithPageHeader.qml'
--- Components/ListViewWithPageHeader.qml 2013-02-27 17:36:32 +0000
+++ Components/ListViewWithPageHeader.qml 2013-04-12 15:11:26 +0000
@@ -64,6 +64,10 @@
64 headerAnimation.start()64 headerAnimation.start()
65 }65 }
6666
67 function flick(xVelocity, yVelocity) {
68 flicker.flick(xVelocity, yVelocity);
69 }
70
67 onPageHeaderChanged: {71 onPageHeaderChanged: {
68 pageHeader.parent = pageHeaderContainer;72 pageHeader.parent = pageHeaderContainer;
69 pageHeader.anchors.fill = pageHeaderContainer;73 pageHeader.anchors.fill = pageHeaderContainer;
7074
=== modified file 'tests/qmluitests/Components/CMakeLists.txt'
--- tests/qmluitests/Components/CMakeLists.txt 2013-04-12 12:49:20 +0000
+++ tests/qmluitests/Components/CMakeLists.txt 2013-04-12 15:11:26 +0000
@@ -1,5 +1,6 @@
1add_qml_test(DraggingArea)1add_qml_test(DraggingArea)
2add_qml_test(FilterGrid IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)2add_qml_test(FilterGrid IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
3add_qml_test(ListViewWithPageHeader)
3add_qml_test(ResponsiveFlowView)4add_qml_test(ResponsiveFlowView)
4add_qml_test(ResponsiveGridView)5add_qml_test(ResponsiveGridView)
5add_qml_test(Revealer)6add_qml_test(Revealer)
67
=== added file 'tests/qmluitests/Components/tst_ListViewWithPageHeader.qml'
--- tests/qmluitests/Components/tst_ListViewWithPageHeader.qml 1970-01-01 00:00:00 +0000
+++ tests/qmluitests/Components/tst_ListViewWithPageHeader.qml 2013-04-12 15:11:26 +0000
@@ -0,0 +1,350 @@
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
17import QtQuick 2.0
18import QtTest 1.0
19import ".."
20import "../../../Components"
21import Ubuntu.Components.ListItems 0.1 as ListItem
22import Ubuntu.Components 0.1
23
24Item {
25 id: root
26 width: units.gu(40)
27 height: units.gu(80)
28
29 ListModel {
30 id: animalsModel
31 ListElement { name: "Parrot"; size: "Small" }
32 ListElement { name: "Guinea pig"; size: "Small" }
33 ListElement { name: "Mouse"; size: "Small" }
34 ListElement { name: "Sparrow"; size: "Small" }
35 ListElement { name: "Dog"; size: "Medium" }
36 ListElement { name: "Cat"; size: "Medium" }
37 ListElement { name: "Dolphin"; size: "Medium" }
38 ListElement { name: "Seal"; size: "Medium" }
39 ListElement { name: "Elephant"; size: "Large" }
40 ListElement { name: "Blue whale"; size: "Large" }
41 ListElement { name: "Rhino"; size: "Large" }
42 ListElement { name: "Ostrich"; size: "Large" }
43 ListElement { name: "Sperm whale"; size: "Large" }
44 ListElement { name: "Giraffe"; size: "Large" }
45 ListElement { name: "Parrot"; size: "Small" }
46 ListElement { name: "Guinea pig"; size: "Small" }
47 ListElement { name: "Mouse"; size: "Small" }
48 ListElement { name: "Sparrow"; size: "Small" }
49 ListElement { name: "Dog"; size: "Medium" }
50 ListElement { name: "Cat"; size: "Medium" }
51 ListElement { name: "Dolphin"; size: "Medium" }
52 ListElement { name: "Seal"; size: "Medium" }
53 ListElement { name: "Elephant"; size: "Large" }
54 ListElement { name: "Blue whale"; size: "Large" }
55 ListElement { name: "Rhino"; size: "Large" }
56 ListElement { name: "Ostrich"; size: "Large" }
57 ListElement { name: "Sperm whale"; size: "Large" }
58 ListElement { name: "Giraffe"; size: "Large" }
59 ListElement { name: "Parrot"; size: "Small" }
60 ListElement { name: "Guinea pig"; size: "Small" }
61 ListElement { name: "Mouse"; size: "Small" }
62 ListElement { name: "Sparrow"; size: "Small" }
63 ListElement { name: "Dog"; size: "Medium" }
64 ListElement { name: "Cat"; size: "Medium" }
65 ListElement { name: "Dolphin"; size: "Medium" }
66 ListElement { name: "Seal"; size: "Medium" }
67 ListElement { name: "Elephant"; size: "Large" }
68 ListElement { name: "Blue whale"; size: "Large" }
69 ListElement { name: "Rhino"; size: "Large" }
70 ListElement { name: "Ostrich"; size: "Large" }
71 ListElement { name: "Sperm whale"; size: "Large" }
72 ListElement { name: "Giraffe"; size: "Large" }
73 ListElement { name: "Parrot"; size: "Small" }
74 ListElement { name: "Guinea pig"; size: "Small" }
75 ListElement { name: "Mouse"; size: "Small" }
76 ListElement { name: "Sparrow"; size: "Small" }
77 ListElement { name: "Dog"; size: "Medium" }
78 ListElement { name: "Cat"; size: "Medium" }
79 ListElement { name: "Dolphin"; size: "Medium" }
80 ListElement { name: "Seal"; size: "Medium" }
81 ListElement { name: "Elephant"; size: "Large" }
82 ListElement { name: "Blue whale"; size: "Large" }
83 ListElement { name: "Rhino"; size: "Large" }
84 ListElement { name: "Ostrich"; size: "Large" }
85 ListElement { name: "Sperm whale"; size: "Large" }
86 ListElement { name: "Giraffe"; size: "Large" }
87 }
88
89 ListViewWithPageHeader {
90 id: listView
91 anchors.fill: parent
92 model: animalsModel
93
94 delegate: Item {
95 height: units.gu(6)
96 anchors {
97 left: parent.left
98 right: parent.right
99 }
100
101 Label {
102 id: label
103 anchors.fill: parent
104 text: name
105 verticalAlignment: Text.AlignVCenter
106 }
107 }
108
109 sectionProperty: "size"
110 sectionDelegate: Rectangle {
111 anchors {
112 left: (parent) ? parent.left : undefined
113 right: (parent) ? parent.right : undefined
114 }
115 height: units.gu(5)
116 color: "lightsteelblue"
117
118 Label {
119 id: label
120 anchors.fill: parent
121 text: section
122 verticalAlignment: Text.AlignVCenter
123 }
124 }
125
126 pageHeader: PageHeader {
127 id: pageHeader
128 anchors {
129 left: parent.left
130 right: parent.right
131 }
132 text: "Animals"
133 }
134 }
135
136
137
138
139 UnityTestCase {
140 name: "ListViewWithPageHeader"
141 when: windowShown
142
143 readonly property real xPos: listView.width / 2
144 readonly property real headerHeight: pageHeader.height
145
146 /**************************** Helper functions ****************************/
147 function listViewFirstSectionHeaderYPosition() {
148 return Math.round(listView.pageHeader.mapToItem(listView).y); //round as using floats
149 }
150
151 function firstSectionHeaderYPosition() {
152 return Math.round(listView.view.children[0].mapToItem(listView).y);
153 }
154
155 function cleanup() {
156 listView.positionAtBeginning();
157 // wait for list position to reset
158 tryCompareFunction(listViewFirstSectionHeaderYPosition, 0);
159 tryCompare(listView.view.contentY, 0);
160 }
161
162 // these functions are hand-crafted to move the Flickable down/up one pixel
163 function swipeDown1Pixel(item) {
164 mousePress(item, xPos, 15);
165 mouseMove(item, xPos, 14, 100);
166 mouseMove(item, xPos, 10, 100);
167 mouseMove(item, xPos, 6, 100);
168 mouseMove(item, xPos, 3, 100);
169 mouseMove(item, xPos, 1, 100);
170 mouseMove(item, xPos, 0, 100);
171 mouseRelease(item, xPos, 0);
172 }
173
174 function swipeUp1Pixel(item) {
175 mousePress(item, xPos, 0);
176 mouseMove(item, xPos, 1, 100);
177 mouseMove(item, xPos, 5, 100);
178 mouseMove(item, xPos, 9, 100);
179 mouseMove(item, xPos, 12, 100);
180 mouseMove(item, xPos, 14, 100);
181 mouseMove(item, xPos, 15, 100);
182 mouseRelease(item, xPos, 15);
183 }
184
185 /******************************* Test cases *******************************/
186
187 /* Check the initial positions of components are correct */
188 function test_initialState() {
189 compare(listViewFirstSectionHeaderYPosition(), 0);
190 compare(listView.view.contentY, 0);
191
192 // Check that the section delegate is positioned underneath the header
193 // First section delegate is the first child of the view
194 tryCompareFunction(firstSectionHeaderYPosition, headerHeight);
195 }
196
197 /* Check the header moves up one pixel when the view is moved up by one pixel */
198 function test_headerPositionAfterDownMoveByOnePixel() {
199 swipeDown1Pixel(listView)
200
201 tryCompareFunction(listViewFirstSectionHeaderYPosition, -1);
202 tryCompareFunction(firstSectionHeaderYPosition, headerHeight - 1);
203 tryCompare(listView.view.contentY, -1);
204 }
205
206 /* Check the header position is y=0 when view moved up and then down by one pixel */
207 function test_headerPositionAfterDownAndThenUpMoveByOne() {
208 swipeDown1Pixel(listView)
209
210 tryCompareFunction(listViewFirstSectionHeaderYPosition, -1);
211 tryCompare(listView.view.contentY, -1);
212
213 // these operations move the Flickabe up one pixel
214 swipeUp1Pixel(listView);
215
216 tryCompare(listView.view.contentY, 0);
217 // tryCompareFunction(listViewFirstSectionHeaderYPosition, 0) //FIXME - this fails due to bug in LVWPH
218 tryCompareFunction(firstSectionHeaderYPosition, headerHeight)
219 }
220
221 /* Check after a big flick the header is moved off-screen, with the header bottom
222 placed just above the view */
223 function test_headerPositionAfterDownMove() {
224 // move the Flickabe up to hide header
225 listView.flick(0, -10000);
226
227 // wait for flick to finish
228 tryCompare(listView.moving, false);
229
230 tryCompareFunction(listViewFirstSectionHeaderYPosition, -headerHeight);
231 }
232
233 /* Check when header off-screen, moving down the view by one pixel moves the header
234 down by one pixel */
235 function test_hiddenHeaderPositionAfterUpMoveByOnePixel() {
236 // move the Flickabe up to hide header
237 listView.flick(0, -10000);
238
239 // wait for flick to fully hide header
240 tryCompareFunction(listViewFirstSectionHeaderYPosition, -headerHeight);
241
242 swipeUp1Pixel(listView);
243
244 tryCompareFunction( function() {
245 return Math.floor( listViewFirstSectionHeaderYPosition() ); // need to round to make test more robust
246 }, -headerHeight + 1);
247 }
248
249 /* Check if up swipe causes list to bounces at the bottom, header stays hidden */
250 function test_upSwipeCausingBounceKeepsHeaderHidden() {
251 // move list to the bottom (will bounce)
252 listView.flick(0, -1000000);
253
254 // wait for bounce to complete
255 tryCompare(listView.moving, false);
256 tryCompare(listView.view.atYEnd, true);
257
258 tryCompareFunction(listViewFirstSectionHeaderYPosition, -headerHeight);
259 }
260
261 /* Check if up swipe causes list to bounces at the bottom, header stays hidden */
262 function test_downSwipeCausingBounceKeepsHeaderVisible() {
263 // move list to the bottom (will bounce)
264 listView.flick(0, -1000000);
265
266 // wait for bounce to complete
267 tryCompare(listView.moving, false);
268 tryCompare(listView.view.atYBeginning, true);
269
270 tryCompareFunction(listViewFirstSectionHeaderYPosition, 0);
271 }
272
273 /* Check if list at top is pulled down further, that the list contents move but the
274 header remains at the top of the view */
275 function test_topDragOverBoundsKeepsHeaderVisible() {
276 // drag list up - but don't release yet
277 mouseFlick(listView,
278 xPos, // from_x
279 0, // from_y
280 xPos, // to_x
281 100, true, false, 0.2);
282
283 // wait for gesture to occur
284 tryCompareFunction(function() { return listView.view.contentY < 20; }, true);
285 tryCompareFunction(listViewFirstSectionHeaderYPosition, 0);
286
287 mouseRelease(listView, xPos, 400);
288
289 // ensure list moving to recover from over-bound drag keeps header unchanged
290 tryCompare(listView.view.contentY, 0);
291 tryCompareFunction(listViewFirstSectionHeaderYPosition, 0);
292 }
293
294 /* Check if list at top is pulled down further, that the list contents move but the
295 header remains at the top of the view */
296 function test_bottomDragOverBoundsKeepsHeaderHidden() {
297 // move list to the bottom (will bounce)
298 listView.flick(0, -1000000);
299
300 // wait for bounce to complete
301 tryCompare(listView.moving, false);
302 tryCompare(listView.view.atYEnd, true);
303
304 // drag list up but don't release
305 mouseFlick(listView,
306 xPos, // from_x
307 0, // from_y
308 xPos, // to_x
309 -listView.height, true, false);
310
311 tryCompareFunction(listViewFirstSectionHeaderYPosition, -headerHeight);
312
313 mouseRelease(listView, xPos, -listView.height);
314 // wait for list to reset position
315 tryCompare(listView.moving, false);
316 tryCompare(listView.view.atYEnd, true);
317
318 // ensure list moving to recover from over-bound drag keeps header unchanged
319 tryCompareFunction(listViewFirstSectionHeaderYPosition, -headerHeight);
320 }
321
322 /* Check positionAtBeginning() works resets list and header position */
323 function test_positionAtBeginning() {
324 // move the Flickabe up to hide header
325 listView.flick(0, -10000);
326
327 // wait for gesture to complete
328 tryCompare(listView.moving, false);
329
330 listView.positionAtBeginning();
331 tryCompareFunction(listViewFirstSectionHeaderYPosition, 0);
332 tryCompare(listView.view.contentY, 0);
333 }
334
335 /* Check showHeader forces header to appear but list position remains unchanged */
336 function test_showHeader() {
337 // move the Flickabe up to hide header
338 listView.flick(0, -10000);
339
340 // wait for gesture to complete
341 tryCompare(listView.moving, false);
342
343 var listContentY = listView.view.contentY;
344
345 listView.showHeader();
346 tryCompareFunction(listViewFirstSectionHeaderYPosition, 0);
347 tryCompare(listView.view.contentY, listContentY);
348 }
349 }
350}
0351
=== modified file 'tests/qmluitests/UnityTestCase.qml'
--- tests/qmluitests/UnityTestCase.qml 2013-04-05 11:03:11 +0000
+++ tests/qmluitests/UnityTestCase.qml 2013-04-12 15:11:26 +0000
@@ -54,9 +54,9 @@
54 if (i === nIterations - 1) {54 if (i === nIterations - 1) {
55 // Avoid any rounding errors by making the last move be at precisely55 // Avoid any rounding errors by making the last move be at precisely
56 // the point specified56 // the point specified
57 mouseMove(item, toX, toY)57 mouseMove(item, toX, toY, nIterations / speed)
58 } else {58 } else {
59 mouseMove(item, x + (i + 1) * diffX, y + (i + 1) * diffY)59 mouseMove(item, x + (i + 1) * diffX, y + (i + 1) * diffY, nIterations / speed)
60 }60 }
61 }61 }
62 if (releaseMouse) {62 if (releaseMouse) {

Subscribers

People subscribed via source and target branches