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

Proposed by Tim Peeters on 2015-03-26
Status: Merged
Approved by: Zsombor Egri on 2015-04-04
Approved revision: 1492
Merged at revision: 1464
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/35-tstHeaderActions
Merge into: lp:ubuntu-ui-toolkit/staging
Prerequisite: lp:~tpeeters/ubuntu-ui-toolkit/headlock
Diff against target: 400 lines (+112/-207)
6 files modified
tests/resources/header/actions.qml (+0/-47)
tests/resources/header/backButton.qml (+0/-59)
tests/resources/header/sections.qml (+0/-41)
tests/unit_x11/tst_components/tst_header_actions.qml (+46/-3)
tests/unit_x11/tst_components/tst_header_sections.qml (+65/-56)
tests/unit_x11/tst_components/tst_header_visible.qml (+1/-1)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/35-tstHeaderActions
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2015-04-04
Christian Dywan 2015-03-26 Approve on 2015-03-30
Review via email: mp+254228@code.launchpad.net

Commit Message

Merge header tests in resources with header unit tests.

Description of the Change

Merge header tests in resources with header unit tests so that both the manual tests and unit tests can be executed from the same code.

Also UbuntuTestCase is no longer used as the root item because that gives problems (see https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1436088 and https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1436091 ).

I use these tests in a following MR where I update the header visuals.

To post a comment you must log in.
Christian Dywan (kalikiana) wrote :

components.api seems to be off?

Also, just to note, tests/unit_x11/tst_components/tst_header_sections.qml uses Item as the root with a MainView child - this isn't fully supported for some components, but no harm in doing it so long as it works for the test.

review: Needs Fixing
Tim Peeters (tpeeters) wrote :

Yes, components.api was off in the prerequisite branch. Fixed.

Christian Dywan (kalikiana) wrote :

Looking nice. Thanks!

review: Approve
1492. By Tim Peeters on 2015-04-02

