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

Proposed by Tim Peeters
Status: Merged
Approved by: Cris Dywan
Approved revision: 2130
Merged at revision: 2130
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/qt56fixes2sections
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 729 lines (+453/-61)
20 files modified
src/UbuntuToolkit/ubuntutoolkitmodule.cpp (+5/-0)
src/imports/Components/1.2/MainView.qml (+9/-9)
src/imports/Components/1.2/MainView12.qml (+9/-9)
src/imports/Components/1.2/OrientationHelper.qml (+6/-4)
src/imports/Components/1.3/MainView.qml (+9/-9)
src/imports/Components/1.3/OrientationHelper.qml (+6/-4)
tests/unit/mainview11/tst_mainview.cpp (+0/-17)
tests/unit/mainview13/AppName.qml (+23/-0)
tests/unit/mainview13/LocalStorage.qml (+32/-0)
tests/unit/mainview13/PageStack.qml (+38/-0)
tests/unit/mainview13/PageTitle.qml (+32/-0)
tests/unit/mainview13/Settings.qml (+2/-2)
tests/unit/mainview13/mainview13.pro (+4/-0)
tests/unit/mainview13/tst_mainview.cpp (+216/-0)
tests/unit/orientation/tst_orientation.cpp (+2/-2)
tests/unit/runtest.sh (+2/-2)
tests/unit/unit.pro (+2/-1)
tests/unit/visual/tst_pagehead_sections_bug1511839.13.qml (+0/-1)
tests/unit/visual/tst_sections.13.qml (+0/-1)
tests/unit/visual/tst_window_context_property_init_bug1621509.13.qml (+56/-0)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/qt56fixes2sections
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Approve
Cris Dywan Approve
Review via email: mp+306328@code.launchpad.net

Commit message

Initialize the 'window' context property with null and add MainView 1.3 unit tests.

Description of the change

Initialize the 'window' context property with null instead of leaving it 'undefined' until the window exists.

