Merge lp:~tpeeters/ubuntu-ui-toolkit/pagestack-unit-tests into lp:ubuntu-ui-toolkit/staging
- pagestack-unit-tests
- Merge into staging
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 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
ubuntu-sdk-build-bot | continuous-integration | Approve | |
Cris Dywan | Approve | ||
Review via email:
|
Commit message
Update PageStack unit tests to use PageHeader.
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1933
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1933
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1933
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1933
https:/
Executed test runs:
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1933
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1933
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1933
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:1933
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | === modified file 'src/Ubuntu/Components/1.3/PageStack.qml' |
2 | --- src/Ubuntu/Components/1.3/PageStack.qml 2016-04-07 14:35:59 +0000 |
3 | +++ src/Ubuntu/Components/1.3/PageStack.qml 2016-04-13 10:52:21 +0000 |
4 | @@ -185,7 +185,7 @@ |
5 | |
6 | /*! |
7 | Pop the top item from the stack if the stack size is at least 1. |
8 | - Do not do anything if 0 or 1 items are on the stack. |
9 | + Do not do anything if 0 items are on the stack. |
10 | */ |
11 | function pop() { |
12 | internal.finishPreviousAction(); |
13 | |
14 | === renamed file 'tests/unit_x11/tst_components/MyExternalPage.qml' => 'tests/unit_x11/tst_components/MyExternalPage.DEPRECATED_APPHEADER.qml' |
15 | --- tests/unit_x11/tst_components/MyExternalPage.qml 2016-03-07 06:19:27 +0000 |
16 | +++ tests/unit_x11/tst_components/MyExternalPage.DEPRECATED_APPHEADER.qml 2016-04-13 10:52:21 +0000 |
17 | @@ -21,6 +21,6 @@ |
18 | title: "Page from QML file" |
19 | Label { |
20 | anchors.centerIn: parent |
21 | - text: "This page was created from MyExternalPage.qml." |
22 | + text: "This page was created from MyExternalPage.DEPRECATED_APPHEADER.qml." |
23 | } |
24 | } |
25 | |
26 | === modified file 'tests/unit_x11/tst_components/tst_multicolumnheader.qml' |
27 | --- tests/unit_x11/tst_components/tst_multicolumnheader.qml 2015-10-22 12:42:42 +0000 |
28 | +++ tests/unit_x11/tst_components/tst_multicolumnheader.qml 2016-04-13 10:52:21 +0000 |
29 | @@ -59,7 +59,7 @@ |
30 | ListItemWithLabel { |
31 | text: "Add external page right" |
32 | onClicked: layout.addPageToNextColumn( |
33 | - rootPage, Qt.resolvedUrl("MyExternalPage.qml")) |
34 | + rootPage, Qt.resolvedUrl("MyExternalPage.DEPRECATED_APPHEADER.qml")) |
35 | } |
36 | ListItemWithLabel { |
37 | text: "Add page with head contents left" |
38 | @@ -305,7 +305,7 @@ |
39 | } |
40 | |
41 | function test_header_title_for_external_page() { |
42 | - var incubator = layout.addPageToNextColumn(rootPage, Qt.resolvedUrl("MyExternalPage.qml")); |
43 | + var incubator = layout.addPageToNextColumn(rootPage, Qt.resolvedUrl("MyExternalPage.DEPRECATED_APPHEADER.qml")); |
44 | var pageLoaded = false; |
45 | incubator.onStatusChanged = function (status) { |
46 | pageLoaded = (incubator.object != null); |
47 | |
48 | === renamed file 'tests/unit_x11/tst_components/tst_pagestack.qml' => 'tests/unit_x11/tst_components/tst_pagestack.DEPRECATED_APPHEADER_TABS.qml' |
49 | --- tests/unit_x11/tst_components/tst_pagestack.qml 2016-04-07 14:52:32 +0000 |
50 | +++ tests/unit_x11/tst_components/tst_pagestack.DEPRECATED_APPHEADER_TABS.qml 2016-04-13 10:52:21 +0000 |
51 | @@ -1,5 +1,5 @@ |
52 | /* |
53 | - * Copyright 2012-2015 Canonical Ltd. |
54 | + * Copyright 2012-2016 Canonical Ltd. |
55 | * |
56 | * This program is free software; you can redistribute it and/or modify |
57 | * it under the terms of the GNU Lesser General Public License as published by |
58 | @@ -61,10 +61,6 @@ |
59 | onClicked: pageStack.push(tabs) |
60 | } |
61 | Button { |
62 | - text: "pageWithHeader" |
63 | - onClicked: pageStack.push(pageWithHeader) |
64 | - } |
65 | - Button { |
66 | text: "pageComponent" |
67 | onClicked: pageStack.push(pageComponent) |
68 | } |
69 | @@ -100,13 +96,6 @@ |
70 | } |
71 | } |
72 | } |
73 | - Page { |
74 | - id: pageWithHeader |
75 | - title: "Page with PageHeader" |
76 | - header: PageHeader { |
77 | - title: pageWithHeader.title |
78 | - } |
79 | - } |
80 | |
81 | Component { |
82 | id: pageComponent |
83 | @@ -116,7 +105,7 @@ |
84 | } |
85 | |
86 | UbuntuTestCase { |
87 | - name: "PageStackAPI" |
88 | + name: "PageStackDeprecatedAppHeaderAPI" |
89 | when: windowShown |
90 | id: testCase |
91 | |
92 | @@ -268,24 +257,9 @@ |
93 | pushedPage = pageStack.push(pageComponent); |
94 | compare(pushedPage.title, "Page from component", |
95 | "PageStack.push() returns Page created from Component"); |
96 | - pushedPage = pageStack.push(Qt.resolvedUrl("MyExternalPage.qml")); |
97 | + pushedPage = pageStack.push(Qt.resolvedUrl("MyExternalPage.DEPRECATED_APPHEADER.qml")); |
98 | compare(pushedPage.title, "Page from QML file", |
99 | "PageStack.push() returns Page created from QML file"); |
100 | } |
101 | - |
102 | - function test_page_header_back_button_bug1565811() { |
103 | - pageStack.push(pageWithHeader); |
104 | - var backButton = findChild(pageWithHeader.header.leadingActionBar, |
105 | - "pagestack_back_action_button"); |
106 | - compare(backButton, null, |
107 | - "Page header shows back button with only one page on the stack."); |
108 | - pageStack.pop(); |
109 | - pageStack.push(page1); |
110 | - pageStack.push(pageWithHeader); |
111 | - waitForHeaderAnimation(mainView); |
112 | - backButton = findChild(pageWithHeader.header, "pagestack_back_action_button"); |
113 | - compare(backButton && backButton.visible, true, |
114 | - "Page header has no back button with two pages on the stack."); |
115 | - } |
116 | } |
117 | } |
118 | |
119 | === added file 'tests/unit_x11/tst_components/tst_pagestack.qml' |
120 | --- tests/unit_x11/tst_components/tst_pagestack.qml 1970-01-01 00:00:00 +0000 |
121 | +++ tests/unit_x11/tst_components/tst_pagestack.qml 2016-04-13 10:52:21 +0000 |
122 | @@ -0,0 +1,214 @@ |
123 | +/* |
124 | + * Copyright 2016 Canonical Ltd. |
125 | + * |
126 | + * This program is free software; you can redistribute it and/or modify |
127 | + * it under the terms of the GNU Lesser General Public License as published by |
128 | + * the Free Software Foundation; version 3. |
129 | + * |
130 | + * This program is distributed in the hope that it will be useful, |
131 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
132 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
133 | + * GNU Lesser General Public License for more details. |
134 | + * |
135 | + * You should have received a copy of the GNU Lesser General Public License |
136 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
137 | + */ |
138 | + |
139 | +import QtQuick 2.4 |
140 | +import Ubuntu.Components 1.3 |
141 | +import Ubuntu.Test 1.3 |
142 | + |
143 | +Item { |
144 | + width: units.gu(50) |
145 | + height: units.gu(80) |
146 | + |
147 | + MainView { |
148 | + id: mainView |
149 | + anchors.fill: parent |
150 | + PageStack { |
151 | + id: pageStack |
152 | + Page { |
153 | + id: pageInStack |
154 | + } |
155 | + } |
156 | + |
157 | + Column { |
158 | + // for manual testing |
159 | + visible: pageStack.depth === 0 |
160 | + anchors { |
161 | + left: parent.left |
162 | + right: parent.right |
163 | + top: parent.top |
164 | + margins: units.gu(1) |
165 | + } |
166 | + Button { |
167 | + text: "page1" |
168 | + onClicked: pageStack.push(page1) |
169 | + } |
170 | + Button { |
171 | + text: "page2" |
172 | + onClicked: pageStack.push(page2) |
173 | + } |
174 | + Button { |
175 | + text: "pageWithPage" |
176 | + onClicked: pageStack.push(pageWithPage) |
177 | + } |
178 | + Button { |
179 | + text: "pageComponent" |
180 | + onClicked: pageStack.push(pageComponent) |
181 | + } |
182 | + } |
183 | + } |
184 | + Page { |
185 | + id: page1 |
186 | + header: PageHeader { |
187 | + title: "Title 1" |
188 | + } |
189 | + } |
190 | + Page { |
191 | + id: page2 |
192 | + header: PageHeader { |
193 | + title: "Title 2" |
194 | + } |
195 | + } |
196 | + Page { |
197 | + id: pageWithPage |
198 | + header: PageHeader { |
199 | + title: "Outer" |
200 | + } |
201 | + Page { |
202 | + header: PageHeader { |
203 | + title: "Inner" |
204 | + } |
205 | + } |
206 | + } |
207 | + |
208 | + Component { |
209 | + id: pageComponent |
210 | + Page { |
211 | + header: PageHeader { |
212 | + title: "Page from component" |
213 | + } |
214 | + } |
215 | + } |
216 | + |
217 | + UbuntuTestCase { |
218 | + name: "PageStackAPI" |
219 | + when: windowShown |
220 | + id: testCase |
221 | + |
222 | + function initTestCase() { |
223 | + waitForHeaderAnimation(mainView); |
224 | + compare(pageStack.currentPage, null, "is not set by default"); |
225 | + compare(pageStack.__propagated, mainView.__propagated, "propagated property of pageStack equals mainView.__propagated") |
226 | + compare(mainView.__propagated.header.title, "", "empty title by default"); |
227 | + } |
228 | + |
229 | + function cleanup() { |
230 | + pageStack.clear(); |
231 | + waitForHeaderAnimation(mainView); |
232 | + compare(pageStack.depth, 0, "depth is not 0 after clearing."); |
233 | + compare(pageStack.currentPage, null, "currentPage is not null after clearing."); |
234 | + } |
235 | + |
236 | + function test_depth() { |
237 | + compare(pageStack.depth, 0, "depth is 0 by default"); |
238 | + pageStack.push(page1); |
239 | + waitForHeaderAnimation(mainView); |
240 | + compare(pageStack.depth, 1, "depth is correctly increased when pushing a page"); |
241 | + pageStack.push(page2); |
242 | + waitForHeaderAnimation(mainView); |
243 | + compare(pageStack.depth, 2, "depth is correctly updated when pushing a page"); |
244 | + pageStack.pop(); |
245 | + waitForHeaderAnimation(mainView); |
246 | + compare(pageStack.depth, 1, "depth is correctly decreased when popping a page"); |
247 | + } |
248 | + |
249 | + function test_currentPage() { |
250 | + compare(pageStack.currentPage, null, "currentPage is null by default"); |
251 | + pageStack.push(page1); |
252 | + waitForHeaderAnimation(mainView); |
253 | + compare(pageStack.currentPage, page1, "currentPage properly updated"); |
254 | + } |
255 | + |
256 | + function test_page_order() { |
257 | + compare(pageStack.depth, 0, "depth is 0 initially"); |
258 | + pageStack.push(page1); |
259 | + pageStack.push(page2); |
260 | + waitForHeaderAnimation(mainView); |
261 | + compare(pageStack.currentPage, page2, "last pushed page is on top"); |
262 | + pageStack.pop(); |
263 | + waitForHeaderAnimation(mainView); |
264 | + compare(pageStack.currentPage, page1, "popping puts previously pushed page on top"); |
265 | + } |
266 | + |
267 | + function test_multipop_bug1461729() { |
268 | + for (var i=0; i < 10; i++) { |
269 | + pageStack.push(pageComponent); |
270 | + } |
271 | + waitForHeaderAnimation(mainView); |
272 | + compare(pageStack.depth, 10, "couldn't push 10 new pages"); |
273 | + // When updating depth after animating out the header, depth |
274 | + // is not reliable to be used to guard a loop: |
275 | + while(pageStack.depth > 1) { |
276 | + pageStack.pop(); |
277 | + } |
278 | + waitForHeaderAnimation(mainView); |
279 | + compare(pageStack.depth, 1, "popping until one page is left failed. " + |
280 | + pageStack.depth + " pages left on stack"); |
281 | + } |
282 | + |
283 | + function test_active_bug1260116() { |
284 | + pageStack.push(page1); |
285 | + waitForHeaderAnimation(mainView); |
286 | + |
287 | + compare(page1.active, true, "Page is active after pushing"); |
288 | + pageStack.push(page2); |
289 | + waitForHeaderAnimation(mainView); |
290 | + |
291 | + compare(page1.active, false, "Page no longer active after pushing a new page"); |
292 | + compare(page2.active, true, "New page is active after pushing"); |
293 | + pageStack.pop(); |
294 | + waitForHeaderAnimation(mainView); |
295 | + compare(page1.active, true, "Page re-activated when on top of the stack"); |
296 | + compare(page2.active, false, "Page no longer active after being popped"); |
297 | + pageStack.clear(); |
298 | + waitForHeaderAnimation(mainView); |
299 | + |
300 | + compare(pageInStack.active, false, "Page defined inside PageStack is not active by default"); |
301 | + pageStack.push(pageInStack); |
302 | + waitForHeaderAnimation(mainView); |
303 | + compare(pageInStack.active, true, "Pushing a page on PageStack makes it active"); |
304 | + pageStack.pop(); |
305 | + waitForHeaderAnimation(mainView); |
306 | + compare(pageInStack.active, false, "Popping a page from PageStack makes it inactive"); |
307 | + } |
308 | + |
309 | + function test_push_return_values() { |
310 | + var pushedPage = pageStack.push(page1); |
311 | + compare(pushedPage, page1, |
312 | + "PageStack.push() returns pushed Page"); |
313 | + pushedPage = pageStack.push(pageComponent); |
314 | + compare(pushedPage.header.title, "Page from component", |
315 | + "PageStack.push() returns Page created from Component"); |
316 | + pushedPage = pageStack.push(Qt.resolvedUrl("MyExternalPageWithNewHeader.qml")); |
317 | + compare(pushedPage.header.title, "Page from QML file", |
318 | + "PageStack.push() returns Page created from QML file"); |
319 | + } |
320 | + |
321 | + function test_page_header_back_button_bug1565811() { |
322 | + pageStack.push(page2); |
323 | + var backButton = findChild(page2.header.leadingActionBar, |
324 | + "pagestack_back_action_button"); |
325 | + compare(backButton, null, |
326 | + "Page header shows back button with only one page on the stack."); |
327 | + pageStack.pop(); |
328 | + pageStack.push(page1); |
329 | + pageStack.push(page2); |
330 | + waitForHeaderAnimation(mainView); |
331 | + backButton = findChild(page2.header, "pagestack_back_action_button"); |
332 | + compare(backButton && backButton.visible, true, |
333 | + "Page header has no back button with two pages on the stack."); |
334 | + } |
335 | + } |
336 | +} |
PASSED: Continuous integration, rev:1933 /jenkins. ubuntu. com/ubuntu- sdk/job/ ubuntu- ui-toolkit- ci-amd64- devel/456/ /jenkins. ubuntu. com/ubuntu- sdk/job/ generic- update- mp/2573/ console
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild: /jenkins. ubuntu. com/ubuntu- sdk/job/ ubuntu- ui-toolkit- ci-amd64- devel/456/ rebuild
https:/