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

Proposed by Tim Peeters
Status: Superseded
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/waitForHeaderAnimation
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 804 lines (+344/-104)
13 files modified
components.api (+6/-0)
modules/Ubuntu/Components/AppHeader.qml (+1/-0)
modules/Ubuntu/Components/MainView12.qml (+9/-4)
modules/Ubuntu/Components/Page10.qml (+2/-30)
modules/Ubuntu/Components/Page13.qml (+84/-0)
modules/Ubuntu/Components/pageUtils.js (+47/-0)
modules/Ubuntu/Components/qmldir (+3/-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_page11.qml (+1/-1)
tests/unit_x11/tst_components/tst_page13.qml (+124/-0)
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 Needs Fixing
Cris Dywan Approve
Review via email: mp+253542@code.launchpad.net

This proposal has been superseded by a proposal from 2015-03-23.

Commit message

Add UbuntuTestCase.waitForHeaderAnimation().

Description of the change

Add UbuntuTestCase.waitForHeaderAnimation().

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1459. By Tim Peeters

update components.api

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1460. By Tim Peeters

kick CI

Revision history for this message
Cris Dywan (kalikiana) wrote :

Does the job nicely!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1461. By Tim Peeters

merge page13 branch

1462. By Tim Peeters

merge staging

1463. By Tim Peeters

merge staging

1464. By Tim Peeters

merge prerequisite page13 branch

Unmerged revisions

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-03-10 13:58:52 +0000
3+++ components.api 2015-03-23 15:48:48 +0000
4@@ -248,6 +248,11 @@
5 Page 1.1
6 Page10
7 readonly property PageHeadConfiguration head
8+Page 1.3
9+PageTreeNode
10+ property string title
11+ property Flickable flickable
12+ readonly property PageHeadConfiguration head
13 PageHeadConfiguration 1.1
14 Object
15 property list<Action> actions
16@@ -692,6 +697,7 @@
17 function tryCompareFunction(func, expectedResult, timeout)
18 function typeString(string)
19 function warningFormat(line, column, message)
20+ function waitForHeaderAnimation(mainView)
21 plugins.qmltypes
22 name: "FilterBehavior"
23 prototype: "QObject"
24
25=== modified file 'modules/Ubuntu/Components/AppHeader.qml'
26--- modules/Ubuntu/Components/AppHeader.qml 2015-03-03 13:47:48 +0000
27+++ modules/Ubuntu/Components/AppHeader.qml 2015-03-23 15:48:48 +0000
28@@ -89,6 +89,7 @@
29
30 /*!
31 The contents of the header. If this is set, \l title will be ignored.
32+ DEPRECATED and replaced by Page.head.contents.
33 */
34 property Item contents: null
35 onContentsChanged: {
36
37=== modified file 'modules/Ubuntu/Components/MainView12.qml'
38--- modules/Ubuntu/Components/MainView12.qml 2015-03-03 12:53:42 +0000
39+++ modules/Ubuntu/Components/MainView12.qml 2015-03-23 15:48:48 +0000
40@@ -80,7 +80,8 @@
41 flickable: internal.activePage ? internal.activePage.flickable : null
42 pageStack: internal.activePage ? internal.activePage.pageStack : null
43
44- contents: internal.activePage ?
45+ contents: internal.activePage &&
46+ internal.activePage.hasOwnProperty("__customHeaderContents") ?
47 internal.activePage.__customHeaderContents : null
48
49 PageHeadConfiguration {
50@@ -127,11 +128,15 @@
51
52 // Even when using MainView 1.1, we still support Page 1.0.
53 // PageBase (=Page 1.0) is the superclass of Page 1.1.
54- property PageBase activePage: isPage(mainView.activeLeafNode) ? mainView.activeLeafNode : null
55+ property Item activePage: isPage(mainView.activeLeafNode) ? mainView.activeLeafNode : null
56
57 function isPage(item) {
58- return item && item.hasOwnProperty("__isPageTreeNode") && item.__isPageTreeNode &&
59- item.hasOwnProperty("title") && item.hasOwnProperty("tools");
60+ return item && item.hasOwnProperty("__isPageTreeNode") &&
61+ item.__isPageTreeNode &&
62+ item.hasOwnProperty("title") &&
63+ item.hasOwnProperty("flickable") &&
64+ item.hasOwnProperty("active") &&
65+ item.hasOwnProperty("pageStack")
66 }
67 }
68
69
70=== modified file 'modules/Ubuntu/Components/Page10.qml'
71--- modules/Ubuntu/Components/Page10.qml 2015-03-03 13:47:48 +0000
72+++ modules/Ubuntu/Components/Page10.qml 2015-03-23 15:48:48 +0000
73@@ -16,6 +16,7 @@
74
75 import QtQuick 2.4
76 import Ubuntu.Components 1.2 as Toolkit
77+import "pageUtils.js" as Utils
78
79 /*!
80 \internal
81@@ -53,7 +54,7 @@
82 */
83 property Item __customHeaderContents: null
84
85- property Flickable flickable: internal.getFlickableChild(page)
86+ property Flickable flickable: Utils.getFlickableChild(page)
87
88 /*! \internal */
89 onActiveChanged: {
90@@ -95,34 +96,5 @@
91 when: internal.header && !internal.header.useDeprecatedToolbar &&
92 page.tools !== null
93 }
94-
95- function isVerticalFlickable(object) {
96- if (object && object.hasOwnProperty("flickableDirection") && object.hasOwnProperty("contentHeight")) {
97- var direction = object.flickableDirection;
98- if ( ((direction === Flickable.AutoFlickDirection) && (object.contentHeight !== object.height) )
99- || direction === Flickable.VerticalFlick
100- || direction === Flickable.HorizontalAndVerticalFlick) {
101- return true;
102- }
103- }
104- return false;
105- }
106-
107- /*!
108- Return the first flickable child of this page.
109- */
110- function getFlickableChild(item) {
111- if (item && item.hasOwnProperty("children")) {
112- for (var i=0; i < item.children.length; i++) {
113- var child = item.children[i];
114- if (internal.isVerticalFlickable(child)) {
115- if (child.anchors.top === page.top || child.anchors.fill === page) {
116- return item.children[i];
117- }
118- }
119- }
120- }
121- return null;
122- }
123 }
124 }
125
126=== added file 'modules/Ubuntu/Components/Page13.qml'
127--- modules/Ubuntu/Components/Page13.qml 1970-01-01 00:00:00 +0000
128+++ modules/Ubuntu/Components/Page13.qml 2015-03-23 15:48:48 +0000
129@@ -0,0 +1,84 @@
130+/*
131+ * Copyright 2015 Canonical Ltd.
132+ *
133+ * This program is free software; you can redistribute it and/or modify
134+ * it under the terms of the GNU Lesser General Public License as published by
135+ * the Free Software Foundation; version 3.
136+ *
137+ * This program is distributed in the hope that it will be useful,
138+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
139+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
140+ * GNU Lesser General Public License for more details.
141+ *
142+ * You should have received a copy of the GNU Lesser General Public License
143+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
144+ */
145+
146+import QtQuick 2.4
147+import Ubuntu.Components 1.3 as Toolkit13
148+import "pageUtils.js" as Utils
149+
150+/*!
151+ \internal
152+ Documentation is in Page.qdoc
153+*/
154+PageTreeNode {
155+ id: page
156+ anchors {
157+ left: parent ? parent.left : undefined
158+ bottom: parent ? parent.bottom : undefined
159+ }
160+ // Set width and height so that a parent Loader can be automatically resized
161+ // to the size of the loaded Page.
162+ width: parentNode ? parentNode.width - page.x : undefined
163+ height: parentNode ? page.flickable ? parentNode.height : parentNode.height - internal.headerHeight : undefined
164+
165+ isLeaf: true
166+ property string title: parentNode && parentNode.hasOwnProperty("title") ? parentNode.title : ""
167+ property Flickable flickable: Utils.getFlickableChild(page)
168+
169+ /*!
170+ \qmlproperty PageHeadConfiguration head
171+ */
172+ readonly property alias head: headerConfig
173+ Toolkit13.PageHeadConfiguration {
174+ id: headerConfig
175+ }
176+
177+ Object {
178+ id: internal
179+
180+ property AppHeader header: page.__propagated && page.__propagated.header ? page.__propagated.header : null
181+ // Used to position the Page when there is no flickable.
182+ // When there is a flickable, the header will automatically position it.
183+ property real headerHeight: internal.header && internal.header.visible ? internal.header.height : 0
184+
185+ // Note: The bindings below need to check whether headerConfig.contents
186+ // is valid in the "value", even when that is required in the Binding's "when"
187+ // property, to avoid TypeErrors while/after a page becomes (in)active.
188+ //
189+ // Note 2: contents.parent binding is made by PageHeadStyle.
190+ property bool hasParent: headerConfig.contents &&
191+ headerConfig.contents.parent
192+
193+ Binding {
194+ target: headerConfig.contents
195+ property: "visible"
196+ value: page.active
197+ when: headerConfig.contents
198+ }
199+ Binding {
200+ target: headerConfig.contents
201+ property: "anchors.verticalCenter"
202+ value: internal.hasParent ? headerConfig.contents.parent.verticalCenter :
203+ undefined
204+ when: headerConfig.contents
205+ }
206+ Binding {
207+ target: headerConfig.contents
208+ property: "anchors.left"
209+ value: internal.hasParent ? headerConfig.contents.parent.left : undefined
210+ when: headerConfig.contents
211+ }
212+ }
213+}
214
215=== added file 'modules/Ubuntu/Components/pageUtils.js'
216--- modules/Ubuntu/Components/pageUtils.js 1970-01-01 00:00:00 +0000
217+++ modules/Ubuntu/Components/pageUtils.js 2015-03-23 15:48:48 +0000
218@@ -0,0 +1,47 @@
219+/*
220+ * Copyright 2015 Canonical Ltd.
221+ *
222+ * This program is free software; you can redistribute it and/or modify
223+ * it under the terms of the GNU Lesser General Public License as published by
224+ * the Free Software Foundation; version 3.
225+ *
226+ * This program is distributed in the hope that it will be useful,
227+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
228+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
229+ * GNU Lesser General Public License for more details.
230+ *
231+ * You should have received a copy of the GNU Lesser General Public License
232+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
233+ */
234+
235+/*!
236+ Return true if the object is a Flickable that can be flicked in vertical direction.
237+ */
238+function isVerticalFlickable(object) {
239+ if (object && object.hasOwnProperty("flickableDirection") && object.hasOwnProperty("contentHeight")) {
240+ var direction = object.flickableDirection;
241+ if ( ((direction === Flickable.AutoFlickDirection) && (object.contentHeight !== object.height) )
242+ || direction === Flickable.VerticalFlick
243+ || direction === Flickable.HorizontalAndVerticalFlick) {
244+ return true;
245+ }
246+ }
247+ return false;
248+}
249+
250+/*!
251+ Return the first child of the item that is flickable in the vertical direction.
252+ */
253+function getFlickableChild(item) {
254+ if (item && item.hasOwnProperty("children")) {
255+ for (var i=0; i < item.children.length; i++) {
256+ var child = item.children[i];
257+ if (isVerticalFlickable(child)) {
258+ if (child.anchors.top === page.top || child.anchors.fill === page) {
259+ return item.children[i];
260+ }
261+ }
262+ }
263+ }
264+ return null;
265+}
266
267=== modified file 'modules/Ubuntu/Components/qmldir'
268--- modules/Ubuntu/Components/qmldir 2015-03-02 13:39:03 +0000
269+++ modules/Ubuntu/Components/qmldir 2015-03-23 15:48:48 +0000
270@@ -111,3 +111,6 @@
271 #version 1.2
272 MainView 1.2 MainView12.qml
273 Captions 1.2 Captions.qml
274+
275+#version 1.3
276+Page 1.3 Page13.qml
277
278=== modified file 'modules/Ubuntu/Test/UbuntuTestCase.qml'
279--- modules/Ubuntu/Test/UbuntuTestCase.qml 2015-03-03 13:47:48 +0000
280+++ modules/Ubuntu/Test/UbuntuTestCase.qml 2015-03-23 15:48:48 +0000
281@@ -237,4 +237,23 @@
282 function warningFormat(line, column, message) {
283 return util.callerFile() + ":" + line + ":" + column + ": " + message;
284 }
285+
286+ /*!
287+ Wait for animations of the header and the style inside the header to finish.
288+ The MainView that has the header that may animate must be passed as an argument.
289+ */
290+ function waitForHeaderAnimation(mainView) {
291+ var header = findChild(mainView, "MainView_Header");
292+ verify(header !== null, "Could not find header.");
293+ var headerStyle = findChild(header, "PageHeadStyle");
294+ verify(headerStyle !== null, "Could not find header style.");
295+
296+ // Wait for the header to start to move:
297+ wait(50);
298+ // Wait for animation of the style inside the header (when pushing/popping):
299+ tryCompareFunction(function(){ return headerStyle.animating }, false);
300+ // Wait for the header to finish showing/hiding:
301+ // FIXME: Uncomment this in the following MR that adds the header.moving property.
302+ //tryCompareFunction(function(){ return header.moving }, false);
303+ }
304 }
305
306=== modified file 'tests/unit_x11/tst_components/tst_header_actions.qml'
307--- tests/unit_x11/tst_components/tst_header_actions.qml 2015-03-06 12:42:00 +0000
308+++ tests/unit_x11/tst_components/tst_header_actions.qml 2015-03-23 15:48:48 +0000
309@@ -1,5 +1,5 @@
310 /*
311- * Copyright 2014 Canonical Ltd.
312+ * Copyright 2014-2015 Canonical Ltd.
313 *
314 * This program is free software; you can redistribute it and/or modify
315 * it under the terms of the GNU Lesser General Public License as published by
316@@ -14,9 +14,9 @@
317 * along with this program. If not, see <http://www.gnu.org/licenses/>.
318 */
319
320-import QtQuick 2.2
321+import QtQuick 2.4
322 import Ubuntu.Test 1.0
323-import Ubuntu.Components 1.1
324+import Ubuntu.Components 1.2
325
326 // NOTE: Other parts of the page head API are tested with autopilot in
327 // ubuntuuitoolkit.tests.components.test_header
328@@ -28,7 +28,6 @@
329 MainView {
330 id: mainView
331 anchors.fill: parent
332- useDeprecatedToolbar: false
333
334 PageStack {
335 id: pageStack
336@@ -61,55 +60,48 @@
337 when: windowShown
338 id: testCase
339
340- property var app_header
341 property var back_button
342 property var custom_back_button
343- property var head_style
344
345 function initTestCase() {
346- testCase.app_header = findChild(mainView, "MainView_Header");
347+ var app_header = findChild(mainView, "MainView_Header");
348 testCase.back_button = findChild(app_header, "backButton");
349 testCase.custom_back_button = findChild(app_header, "customBackButton");
350- testCase.head_style = findChild(app_header, "PageHeadStyle");
351
352- wait_for_animation();
353+ waitForHeaderAnimation(mainView);
354 compare(page2.head.backAction, null, "Back action set by default.");
355 compare(back_button.visible, false, "Back button visible with only 1 page on the stack.");
356 compare(custom_back_button.visible, false, "Custom back button visible without custom back action.")
357 }
358
359- function wait_for_animation() {
360- tryCompareFunction(function(){return testCase.head_style.animating}, false);
361- }
362-
363 function test_default_back_button() {
364 pageStack.push(page2);
365- wait_for_animation();
366+ waitForHeaderAnimation(mainView);
367 compare(back_button.visible, true, "Back button not visible with 2 pages on stack.");
368 compare(custom_back_button.visible, false, "Showing custom back button without custom back action.");
369 pageStack.pop();
370- wait_for_animation();
371+ waitForHeaderAnimation(mainView);
372 }
373
374 function test_custom_back_button() {
375 page2.head.backAction = customBackAction;
376 pageStack.push(page2);
377- wait_for_animation();
378+ waitForHeaderAnimation(mainView);
379 compare(back_button.visible, false, "Default back button visible with custom back action.");
380 compare(custom_back_button.visible, true, "Custom back button invisible with back action.");
381 pageStack.pop();
382- wait_for_animation();
383+ waitForHeaderAnimation(mainView);
384 page2.head.backAction = null;
385 }
386
387 function test_no_back_button() {
388 page2.head.backAction = invisibleAction;
389 pageStack.push(page2);
390- wait_for_animation();
391+ waitForHeaderAnimation(mainView);
392 compare(back_button.visible, false, "Default back button visible with invisible custom back action.");
393 compare(custom_back_button.visible, false, "Custom back button visible with invisible custom back action.");
394 pageStack.pop();
395- wait_for_animation();
396+ waitForHeaderAnimation(mainView);
397 page2.head.backAction = null;
398 }
399 }
400
401=== modified file 'tests/unit_x11/tst_components/tst_header_contents_width.qml'
402--- tests/unit_x11/tst_components/tst_header_contents_width.qml 2015-03-03 13:20:06 +0000
403+++ tests/unit_x11/tst_components/tst_header_contents_width.qml 2015-03-23 15:48:48 +0000
404@@ -14,9 +14,9 @@
405 * along with this program. If not, see <http://www.gnu.org/licenses/>.
406 */
407
408-import QtQuick 2.2
409+import QtQuick 2.4
410 import Ubuntu.Test 1.0
411-import Ubuntu.Components 1.1
412+import Ubuntu.Components 1.2
413
414 Item {
415 width: units.gu(50)
416@@ -25,7 +25,6 @@
417 MainView {
418 id: mainView
419 anchors.fill: parent
420- useDeprecatedToolbar: false
421
422 Tabs {
423 id: tabs
424@@ -69,12 +68,8 @@
425
426 property var head_style
427
428- function wait_for_animation() {
429- tryCompareFunction(function(){return testCase.head_style.animating}, false);
430- }
431 function initTestCase() {
432- testCase.head_style = findChild(mainView, "PageHeadStyle");
433- testCase.wait_for_animation();
434+ waitForHeaderAnimation(mainView);
435 }
436
437 function test_header_contents_width_bug1408481() {
438@@ -82,14 +77,14 @@
439 testCase.verify(initialWidth > 0, "Initial width has a positive value.");
440 // Select the tab that has more actions.
441 tabs.selectedTabIndex = 1;
442- testCase.wait_for_animation();
443+ waitForHeaderAnimation(mainView);
444 // Now less space is available for the header contents, so that the action buttons fit.
445 testCase.verify(searchField.width < initialWidth, "Contents width is reduced.");
446 // Without this wait(), the test does not reproduce bug 1408481.
447 wait(100);
448 // Select the first tab again:
449 tabs.selectedTabIndex = 0;
450- testCase.wait_for_animation();
451+ waitForHeaderAnimation(mainView);
452 // Without actions in tab one, the full width is available again for contents
453 testCase.verify(searchField.width === initialWidth, "Contents width is reset.");
454 }
455
456=== renamed file 'tests/unit_x11/tst_components/tst_page.qml' => 'tests/unit_x11/tst_components/tst_page11.qml'
457--- tests/unit_x11/tst_components/tst_page.qml 2015-03-03 13:20:06 +0000
458+++ tests/unit_x11/tst_components/tst_page11.qml 2015-03-23 15:48:48 +0000
459@@ -54,7 +54,7 @@
460 }
461
462 TestCase {
463- name: "PageAPI"
464+ name: "Page11API"
465 when: windowShown
466
467 function initTestCase() {
468
469=== added file 'tests/unit_x11/tst_components/tst_page13.qml'
470--- tests/unit_x11/tst_components/tst_page13.qml 1970-01-01 00:00:00 +0000
471+++ tests/unit_x11/tst_components/tst_page13.qml 2015-03-23 15:48:48 +0000
472@@ -0,0 +1,124 @@
473+/*
474+ * Copyright 2012-2015 Canonical Ltd.
475+ *
476+ * This program is free software; you can redistribute it and/or modify
477+ * it under the terms of the GNU Lesser General Public License as published by
478+ * the Free Software Foundation; version 3.
479+ *
480+ * This program is distributed in the hope that it will be useful,
481+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
482+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
483+ * GNU Lesser General Public License for more details.
484+ *
485+ * You should have received a copy of the GNU Lesser General Public License
486+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
487+ */
488+
489+import QtQuick 2.4
490+import QtTest 1.0
491+import Ubuntu.Components 1.3
492+
493+Item {
494+ width: 400
495+ height: 600
496+
497+ Flickable {
498+ id: testFlickable
499+ }
500+
501+ MainView {
502+ anchors.fill: parent
503+ id: mainView
504+ Page {
505+ id: page
506+ Flickable {
507+ id: pageFlickable
508+ anchors.fill: parent
509+ contentHeight: column.height
510+
511+ Column {
512+ id: column
513+ Repeater {
514+ model: 100
515+ Label {
516+ text: "line "+index
517+ }
518+ }
519+ }
520+ }
521+ }
522+ }
523+
524+ TestCase {
525+ name: "Page13API"
526+ when: windowShown
527+
528+ function initTestCase() {
529+ compare(page.title, "", "Page title is set by default.");
530+ compare(page.active, true, "Page is inactive by default.");
531+ compare(page.pageStack, null, "Page has a PageStack by default.");
532+ }
533+
534+ function test_title() {
535+ var newTitle = "Hello World!";
536+ page.title = newTitle;
537+ compare(page.title, newTitle, "Could not set page title.");
538+ page.title = "";
539+ compare(page.title, "", "Could not unset page title.");
540+ }
541+
542+ function test_header_title() {
543+ var newTitle = "Hello header!";
544+ page.title = newTitle;
545+ var header = mainView.__propagated.header;
546+ compare(header.title, newTitle, "Header title does not match active page title.");
547+ page.title = "";
548+ }
549+
550+ function test_flickable_bug1200642_bug1192591() {
551+ var header = page.__propagated.header;
552+ compare(page.flickable, pageFlickable,
553+ "Flickable is not correctly detected.");
554+ compare(header.flickable, pageFlickable,
555+ "Header flickable is not correctly set.");
556+
557+ page.flickable = testFlickable;
558+ compare(page.flickable, testFlickable, "Flickable could not be set.");
559+ compare(header.flickable, testFlickable,
560+ "Header flickable was not update correctly.");
561+
562+ page.flickable = null;
563+ compare(page.flickable, null, "Flickable cannot be unset.");
564+ compare(header.flickable, null,
565+ "Header flickable was not correctly unset.");
566+ }
567+
568+ function test_flickableY_bug1201452() {
569+ var pageTitle = "Hello bug!";
570+ page.title = pageTitle;
571+ var header = page.__propagated.header;
572+
573+ var headerHeight = header.height
574+ var flickableY = 150;
575+ page.flickable.contentY = flickableY;
576+ compare(page.flickable.contentY, flickableY,
577+ "Flickable.contentY could not be set.");
578+ compare(page.flickable.topMargin, headerHeight,
579+ "topMargin of the flickable does not equal header height.");
580+ page.title = "";
581+
582+ // FIXME: Update the checks below when new API is added
583+ // for showing and hiding the header.
584+ compare(header.visible, false, "Header is not hidden when title is unset.");
585+ compare(page.flickable.topMargin, 0,
586+ "topMargin is not 0 when header is hidden.");
587+ compare(page.flickable.contentY, flickableY + headerHeight,
588+ "contentY was not updated properly when header was hidden.");
589+ page.title = pageTitle;
590+ compare(page.flickable.contentY, flickableY,
591+ "Making header visible changes flickable.contentY");
592+ compare(page.flickable.topMargin, headerHeight,
593+ "topMargin was not updated when header became visible.");
594+ }
595+ }
596+}
597
598=== modified file 'tests/unit_x11/tst_components/tst_pagestack.new_header.qml'
599--- tests/unit_x11/tst_components/tst_pagestack.new_header.qml 2015-03-06 12:42:00 +0000
600+++ tests/unit_x11/tst_components/tst_pagestack.new_header.qml 2015-03-23 15:48:48 +0000
601@@ -1,5 +1,5 @@
602 /*
603- * Copyright 2012-2014 Canonical Ltd.
604+ * Copyright 2012-2015 Canonical Ltd.
605 *
606 * This program is free software; you can redistribute it and/or modify
607 * it under the terms of the GNU Lesser General Public License as published by
608@@ -16,7 +16,7 @@
609
610 import QtQuick 2.2
611 import Ubuntu.Test 1.0
612-import Ubuntu.Components 1.1
613+import Ubuntu.Components 1.2
614
615 // pagestack tests for deprecated toolbar are in
616 // unit/tst_components/tst_pagestack_deprecated_toolbar.qml
617@@ -28,7 +28,6 @@
618 MainView {
619 id: mainView
620 anchors.fill: parent
621- useDeprecatedToolbar: false
622 PageStack {
623 id: pageStack
624 Page {
625@@ -73,43 +72,36 @@
626 when: windowShown
627 id: testCase
628
629- property var head_style
630-
631 function initTestCase() {
632- testCase.head_style = findChild(mainView, "PageHeadStyle");
633- wait_for_animation();
634+ waitForHeaderAnimation(mainView);
635 compare(pageStack.currentPage, null, "is not set by default");
636 compare(pageStack.__propagated, mainView.__propagated, "propagated property of pageStack equals mainView.__propagated")
637 compare(mainView.__propagated.header.title, "", "empty title by default");
638 }
639
640- function wait_for_animation() {
641- tryCompareFunction(function(){return testCase.head_style.animating}, false);
642- }
643-
644 function test_depth() {
645 compare(pageStack.depth, 0, "depth is 0 by default");
646 pageStack.push(page1);
647- wait_for_animation();
648+ waitForHeaderAnimation(mainView);
649 compare(pageStack.depth, 1, "depth is correctly increased when pushing a page");
650 pageStack.push(page2);
651- wait_for_animation();
652+ waitForHeaderAnimation(mainView);
653 compare(pageStack.depth, 2, "depth is correctly updated when pushing a page");
654 pageStack.pop();
655- wait_for_animation();
656+ waitForHeaderAnimation(mainView);
657 compare(pageStack.depth, 1, "depth is correctly decreased when popping a page");
658 pageStack.clear();
659- wait_for_animation();
660+ waitForHeaderAnimation(mainView);
661 compare(pageStack.depth, 0, "depth is after clearing");
662 }
663
664 function test_currentPage() {
665 compare(pageStack.currentPage, null, "currentPage is null by default");
666 pageStack.push(page1);
667- wait_for_animation();
668+ waitForHeaderAnimation(mainView);
669 compare(pageStack.currentPage, page1, "currentPage properly updated");
670 pageStack.clear();
671- wait_for_animation();
672+ waitForHeaderAnimation(mainView);
673 compare(pageStack.currentPage, null, "currentPage properly reset");
674 }
675
676@@ -117,60 +109,60 @@
677 compare(pageStack.depth, 0, "depth is 0 initially");
678 pageStack.push(page1);
679 pageStack.push(page2);
680- wait_for_animation();
681+ waitForHeaderAnimation(mainView);
682 compare(pageStack.currentPage, page2, "last pushed page is on top");
683 pageStack.pop();
684- wait_for_animation();
685+ waitForHeaderAnimation(mainView);
686 compare(pageStack.currentPage, page1, "popping puts previously pushed page on top");
687 pageStack.clear();
688- wait_for_animation();
689+ waitForHeaderAnimation(mainView);
690 }
691
692 function test_active_bug1260116() {
693 pageStack.push(page1);
694- wait_for_animation();
695+ waitForHeaderAnimation(mainView);
696
697 compare(page1.active, true, "Page is active after pushing");
698 pageStack.push(page2);
699- wait_for_animation();
700+ waitForHeaderAnimation(mainView);
701
702 compare(page1.active, false, "Page no longer active after pushing a new page");
703 compare(page2.active, true, "New page is active after pushing");
704 pageStack.pop();
705- wait_for_animation();
706+ waitForHeaderAnimation(mainView);
707 compare(page1.active, true, "Page re-activated when on top of the stack");
708 compare(page2.active, false, "Page no longer active after being popped");
709 pageStack.clear();
710- wait_for_animation();
711+ waitForHeaderAnimation(mainView);
712
713 compare(pageInStack.active, false, "Page defined inside PageStack is not active by default");
714 pageStack.push(pageInStack);
715- wait_for_animation();
716+ waitForHeaderAnimation(mainView);
717 compare(pageInStack.active, true, "Pushing a page on PageStack makes it active");
718 pageStack.pop();
719- wait_for_animation();
720+ waitForHeaderAnimation(mainView);
721 compare(pageInStack.active, false, "Popping a page from PageStack makes it inactive");
722 pageStack.clear();
723- wait_for_animation();
724+ waitForHeaderAnimation(mainView);
725 }
726
727 function test_title_bug1143345_bug1317902() {
728 pageStack.push(page1);
729- wait_for_animation();
730+ waitForHeaderAnimation(mainView);
731 compare(mainView.__propagated.header.title, "Title 1", "Header title is correctly set by page");
732 page1.title = "New title";
733 compare(mainView.__propagated.header.title, "New title", "Header title correctly updated by page");
734 pageStack.push(page2);
735- wait_for_animation();
736+ waitForHeaderAnimation(mainView);
737 compare(mainView.__propagated.header.title, "Title 2", "Header title is correctly set by page");
738 pageStack.clear();
739 page1.title = "Title 1";
740
741 pageStack.push(pageWithPage);
742- wait_for_animation();
743+ waitForHeaderAnimation(mainView);
744 compare(mainView.__propagated.header.title, pageWithPage.title, "Embedded page sets title of outer page");
745 pageStack.clear();
746- wait_for_animation();
747+ waitForHeaderAnimation(mainView);
748 }
749
750 function get_tabs_button() {
751@@ -182,36 +174,36 @@
752 function test_tabs_inside_stack_bug1187850() {
753 compare(get_tabs_button(), null, "Without tabs there is no visible tabs button.");
754 pageStack.push(tabs);
755- wait_for_animation();
756+ waitForHeaderAnimation(mainView);
757 compare(pageStack.currentPage, tabs, "Tabs can be pushed on a PageStack");
758 compare(tabs.active, true, "Tabs on top of a PageStack are active");
759 compare(get_tabs_button().visible, true, "Pushing tabs on pagestack enables the tabs button");
760 pageStack.push(page1);
761- wait_for_animation();
762+ waitForHeaderAnimation(mainView);
763 compare(pageStack.currentPage, page1, "A page can be pushed on top of a Tabs");
764 compare(tabs.active, false, "Tabs on a PageStack, but not on top, are inactive");
765 compare(get_tabs_button(), null, "Contents of inactive Tabs is not applied to header");
766 pageStack.pop();
767- wait_for_animation();
768+ waitForHeaderAnimation(mainView);
769 compare(tabs.active, true, "Tabs on top of PageStack is active");
770 compare(get_tabs_button().visible, true, "Active Tabs controls header contents");
771 pageStack.clear();
772- wait_for_animation();
773+ waitForHeaderAnimation(mainView);
774 }
775
776 function test_pop_to_tabs_bug1316736() {
777 pageStack.push(tabs);
778- wait_for_animation();
779+ waitForHeaderAnimation(mainView);
780 tabs.selectedTabIndex = 1;
781 pageStack.push(page1);
782- wait_for_animation();
783+ waitForHeaderAnimation(mainView);
784 compare(tabs.active, false, "Tabs on a PageStack, but not on top, are inactive");
785 pageStack.pop();
786- wait_for_animation();
787+ waitForHeaderAnimation(mainView);
788 compare(tabs.active, true, "Tabs on top of PageStack is active");
789 compare(tabs.selectedTabIndex, 1, "Pushing and popping another page on top of Tabs does not change selectedTabsIndex");
790 pageStack.clear();
791- wait_for_animation();
792+ waitForHeaderAnimation(mainView);
793 }
794
795 function test_push_return_values() {
796@@ -225,7 +217,7 @@
797 compare(pushedPage.title, "Page from QML file",
798 "PageStack.push() returns Page created from QML file");
799 pageStack.clear();
800- wait_for_animation();
801+ waitForHeaderAnimation(mainView);
802 }
803 }
804 }

Subscribers

People subscribed via source and target branches