Merge lp:~tpeeters/ubuntu-ui-toolkit/waitForHeaderAnimation into lp:ubuntu-ui-toolkit/staging

Proposed by Tim Peeters on 2015-03-23
Status: Merged
Approved by: Christian Dywan on 2015-04-02
Approved revision: 1464
Merged at revision: 1462
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/waitForHeaderAnimation
Merge into: lp:ubuntu-ui-toolkit/staging
Prerequisite: lp:~tpeeters/ubuntu-ui-toolkit/page13
Diff against target: 397 lines (+68/-69)
5 files modified
components.api (+1/-0)
modules/Ubuntu/Test/UbuntuTestCase.qml (+19/-0)
tests/unit_x11/tst_components/tst_header_actions.qml (+11/-19)
tests/unit_x11/tst_components/tst_header_contents_width.qml (+5/-10)
tests/unit_x11/tst_components/tst_pagestack.new_header.qml (+32/-40)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/waitForHeaderAnimation
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration 2015-03-23 Approve on 2015-04-02
Christian Dywan 2015-03-23 Approve on 2015-04-02
Review via email: mp+253843@code.launchpad.net

This proposal supersedes a proposal from 2015-03-19.

Commit Message

Add UbuntuTestCase.waitForHeaderAnimation().

Description of the Change

Add UbuntuTestCase.waitForHeaderAnimation().

To post a comment you must log in.
Christian Dywan (kalikiana) wrote : Posted in a previous version of this proposal

Does the job nicely!

review: Approve
Tim Peeters (tpeeters) wrote :

I resubmitted this MR with a prerequisite because a follow-up MR will need both this branch and the new prerequisite as prerequisites. I synced this MR with its new prerequisite, but nothing else changed.

Christian Dywan (kalikiana) wrote :

Ack.

review: Approve
review: Approve (continuous-integration)
Christian Dywan (kalikiana) wrote :

(Still) looks fine.

