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
=== modified file 'src/UbuntuToolkit/ubuntutoolkitmodule.cpp'
--- src/UbuntuToolkit/ubuntutoolkitmodule.cpp 2016-09-22 14:58:31 +0000
+++ src/UbuntuToolkit/ubuntutoolkitmodule.cpp 2016-09-27 10:56:19 +0000
@@ -190,6 +190,11 @@
190 new ContextPropertyChangeListener(context, QStringLiteral("FontUtils"));190 new ContextPropertyChangeListener(context, QStringLiteral("FontUtils"));
191 QObject::connect(UCUnits::instance(), SIGNAL(gridUnitChanged()),191 QObject::connect(UCUnits::instance(), SIGNAL(gridUnitChanged()),
192 fontUtilsListener, SLOT(updateContextProperty()));192 fontUtilsListener, SLOT(updateContextProperty()));
193
194 // Make the context property 'window' available even before there is a window,
195 // so that in QML we do not have to check whether 'window' is defined, and no new
196 // context property will be added after all components are completed (bug #1621509).
197 context->setContextProperty("window", Q_NULLPTR);
193}198}
194199
195void UbuntuToolkitModule::registerTypesToVersion(const char *uri, int major, int minor)200void UbuntuToolkitModule::registerTypesToVersion(const char *uri, int major, int minor)
196201
=== modified file 'src/imports/Components/1.2/MainView.qml'
--- src/imports/Components/1.2/MainView.qml 2015-12-17 09:13:29 +0000
+++ src/imports/Components/1.2/MainView.qml 2016-09-27 10:56:19 +0000
@@ -204,17 +204,17 @@
204204
205 // 'window' is defined by QML between startup and showing on the screen.205 // 'window' is defined by QML between startup and showing on the screen.
206 // There is no signal for when it becomes available and re-declaring it is not safe.206 // There is no signal for when it becomes available and re-declaring it is not safe.
207 property bool windowActive: typeof window != 'undefined'207 property bool windowActive: window !== null
208 function updateWindowTitle() {
209 if (window) {
210 window.title = headerItem.title;
211 }
212 }
208 onWindowActiveChanged: {213 onWindowActiveChanged: {
209 window.title = headerItem.title214 updateWindowTitle();
210 }215 }
211216 onTitleChanged: {
212 Connections {217 updateWindowTitle();
213 target: headerItem
214 onTitleChanged: {
215 if (headerItem.windowActive)
216 window.title = headerItem.title
217 }
218 }218 }
219219
220 useDeprecatedToolbar: mainView.useDeprecatedToolbar220 useDeprecatedToolbar: mainView.useDeprecatedToolbar
221221
=== modified file 'src/imports/Components/1.2/MainView12.qml'
--- src/imports/Components/1.2/MainView12.qml 2015-06-10 14:17:25 +0000
+++ src/imports/Components/1.2/MainView12.qml 2016-09-27 10:56:19 +0000
@@ -93,17 +93,17 @@
9393
94 // 'window' is defined by QML between startup and showing on the screen.94 // 'window' is defined by QML between startup and showing on the screen.
95 // There is no signal for when it becomes available and re-declaring it is not safe.95 // There is no signal for when it becomes available and re-declaring it is not safe.
96 property bool windowActive: typeof window != 'undefined'96 property bool windowActive: window !== null
97 function updateWindowTitle() {
98 if (window) {
99 window.title = headerItem.title;
100 }
101 }
97 onWindowActiveChanged: {102 onWindowActiveChanged: {
98 window.title = headerItem.title103 updateWindowTitle();
99 }104 }
100105 onTitleChanged: {
101 Connections {106 updateWindowTitle();
102 target: headerItem
103 onTitleChanged: {
104 if (headerItem.windowActive)
105 window.title = headerItem.title
106 }
107 }107 }
108108
109 // Use of the deprecated toolbar is no longer supported in MainView 1.2.109 // Use of the deprecated toolbar is no longer supported in MainView 1.2.
110110
=== modified file 'src/imports/Components/1.2/OrientationHelper.qml'
--- src/imports/Components/1.2/OrientationHelper.qml 2016-05-25 12:48:10 +0000
+++ src/imports/Components/1.2/OrientationHelper.qml 2016-09-27 10:56:19 +0000
@@ -129,20 +129,22 @@
129 http://qt-project.org/doc/qt-5.1/qtqml/qml-qtqml2-qt.html129 http://qt-project.org/doc/qt-5.1/qtqml/qml-qtqml2-qt.html
130 http://qt-project.org/doc/qt-5.1/qtquick/qmlmodule-qtquick-window2-qtquick-window-2.html130 http://qt-project.org/doc/qt-5.1/qtquick/qmlmodule-qtquick-window2-qtquick-window-2.html
131 */131 */
132 property bool windowActive: typeof window != 'undefined'132 property bool windowActive: window !== null
133133
134 /*!134 /*!
135 Report the current orientation of the application via QWindow::contentOrientation.135 Report the current orientation of the application via QWindow::contentOrientation.
136 http://qt-project.org/doc/qt-5.0/qtgui/qwindow.html#contentOrientation-prop136 http://qt-project.org/doc/qt-5.0/qtgui/qwindow.html#contentOrientation-prop
137 */137 */
138 function applyOrientation() {138 function applyOrientation() {
139 if (windowActive && window)139 if (window) {
140 window.contentOrientation = Screen.orientation140 window.contentOrientation = Screen.orientation;
141 }
141 }142 }
142143
143 onWindowActiveChanged: {144 onWindowActiveChanged: {
144 if (automaticOrientation)145 if (automaticOrientation) {
145 applyOrientation();146 applyOrientation();
147 }
146 }148 }
147149
148 Timer {150 Timer {
149151
=== modified file 'src/imports/Components/1.3/MainView.qml'
--- src/imports/Components/1.3/MainView.qml 2016-07-27 15:40:52 +0000
+++ src/imports/Components/1.3/MainView.qml 2016-09-27 10:56:19 +0000
@@ -167,17 +167,17 @@
167167
168 // 'window' is defined by QML between startup and showing on the screen.168 // 'window' is defined by QML between startup and showing on the screen.
169 // There is no signal for when it becomes available and re-declaring it is not safe.169 // There is no signal for when it becomes available and re-declaring it is not safe.
170 property bool windowActive: typeof window != 'undefined'170 property bool windowActive: window !== null
171 function updateWindowTitle() {
172 if (window) {
173 window.title = headerItem.title;
174 }
175 }
171 onWindowActiveChanged: {176 onWindowActiveChanged: {
172 window.title = headerItem.title177 updateWindowTitle();
173 }178 }
174179 onTitleChanged: {
175 Connections {180 updateWindowTitle();
176 target: headerItem
177 onTitleChanged: {
178 if (headerItem.windowActive)
179 window.title = headerItem.title
180 }
181 }181 }
182 }182 }
183183
184184
=== modified file 'src/imports/Components/1.3/OrientationHelper.qml'
--- src/imports/Components/1.3/OrientationHelper.qml 2016-05-25 12:48:10 +0000
+++ src/imports/Components/1.3/OrientationHelper.qml 2016-09-27 10:56:19 +0000
@@ -129,20 +129,22 @@
129 http://qt-project.org/doc/qt-5.1/qtqml/qml-qtqml2-qt.html129 http://qt-project.org/doc/qt-5.1/qtqml/qml-qtqml2-qt.html
130 http://qt-project.org/doc/qt-5.1/qtquick/qmlmodule-qtquick-window2-qtquick-window-2.html130 http://qt-project.org/doc/qt-5.1/qtquick/qmlmodule-qtquick-window2-qtquick-window-2.html
131 */131 */
132 property bool windowActive: typeof window != 'undefined'132 property bool windowActive: window !== null
133133
134 /*!134 /*!
135 Report the current orientation of the application via QWindow::contentOrientation.135 Report the current orientation of the application via QWindow::contentOrientation.
136 http://qt-project.org/doc/qt-5.0/qtgui/qwindow.html#contentOrientation-prop136 http://qt-project.org/doc/qt-5.0/qtgui/qwindow.html#contentOrientation-prop
137 */137 */
138 function applyOrientation() {138 function applyOrientation() {
139 if (windowActive && window)139 if (window) {
140 window.contentOrientation = Screen.orientation140 window.contentOrientation = Screen.orientation;
141 }
141 }142 }
142143
143 onWindowActiveChanged: {144 onWindowActiveChanged: {
144 if (automaticOrientation)145 if (automaticOrientation) {
145 applyOrientation();146 applyOrientation();
147 }
146 }148 }
147149
148 Timer {150 Timer {
149151
=== renamed directory 'tests/unit/mainview' => 'tests/unit/mainview11'
=== renamed file 'tests/unit/mainview/mainview.pro' => 'tests/unit/mainview11/mainview11.pro'
=== modified file 'tests/unit/mainview11/tst_mainview.cpp'
--- tests/unit/mainview/tst_mainview.cpp 2016-09-09 17:49:07 +0000
+++ tests/unit/mainview11/tst_mainview.cpp 2016-09-27 10:56:19 +0000
@@ -156,23 +156,6 @@
156 return filename;156 return filename;
157 }157 }
158158
159 void testLabsSettings() {
160 QString applicationName("red.riding.hood");
161 // Delete file if it exists to avoid false positives
162 QString filename(getConfFile(applicationName));
163 QFile::remove(filename);
164
165 QQuickItem *root = loadTest("Settings.qml");
166 QVERIFY(root);
167 QQuickItem *mainView = root;
168 QCOMPARE(applicationName, mainView->property("applicationName").toString());
169 QCOMPARE(QString(applicationName), QCoreApplication::organizationDomain());
170 QQuickItem *textField(testItem(mainView, "textfield"));
171 textField->setProperty("text", "Blue");
172 delete root;
173 QVERIFY(QFile::exists(filename));
174 }
175
176 void testQSettings() {159 void testQSettings() {
177 QString applicationName("i.prefer.pi");160 QString applicationName("i.prefer.pi");
178 // Delete file if it exists to avoid false positives161 // Delete file if it exists to avoid false positives
179162
=== added directory 'tests/unit/mainview13'
=== added file 'tests/unit/mainview13/AppName.qml'
--- tests/unit/mainview13/AppName.qml 1970-01-01 00:00:00 +0000
+++ tests/unit/mainview13/AppName.qml 2016-09-27 10:56:19 +0000
@@ -0,0 +1,23 @@
1/*
2 * Copyright 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.4
18import Ubuntu.Components 1.3
19
20MainView {
21 objectName: "appName"
22 applicationName: "org.gnu.wildebeest"
23}
024
=== added file 'tests/unit/mainview13/LocalStorage.qml'
--- tests/unit/mainview13/LocalStorage.qml 1970-01-01 00:00:00 +0000
+++ tests/unit/mainview13/LocalStorage.qml 2016-09-27 10:56:19 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright 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.4
18import Ubuntu.Components 1.3
19import QtQuick.LocalStorage 2.0
20
21MainView {
22 objectName: "localStorage"
23 applicationName: "tv.island.pacific"
24
25 Component.onCompleted: {
26 var db = LocalStorage.openDatabaseSync("pacific.island.tv", "1.0", "lorem ipsum", 1000)
27 db.transaction(function(tx){
28 tx.executeSql('CREATE TABLE IF NOT EXISTS Island(name TEXT)')
29 tx.executeSql('INSERT INTO Island VALUES(?)', ['Tuvalu'])
30 })
31 }
32}
033
=== added file 'tests/unit/mainview13/PageStack.qml'
--- tests/unit/mainview13/PageStack.qml 1970-01-01 00:00:00 +0000
+++ tests/unit/mainview13/PageStack.qml 2016-09-27 10:56:19 +0000
@@ -0,0 +1,38 @@
1/*
2 * Copyright 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.4
18import Ubuntu.Components 1.3
19
20MainView {
21 objectName: "pageStack"
22 applicationName: "once.upon.a.time"
23
24 PageStack {
25 id: stack
26 objectName: "stack"
27 Component.onCompleted: stack.push(pageOnStack)
28
29 Page {
30 id: pageOnStack
31 objectName: "page"
32 title: 'Far far away' // sets the window title.
33 header: PageHeader {
34 title: pageOnStack.title
35 }
36 }
37 }
38}
039
=== added file 'tests/unit/mainview13/PageTitle.qml'
--- tests/unit/mainview13/PageTitle.qml 1970-01-01 00:00:00 +0000
+++ tests/unit/mainview13/PageTitle.qml 2016-09-27 10:56:19 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright 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.4
18import Ubuntu.Components 1.3
19
20MainView {
21 objectName: "pageTitle"
22 applicationName: "once.upon.a.time"
23
24 Page {
25 id: page
26 objectName: "page"
27 title: 'Once upon a time' // sets the window title
28 header: PageHeader {
29 title: page.title
30 }
31 }
32}
033
=== renamed file 'tests/unit/mainview/Settings.qml' => 'tests/unit/mainview13/Settings.qml'
--- tests/unit/mainview/Settings.qml 2016-01-20 16:42:29 +0000
+++ tests/unit/mainview13/Settings.qml 2016-09-27 10:56:19 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright 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,7 +14,7 @@
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.017import QtQuick 2.4
18import Ubuntu.Components 1.318import Ubuntu.Components 1.3
19import Qt.labs.settings 1.019import Qt.labs.settings 1.0
2020
2121
=== added file 'tests/unit/mainview13/mainview13.pro'
--- tests/unit/mainview13/mainview13.pro 1970-01-01 00:00:00 +0000
+++ tests/unit/mainview13/mainview13.pro 2016-09-27 10:56:19 +0000
@@ -0,0 +1,4 @@
1include(../test-include.pri)
2
3QT += gui
4SOURCES += tst_mainview.cpp
05
=== added file 'tests/unit/mainview13/tst_mainview.cpp'
--- tests/unit/mainview13/tst_mainview.cpp 1970-01-01 00:00:00 +0000
+++ tests/unit/mainview13/tst_mainview.cpp 2016-09-27 10:56:19 +0000
@@ -0,0 +1,216 @@
1/*
2 * Copyright 2012-2013 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 * Author: Christian Dywan <christian.dywan@canonical.com>
17 */
18
19#include <QtCore/QCoreApplication>
20#include <QtCore/QCryptographicHash>
21#include <QtCore/QDebug>
22#include <QtCore/QDir>
23#include <QtCore/QFileInfo>
24#include <QtCore/QProcessEnvironment>
25#include <QtCore/QSettings>
26#include <QtCore/QStandardPaths>
27#include <QtCore/QString>
28#include <QtCore/QTextCodec>
29#include <QtCore/QThread>
30#include <QtQml/QQmlEngine>
31#include <QtQuick/QQuickItem>
32#include <QtQuick/QQuickView>
33#include <QtTest/QSignalSpy>
34#include <QtTest/QTest>
35#include <UbuntuToolkit/ubuntutoolkitmodule.h>
36#include <UbuntuToolkit/private/ucapplication_p.h>
37#include <UbuntuToolkit/private/ucunits_p.h>
38
39#include "uctestcase.h"
40
41UT_USE_NAMESPACE
42
43class tst_MainView : public QObject
44{
45 Q_OBJECT
46
47private:
48 QQuickView *view;
49
50public:
51 tst_MainView() :
52 view(0)
53 {
54 }
55
56 QQuickItem *loadTest(const QString &document)
57 {
58 // load the document
59 view->setSource(QUrl::fromLocalFile(document));
60 QTest::waitForEvents();
61
62 return view->rootObject();
63 }
64
65 QQuickItem *testItem(QQuickItem *that, const QString &identifier)
66 {
67 if (that->property(identifier.toLocal8Bit()).isValid())
68 return that->property(identifier.toLocal8Bit()).value<QQuickItem*>();
69
70 QList<QQuickItem*> children = that->findChildren<QQuickItem*>(identifier);
71 return (children.count() > 0) ? children[0] : 0;
72 }
73
74private Q_SLOTS:
75
76 void initTestCase()
77 {
78 QString modules(UBUNTU_QML_IMPORT_PATH);
79 QVERIFY(QDir(modules).exists());
80
81 view = new QQuickView;
82 QQmlEngine *quickEngine = view->engine();
83 UbuntuToolkitModule::initializeContextProperties(quickEngine);
84
85 view->setGeometry(0,0, UCUnits::instance()->gu(40), UCUnits::instance()->gu(30));
86 //add modules folder so we have access to the plugin from QML
87 QStringList imports = quickEngine->importPathList();
88 imports.prepend(QDir(modules).absolutePath());
89 quickEngine->setImportPathList(imports);
90 }
91
92 void cleanupTestCase()
93 {
94 delete view;
95 }
96
97 void testCase_AppName()
98 {
99 QQuickItem *root = loadTest("AppName.qml");
100 QVERIFY(root);
101 QQuickItem *mainView = root;
102 QString applicationName(mainView->property("applicationName").toString());
103 QCOMPARE(applicationName, QString("org.gnu.wildebeest"));
104 QCOMPARE(applicationName, QCoreApplication::applicationName());
105 QCOMPARE(QString(""), QCoreApplication::organizationName());
106 }
107
108 void testSetApplicationName() {
109 QString appName("com.ubuntu.foo");
110 UCApplication::instance()->setApplicationName(appName);
111 QCOMPARE(UCApplication::instance()->applicationName(), appName);
112 QCOMPARE(QCoreApplication::applicationName(), appName);
113 QCOMPARE(QString(""), QCoreApplication::organizationName());
114 }
115
116 void testExpectedDataFolder() {
117 QString appName("net.weight.gain");
118 UCApplication::instance()->setApplicationName(appName);
119 QString dataFolder(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
120 QString xdgDataHome(QProcessEnvironment::systemEnvironment().value("XDG_DATA_HOME",
121 QProcessEnvironment::systemEnvironment().value("HOME") + "/.local/share"));
122 QString expectedDataFolder(xdgDataHome + "/" + appName);
123 QCOMPARE(dataFolder, expectedDataFolder);
124 }
125
126 void testExpectedCacheFolder() {
127 QString appName("cat.long.very");
128 UCApplication::instance()->setApplicationName(appName);
129 QString cacheFolder(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
130 QString xdgCacheHome(QProcessEnvironment::systemEnvironment().value("XDG_CACHE_HOME",
131 QProcessEnvironment::systemEnvironment().value("HOME") + "/.cache"));
132 QString expectedCacheFolder(xdgCacheHome + "/" + appName);
133 QCOMPARE(cacheFolder, expectedCacheFolder);
134 }
135
136 void testLocalStorage() {
137 QQuickItem *root = loadTest("LocalStorage.qml");
138 QVERIFY(root);
139 QQuickItem *mainView = root;
140 QString applicationName(mainView->property("applicationName").toString());
141 QCOMPARE(applicationName, QString("tv.island.pacific"));
142 QCOMPARE(applicationName, QCoreApplication::applicationName());
143 QCOMPARE(QString(""), QCoreApplication::organizationName());
144 QString dataFolder(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
145 QString databaseFolder(dataFolder + "/Databases");
146 QVERIFY(QFile::exists(databaseFolder));
147 QString hash(QCryptographicHash::hash("pacific.island.tv", QCryptographicHash::Md5).toHex());
148 QString database(databaseFolder + "/" + hash + ".sqlite");
149 QVERIFY(QFile::exists(database));
150 }
151
152 QString getConfFile(QString applicationName) {
153 QString configFolder(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation));
154 QString subFolder(configFolder + "/" + applicationName);
155 QString filename(subFolder + "/" + applicationName + ".conf");
156 return filename;
157 }
158
159 void testLabsSettings() {
160 QString applicationName("red.riding.hood");
161 // Delete file if it exists to avoid false positives
162 QString filename(getConfFile(applicationName));
163 QFile::remove(filename);
164
165 QQuickItem *root = loadTest("Settings.qml");
166 QVERIFY(root);
167 QQuickItem *mainView = root;
168 QCOMPARE(applicationName, mainView->property("applicationName").toString());
169 QCOMPARE(QString(applicationName), QCoreApplication::organizationDomain());
170 QQuickItem *textField(testItem(mainView, "textfield"));
171 textField->setProperty("text", "Blue");
172 delete root;
173 QVERIFY(QFile::exists(filename));
174 }
175
176 void testQSettings() {
177 QString applicationName("i.prefer.pi");
178 // Delete file if it exists to avoid false positives
179 QString filename(getConfFile(applicationName));
180 QFile::remove(filename);
181
182 UCApplication::instance()->setApplicationName(applicationName);
183 // QSettings with defaults
184 QSettings mySettings;
185 mySettings.setValue("spam", "eggs");
186 // Force writing to disk
187 mySettings.sync();
188 QVERIFY(QFile::exists(filename));
189 }
190
191 void testNoWarnings_bug186065() {
192 // An empty MainView would suffice
193 QScopedPointer<UbuntuTestCase>testCase (new UbuntuTestCase("AppName.qml"));
194
195 // No warnings from QML
196 QCOMPARE(testCase->warnings(), 0);
197 }
198
199 void testWindowTitleFromPage() {
200 QScopedPointer<UbuntuTestCase> testCase(new UbuntuTestCase("PageTitle.qml"));
201 QQuickItem *page = testCase->findItem<QQuickItem*>("page");
202 QCOMPARE(QString("Once upon a time"), page->property("title").toString());
203 QCOMPARE(testCase->title(), page->property("title").toString());
204 }
205
206 void testWindowTitleFromStack() {
207 QScopedPointer<UbuntuTestCase> testCase(new UbuntuTestCase("PageStack.qml"));
208 QQuickItem *page = testCase->findItem<QQuickItem*>("page");
209 QCOMPARE(QString("Far far away"), page->property("title").toString());
210 QCOMPARE(testCase->title(), page->property("title").toString());
211 }
212};
213
214QTEST_MAIN(tst_MainView)
215
216#include "tst_mainview.moc"
0217
=== modified file 'tests/unit/orientation/tst_orientation.cpp'
--- tests/unit/orientation/tst_orientation.cpp 2016-09-09 17:49:07 +0000
+++ tests/unit/orientation/tst_orientation.cpp 2016-09-27 10:56:19 +0000
@@ -52,12 +52,12 @@
52 QScopedPointer<UbuntuTestCase> testCase(new UbuntuTestCase("ManualAngle.qml"));52 QScopedPointer<UbuntuTestCase> testCase(new UbuntuTestCase("ManualAngle.qml"));
53 QQuickItem *helper = testCase->findItem<QQuickItem*>("helper");53 QQuickItem *helper = testCase->findItem<QQuickItem*>("helper");
54 // No warning about "window" being undefined must appear54 // No warning about "window" being undefined must appear
55 QSKIP("TypeError: Cannot set property 'contentOrientation' of null");55 QSKIP("FIXME: We have no valid effectiveness tests for OrientationHelper. See bug #1626063.");
56 QCOMPARE(testCase->warnings(), 0);56 QCOMPARE(testCase->warnings(), 0);
57 QCOMPARE(helper->property("orientationAngle").toInt(), 90);57 QCOMPARE(helper->property("orientationAngle").toInt(), 90);
58 // Verify expected values58 // Verify expected values
59 QQuickItem *checkpoint = testCase->findItem<QQuickItem*>("checkpoint");59 QQuickItem *checkpoint = testCase->findItem<QQuickItem*>("checkpoint");
60 // window.contentOrientation 60 // window.contentOrientation
61 QCOMPARE(checkpoint->property("contentOrientation").toInt(), helper->property("orientationAngle").toInt());61 QCOMPARE(checkpoint->property("contentOrientation").toInt(), helper->property("orientationAngle").toInt());
62 }62 }
63};63};
6464
=== modified file 'tests/unit/runtest.sh'
--- tests/unit/runtest.sh 2016-06-07 12:53:59 +0000
+++ tests/unit/runtest.sh 2016-09-27 10:56:19 +0000
@@ -45,8 +45,8 @@
45 echo 'Examples:'45 echo 'Examples:'
46 echo " $0 $(relpath ${BUILD_DIR}/tests/unit/components/components) $(relpath ${SRC_DIR}/tests/unit/components/tst_label13.qml) minimal"46 echo " $0 $(relpath ${BUILD_DIR}/tests/unit/components/components) $(relpath ${SRC_DIR}/tests/unit/components/tst_label13.qml) minimal"
47 echo ''47 echo ''
48 echo " cd $(relpath ${BUILD_DIR}/tests/unit/mainview)"48 echo " cd $(relpath ${BUILD_DIR}/tests/unit/mainview13)"
49 echo " ../$(basename $0) mainview minimal"49 echo " ../$(basename $0) mainview13 minimal"
50 echo " cd ../../.."50 echo " cd ../../.."
51 echo ''51 echo ''
52 echo " cd $(relpath ${BUILD_DIR}/tests/unit/visual)"52 echo " cd $(relpath ${BUILD_DIR}/tests/unit/visual)"
5353
=== modified file 'tests/unit/unit.pro'
--- tests/unit/unit.pro 2016-09-23 11:14:46 +0000
+++ tests/unit/unit.pro 2016-09-27 10:56:19 +0000
@@ -39,7 +39,8 @@
39 scaling_image_provider \39 scaling_image_provider \
40 qquick_image_extension \40 qquick_image_extension \
41 performance \41 performance \
42 mainview \42 mainview11 \
43 mainview13 \
43 i18n \44 i18n \
44 arguments \45 arguments \
45 argument \46 argument \
4647
=== renamed file 'tests/unit/visual/FIXME-QT56_pagehead_sections_bug1511839.13.qml' => 'tests/unit/visual/tst_pagehead_sections_bug1511839.13.qml'
--- tests/unit/visual/FIXME-QT56_pagehead_sections_bug1511839.13.qml 2016-09-16 11:13:32 +0000
+++ tests/unit/visual/tst_pagehead_sections_bug1511839.13.qml 2016-09-27 10:56:19 +0000
@@ -40,7 +40,6 @@
40 stack.push(pageComponent)40 stack.push(pageComponent)
41 }41 }
4242
43 // FIXME: Tests failing with Qt 5.6. See bug #1624337.
44 UbuntuTestCase {43 UbuntuTestCase {
45 id: testCase44 id: testCase
46 name: "Page.head.sections"45 name: "Page.head.sections"
4746
=== renamed file 'tests/unit/visual/FIXME-QT56_sections.13.qml' => 'tests/unit/visual/tst_sections.13.qml'
--- tests/unit/visual/FIXME-QT56_sections.13.qml 2016-09-16 11:13:32 +0000
+++ tests/unit/visual/tst_sections.13.qml 2016-09-27 10:56:19 +0000
@@ -142,7 +142,6 @@
142 name: "SectionsApi"142 name: "SectionsApi"
143 when: windowShown143 when: windowShown
144144
145 // FIXME: Fails with Qt 5.6. See bug #1610231.
146 function initTestCase() {145 function initTestCase() {
147 // The initially selected actions must be triggered.146 // The initially selected actions must be triggered.
148 compare(label.text, "First action triggered.",147 compare(label.text, "First action triggered.",
149148
=== added file 'tests/unit/visual/tst_window_context_property_init_bug1621509.13.qml'
--- tests/unit/visual/tst_window_context_property_init_bug1621509.13.qml 1970-01-01 00:00:00 +0000
+++ tests/unit/visual/tst_window_context_property_init_bug1621509.13.qml 2016-09-27 10:56:19 +0000
@@ -0,0 +1,56 @@
1/*
2 * Copyright 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.4
18import QtTest 1.0
19
20// Ubuntu.Components is not explicitly used below, but its import causes bug #1621509.
21import Ubuntu.Components 1.3
22
23TestCase {
24 id: testCase
25 name: "ContextPropertyInit"
26 width: 100
27 height: 100
28
29 // Bug #1621509 only occurs when we wait for the window to be visible.
30 // Forces the components to be completed before the test functions are executed.
31 when: windowShown
32
33 Item {
34 id: testItem
35
36 // This property changes its value when a new context property is added.
37 property var myObject: objectOne
38 property int count: 0
39 onMyObjectChanged: {
40 count++;
41 }
42 Component.onCompleted: {
43 count = 0;
44 print("Component completed."); // must print something to reproduce the bug.
45 }
46 QtObject {
47 objectName: "one"
48 id: objectOne
49 }
50 }
51
52 function test_no_property_change_after_completed_bug1621509_bug1610231() {
53 compare(testItem.count, 0,
54 "The property was changed after the component was completed.");
55 }
56}

Subscribers

People subscribed via source and target branches