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
1=== modified file 'src/Ubuntu/Components/plugin/ucmainviewbase.cpp'
2--- src/Ubuntu/Components/plugin/ucmainviewbase.cpp 2016-04-04 04:47:11 +0000
3+++ src/Ubuntu/Components/plugin/ucmainviewbase.cpp 2016-05-09 09:15:00 +0000
4@@ -53,7 +53,9 @@
5
6 m_actionContext->setObjectName(QStringLiteral("RootContext"));
7 m_actionContext->setActive(true);
8- q->setActive(true);
9+ // setActive(true) is called in componentComplete to wait
10+ // until the MainView (and all its children) are complete
11+ // to prevent bug #1570886.
12
13 QObject::connect(m_actionManager,&UCActionManager::quit, [](){
14 // FIXME Wire this up to the application lifecycle management API instead of quit().
15@@ -307,6 +309,9 @@
16 {
17 Q_D(UCMainViewBase);
18 UCPageTreeNode::componentComplete();
19+ // Do not call setActive() in d->init() but postpone until the
20+ // component is complete to avoid bug #1570886.
21+ this->setActive(true);
22 d->doAutoTheme();
23
24 if (d->m_actionContext)
25
26=== added file 'tests/unit_x11/tst_components/tst_tabs11.qml'
27--- tests/unit_x11/tst_components/tst_tabs11.qml 1970-01-01 00:00:00 +0000
28+++ tests/unit_x11/tst_components/tst_tabs11.qml 2016-05-09 09:15:00 +0000
29@@ -0,0 +1,198 @@
30+/*
31+ * Copyright 2012-2016 Canonical Ltd.
32+ *
33+ * This program is free software; you can redistribute it and/or modify
34+ * it under the terms of the GNU Lesser General Public License as published by
35+ * the Free Software Foundation; version 3.
36+ *
37+ * This program is distributed in the hope that it will be useful,
38+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
39+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40+ * GNU Lesser General Public License for more details.
41+ *
42+ * You should have received a copy of the GNU Lesser General Public License
43+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
44+ */
45+
46+import QtQuick 2.2
47+import Ubuntu.Test 1.0
48+import Ubuntu.Components 1.1
49+
50+MainView {
51+ id: mainView
52+ width: units.gu(50)
53+ height: units.gu(80)
54+ useDeprecatedToolbar: false
55+
56+ Tabs {
57+ id: tabs
58+ Tab {
59+ id: tab1
60+ title: "tab 1"
61+ page: Page {
62+ id: page1
63+ Button {
64+ id: button
65+ anchors.centerIn: parent
66+ text: "click"
67+ }
68+ }
69+ }
70+ Tab {
71+ id: tab2
72+ title: "tab 2"
73+ page: Page {
74+ id: page2
75+ }
76+ }
77+ Tab {
78+ id: tab3
79+ title: "tab 3"
80+ page: Page {
81+ id: page3
82+ }
83+ }
84+ Tab {
85+ id: tabFlick1
86+ title: "flick"
87+ page: Page {
88+ Flickable {
89+ id: flickable1
90+ anchors.fill: parent
91+ }
92+ }
93+ }
94+ Tab {
95+ id: tabFlick2
96+ title: "flick 2"
97+ page: Page {
98+ Flickable {
99+ id: flickable2
100+ anchors.fill: parent
101+ }
102+ }
103+ }
104+ Tab {
105+ id: tabFlickLoader
106+ title: "load"
107+ page: Loader {
108+ id: loader
109+ sourceComponent: tabs.selectedTabIndex != 5 ? null : pageComponent
110+ }
111+ }
112+ Tab {
113+ id: tabNoFlickLoader
114+ title: "loadNoFlick"
115+ page: Loader {
116+ id: loaderNoFlick
117+ anchors {
118+ left: parent.left
119+ right: parent.right
120+ bottom: parent.bottom
121+ }
122+ // height compes from the loaded Page
123+ sourceComponent: tabs.selectedTabIndex === 6 ? pageComponentNoFlick : null
124+ }
125+ }
126+ Tab {
127+ // Test for bug #1570886, see initTestCase().
128+ id: tabWithTitleFromPage
129+ page: Page {
130+ title: "Title from Page"
131+ }
132+ }
133+ }
134+ Component {
135+ id: pageComponent
136+ Page {
137+ title: "Loaded page"
138+ property Flickable flick: loadedFlickable
139+ Flickable {
140+ id: loadedFlickable
141+ anchors.fill: parent
142+ contentHeight: 1000
143+ }
144+ }
145+ }
146+ Component {
147+ id: pageComponentNoFlick
148+ Page {
149+ title: "Loaded page without flickable"
150+ }
151+ }
152+
153+ UbuntuTestCase {
154+ name: "TabsAPINewHeader"
155+ when: windowShown
156+
157+ function initTestCase() {
158+ // Test for bug #1570886.
159+ compare(mainView.__propagated.header.title, tab1.title,
160+ "Incorrect initial header title.");
161+ }
162+
163+ function test_tabsDefaults() {
164+ compare(tabs.selectedTabIndex, 0, "The default selectedTabIndex is 0 when Tabs has contents");
165+ compare(tabs.selectedTab, tab1, "The default selectedTab is the first tab");
166+ compare(tabs.currentPage, page1, "The default currentPage is the page of the first tab");
167+ }
168+
169+ function test_tabsSetSelectedTab() {
170+ var tabArray = [tab1, tab2, tab3];
171+ var pageArray = [page1, page2, page3];
172+ for (var i=0; i < 3; i++) {
173+ tabs.selectedTabIndex = i;
174+ compare(tabs.selectedTabIndex, i, "Can set selectedTabIndex");
175+ compare(tabs.selectedTab, tabArray[i], "Can update selectedTab by setting selectedTabIndex");
176+ compare(tabs.currentPage, pageArray[i], "Can update currentPage by setting selectedTabIndex");
177+ for (var j=0; j < 3; j++) {
178+ compare(pageArray[j].active, j===i, "Only the page of the selected tab is active");
179+ }
180+ }
181+ }
182+
183+ function test_flickable() {
184+ // ensure that the flickable of the header is set to the flickable of the selected tab.
185+ tabs.selectedTabIndex = 3;
186+ compare(mainView.__propagated.header.flickable, flickable1, "Header flickable correctly initialized");
187+ tabs.selectedTabIndex = 4;
188+ compare(mainView.__propagated.header.flickable, flickable2, "Header flickable correctly updated");
189+ tabs.selectedTabIndex = 0;
190+ }
191+
192+ function test_pageLoader() {
193+ tabs.selectedTabIndex = 0;
194+ compare(loader.item, null, "Page not loaded when tab is not selected");
195+ tabs.selectedTabIndex = 5;
196+ compare(tabs.currentPage, loader, "Selected loader for current page");
197+ compare(loader.item.title, "Loaded page", "Loaded item is a page");
198+ tabs.selectedTabIndex = 0;
199+ compare(loader.item, null, "Loaded page was properly unloaded");
200+ }
201+
202+ function test_bug1088740() {
203+ tabs.selectedTabIndex = 5;
204+ compare(mainView.__propagated.header.flickable, loader.item.flick, "Header flickable correctly updated with Loader");
205+ compare(loader.item.flick.contentHeight, 1000, "Header flickable is correct flickable");
206+ tabs.selectedTabIndex = 0;
207+ }
208+
209+ function test_pageHeightLoaderNoFlick_bug1259917() {
210+ tabs.selectedTabIndex = 6;
211+ compare(tabs.selectedTab, tabNoFlickLoader, "Tab 6 was selected.");
212+ compare(mainView.__propagated.header.flickable, null, "Loaded page without flickable.");
213+ compare(loaderNoFlick.item.height, mainView.height - mainView.__propagated.header.height,
214+ "Correct height for loaded Page without flickable.");
215+ }
216+
217+ function test_index() {
218+ compare(tab1.index, 0, "tab1 is at 0");
219+ compare(tab2.index, 1, "tab2 is at 1");
220+ compare(tab3.index, 2, "tab3 is at 2");
221+ compare(tabFlick1.index, 3, "tabFlick1 is at 3");
222+ compare(tabFlick2.index, 4, "tabFlick2 is at 4");
223+ compare(tabFlickLoader.index, 5, "tabFlickLoader is at 5");
224+ compare(tabNoFlickLoader.index, 6, "tabNoFlickLoader is at 6");
225+ }
226+ }
227+}
228
229=== renamed file 'tests/unit_x11/tst_components/tst_tabs.qml' => 'tests/unit_x11/tst_components/tst_tabs13.qml'
230--- tests/unit_x11/tst_components/tst_tabs.qml 2015-09-03 11:44:38 +0000
231+++ tests/unit_x11/tst_components/tst_tabs13.qml 2016-05-09 09:15:00 +0000
232@@ -1,5 +1,5 @@
233 /*
234- * Copyright 2012-2014 Canonical Ltd.
235+ * Copyright 2016 Canonical Ltd.
236 *
237 * This program is free software; you can redistribute it and/or modify
238 * it under the terms of the GNU Lesser General Public License as published by
239@@ -14,15 +14,14 @@
240 * along with this program. If not, see <http://www.gnu.org/licenses/>.
241 */
242
243-import QtQuick 2.2
244+import QtQuick 2.4
245 import Ubuntu.Test 1.0
246-import Ubuntu.Components 1.1
247+import Ubuntu.Components 1.3
248
249 MainView {
250 id: mainView
251 width: units.gu(50)
252 height: units.gu(80)
253- useDeprecatedToolbar: false
254
255 Tabs {
256 id: tabs
257@@ -94,6 +93,13 @@
258 sourceComponent: tabs.selectedTabIndex === 6 ? pageComponentNoFlick : null
259 }
260 }
261+ Tab {
262+ // Test for bug #1570886, see initTestCase().
263+ id: tabWithTitleFromPage
264+ page: Page {
265+ title: "Title from Page"
266+ }
267+ }
268 }
269 Component {
270 id: pageComponent
271@@ -118,6 +124,12 @@
272 name: "TabsAPINewHeader"
273 when: windowShown
274
275+ function initTestCase() {
276+ // Test for bug #1570886.
277+ compare(mainView.__propagated.header.title, tab1.title,
278+ "Incorrect initial header title.");
279+ }
280+
281 function test_tabsDefaults() {
282 compare(tabs.selectedTabIndex, 0, "The default selectedTabIndex is 0 when Tabs has contents");
283 compare(tabs.selectedTab, tab1, "The default selectedTab is the first tab");

Subscribers

People subscribed via source and target branches