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

Proposed by Tim Peeters
Status: Merged
Approved by: Timo Jyrinki
Approved revision: 1979
Merged at revision: 1976
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/active-init
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 283 lines (+220/-5)
3 files modified
src/Ubuntu/Components/plugin/ucmainviewbase.cpp (+6/-1)
tests/unit_x11/tst_components/tst_tabs11.qml (+198/-0)
tests/unit_x11/tst_components/tst_tabs13.qml (+16/-4)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/active-init
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Approve
Benjamin Zeller Approve
Review via email: mp+293556@code.launchpad.net

Commit message

Postpone setting MainPage.active to true until the components are loaded to avoid initialization problems.

Description of the change

Postpone setting MainPage.active to true until the components are loaded to avoid initialization problems.

To post a comment you must log in.
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (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
Tim Peeters (tpeeters) wrote :

TODO: add the same unit test to tst_tabs11

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: Needs Fixing (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
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
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
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Benjamin Zeller (zeller-benjamin) wrote :

LGTM

review: Approve
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (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: Needs Fixing (continuous-integration)
1979. By Tim Peeters

sync staging

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
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/plugin/ucmainviewbase.cpp'
--- src/Ubuntu/Components/plugin/ucmainviewbase.cpp 2016-04-04 04:47:11 +0000
+++ src/Ubuntu/Components/plugin/ucmainviewbase.cpp 2016-05-09 09:15:00 +0000
@@ -53,7 +53,9 @@
5353
54 m_actionContext->setObjectName(QStringLiteral("RootContext"));54 m_actionContext->setObjectName(QStringLiteral("RootContext"));
55 m_actionContext->setActive(true);55 m_actionContext->setActive(true);
56 q->setActive(true);56 // setActive(true) is called in componentComplete to wait
57 // until the MainView (and all its children) are complete
58 // to prevent bug #1570886.
5759
58 QObject::connect(m_actionManager,&UCActionManager::quit, [](){60 QObject::connect(m_actionManager,&UCActionManager::quit, [](){
59 // FIXME Wire this up to the application lifecycle management API instead of quit().61 // FIXME Wire this up to the application lifecycle management API instead of quit().
@@ -307,6 +309,9 @@
307{309{
308 Q_D(UCMainViewBase);310 Q_D(UCMainViewBase);
309 UCPageTreeNode::componentComplete();311 UCPageTreeNode::componentComplete();
312 // Do not call setActive() in d->init() but postpone until the
313 // component is complete to avoid bug #1570886.
314 this->setActive(true);
310 d->doAutoTheme();315 d->doAutoTheme();
311316
312 if (d->m_actionContext)317 if (d->m_actionContext)
313318
=== added file 'tests/unit_x11/tst_components/tst_tabs11.qml'
--- tests/unit_x11/tst_components/tst_tabs11.qml 1970-01-01 00:00:00 +0000
+++ tests/unit_x11/tst_components/tst_tabs11.qml 2016-05-09 09:15:00 +0000
@@ -0,0 +1,198 @@
1/*
2 * Copyright 2012-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.2
18import Ubuntu.Test 1.0
19import Ubuntu.Components 1.1
20
21MainView {
22 id: mainView
23 width: units.gu(50)
24 height: units.gu(80)
25 useDeprecatedToolbar: false
26
27 Tabs {
28 id: tabs
29 Tab {
30 id: tab1
31 title: "tab 1"
32 page: Page {
33 id: page1
34 Button {
35 id: button
36 anchors.centerIn: parent
37 text: "click"
38 }
39 }
40 }
41 Tab {
42 id: tab2
43 title: "tab 2"
44 page: Page {
45 id: page2
46 }
47 }
48 Tab {
49 id: tab3
50 title: "tab 3"
51 page: Page {
52 id: page3
53 }
54 }
55 Tab {
56 id: tabFlick1
57 title: "flick"
58 page: Page {
59 Flickable {
60 id: flickable1
61 anchors.fill: parent
62 }
63 }
64 }
65 Tab {
66 id: tabFlick2
67 title: "flick 2"
68 page: Page {
69 Flickable {
70 id: flickable2
71 anchors.fill: parent
72 }
73 }
74 }
75 Tab {
76 id: tabFlickLoader
77 title: "load"
78 page: Loader {
79 id: loader
80 sourceComponent: tabs.selectedTabIndex != 5 ? null : pageComponent
81 }
82 }
83 Tab {
84 id: tabNoFlickLoader
85 title: "loadNoFlick"
86 page: Loader {
87 id: loaderNoFlick
88 anchors {
89 left: parent.left
90 right: parent.right
91 bottom: parent.bottom
92 }
93 // height compes from the loaded Page
94 sourceComponent: tabs.selectedTabIndex === 6 ? pageComponentNoFlick : null
95 }
96 }
97 Tab {
98 // Test for bug #1570886, see initTestCase().
99 id: tabWithTitleFromPage
100 page: Page {
101 title: "Title from Page"
102 }
103 }
104 }
105 Component {
106 id: pageComponent
107 Page {
108 title: "Loaded page"
109 property Flickable flick: loadedFlickable
110 Flickable {
111 id: loadedFlickable
112 anchors.fill: parent
113 contentHeight: 1000
114 }
115 }
116 }
117 Component {
118 id: pageComponentNoFlick
119 Page {
120 title: "Loaded page without flickable"
121 }
122 }
123
124 UbuntuTestCase {
125 name: "TabsAPINewHeader"
126 when: windowShown
127
128 function initTestCase() {
129 // Test for bug #1570886.
130 compare(mainView.__propagated.header.title, tab1.title,
131 "Incorrect initial header title.");
132 }
133
134 function test_tabsDefaults() {
135 compare(tabs.selectedTabIndex, 0, "The default selectedTabIndex is 0 when Tabs has contents");
136 compare(tabs.selectedTab, tab1, "The default selectedTab is the first tab");
137 compare(tabs.currentPage, page1, "The default currentPage is the page of the first tab");
138 }
139
140 function test_tabsSetSelectedTab() {
141 var tabArray = [tab1, tab2, tab3];
142 var pageArray = [page1, page2, page3];
143 for (var i=0; i < 3; i++) {
144 tabs.selectedTabIndex = i;
145 compare(tabs.selectedTabIndex, i, "Can set selectedTabIndex");
146 compare(tabs.selectedTab, tabArray[i], "Can update selectedTab by setting selectedTabIndex");
147 compare(tabs.currentPage, pageArray[i], "Can update currentPage by setting selectedTabIndex");
148 for (var j=0; j < 3; j++) {
149 compare(pageArray[j].active, j===i, "Only the page of the selected tab is active");
150 }
151 }
152 }
153
154 function test_flickable() {
155 // ensure that the flickable of the header is set to the flickable of the selected tab.
156 tabs.selectedTabIndex = 3;
157 compare(mainView.__propagated.header.flickable, flickable1, "Header flickable correctly initialized");
158 tabs.selectedTabIndex = 4;
159 compare(mainView.__propagated.header.flickable, flickable2, "Header flickable correctly updated");
160 tabs.selectedTabIndex = 0;
161 }
162
163 function test_pageLoader() {
164 tabs.selectedTabIndex = 0;
165 compare(loader.item, null, "Page not loaded when tab is not selected");
166 tabs.selectedTabIndex = 5;
167 compare(tabs.currentPage, loader, "Selected loader for current page");
168 compare(loader.item.title, "Loaded page", "Loaded item is a page");
169 tabs.selectedTabIndex = 0;
170 compare(loader.item, null, "Loaded page was properly unloaded");
171 }
172
173 function test_bug1088740() {
174 tabs.selectedTabIndex = 5;
175 compare(mainView.__propagated.header.flickable, loader.item.flick, "Header flickable correctly updated with Loader");
176 compare(loader.item.flick.contentHeight, 1000, "Header flickable is correct flickable");
177 tabs.selectedTabIndex = 0;
178 }
179
180 function test_pageHeightLoaderNoFlick_bug1259917() {
181 tabs.selectedTabIndex = 6;
182 compare(tabs.selectedTab, tabNoFlickLoader, "Tab 6 was selected.");
183 compare(mainView.__propagated.header.flickable, null, "Loaded page without flickable.");
184 compare(loaderNoFlick.item.height, mainView.height - mainView.__propagated.header.height,
185 "Correct height for loaded Page without flickable.");
186 }
187
188 function test_index() {
189 compare(tab1.index, 0, "tab1 is at 0");
190 compare(tab2.index, 1, "tab2 is at 1");
191 compare(tab3.index, 2, "tab3 is at 2");
192 compare(tabFlick1.index, 3, "tabFlick1 is at 3");
193 compare(tabFlick2.index, 4, "tabFlick2 is at 4");
194 compare(tabFlickLoader.index, 5, "tabFlickLoader is at 5");
195 compare(tabNoFlickLoader.index, 6, "tabNoFlickLoader is at 6");
196 }
197 }
198}
0199
=== renamed file 'tests/unit_x11/tst_components/tst_tabs.qml' => 'tests/unit_x11/tst_components/tst_tabs13.qml'
--- tests/unit_x11/tst_components/tst_tabs.qml 2015-09-03 11:44:38 +0000
+++ tests/unit_x11/tst_components/tst_tabs13.qml 2016-05-09 09:15:00 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright 2012-2014 Canonical Ltd.2 * Copyright 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
@@ -14,15 +14,14 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */15 */
1616
17import QtQuick 2.217import QtQuick 2.4
18import Ubuntu.Test 1.018import Ubuntu.Test 1.0
19import Ubuntu.Components 1.119import Ubuntu.Components 1.3
2020
21MainView {21MainView {
22 id: mainView22 id: mainView
23 width: units.gu(50)23 width: units.gu(50)
24 height: units.gu(80)24 height: units.gu(80)
25 useDeprecatedToolbar: false
2625
27 Tabs {26 Tabs {
28 id: tabs27 id: tabs
@@ -94,6 +93,13 @@
94 sourceComponent: tabs.selectedTabIndex === 6 ? pageComponentNoFlick : null93 sourceComponent: tabs.selectedTabIndex === 6 ? pageComponentNoFlick : null
95 }94 }
96 }95 }
96 Tab {
97 // Test for bug #1570886, see initTestCase().
98 id: tabWithTitleFromPage
99 page: Page {
100 title: "Title from Page"
101 }
102 }
97 }103 }
98 Component {104 Component {
99 id: pageComponent105 id: pageComponent
@@ -118,6 +124,12 @@
118 name: "TabsAPINewHeader"124 name: "TabsAPINewHeader"
119 when: windowShown125 when: windowShown
120126
127 function initTestCase() {
128 // Test for bug #1570886.
129 compare(mainView.__propagated.header.title, tab1.title,
130 "Incorrect initial header title.");
131 }
132
121 function test_tabsDefaults() {133 function test_tabsDefaults() {
122 compare(tabs.selectedTabIndex, 0, "The default selectedTabIndex is 0 when Tabs has contents");134 compare(tabs.selectedTabIndex, 0, "The default selectedTabIndex is 0 when Tabs has contents");
123 compare(tabs.selectedTab, tab1, "The default selectedTab is the first tab");135 compare(tabs.selectedTab, tab1, "The default selectedTab is the first tab");

Subscribers

People subscribed via source and target branches