merge staging

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'tests/resources/header/actions.qml'
2--- tests/resources/header/actions.qml 2015-03-02 23:48:42 +0000
3+++ tests/resources/header/actions.qml 1970-01-01 00:00:00 +0000
4@@ -1,47 +0,0 @@
5-/*
6- * Copyright (C) 2013-2015 Canonical Ltd.
7- *
8- * This program is free software; you can redistribute it and/or modify
9- * it under the terms of the GNU Lesser General Public License as published by
10- * the Free Software Foundation; version 3.
11- *
12- * This program is distributed in the hope that it will be useful,
13- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- * GNU Lesser General Public License for more details.
16- *
17- * You should have received a copy of the GNU Lesser General Public License
18- * along with this program. If not, see <http://www.gnu.org/licenses/>.
19- */
20-
21-import QtQuick 2.4
22-import Ubuntu.Components 1.2
23-
24-MainView {
25- width: units.gu(50)
26- height: units.gu(70)
27-
28- Page {
29- title: "Actions"
30- Label {
31- anchors.centerIn: parent
32- text: "New API"
33- }
34- head {
35- actions: [
36- Action {
37- iconName: "settings"
38- onTriggered: print("Trigger first action")
39- },
40- Action {
41- iconName: "camera-flip"
42- onTriggered: print("Trigger second action")
43- }
44- ]
45- backAction: Action {
46- iconName: "close"
47- onTriggered: print("Trigger custom back action")
48- }
49- }
50- }
51-}
52
53=== removed file 'tests/resources/header/backButton.qml'
54--- tests/resources/header/backButton.qml 2015-03-02 23:48:42 +0000
55+++ tests/resources/header/backButton.qml 1970-01-01 00:00:00 +0000
56@@ -1,59 +0,0 @@
57-/*
58- * Copyright (C) 2013-2015 Canonical Ltd.
59- *
60- * This program is free software; you can redistribute it and/or modify
61- * it under the terms of the GNU Lesser General Public License as published by
62- * the Free Software Foundation; version 3.
63- *
64- * This program is distributed in the hope that it will be useful,
65- * but WITHOUT ANY WARRANTY; without even the implied warranty of
66- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
67- * GNU Lesser General Public License for more details.
68- *
69- * You should have received a copy of the GNU Lesser General Public License
70- * along with this program. If not, see <http://www.gnu.org/licenses/>.
71- */
72-
73-import QtQuick 2.4
74-import Ubuntu.Components 1.2
75-
76-MainView {
77- id: mainView
78- width: units.gu(50)
79- height: units.gu(70)
80-
81- PageStack {
82- id: stack
83-
84- Component.onCompleted: stack.push(firstPage)
85- Page {
86- id: firstPage
87- title: "Stack"
88- Button {
89- anchors.centerIn: parent
90- text: "Click me"
91- onTriggered: stack.push(pageOnStack)
92- }
93- head {
94- actions: Action {
95- iconName: "settings"
96- text: "Settings"
97- }
98- }
99- }
100-
101- Page {
102- id: pageOnStack
103- visible: false
104- title: "Stacked page"
105- Label {
106- anchors.centerIn: parent
107- text: "Use back button to return"
108- }
109- head.actions: Action {
110- iconName: "info"
111- text: "information"
112- }
113- }
114- }
115-}
116
117=== removed file 'tests/resources/header/sections.qml'
118--- tests/resources/header/sections.qml 2015-03-02 23:48:42 +0000
119+++ tests/resources/header/sections.qml 1970-01-01 00:00:00 +0000
120@@ -1,41 +0,0 @@
121-/*
122- * Copyright (C) 2013-2015 Canonical Ltd.
123- *
124- * This program is free software; you can redistribute it and/or modify
125- * it under the terms of the GNU Lesser General Public License as published by
126- * the Free Software Foundation; version 3.
127- *
128- * This program is distributed in the hope that it will be useful,
129- * but WITHOUT ANY WARRANTY; without even the implied warranty of
130- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
131- * GNU Lesser General Public License for more details.
132- *
133- * You should have received a copy of the GNU Lesser General Public License
134- * along with this program. If not, see <http://www.gnu.org/licenses/>.
135- */
136-
137-import QtQuick 2.4
138-import Ubuntu.Components 1.2
139-
140-MainView {
141- id: mainView
142- width: units.gu(50)
143- height: units.gu(70)
144-
145- Page {
146- title: "Sections"
147- id: sectionsPage
148- head {
149- sections {
150- model: ["navy", "lightblue", "brown"]
151- }
152- }
153- Rectangle {
154- anchors {
155- fill: parent
156- margins: units.gu(2)
157- }
158- color: sectionsPage.head.sections.model[sectionsPage.head.sections.selectedIndex]
159- }
160- }
161-}
162
163=== modified file 'tests/unit_x11/tst_components/tst_header_actions.qml'
164--- tests/unit_x11/tst_components/tst_header_actions.qml 2015-03-19 16:31:11 +0000
165+++ tests/unit_x11/tst_components/tst_header_actions.qml 2015-04-02 19:21:49 +0000
166@@ -16,7 +16,7 @@
167
168 import QtQuick 2.4
169 import Ubuntu.Test 1.0
170-import Ubuntu.Components 1.2
171+import Ubuntu.Components 1.3
172
173 // NOTE: Other parts of the page head API are tested with autopilot in
174 // ubuntuuitoolkit.tests.components.test_header
175@@ -34,20 +34,63 @@
176 Page {
177 id: page1
178 title: "First page"
179+
180+ Button {
181+ anchors.centerIn: parent
182+ onClicked: pageStack.push(page2)
183+ text: "Push page 2"
184+ }
185+
186+ head {
187+ actions: [
188+ Action {
189+ iconName: "settings"
190+ onTriggered: print("Trigger first action")
191+ },
192+ Action {
193+ iconName: "info"
194+ onTriggered: print("Trigger second action")
195+ },
196+ Action {
197+ iconName: "search"
198+ onTriggered: print("Trigger third action")
199+ }
200+ ]
201+ }
202 }
203 Page {
204 id: page2
205+ visible: false
206 title: "Second page"
207
208 Action {
209 id: customBackAction
210- iconName: "search"
211- text: "Search"
212+ iconName: "close"
213+ text: "Close"
214+ onTriggered: print("Triggered custom back action.")
215 }
216 Action {
217 id: invisibleAction
218 visible: false
219 }
220+ head {
221+ backAction: customBackActionSwitch.checked ?
222+ customBackAction : null
223+ }
224+
225+ Row {
226+ anchors.centerIn: parent
227+ spacing: units.gu(1)
228+ Label {
229+ text: "standard"
230+ }
231+ Switch {
232+ id: customBackActionSwitch
233+ }
234+ Label {
235+ text: "custom back action"
236+ }
237+ }
238 }
239 }
240 Component.onCompleted: {
241
242=== renamed file 'tests/unit/tst_components/tst_header_sections.qml' => 'tests/unit_x11/tst_components/tst_header_sections.qml'
243--- tests/unit/tst_components/tst_header_sections.qml 2015-03-03 13:20:06 +0000
244+++ tests/unit_x11/tst_components/tst_header_sections.qml 2015-04-02 19:21:49 +0000
245@@ -1,5 +1,5 @@
246 /*
247- * Copyright 2014 Canonical Ltd.
248+ * Copyright 2014-2015 Canonical Ltd.
249 *
250 * This program is free software; you can redistribute it and/or modify
251 * it under the terms of the GNU Lesser General Public License as published by
252@@ -14,71 +14,80 @@
253 * along with this program. If not, see <http://www.gnu.org/licenses/>.
254 */
255
256-import QtQuick 2.2
257-import QtTest 1.0
258-import Ubuntu.Components 1.1
259+import QtQuick 2.4
260+import Ubuntu.Components 1.3
261 import Ubuntu.Test 1.0
262
263-UbuntuTestCase {
264- name: "PageHeadSectionsAPI"
265+Item {
266+ width: units.gu(50)
267+ height: units.gu(70)
268
269 MainView {
270 id: mainView
271- width: units.gu(50)
272- height: units.gu(80)
273-
274- useDeprecatedToolbar: false
275+ anchors.fill: parent
276
277 Page {
278 id: page
279 title: "Sections"
280 head {
281 sections {
282- model: ["one", "two", "three"]
283- }
284- }
285- }
286- }
287-
288- function initTestCase() {
289- compare(mainView.active, true, "MainView always active.");
290- compare(page.active, true, "Single page is active in MainView.");
291- }
292-
293- function test_number_of_sections() {
294- var sectionsRepeater = findChild(mainView, "page_head_sections_repeater");
295- compare(sectionsRepeater.count, 3, "Number of sections initialization failed.");
296- page.head.sections.model = ["one"]
297- compare(sectionsRepeater.count, 1, "Number of sections not updated.");
298- page.head.sections.model = ["one", "two", "three"];
299- compare(sectionsRepeater.count, 3, "Number of sections reverted.");
300- }
301-
302- function check_selected_button(numberOfButtons, selectedButtonIndex) {
303- for (var i = 0; i < numberOfButtons; i++) {
304- var button = findChild(mainView, "section_button_"+i);
305- if (i === selectedButtonIndex) {
306- compare(button.selected, true, "Button "+i+" is not selected.");
307- } else {
308- compare(button.selected, false, "Button "+i+" is selected.");
309- }
310- }
311- }
312-
313- function test_selected_section() {
314- var sectionsRepeater = findChild(mainView, "page_head_sections_repeater");
315- var count = sectionsRepeater.count;
316- check_selected_button(count, 0);
317- page.head.sections.selectedIndex = 2;
318- check_selected_button(count, 2);
319- page.head.sections.selectedIndex = 1;
320- check_selected_button(count, 1);
321- page.head.sections.selectedIndex = 0;
322- check_selected_button(count, 0);
323- }
324-
325- function test_warn_when_too_many_sections() {
326- ignoreWarning("It is not recommended or supported to use more than three sections in Page.head.sections.model.")
327- page.head.sections.model = ["1", "2", "3", "4"];
328+ model: ["navy", "lightblue", "brown"]
329+ }
330+ }
331+ Rectangle {
332+ anchors {
333+ fill: parent
334+ margins: units.gu(2)
335+ }
336+ color: page.head.sections.model[page.head.sections.selectedIndex]
337+ }
338+ }
339+ }
340+
341+ UbuntuTestCase {
342+ name: "PageHeadSectionsAPI"
343+ when: windowShown
344+
345+ function initTestCase() {
346+ compare(mainView.active, true, "MainView always active.");
347+ compare(page.active, true, "Single page is active in MainView.");
348+ }
349+
350+ function test_number_of_sections() {
351+ var sectionsRepeater = findChild(mainView, "page_head_sections_repeater");
352+ compare(sectionsRepeater.count, 3, "Number of sections initialization failed.");
353+ page.head.sections.model = ["red"]
354+ compare(sectionsRepeater.count, 1, "Number of sections not updated.");
355+ page.head.sections.model = ["navy", "lightblue", "brown"];
356+ compare(sectionsRepeater.count, 3, "Number of sections reverted.");
357+ }
358+
359+ function check_selected_button(numberOfButtons, selectedButtonIndex) {
360+ for (var i = 0; i < numberOfButtons; i++) {
361+ var button = findChild(mainView, "section_button_"+i);
362+ if (i === selectedButtonIndex) {
363+ compare(button.selected, true, "Button "+i+" is not selected.");
364+ } else {
365+ compare(button.selected, false, "Button "+i+" is selected.");
366+ }
367+ }
368+ }
369+
370+ function test_selected_section() {
371+ var sectionsRepeater = findChild(mainView, "page_head_sections_repeater");
372+ var count = sectionsRepeater.count;
373+ check_selected_button(count, 0);
374+ page.head.sections.selectedIndex = 2;
375+ check_selected_button(count, 2);
376+ page.head.sections.selectedIndex = 1;
377+ check_selected_button(count, 1);
378+ page.head.sections.selectedIndex = 0;
379+ check_selected_button(count, 0);
380+ }
381+
382+ function test_warn_when_too_many_sections() {
383+ ignoreWarning("It is not recommended or supported to use more than three sections in Page.head.sections.model.")
384+ page.head.sections.model = ["red", "orange", "yellow", "green"];
385+ }
386 }
387 }
388
389=== modified file 'tests/unit_x11/tst_components/tst_header_visible.qml'
390--- tests/unit_x11/tst_components/tst_header_visible.qml 2015-03-20 11:48:29 +0000
391+++ tests/unit_x11/tst_components/tst_header_visible.qml 2015-04-02 19:21:49 +0000
392@@ -52,7 +52,7 @@
393 right: parent.right
394 top: parent.top
395 }
396- height: 1
397+ height: units.gu(2)
398 }
399
400 Grid {

Subscribers

People subscribed via source and target branches