Merge lp:~tpeeters/ubuntu-ui-toolkit/pagestack-unit-tests into lp:ubuntu-ui-toolkit/staging

Proposed by Tim Peeters
Status: Merged
Approved by: Cris Dywan
Approved revision: 1933
Merged at revision: 1940
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/pagestack-unit-tests
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 336 lines (+221/-33)
5 files modified
src/Ubuntu/Components/1.3/PageStack.qml (+1/-1)
tests/unit_x11/tst_components/MyExternalPage.DEPRECATED_APPHEADER.qml (+1/-1)
tests/unit_x11/tst_components/tst_multicolumnheader.qml (+2/-2)
tests/unit_x11/tst_components/tst_pagestack.DEPRECATED_APPHEADER_TABS.qml (+3/-29)
tests/unit_x11/tst_components/tst_pagestack.qml (+214/-0)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/pagestack-unit-tests
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Approve
Cris Dywan Approve
Review via email: mp+291731@code.launchpad.net

Commit message

Update PageStack unit tests to use PageHeader.

To post a comment you must log in.
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

For the record, the key here is indeed that the new tests use the PageHeader whilst the old ones go back to AppHeader, the internal default.

review: Approve
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Ubuntu/Components/1.3/PageStack.qml'
--- src/Ubuntu/Components/1.3/PageStack.qml 2016-04-07 14:35:59 +0000
+++ src/Ubuntu/Components/1.3/PageStack.qml 2016-04-13 10:52:21 +0000
@@ -185,7 +185,7 @@
185185
186 /*!186 /*!
187 Pop the top item from the stack if the stack size is at least 1.187 Pop the top item from the stack if the stack size is at least 1.
188 Do not do anything if 0 or 1 items are on the stack.188 Do not do anything if 0 items are on the stack.
189 */189 */
190 function pop() {190 function pop() {
191 internal.finishPreviousAction();191 internal.finishPreviousAction();
192192
=== renamed file 'tests/unit_x11/tst_components/MyExternalPage.qml' => 'tests/unit_x11/tst_components/MyExternalPage.DEPRECATED_APPHEADER.qml'
--- tests/unit_x11/tst_components/MyExternalPage.qml 2016-03-07 06:19:27 +0000
+++ tests/unit_x11/tst_components/MyExternalPage.DEPRECATED_APPHEADER.qml 2016-04-13 10:52:21 +0000
@@ -21,6 +21,6 @@
21 title: "Page from QML file"21 title: "Page from QML file"
22 Label {22 Label {
23 anchors.centerIn: parent23 anchors.centerIn: parent
24 text: "This page was created from MyExternalPage.qml."24 text: "This page was created from MyExternalPage.DEPRECATED_APPHEADER.qml."
25 }25 }
26}26}
2727
=== modified file 'tests/unit_x11/tst_components/tst_multicolumnheader.qml'
--- tests/unit_x11/tst_components/tst_multicolumnheader.qml 2015-10-22 12:42:42 +0000
+++ tests/unit_x11/tst_components/tst_multicolumnheader.qml 2016-04-13 10:52:21 +0000
@@ -59,7 +59,7 @@
59 ListItemWithLabel {59 ListItemWithLabel {
60 text: "Add external page right"60 text: "Add external page right"
61 onClicked: layout.addPageToNextColumn(61 onClicked: layout.addPageToNextColumn(
62 rootPage, Qt.resolvedUrl("MyExternalPage.qml"))62 rootPage, Qt.resolvedUrl("MyExternalPage.DEPRECATED_APPHEADER.qml"))
63 }63 }
64 ListItemWithLabel {64 ListItemWithLabel {
65 text: "Add page with head contents left"65 text: "Add page with head contents left"
@@ -305,7 +305,7 @@
305 }305 }
306306
307 function test_header_title_for_external_page() {307 function test_header_title_for_external_page() {
308 var incubator = layout.addPageToNextColumn(rootPage, Qt.resolvedUrl("MyExternalPage.qml"));308 var incubator = layout.addPageToNextColumn(rootPage, Qt.resolvedUrl("MyExternalPage.DEPRECATED_APPHEADER.qml"));
309 var pageLoaded = false;309 var pageLoaded = false;
310 incubator.onStatusChanged = function (status) {310 incubator.onStatusChanged = function (status) {
311 pageLoaded = (incubator.object != null);311 pageLoaded = (incubator.object != null);
312312
=== renamed file 'tests/unit_x11/tst_components/tst_pagestack.qml' => 'tests/unit_x11/tst_components/tst_pagestack.DEPRECATED_APPHEADER_TABS.qml'
--- tests/unit_x11/tst_components/tst_pagestack.qml 2016-04-07 14:52:32 +0000
+++ tests/unit_x11/tst_components/tst_pagestack.DEPRECATED_APPHEADER_TABS.qml 2016-04-13 10:52:21 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright 2012-2015 Canonical Ltd.2 * Copyright 2012-2016 Canonical Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by5 * it under the terms of the GNU Lesser General Public License as published by
@@ -61,10 +61,6 @@
61 onClicked: pageStack.push(tabs)61 onClicked: pageStack.push(tabs)
62 }62 }
63 Button {63 Button {
64 text: "pageWithHeader"
65 onClicked: pageStack.push(pageWithHeader)
66 }
67 Button {
68 text: "pageComponent"64 text: "pageComponent"
69 onClicked: pageStack.push(pageComponent)65 onClicked: pageStack.push(pageComponent)
70 }66 }
@@ -100,13 +96,6 @@
100 }96 }
101 }97 }
102 }98 }
103 Page {
104 id: pageWithHeader
105 title: "Page with PageHeader"
106 header: PageHeader {
107 title: pageWithHeader.title
108 }
109 }
11099
111 Component {100 Component {
112 id: pageComponent101 id: pageComponent
@@ -116,7 +105,7 @@
116 }105 }
117106
118 UbuntuTestCase {107 UbuntuTestCase {
119 name: "PageStackAPI"108 name: "PageStackDeprecatedAppHeaderAPI"
120 when: windowShown109 when: windowShown
121 id: testCase110 id: testCase
122111
@@ -268,24 +257,9 @@
268 pushedPage = pageStack.push(pageComponent);257 pushedPage = pageStack.push(pageComponent);
269 compare(pushedPage.title, "Page from component",258 compare(pushedPage.title, "Page from component",
270 "PageStack.push() returns Page created from Component");259 "PageStack.push() returns Page created from Component");
271 pushedPage = pageStack.push(Qt.resolvedUrl("MyExternalPage.qml"));260 pushedPage = pageStack.push(Qt.resolvedUrl("MyExternalPage.DEPRECATED_APPHEADER.qml"));
272 compare(pushedPage.title, "Page from QML file",261 compare(pushedPage.title, "Page from QML file",
273 "PageStack.push() returns Page created from QML file");262 "PageStack.push() returns Page created from QML file");
274 }263 }
275
276 function test_page_header_back_button_bug1565811() {
277 pageStack.push(pageWithHeader);
278 var backButton = findChild(pageWithHeader.header.leadingActionBar,
279 "pagestack_back_action_button");
280 compare(backButton, null,
281 "Page header shows back button with only one page on the stack.");
282 pageStack.pop();
283 pageStack.push(page1);
284 pageStack.push(pageWithHeader);
285 waitForHeaderAnimation(mainView);
286 backButton = findChild(pageWithHeader.header, "pagestack_back_action_button");
287 compare(backButton && backButton.visible, true,
288 "Page header has no back button with two pages on the stack.");
289 }
290 }264 }
291}265}
292266
=== added file 'tests/unit_x11/tst_components/tst_pagestack.qml'
--- tests/unit_x11/tst_components/tst_pagestack.qml 1970-01-01 00:00:00 +0000
+++ tests/unit_x11/tst_components/tst_pagestack.qml 2016-04-13 10:52:21 +0000
@@ -0,0 +1,214 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19import Ubuntu.Test 1.3
20
21Item {
22 width: units.gu(50)
23 height: units.gu(80)
24
25 MainView {
26 id: mainView
27 anchors.fill: parent
28 PageStack {
29 id: pageStack
30 Page {
31 id: pageInStack
32 }
33 }
34
35 Column {
36 // for manual testing
37 visible: pageStack.depth === 0
38 anchors {
39 left: parent.left
40 right: parent.right
41 top: parent.top
42 margins: units.gu(1)
43 }
44 Button {
45 text: "page1"
46 onClicked: pageStack.push(page1)
47 }
48 Button {
49 text: "page2"
50 onClicked: pageStack.push(page2)
51 }
52 Button {
53 text: "pageWithPage"
54 onClicked: pageStack.push(pageWithPage)
55 }
56 Button {
57 text: "pageComponent"
58 onClicked: pageStack.push(pageComponent)
59 }
60 }
61 }
62 Page {
63 id: page1
64 header: PageHeader {
65 title: "Title 1"
66 }
67 }
68 Page {
69 id: page2
70 header: PageHeader {
71 title: "Title 2"
72 }
73 }
74 Page {
75 id: pageWithPage
76 header: PageHeader {
77 title: "Outer"
78 }
79 Page {
80 header: PageHeader {
81 title: "Inner"
82 }
83 }
84 }
85
86 Component {
87 id: pageComponent
88 Page {
89 header: PageHeader {
90 title: "Page from component"
91 }
92 }
93 }
94
95 UbuntuTestCase {
96 name: "PageStackAPI"
97 when: windowShown
98 id: testCase
99
100 function initTestCase() {
101 waitForHeaderAnimation(mainView);
102 compare(pageStack.currentPage, null, "is not set by default");
103 compare(pageStack.__propagated, mainView.__propagated, "propagated property of pageStack equals mainView.__propagated")
104 compare(mainView.__propagated.header.title, "", "empty title by default");
105 }
106
107 function cleanup() {
108 pageStack.clear();
109 waitForHeaderAnimation(mainView);
110 compare(pageStack.depth, 0, "depth is not 0 after clearing.");
111 compare(pageStack.currentPage, null, "currentPage is not null after clearing.");
112 }
113
114 function test_depth() {
115 compare(pageStack.depth, 0, "depth is 0 by default");
116 pageStack.push(page1);
117 waitForHeaderAnimation(mainView);
118 compare(pageStack.depth, 1, "depth is correctly increased when pushing a page");
119 pageStack.push(page2);
120 waitForHeaderAnimation(mainView);
121 compare(pageStack.depth, 2, "depth is correctly updated when pushing a page");
122 pageStack.pop();
123 waitForHeaderAnimation(mainView);
124 compare(pageStack.depth, 1, "depth is correctly decreased when popping a page");
125 }
126
127 function test_currentPage() {
128 compare(pageStack.currentPage, null, "currentPage is null by default");
129 pageStack.push(page1);
130 waitForHeaderAnimation(mainView);
131 compare(pageStack.currentPage, page1, "currentPage properly updated");
132 }
133
134 function test_page_order() {
135 compare(pageStack.depth, 0, "depth is 0 initially");
136 pageStack.push(page1);
137 pageStack.push(page2);
138 waitForHeaderAnimation(mainView);
139 compare(pageStack.currentPage, page2, "last pushed page is on top");
140 pageStack.pop();
141 waitForHeaderAnimation(mainView);
142 compare(pageStack.currentPage, page1, "popping puts previously pushed page on top");
143 }
144
145 function test_multipop_bug1461729() {
146 for (var i=0; i < 10; i++) {
147 pageStack.push(pageComponent);
148 }
149 waitForHeaderAnimation(mainView);
150 compare(pageStack.depth, 10, "couldn't push 10 new pages");
151 // When updating depth after animating out the header, depth
152 // is not reliable to be used to guard a loop:
153 while(pageStack.depth > 1) {
154 pageStack.pop();
155 }
156 waitForHeaderAnimation(mainView);
157 compare(pageStack.depth, 1, "popping until one page is left failed. " +
158 pageStack.depth + " pages left on stack");
159 }
160
161 function test_active_bug1260116() {
162 pageStack.push(page1);
163 waitForHeaderAnimation(mainView);
164
165 compare(page1.active, true, "Page is active after pushing");
166 pageStack.push(page2);
167 waitForHeaderAnimation(mainView);
168
169 compare(page1.active, false, "Page no longer active after pushing a new page");
170 compare(page2.active, true, "New page is active after pushing");
171 pageStack.pop();
172 waitForHeaderAnimation(mainView);
173 compare(page1.active, true, "Page re-activated when on top of the stack");
174 compare(page2.active, false, "Page no longer active after being popped");
175 pageStack.clear();
176 waitForHeaderAnimation(mainView);
177
178 compare(pageInStack.active, false, "Page defined inside PageStack is not active by default");
179 pageStack.push(pageInStack);
180 waitForHeaderAnimation(mainView);
181 compare(pageInStack.active, true, "Pushing a page on PageStack makes it active");
182 pageStack.pop();
183 waitForHeaderAnimation(mainView);
184 compare(pageInStack.active, false, "Popping a page from PageStack makes it inactive");
185 }
186
187 function test_push_return_values() {
188 var pushedPage = pageStack.push(page1);
189 compare(pushedPage, page1,
190 "PageStack.push() returns pushed Page");
191 pushedPage = pageStack.push(pageComponent);
192 compare(pushedPage.header.title, "Page from component",
193 "PageStack.push() returns Page created from Component");
194 pushedPage = pageStack.push(Qt.resolvedUrl("MyExternalPageWithNewHeader.qml"));
195 compare(pushedPage.header.title, "Page from QML file",
196 "PageStack.push() returns Page created from QML file");
197 }
198
199 function test_page_header_back_button_bug1565811() {
200 pageStack.push(page2);
201 var backButton = findChild(page2.header.leadingActionBar,
202 "pagestack_back_action_button");
203 compare(backButton, null,
204 "Page header shows back button with only one page on the stack.");
205 pageStack.pop();
206 pageStack.push(page1);
207 pageStack.push(page2);
208 waitForHeaderAnimation(mainView);
209 backButton = findChild(page2.header, "pagestack_back_action_button");
210 compare(backButton && backButton.visible, true,
211 "Page header has no back button with two pages on the stack.");
212 }
213 }
214}

Subscribers

People subscribed via source and target branches