review: Approve
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components.api'
2--- components.api 2015-04-02 11:16:25 +0000
3+++ components.api 2015-04-02 11:16:25 +0000
4@@ -697,6 +697,7 @@
5 function tryCompareFunction(func, expectedResult, timeout)
6 function typeString(string)
7 function warningFormat(line, column, message)
8+ function waitForHeaderAnimation(mainView)
9 plugins.qmltypes
10 name: "FilterBehavior"
11 prototype: "QObject"
12
13=== modified file 'modules/Ubuntu/Test/UbuntuTestCase.qml'
14--- modules/Ubuntu/Test/UbuntuTestCase.qml 2015-03-03 13:47:48 +0000
15+++ modules/Ubuntu/Test/UbuntuTestCase.qml 2015-04-02 11:16:25 +0000
16@@ -237,4 +237,23 @@
17 function warningFormat(line, column, message) {
18 return util.callerFile() + ":" + line + ":" + column + ": " + message;
19 }
20+
21+ /*!
22+ Wait for animations of the header and the style inside the header to finish.
23+ The MainView that has the header that may animate must be passed as an argument.
24+ */
25+ function waitForHeaderAnimation(mainView) {
26+ var header = findChild(mainView, "MainView_Header");
27+ verify(header !== null, "Could not find header.");
28+ var headerStyle = findChild(header, "PageHeadStyle");
29+ verify(headerStyle !== null, "Could not find header style.");
30+
31+ // Wait for the header to start to move:
32+ wait(50);
33+ // Wait for animation of the style inside the header (when pushing/popping):
34+ tryCompareFunction(function(){ return headerStyle.animating }, false);
35+ // Wait for the header to finish showing/hiding:
36+ // FIXME: Uncomment this in the following MR that adds the header.moving property.
37+ //tryCompareFunction(function(){ return header.moving }, false);
38+ }
39 }
40
41=== modified file 'tests/unit_x11/tst_components/tst_header_actions.qml'
42--- tests/unit_x11/tst_components/tst_header_actions.qml 2015-03-06 12:42:00 +0000
43+++ tests/unit_x11/tst_components/tst_header_actions.qml 2015-04-02 11:16:25 +0000
44@@ -1,5 +1,5 @@
45 /*
46- * Copyright 2014 Canonical Ltd.
47+ * Copyright 2014-2015 Canonical Ltd.
48 *
49 * This program is free software; you can redistribute it and/or modify
50 * it under the terms of the GNU Lesser General Public License as published by
51@@ -14,9 +14,9 @@
52 * along with this program. If not, see <http://www.gnu.org/licenses/>.
53 */
54
55-import QtQuick 2.2
56+import QtQuick 2.4
57 import Ubuntu.Test 1.0
58-import Ubuntu.Components 1.1
59+import Ubuntu.Components 1.2
60
61 // NOTE: Other parts of the page head API are tested with autopilot in
62 // ubuntuuitoolkit.tests.components.test_header
63@@ -28,7 +28,6 @@
64 MainView {
65 id: mainView
66 anchors.fill: parent
67- useDeprecatedToolbar: false
68
69 PageStack {
70 id: pageStack
71@@ -61,55 +60,48 @@
72 when: windowShown
73 id: testCase
74
75- property var app_header
76 property var back_button
77 property var custom_back_button
78- property var head_style
79
80 function initTestCase() {
81- testCase.app_header = findChild(mainView, "MainView_Header");
82+ var app_header = findChild(mainView, "MainView_Header");
83 testCase.back_button = findChild(app_header, "backButton");
84 testCase.custom_back_button = findChild(app_header, "customBackButton");
85- testCase.head_style = findChild(app_header, "PageHeadStyle");
86
87- wait_for_animation();
88+ waitForHeaderAnimation(mainView);
89 compare(page2.head.backAction, null, "Back action set by default.");
90 compare(back_button.visible, false, "Back button visible with only 1 page on the stack.");
91 compare(custom_back_button.visible, false, "Custom back button visible without custom back action.")
92 }
93
94- function wait_for_animation() {
95- tryCompareFunction(function(){return testCase.head_style.animating}, false);
96- }
97-
98 function test_default_back_button() {
99 pageStack.push(page2);
100- wait_for_animation();
101+ waitForHeaderAnimation(mainView);
102 compare(back_button.visible, true, "Back button not visible with 2 pages on stack.");
103 compare(custom_back_button.visible, false, "Showing custom back button without custom back action.");
104 pageStack.pop();
105- wait_for_animation();
106+ waitForHeaderAnimation(mainView);
107 }
108
109 function test_custom_back_button() {
110 page2.head.backAction = customBackAction;
111 pageStack.push(page2);
112- wait_for_animation();
113+ waitForHeaderAnimation(mainView);
114 compare(back_button.visible, false, "Default back button visible with custom back action.");
115 compare(custom_back_button.visible, true, "Custom back button invisible with back action.");
116 pageStack.pop();
117- wait_for_animation();
118+ waitForHeaderAnimation(mainView);
119 page2.head.backAction = null;
120 }
121
122 function test_no_back_button() {
123 page2.head.backAction = invisibleAction;
124 pageStack.push(page2);
125- wait_for_animation();
126+ waitForHeaderAnimation(mainView);
127 compare(back_button.visible, false, "Default back button visible with invisible custom back action.");
128 compare(custom_back_button.visible, false, "Custom back button visible with invisible custom back action.");
129 pageStack.pop();
130- wait_for_animation();
131+ waitForHeaderAnimation(mainView);
132 page2.head.backAction = null;
133 }
134 }
135
136=== modified file 'tests/unit_x11/tst_components/tst_header_contents_width.qml'
137--- tests/unit_x11/tst_components/tst_header_contents_width.qml 2015-03-03 13:20:06 +0000
138+++ tests/unit_x11/tst_components/tst_header_contents_width.qml 2015-04-02 11:16:25 +0000
139@@ -14,9 +14,9 @@
140 * along with this program. If not, see <http://www.gnu.org/licenses/>.
141 */
142
143-import QtQuick 2.2
144+import QtQuick 2.4
145 import Ubuntu.Test 1.0
146-import Ubuntu.Components 1.1
147+import Ubuntu.Components 1.2
148
149 Item {
150 width: units.gu(50)
151@@ -25,7 +25,6 @@
152 MainView {
153 id: mainView
154 anchors.fill: parent
155- useDeprecatedToolbar: false
156
157 Tabs {
158 id: tabs
159@@ -69,12 +68,8 @@
160
161 property var head_style
162
163- function wait_for_animation() {
164- tryCompareFunction(function(){return testCase.head_style.animating}, false);
165- }
166 function initTestCase() {
167- testCase.head_style = findChild(mainView, "PageHeadStyle");
168- testCase.wait_for_animation();
169+ waitForHeaderAnimation(mainView);
170 }
171
172 function test_header_contents_width_bug1408481() {
173@@ -82,14 +77,14 @@
174 testCase.verify(initialWidth > 0, "Initial width has a positive value.");
175 // Select the tab that has more actions.
176 tabs.selectedTabIndex = 1;
177- testCase.wait_for_animation();
178+ waitForHeaderAnimation(mainView);
179 // Now less space is available for the header contents, so that the action buttons fit.
180 testCase.verify(searchField.width < initialWidth, "Contents width is reduced.");
181 // Without this wait(), the test does not reproduce bug 1408481.
182 wait(100);
183 // Select the first tab again:
184 tabs.selectedTabIndex = 0;
185- testCase.wait_for_animation();
186+ waitForHeaderAnimation(mainView);
187 // Without actions in tab one, the full width is available again for contents
188 testCase.verify(searchField.width === initialWidth, "Contents width is reset.");
189 }
190
191=== modified file 'tests/unit_x11/tst_components/tst_pagestack.new_header.qml'
192--- tests/unit_x11/tst_components/tst_pagestack.new_header.qml 2015-03-06 12:42:00 +0000
193+++ tests/unit_x11/tst_components/tst_pagestack.new_header.qml 2015-04-02 11:16:25 +0000
194@@ -1,5 +1,5 @@
195 /*
196- * Copyright 2012-2014 Canonical Ltd.
197+ * Copyright 2012-2015 Canonical Ltd.
198 *
199 * This program is free software; you can redistribute it and/or modify
200 * it under the terms of the GNU Lesser General Public License as published by
201@@ -16,7 +16,7 @@
202
203 import QtQuick 2.2
204 import Ubuntu.Test 1.0
205-import Ubuntu.Components 1.1
206+import Ubuntu.Components 1.2
207
208 // pagestack tests for deprecated toolbar are in
209 // unit/tst_components/tst_pagestack_deprecated_toolbar.qml
210@@ -28,7 +28,6 @@
211 MainView {
212 id: mainView
213 anchors.fill: parent
214- useDeprecatedToolbar: false
215 PageStack {
216 id: pageStack
217 Page {
218@@ -73,43 +72,36 @@
219 when: windowShown
220 id: testCase
221
222- property var head_style
223-
224 function initTestCase() {
225- testCase.head_style = findChild(mainView, "PageHeadStyle");
226- wait_for_animation();
227+ waitForHeaderAnimation(mainView);
228 compare(pageStack.currentPage, null, "is not set by default");
229 compare(pageStack.__propagated, mainView.__propagated, "propagated property of pageStack equals mainView.__propagated")
230 compare(mainView.__propagated.header.title, "", "empty title by default");
231 }
232
233- function wait_for_animation() {
234- tryCompareFunction(function(){return testCase.head_style.animating}, false);
235- }
236-
237 function test_depth() {
238 compare(pageStack.depth, 0, "depth is 0 by default");
239 pageStack.push(page1);
240- wait_for_animation();
241+ waitForHeaderAnimation(mainView);
242 compare(pageStack.depth, 1, "depth is correctly increased when pushing a page");
243 pageStack.push(page2);
244- wait_for_animation();
245+ waitForHeaderAnimation(mainView);
246 compare(pageStack.depth, 2, "depth is correctly updated when pushing a page");
247 pageStack.pop();
248- wait_for_animation();
249+ waitForHeaderAnimation(mainView);
250 compare(pageStack.depth, 1, "depth is correctly decreased when popping a page");
251 pageStack.clear();
252- wait_for_animation();
253+ waitForHeaderAnimation(mainView);
254 compare(pageStack.depth, 0, "depth is after clearing");
255 }
256
257 function test_currentPage() {
258 compare(pageStack.currentPage, null, "currentPage is null by default");
259 pageStack.push(page1);
260- wait_for_animation();
261+ waitForHeaderAnimation(mainView);
262 compare(pageStack.currentPage, page1, "currentPage properly updated");
263 pageStack.clear();
264- wait_for_animation();
265+ waitForHeaderAnimation(mainView);
266 compare(pageStack.currentPage, null, "currentPage properly reset");
267 }
268
269@@ -117,60 +109,60 @@
270 compare(pageStack.depth, 0, "depth is 0 initially");
271 pageStack.push(page1);
272 pageStack.push(page2);
273- wait_for_animation();
274+ waitForHeaderAnimation(mainView);
275 compare(pageStack.currentPage, page2, "last pushed page is on top");
276 pageStack.pop();
277- wait_for_animation();
278+ waitForHeaderAnimation(mainView);
279 compare(pageStack.currentPage, page1, "popping puts previously pushed page on top");
280 pageStack.clear();
281- wait_for_animation();
282+ waitForHeaderAnimation(mainView);
283 }
284
285 function test_active_bug1260116() {
286 pageStack.push(page1);
287- wait_for_animation();
288+ waitForHeaderAnimation(mainView);
289
290 compare(page1.active, true, "Page is active after pushing");
291 pageStack.push(page2);
292- wait_for_animation();
293+ waitForHeaderAnimation(mainView);
294
295 compare(page1.active, false, "Page no longer active after pushing a new page");
296 compare(page2.active, true, "New page is active after pushing");
297 pageStack.pop();
298- wait_for_animation();
299+ waitForHeaderAnimation(mainView);
300 compare(page1.active, true, "Page re-activated when on top of the stack");
301 compare(page2.active, false, "Page no longer active after being popped");
302 pageStack.clear();
303- wait_for_animation();
304+ waitForHeaderAnimation(mainView);
305
306 compare(pageInStack.active, false, "Page defined inside PageStack is not active by default");
307 pageStack.push(pageInStack);
308- wait_for_animation();
309+ waitForHeaderAnimation(mainView);
310 compare(pageInStack.active, true, "Pushing a page on PageStack makes it active");
311 pageStack.pop();
312- wait_for_animation();
313+ waitForHeaderAnimation(mainView);
314 compare(pageInStack.active, false, "Popping a page from PageStack makes it inactive");
315 pageStack.clear();
316- wait_for_animation();
317+ waitForHeaderAnimation(mainView);
318 }
319
320 function test_title_bug1143345_bug1317902() {
321 pageStack.push(page1);
322- wait_for_animation();
323+ waitForHeaderAnimation(mainView);
324 compare(mainView.__propagated.header.title, "Title 1", "Header title is correctly set by page");
325 page1.title = "New title";
326 compare(mainView.__propagated.header.title, "New title", "Header title correctly updated by page");
327 pageStack.push(page2);
328- wait_for_animation();
329+ waitForHeaderAnimation(mainView);
330 compare(mainView.__propagated.header.title, "Title 2", "Header title is correctly set by page");
331 pageStack.clear();
332 page1.title = "Title 1";
333
334 pageStack.push(pageWithPage);
335- wait_for_animation();
336+ waitForHeaderAnimation(mainView);
337 compare(mainView.__propagated.header.title, pageWithPage.title, "Embedded page sets title of outer page");
338 pageStack.clear();
339- wait_for_animation();
340+ waitForHeaderAnimation(mainView);
341 }
342
343 function get_tabs_button() {
344@@ -182,36 +174,36 @@
345 function test_tabs_inside_stack_bug1187850() {
346 compare(get_tabs_button(), null, "Without tabs there is no visible tabs button.");
347 pageStack.push(tabs);
348- wait_for_animation();
349+ waitForHeaderAnimation(mainView);
350 compare(pageStack.currentPage, tabs, "Tabs can be pushed on a PageStack");
351 compare(tabs.active, true, "Tabs on top of a PageStack are active");
352 compare(get_tabs_button().visible, true, "Pushing tabs on pagestack enables the tabs button");
353 pageStack.push(page1);
354- wait_for_animation();
355+ waitForHeaderAnimation(mainView);
356 compare(pageStack.currentPage, page1, "A page can be pushed on top of a Tabs");
357 compare(tabs.active, false, "Tabs on a PageStack, but not on top, are inactive");
358 compare(get_tabs_button(), null, "Contents of inactive Tabs is not applied to header");
359 pageStack.pop();
360- wait_for_animation();
361+ waitForHeaderAnimation(mainView);
362 compare(tabs.active, true, "Tabs on top of PageStack is active");
363 compare(get_tabs_button().visible, true, "Active Tabs controls header contents");
364 pageStack.clear();
365- wait_for_animation();
366+ waitForHeaderAnimation(mainView);
367 }
368
369 function test_pop_to_tabs_bug1316736() {
370 pageStack.push(tabs);
371- wait_for_animation();
372+ waitForHeaderAnimation(mainView);
373 tabs.selectedTabIndex = 1;
374 pageStack.push(page1);
375- wait_for_animation();
376+ waitForHeaderAnimation(mainView);
377 compare(tabs.active, false, "Tabs on a PageStack, but not on top, are inactive");
378 pageStack.pop();
379- wait_for_animation();
380+ waitForHeaderAnimation(mainView);
381 compare(tabs.active, true, "Tabs on top of PageStack is active");
382 compare(tabs.selectedTabIndex, 1, "Pushing and popping another page on top of Tabs does not change selectedTabsIndex");
383 pageStack.clear();
384- wait_for_animation();
385+ waitForHeaderAnimation(mainView);
386 }
387
388 function test_push_return_values() {
389@@ -225,7 +217,7 @@
390 compare(pushedPage.title, "Page from QML file",
391 "PageStack.push() returns Page created from QML file");
392 pageStack.clear();
393- wait_for_animation();
394+ waitForHeaderAnimation(mainView);
395 }
396 }
397 }

Subscribers

People subscribed via source and target branches