Also add tests for MainView 1.3 and add a FIXME to the broken OrientationHelper tests.

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: Needs Fixing (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: Needs Fixing (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: Needs Fixing (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: Needs Fixing (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: Needs Fixing (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: Needs Fixing (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: Needs Fixing (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: Needs Fixing (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: Needs Fixing (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: Needs Fixing (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: 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: 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)
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: 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)
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
Cris Dywan (kalikiana) wrote :

--- src/imports/Components/1.2/MainView12.qml 2015-06-10 14:17:25 +0000
+++ src/imports/Components/1.2/MainView12.qml 2016-09-25 13:04:30 +0000
@@ -93,17 +93,17 @@

             // 'window' is defined by QML between startup and showing on the screen.
             // There is no signal for when it becomes available and re-declaring it is not safe.
- property bool windowActive: typeof window != 'undefined'
+ property bool windowActive: window !== null

--- src/imports/Components/1.2/OrientationHelper.qml 2016-05-25 12:48:10 +0000
+++ src/imports/Components/1.2/OrientationHelper.qml 2016-09-25 13:04:30 +0000
@@ -129,20 +129,22 @@
           http://qt-project.org/doc/qt-5.1/qtqml/qml-qtqml2-qt.html
           http://qt-project.org/doc/qt-5.1/qtquick/qmlmodule-qtquick-window2-qtquick-window-2.html
          */
- property bool windowActive: typeof window != 'undefined'
+ property bool windowActive: typeof window != 'undefined' && window !== null

--- src/imports/Components/1.3/OrientationHelper.qml 2016-05-25 12:48:10 +0000
+++ src/imports/Components/1.3/OrientationHelper.qml 2016-09-25 13:04:30 +0000
@@ -129,20 +129,22 @@
           http://qt-project.org/doc/qt-5.1/qtqml/qml-qtqml2-qt.html
           http://qt-project.org/doc/qt-5.1/qtquick/qmlmodule-qtquick-window2-qtquick-window-2.html
          */
- property bool windowActive: typeof window != 'undefined'
+ property bool windowActive: typeof window != 'undefined' && window !== null

Why are those above definitions different? I'm guessing by accident?

Otherwise looking good, love the test clean-up.

review: Needs Information
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: Needs Fixing (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

Thanks for the update! Looking great now.

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)
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) :
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) :
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/UbuntuToolkit/ubuntutoolkitmodule.cpp'
2--- src/UbuntuToolkit/ubuntutoolkitmodule.cpp 2016-09-22 14:58:31 +0000
3+++ src/UbuntuToolkit/ubuntutoolkitmodule.cpp 2016-09-27 10:56:19 +0000
4@@ -190,6 +190,11 @@
5 new ContextPropertyChangeListener(context, QStringLiteral("FontUtils"));
6 QObject::connect(UCUnits::instance(), SIGNAL(gridUnitChanged()),
7 fontUtilsListener, SLOT(updateContextProperty()));
8+
9+ // Make the context property 'window' available even before there is a window,
10+ // so that in QML we do not have to check whether 'window' is defined, and no new
11+ // context property will be added after all components are completed (bug #1621509).
12+ context->setContextProperty("window", Q_NULLPTR);
13 }
14
15 void UbuntuToolkitModule::registerTypesToVersion(const char *uri, int major, int minor)
16
17=== modified file 'src/imports/Components/1.2/MainView.qml'
18--- src/imports/Components/1.2/MainView.qml 2015-12-17 09:13:29 +0000
19+++ src/imports/Components/1.2/MainView.qml 2016-09-27 10:56:19 +0000
20@@ -204,17 +204,17 @@
21
22 // 'window' is defined by QML between startup and showing on the screen.
23 // There is no signal for when it becomes available and re-declaring it is not safe.
24- property bool windowActive: typeof window != 'undefined'
25+ property bool windowActive: window !== null
26+ function updateWindowTitle() {
27+ if (window) {
28+ window.title = headerItem.title;
29+ }
30+ }
31 onWindowActiveChanged: {
32- window.title = headerItem.title
33+ updateWindowTitle();
34 }
35-
36- Connections {
37- target: headerItem
38- onTitleChanged: {
39- if (headerItem.windowActive)
40- window.title = headerItem.title
41- }
42+ onTitleChanged: {
43+ updateWindowTitle();
44 }
45
46 useDeprecatedToolbar: mainView.useDeprecatedToolbar
47
48=== modified file 'src/imports/Components/1.2/MainView12.qml'
49--- src/imports/Components/1.2/MainView12.qml 2015-06-10 14:17:25 +0000
50+++ src/imports/Components/1.2/MainView12.qml 2016-09-27 10:56:19 +0000
51@@ -93,17 +93,17 @@
52
53 // 'window' is defined by QML between startup and showing on the screen.
54 // There is no signal for when it becomes available and re-declaring it is not safe.
55- property bool windowActive: typeof window != 'undefined'
56+ property bool windowActive: window !== null
57+ function updateWindowTitle() {
58+ if (window) {
59+ window.title = headerItem.title;
60+ }
61+ }
62 onWindowActiveChanged: {
63- window.title = headerItem.title
64+ updateWindowTitle();
65 }
66-
67- Connections {
68- target: headerItem
69- onTitleChanged: {
70- if (headerItem.windowActive)
71- window.title = headerItem.title
72- }
73+ onTitleChanged: {
74+ updateWindowTitle();
75 }
76
77 // Use of the deprecated toolbar is no longer supported in MainView 1.2.
78
79=== modified file 'src/imports/Components/1.2/OrientationHelper.qml'
80--- src/imports/Components/1.2/OrientationHelper.qml 2016-05-25 12:48:10 +0000
81+++ src/imports/Components/1.2/OrientationHelper.qml 2016-09-27 10:56:19 +0000
82@@ -129,20 +129,22 @@
83 http://qt-project.org/doc/qt-5.1/qtqml/qml-qtqml2-qt.html
84 http://qt-project.org/doc/qt-5.1/qtquick/qmlmodule-qtquick-window2-qtquick-window-2.html
85 */
86- property bool windowActive: typeof window != 'undefined'
87+ property bool windowActive: window !== null
88
89 /*!
90 Report the current orientation of the application via QWindow::contentOrientation.
91 http://qt-project.org/doc/qt-5.0/qtgui/qwindow.html#contentOrientation-prop
92 */
93 function applyOrientation() {
94- if (windowActive && window)
95- window.contentOrientation = Screen.orientation
96+ if (window) {
97+ window.contentOrientation = Screen.orientation;
98+ }
99 }
100
101 onWindowActiveChanged: {
102- if (automaticOrientation)
103+ if (automaticOrientation) {
104 applyOrientation();
105+ }
106 }
107
108 Timer {
109
110=== modified file 'src/imports/Components/1.3/MainView.qml'
111--- src/imports/Components/1.3/MainView.qml 2016-07-27 15:40:52 +0000
112+++ src/imports/Components/1.3/MainView.qml 2016-09-27 10:56:19 +0000
113@@ -167,17 +167,17 @@
114
115 // 'window' is defined by QML between startup and showing on the screen.
116 // There is no signal for when it becomes available and re-declaring it is not safe.
117- property bool windowActive: typeof window != 'undefined'
118+ property bool windowActive: window !== null
119+ function updateWindowTitle() {
120+ if (window) {
121+ window.title = headerItem.title;
122+ }
123+ }
124 onWindowActiveChanged: {
125- window.title = headerItem.title
126+ updateWindowTitle();
127 }
128-
129- Connections {
130- target: headerItem
131- onTitleChanged: {
132- if (headerItem.windowActive)
133- window.title = headerItem.title
134- }
135+ onTitleChanged: {
136+ updateWindowTitle();
137 }
138 }
139
140
141=== modified file 'src/imports/Components/1.3/OrientationHelper.qml'
142--- src/imports/Components/1.3/OrientationHelper.qml 2016-05-25 12:48:10 +0000
143+++ src/imports/Components/1.3/OrientationHelper.qml 2016-09-27 10:56:19 +0000
144@@ -129,20 +129,22 @@
145 http://qt-project.org/doc/qt-5.1/qtqml/qml-qtqml2-qt.html
146 http://qt-project.org/doc/qt-5.1/qtquick/qmlmodule-qtquick-window2-qtquick-window-2.html
147 */
148- property bool windowActive: typeof window != 'undefined'
149+ property bool windowActive: window !== null
150
151 /*!
152 Report the current orientation of the application via QWindow::contentOrientation.
153 http://qt-project.org/doc/qt-5.0/qtgui/qwindow.html#contentOrientation-prop
154 */
155 function applyOrientation() {
156- if (windowActive && window)
157- window.contentOrientation = Screen.orientation
158+ if (window) {
159+ window.contentOrientation = Screen.orientation;
160+ }
161 }
162
163 onWindowActiveChanged: {
164- if (automaticOrientation)
165+ if (automaticOrientation) {
166 applyOrientation();
167+ }
168 }
169
170 Timer {
171
172=== renamed directory 'tests/unit/mainview' => 'tests/unit/mainview11'
173=== renamed file 'tests/unit/mainview/mainview.pro' => 'tests/unit/mainview11/mainview11.pro'
174=== modified file 'tests/unit/mainview11/tst_mainview.cpp'
175--- tests/unit/mainview/tst_mainview.cpp 2016-09-09 17:49:07 +0000
176+++ tests/unit/mainview11/tst_mainview.cpp 2016-09-27 10:56:19 +0000
177@@ -156,23 +156,6 @@
178 return filename;
179 }
180
181- void testLabsSettings() {
182- QString applicationName("red.riding.hood");
183- // Delete file if it exists to avoid false positives
184- QString filename(getConfFile(applicationName));
185- QFile::remove(filename);
186-
187- QQuickItem *root = loadTest("Settings.qml");
188- QVERIFY(root);
189- QQuickItem *mainView = root;
190- QCOMPARE(applicationName, mainView->property("applicationName").toString());
191- QCOMPARE(QString(applicationName), QCoreApplication::organizationDomain());
192- QQuickItem *textField(testItem(mainView, "textfield"));
193- textField->setProperty("text", "Blue");
194- delete root;
195- QVERIFY(QFile::exists(filename));
196- }
197-
198 void testQSettings() {
199 QString applicationName("i.prefer.pi");
200 // Delete file if it exists to avoid false positives
201
202=== added directory 'tests/unit/mainview13'
203=== added file 'tests/unit/mainview13/AppName.qml'
204--- tests/unit/mainview13/AppName.qml 1970-01-01 00:00:00 +0000
205+++ tests/unit/mainview13/AppName.qml 2016-09-27 10:56:19 +0000
206@@ -0,0 +1,23 @@
207+/*
208+ * Copyright 2016 Canonical Ltd.
209+ *
210+ * This program is free software; you can redistribute it and/or modify
211+ * it under the terms of the GNU Lesser General Public License as published by
212+ * the Free Software Foundation; version 3.
213+ *
214+ * This program is distributed in the hope that it will be useful,
215+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
216+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
217+ * GNU Lesser General Public License for more details.
218+ *
219+ * You should have received a copy of the GNU Lesser General Public License
220+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
221+ */
222+
223+import QtQuick 2.4
224+import Ubuntu.Components 1.3
225+
226+MainView {
227+ objectName: "appName"
228+ applicationName: "org.gnu.wildebeest"
229+}
230
231=== added file 'tests/unit/mainview13/LocalStorage.qml'
232--- tests/unit/mainview13/LocalStorage.qml 1970-01-01 00:00:00 +0000
233+++ tests/unit/mainview13/LocalStorage.qml 2016-09-27 10:56:19 +0000
234@@ -0,0 +1,32 @@
235+/*
236+ * Copyright 2016 Canonical Ltd.
237+ *
238+ * This program is free software; you can redistribute it and/or modify
239+ * it under the terms of the GNU Lesser General Public License as published by
240+ * the Free Software Foundation; version 3.
241+ *
242+ * This program is distributed in the hope that it will be useful,
243+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
244+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
245+ * GNU Lesser General Public License for more details.
246+ *
247+ * You should have received a copy of the GNU Lesser General Public License
248+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
249+ */
250+
251+import QtQuick 2.4
252+import Ubuntu.Components 1.3
253+import QtQuick.LocalStorage 2.0
254+
255+MainView {
256+ objectName: "localStorage"
257+ applicationName: "tv.island.pacific"
258+
259+ Component.onCompleted: {
260+ var db = LocalStorage.openDatabaseSync("pacific.island.tv", "1.0", "lorem ipsum", 1000)
261+ db.transaction(function(tx){
262+ tx.executeSql('CREATE TABLE IF NOT EXISTS Island(name TEXT)')
263+ tx.executeSql('INSERT INTO Island VALUES(?)', ['Tuvalu'])
264+ })
265+ }
266+}
267
268=== added file 'tests/unit/mainview13/PageStack.qml'
269--- tests/unit/mainview13/PageStack.qml 1970-01-01 00:00:00 +0000
270+++ tests/unit/mainview13/PageStack.qml 2016-09-27 10:56:19 +0000
271@@ -0,0 +1,38 @@
272+/*
273+ * Copyright 2016 Canonical Ltd.
274+ *
275+ * This program is free software; you can redistribute it and/or modify
276+ * it under the terms of the GNU Lesser General Public License as published by
277+ * the Free Software Foundation; version 3.
278+ *
279+ * This program is distributed in the hope that it will be useful,
280+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
281+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
282+ * GNU Lesser General Public License for more details.
283+ *
284+ * You should have received a copy of the GNU Lesser General Public License
285+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
286+ */
287+
288+import QtQuick 2.4
289+import Ubuntu.Components 1.3
290+
291+MainView {
292+ objectName: "pageStack"
293+ applicationName: "once.upon.a.time"
294+
295+ PageStack {
296+ id: stack
297+ objectName: "stack"
298+ Component.onCompleted: stack.push(pageOnStack)
299+
300+ Page {
301+ id: pageOnStack
302+ objectName: "page"
303+ title: 'Far far away' // sets the window title.
304+ header: PageHeader {
305+ title: pageOnStack.title
306+ }
307+ }
308+ }
309+}
310
311=== added file 'tests/unit/mainview13/PageTitle.qml'
312--- tests/unit/mainview13/PageTitle.qml 1970-01-01 00:00:00 +0000
313+++ tests/unit/mainview13/PageTitle.qml 2016-09-27 10:56:19 +0000
314@@ -0,0 +1,32 @@
315+/*
316+ * Copyright 2016 Canonical Ltd.
317+ *
318+ * This program is free software; you can redistribute it and/or modify
319+ * it under the terms of the GNU Lesser General Public License as published by
320+ * the Free Software Foundation; version 3.
321+ *
322+ * This program is distributed in the hope that it will be useful,
323+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
324+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
325+ * GNU Lesser General Public License for more details.
326+ *
327+ * You should have received a copy of the GNU Lesser General Public License
328+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
329+ */
330+
331+import QtQuick 2.4
332+import Ubuntu.Components 1.3
333+
334+MainView {
335+ objectName: "pageTitle"
336+ applicationName: "once.upon.a.time"
337+
338+ Page {
339+ id: page
340+ objectName: "page"
341+ title: 'Once upon a time' // sets the window title
342+ header: PageHeader {
343+ title: page.title
344+ }
345+ }
346+}
347
348=== renamed file 'tests/unit/mainview/Settings.qml' => 'tests/unit/mainview13/Settings.qml'
349--- tests/unit/mainview/Settings.qml 2016-01-20 16:42:29 +0000
350+++ tests/unit/mainview13/Settings.qml 2016-09-27 10:56:19 +0000
351@@ -1,5 +1,5 @@
352 /*
353- * Copyright 2014 Canonical Ltd.
354+ * Copyright 2016 Canonical Ltd.
355 *
356 * This program is free software; you can redistribute it and/or modify
357 * it under the terms of the GNU Lesser General Public License as published by
358@@ -14,7 +14,7 @@
359 * along with this program. If not, see <http://www.gnu.org/licenses/>.
360 */
361
362-import QtQuick 2.0
363+import QtQuick 2.4
364 import Ubuntu.Components 1.3
365 import Qt.labs.settings 1.0
366
367
368=== added file 'tests/unit/mainview13/mainview13.pro'
369--- tests/unit/mainview13/mainview13.pro 1970-01-01 00:00:00 +0000
370+++ tests/unit/mainview13/mainview13.pro 2016-09-27 10:56:19 +0000
371@@ -0,0 +1,4 @@
372+include(../test-include.pri)
373+
374+QT += gui
375+SOURCES += tst_mainview.cpp
376
377=== added file 'tests/unit/mainview13/tst_mainview.cpp'
378--- tests/unit/mainview13/tst_mainview.cpp 1970-01-01 00:00:00 +0000
379+++ tests/unit/mainview13/tst_mainview.cpp 2016-09-27 10:56:19 +0000
380@@ -0,0 +1,216 @@
381+/*
382+ * Copyright 2012-2013 Canonical Ltd.
383+ *
384+ * This program is free software; you can redistribute it and/or modify
385+ * it under the terms of the GNU Lesser General Public License as published by
386+ * the Free Software Foundation; version 3.
387+ *
388+ * This program is distributed in the hope that it will be useful,
389+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
390+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
391+ * GNU Lesser General Public License for more details.
392+ *
393+ * You should have received a copy of the GNU Lesser General Public License
394+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
395+ *
396+ * Author: Christian Dywan <christian.dywan@canonical.com>
397+ */
398+
399+#include <QtCore/QCoreApplication>
400+#include <QtCore/QCryptographicHash>
401+#include <QtCore/QDebug>
402+#include <QtCore/QDir>
403+#include <QtCore/QFileInfo>
404+#include <QtCore/QProcessEnvironment>
405+#include <QtCore/QSettings>
406+#include <QtCore/QStandardPaths>
407+#include <QtCore/QString>
408+#include <QtCore/QTextCodec>
409+#include <QtCore/QThread>
410+#include <QtQml/QQmlEngine>
411+#include <QtQuick/QQuickItem>
412+#include <QtQuick/QQuickView>
413+#include <QtTest/QSignalSpy>
414+#include <QtTest/QTest>
415+#include <UbuntuToolkit/ubuntutoolkitmodule.h>
416+#include <UbuntuToolkit/private/ucapplication_p.h>
417+#include <UbuntuToolkit/private/ucunits_p.h>
418+
419+#include "uctestcase.h"
420+
421+UT_USE_NAMESPACE
422+
423+class tst_MainView : public QObject
424+{
425+ Q_OBJECT
426+
427+private:
428+ QQuickView *view;
429+
430+public:
431+ tst_MainView() :
432+ view(0)
433+ {
434+ }
435+
436+ QQuickItem *loadTest(const QString &document)
437+ {
438+ // load the document
439+ view->setSource(QUrl::fromLocalFile(document));
440+ QTest::waitForEvents();
441+
442+ return view->rootObject();
443+ }
444+
445+ QQuickItem *testItem(QQuickItem *that, const QString &identifier)
446+ {
447+ if (that->property(identifier.toLocal8Bit()).isValid())
448+ return that->property(identifier.toLocal8Bit()).value<QQuickItem*>();
449+
450+ QList<QQuickItem*> children = that->findChildren<QQuickItem*>(identifier);
451+ return (children.count() > 0) ? children[0] : 0;
452+ }
453+
454+private Q_SLOTS:
455+
456+ void initTestCase()
457+ {
458+ QString modules(UBUNTU_QML_IMPORT_PATH);
459+ QVERIFY(QDir(modules).exists());
460+
461+ view = new QQuickView;
462+ QQmlEngine *quickEngine = view->engine();
463+ UbuntuToolkitModule::initializeContextProperties(quickEngine);
464+
465+ view->setGeometry(0,0, UCUnits::instance()->gu(40), UCUnits::instance()->gu(30));
466+ //add modules folder so we have access to the plugin from QML
467+ QStringList imports = quickEngine->importPathList();
468+ imports.prepend(QDir(modules).absolutePath());
469+ quickEngine->setImportPathList(imports);
470+ }
471+
472+ void cleanupTestCase()
473+ {
474+ delete view;
475+ }
476+
477+ void testCase_AppName()
478+ {
479+ QQuickItem *root = loadTest("AppName.qml");
480+ QVERIFY(root);
481+ QQuickItem *mainView = root;
482+ QString applicationName(mainView->property("applicationName").toString());
483+ QCOMPARE(applicationName, QString("org.gnu.wildebeest"));
484+ QCOMPARE(applicationName, QCoreApplication::applicationName());
485+ QCOMPARE(QString(""), QCoreApplication::organizationName());
486+ }
487+
488+ void testSetApplicationName() {
489+ QString appName("com.ubuntu.foo");
490+ UCApplication::instance()->setApplicationName(appName);
491+ QCOMPARE(UCApplication::instance()->applicationName(), appName);
492+ QCOMPARE(QCoreApplication::applicationName(), appName);
493+ QCOMPARE(QString(""), QCoreApplication::organizationName());
494+ }
495+
496+ void testExpectedDataFolder() {
497+ QString appName("net.weight.gain");
498+ UCApplication::instance()->setApplicationName(appName);
499+ QString dataFolder(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
500+ QString xdgDataHome(QProcessEnvironment::systemEnvironment().value("XDG_DATA_HOME",
501+ QProcessEnvironment::systemEnvironment().value("HOME") + "/.local/share"));
502+ QString expectedDataFolder(xdgDataHome + "/" + appName);
503+ QCOMPARE(dataFolder, expectedDataFolder);
504+ }
505+
506+ void testExpectedCacheFolder() {
507+ QString appName("cat.long.very");
508+ UCApplication::instance()->setApplicationName(appName);
509+ QString cacheFolder(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
510+ QString xdgCacheHome(QProcessEnvironment::systemEnvironment().value("XDG_CACHE_HOME",
511+ QProcessEnvironment::systemEnvironment().value("HOME") + "/.cache"));
512+ QString expectedCacheFolder(xdgCacheHome + "/" + appName);
513+ QCOMPARE(cacheFolder, expectedCacheFolder);
514+ }
515+
516+ void testLocalStorage() {
517+ QQuickItem *root = loadTest("LocalStorage.qml");
518+ QVERIFY(root);
519+ QQuickItem *mainView = root;
520+ QString applicationName(mainView->property("applicationName").toString());
521+ QCOMPARE(applicationName, QString("tv.island.pacific"));
522+ QCOMPARE(applicationName, QCoreApplication::applicationName());
523+ QCOMPARE(QString(""), QCoreApplication::organizationName());
524+ QString dataFolder(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
525+ QString databaseFolder(dataFolder + "/Databases");
526+ QVERIFY(QFile::exists(databaseFolder));
527+ QString hash(QCryptographicHash::hash("pacific.island.tv", QCryptographicHash::Md5).toHex());
528+ QString database(databaseFolder + "/" + hash + ".sqlite");
529+ QVERIFY(QFile::exists(database));
530+ }
531+
532+ QString getConfFile(QString applicationName) {
533+ QString configFolder(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation));
534+ QString subFolder(configFolder + "/" + applicationName);
535+ QString filename(subFolder + "/" + applicationName + ".conf");
536+ return filename;
537+ }
538+
539+ void testLabsSettings() {
540+ QString applicationName("red.riding.hood");
541+ // Delete file if it exists to avoid false positives
542+ QString filename(getConfFile(applicationName));
543+ QFile::remove(filename);
544+
545+ QQuickItem *root = loadTest("Settings.qml");
546+ QVERIFY(root);
547+ QQuickItem *mainView = root;
548+ QCOMPARE(applicationName, mainView->property("applicationName").toString());
549+ QCOMPARE(QString(applicationName), QCoreApplication::organizationDomain());
550+ QQuickItem *textField(testItem(mainView, "textfield"));
551+ textField->setProperty("text", "Blue");
552+ delete root;
553+ QVERIFY(QFile::exists(filename));
554+ }
555+
556+ void testQSettings() {
557+ QString applicationName("i.prefer.pi");
558+ // Delete file if it exists to avoid false positives
559+ QString filename(getConfFile(applicationName));
560+ QFile::remove(filename);
561+
562+ UCApplication::instance()->setApplicationName(applicationName);
563+ // QSettings with defaults
564+ QSettings mySettings;
565+ mySettings.setValue("spam", "eggs");
566+ // Force writing to disk
567+ mySettings.sync();
568+ QVERIFY(QFile::exists(filename));
569+ }
570+
571+ void testNoWarnings_bug186065() {
572+ // An empty MainView would suffice
573+ QScopedPointer<UbuntuTestCase>testCase (new UbuntuTestCase("AppName.qml"));
574+
575+ // No warnings from QML
576+ QCOMPARE(testCase->warnings(), 0);
577+ }
578+
579+ void testWindowTitleFromPage() {
580+ QScopedPointer<UbuntuTestCase> testCase(new UbuntuTestCase("PageTitle.qml"));
581+ QQuickItem *page = testCase->findItem<QQuickItem*>("page");
582+ QCOMPARE(QString("Once upon a time"), page->property("title").toString());
583+ QCOMPARE(testCase->title(), page->property("title").toString());
584+ }
585+
586+ void testWindowTitleFromStack() {
587+ QScopedPointer<UbuntuTestCase> testCase(new UbuntuTestCase("PageStack.qml"));
588+ QQuickItem *page = testCase->findItem<QQuickItem*>("page");
589+ QCOMPARE(QString("Far far away"), page->property("title").toString());
590+ QCOMPARE(testCase->title(), page->property("title").toString());
591+ }
592+};
593+
594+QTEST_MAIN(tst_MainView)
595+
596+#include "tst_mainview.moc"
597
598=== modified file 'tests/unit/orientation/tst_orientation.cpp'
599--- tests/unit/orientation/tst_orientation.cpp 2016-09-09 17:49:07 +0000
600+++ tests/unit/orientation/tst_orientation.cpp 2016-09-27 10:56:19 +0000
601@@ -52,12 +52,12 @@
602 QScopedPointer<UbuntuTestCase> testCase(new UbuntuTestCase("ManualAngle.qml"));
603 QQuickItem *helper = testCase->findItem<QQuickItem*>("helper");
604 // No warning about "window" being undefined must appear
605- QSKIP("TypeError: Cannot set property 'contentOrientation' of null");
606+ QSKIP("FIXME: We have no valid effectiveness tests for OrientationHelper. See bug #1626063.");
607 QCOMPARE(testCase->warnings(), 0);
608 QCOMPARE(helper->property("orientationAngle").toInt(), 90);
609 // Verify expected values
610 QQuickItem *checkpoint = testCase->findItem<QQuickItem*>("checkpoint");
611- // window.contentOrientation
612+ // window.contentOrientation
613 QCOMPARE(checkpoint->property("contentOrientation").toInt(), helper->property("orientationAngle").toInt());
614 }
615 };
616
617=== modified file 'tests/unit/runtest.sh'
618--- tests/unit/runtest.sh 2016-06-07 12:53:59 +0000
619+++ tests/unit/runtest.sh 2016-09-27 10:56:19 +0000
620@@ -45,8 +45,8 @@
621 echo 'Examples:'
622 echo " $0 $(relpath ${BUILD_DIR}/tests/unit/components/components) $(relpath ${SRC_DIR}/tests/unit/components/tst_label13.qml) minimal"
623 echo ''
624- echo " cd $(relpath ${BUILD_DIR}/tests/unit/mainview)"
625- echo " ../$(basename $0) mainview minimal"
626+ echo " cd $(relpath ${BUILD_DIR}/tests/unit/mainview13)"
627+ echo " ../$(basename $0) mainview13 minimal"
628 echo " cd ../../.."
629 echo ''
630 echo " cd $(relpath ${BUILD_DIR}/tests/unit/visual)"
631
632=== modified file 'tests/unit/unit.pro'
633--- tests/unit/unit.pro 2016-09-23 11:14:46 +0000
634+++ tests/unit/unit.pro 2016-09-27 10:56:19 +0000
635@@ -39,7 +39,8 @@
636 scaling_image_provider \
637 qquick_image_extension \
638 performance \
639- mainview \
640+ mainview11 \
641+ mainview13 \
642 i18n \
643 arguments \
644 argument \
645
646=== renamed file 'tests/unit/visual/FIXME-QT56_pagehead_sections_bug1511839.13.qml' => 'tests/unit/visual/tst_pagehead_sections_bug1511839.13.qml'
647--- tests/unit/visual/FIXME-QT56_pagehead_sections_bug1511839.13.qml 2016-09-16 11:13:32 +0000
648+++ tests/unit/visual/tst_pagehead_sections_bug1511839.13.qml 2016-09-27 10:56:19 +0000
649@@ -40,7 +40,6 @@
650 stack.push(pageComponent)
651 }
652
653- // FIXME: Tests failing with Qt 5.6. See bug #1624337.
654 UbuntuTestCase {
655 id: testCase
656 name: "Page.head.sections"
657
658=== renamed file 'tests/unit/visual/FIXME-QT56_sections.13.qml' => 'tests/unit/visual/tst_sections.13.qml'
659--- tests/unit/visual/FIXME-QT56_sections.13.qml 2016-09-16 11:13:32 +0000
660+++ tests/unit/visual/tst_sections.13.qml 2016-09-27 10:56:19 +0000
661@@ -142,7 +142,6 @@
662 name: "SectionsApi"
663 when: windowShown
664
665- // FIXME: Fails with Qt 5.6. See bug #1610231.
666 function initTestCase() {
667 // The initially selected actions must be triggered.
668 compare(label.text, "First action triggered.",
669
670=== added file 'tests/unit/visual/tst_window_context_property_init_bug1621509.13.qml'
671--- tests/unit/visual/tst_window_context_property_init_bug1621509.13.qml 1970-01-01 00:00:00 +0000
672+++ tests/unit/visual/tst_window_context_property_init_bug1621509.13.qml 2016-09-27 10:56:19 +0000
673@@ -0,0 +1,56 @@
674+/*
675+ * Copyright 2016 Canonical Ltd.
676+ *
677+ * This program is free software; you can redistribute it and/or modify
678+ * it under the terms of the GNU Lesser General Public License as published by
679+ * the Free Software Foundation; version 3.
680+ *
681+ * This program is distributed in the hope that it will be useful,
682+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
683+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
684+ * GNU Lesser General Public License for more details.
685+ *
686+ * You should have received a copy of the GNU Lesser General Public License
687+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
688+ */
689+
690+import QtQuick 2.4
691+import QtTest 1.0
692+
693+// Ubuntu.Components is not explicitly used below, but its import causes bug #1621509.
694+import Ubuntu.Components 1.3
695+
696+TestCase {
697+ id: testCase
698+ name: "ContextPropertyInit"
699+ width: 100
700+ height: 100
701+
702+ // Bug #1621509 only occurs when we wait for the window to be visible.
703+ // Forces the components to be completed before the test functions are executed.
704+ when: windowShown
705+
706+ Item {
707+ id: testItem
708+
709+ // This property changes its value when a new context property is added.
710+ property var myObject: objectOne
711+ property int count: 0
712+ onMyObjectChanged: {
713+ count++;
714+ }
715+ Component.onCompleted: {
716+ count = 0;
717+ print("Component completed."); // must print something to reproduce the bug.
718+ }
719+ QtObject {
720+ objectName: "one"
721+ id: objectOne
722+ }
723+ }
724+
725+ function test_no_property_change_after_completed_bug1621509_bug1610231() {
726+ compare(testItem.count, 0,
727+ "The property was changed after the component was completed.");
728+ }
729+}

Subscribers

People subscribed via source and target branches