Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/manualorientation into lp:ubuntu-ui-toolkit
- manualorientation
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Tim Peeters | ||||
Approved revision: | 799 | ||||
Merged at revision: | 817 | ||||
Proposed branch: | lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/manualorientation | ||||
Merge into: | lp:ubuntu-ui-toolkit | ||||
Diff against target: |
228 lines (+189/-1) 6 files modified
modules/Ubuntu/Components/OrientationHelper.qml (+8/-0) tests/unit_x11/tst_orientation/Defaults.qml (+27/-0) tests/unit_x11/tst_orientation/ManualAngle.qml (+34/-0) tests/unit_x11/tst_orientation/tst_orientation.cpp (+110/-0) tests/unit_x11/tst_orientation/tst_orientation.pro (+9/-0) tests/unit_x11/unit_x11.pro (+1/-1) |
||||
To merge this branch: | bzr merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/manualorientation | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Tim Peeters | Needs Information | ||
Review via email: mp+191219@code.launchpad.net |
Commit message
Define window within OrientationHelper to avoid a race condition
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:795
http://
Executed test runs:
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:796
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Cris Dywan (kalikiana) wrote : | # |
Looks like a Jenkins error? There's no change to autopilot tests in this branch.
StateNotFoundError: State not found for class 'ActionItem' and filters {'objectName': 'unexisting'}.
Tim Peeters (tpeeters) wrote : | # |
Do you need to define window, or is it possible to check if window is defined before you use it?
Cris Dywan (kalikiana) wrote : | # |
Two points on that:
If not defined, there's a race between the signals and window being available - if it's defined it can be used exactly when needed.
There's no signal to know that window was defined that I can see. It's a global variable.
Tim Peeters (tpeeters) wrote : | # |
merge again? jenkins needs to pass.
Tim Peeters (tpeeters) wrote : | # |
114 + * Author: Zsombor Egri <email address hidden>
really? ;)
Tim Peeters (tpeeters) wrote : | # |
> Two points on that:
> If not defined, there's a race between the signals and window being available
> - if it's defined it can be used exactly when needed.
> There's no signal to know that window was defined that I can see. It's a
> global variable.
what happens when you define it here? Is there still a global variable in addition to your new local variable?
Tim Peeters (tpeeters) wrote : | # |
Why do you add cpp tests and not simply add qml tests for the orientations in tst_components? Also I'd like to see a test that explicitly checks for a regression of the bug.
Tim Peeters (tpeeters) wrote : | # |
> Why do you add cpp tests and not simply add qml tests for the orientations in
> tst_components? Also I'd like to see a test that explicitly checks for a
> regression of the bug.
You do check for a 'window' warning, but please add a reference to the bug there, or if you add a qml test, add the bug id in the function name.
Tim Peeters (tpeeters) : | # |
Cris Dywan (kalikiana) wrote : | # |
> what happens when you define it here? Is there still a global variable in addition to your new local variable?
I don't understand the question. Defining window fixes the race condition. It's the same object otherwise.
> Why do you add cpp tests and not simply add qml tests for the orientations in tst_components?
I cannot produce the warnings in the qml test case with and without windowShown.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:799
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'modules/Ubuntu/Components/OrientationHelper.qml' |
2 | --- modules/Ubuntu/Components/OrientationHelper.qml 2013-07-29 11:14:35 +0000 |
3 | +++ modules/Ubuntu/Components/OrientationHelper.qml 2013-10-31 16:49:34 +0000 |
4 | @@ -92,6 +92,14 @@ |
5 | Component.onCompleted: orientationTransition.enabled = transitionEnabled |
6 | |
7 | /*! |
8 | + Technically 'window' is defined by QML automatically however this can |
9 | + happen very late. We define it here so there's no race condition. |
10 | + */ |
11 | + Window { |
12 | + id: window |
13 | + } |
14 | + |
15 | + /*! |
16 | \internal |
17 | |
18 | Report the current orientation of the application via QWindow::contentOrientation. |
19 | |
20 | === added directory 'tests/unit_x11/tst_orientation' |
21 | === added file 'tests/unit_x11/tst_orientation/Defaults.qml' |
22 | --- tests/unit_x11/tst_orientation/Defaults.qml 1970-01-01 00:00:00 +0000 |
23 | +++ tests/unit_x11/tst_orientation/Defaults.qml 2013-10-31 16:49:34 +0000 |
24 | @@ -0,0 +1,27 @@ |
25 | +/* |
26 | + * Copyright 2013 Canonical Ltd. |
27 | + * |
28 | + * This program is free software; you can redistribute it and/or modify |
29 | + * it under the terms of the GNU Lesser General Public License as published by |
30 | + * the Free Software Foundation; version 3. |
31 | + * |
32 | + * This program is distributed in the hope that it will be useful, |
33 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
34 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
35 | + * GNU Lesser General Public License for more details. |
36 | + * |
37 | + * You should have received a copy of the GNU Lesser General Public License |
38 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
39 | + */ |
40 | + |
41 | +import QtQuick 2.0 |
42 | +import Ubuntu.Components 0.1 |
43 | + |
44 | +Item { |
45 | + width: 100 |
46 | + height: 100 |
47 | + |
48 | + OrientationHelper { |
49 | + objectName: "helper" |
50 | + } |
51 | +} |
52 | |
53 | === added file 'tests/unit_x11/tst_orientation/ManualAngle.qml' |
54 | --- tests/unit_x11/tst_orientation/ManualAngle.qml 1970-01-01 00:00:00 +0000 |
55 | +++ tests/unit_x11/tst_orientation/ManualAngle.qml 2013-10-31 16:49:34 +0000 |
56 | @@ -0,0 +1,34 @@ |
57 | +/* |
58 | + * Copyright 2013 Canonical Ltd. |
59 | + * |
60 | + * This program is free software; you can redistribute it and/or modify |
61 | + * it under the terms of the GNU Lesser General Public License as published by |
62 | + * the Free Software Foundation; version 3. |
63 | + * |
64 | + * This program is distributed in the hope that it will be useful, |
65 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
66 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
67 | + * GNU Lesser General Public License for more details. |
68 | + * |
69 | + * You should have received a copy of the GNU Lesser General Public License |
70 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
71 | + */ |
72 | + |
73 | +import QtQuick 2.0 |
74 | +import Ubuntu.Components 0.1 |
75 | + |
76 | +Item { |
77 | + width: 100 |
78 | + height: 100 |
79 | + |
80 | + OrientationHelper { |
81 | + objectName: "helper" |
82 | + orientationAngle: 90 |
83 | + } |
84 | + |
85 | + Item { |
86 | + objectName: "checkpoint" |
87 | + property int contentOrientation: window.contentOrientation |
88 | + property int orientation: Screen.Orientation |
89 | + } |
90 | +} |
91 | |
92 | === added file 'tests/unit_x11/tst_orientation/tst_orientation.cpp' |
93 | --- tests/unit_x11/tst_orientation/tst_orientation.cpp 1970-01-01 00:00:00 +0000 |
94 | +++ tests/unit_x11/tst_orientation/tst_orientation.cpp 2013-10-31 16:49:34 +0000 |
95 | @@ -0,0 +1,110 @@ |
96 | +/* |
97 | + * Copyright 2013 Canonical Ltd. |
98 | + * |
99 | + * This program is free software; you can redistribute it and/or modify |
100 | + * it under the terms of the GNU Lesser General Public License as published by |
101 | + * the Free Software Foundation; version 3. |
102 | + * |
103 | + * This program is distributed in the hope that it will be useful, |
104 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
105 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
106 | + * GNU Lesser General Public License for more details. |
107 | + * |
108 | + * You should have received a copy of the GNU Lesser General Public License |
109 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
110 | + * |
111 | + * Author: Christian Dywan <christian.dywan@canonical.com> |
112 | + */ |
113 | + |
114 | +#include <QtTest/QtTest> |
115 | +#include <QtTest/QSignalSpy> |
116 | +#include <QtCore/QCoreApplication> |
117 | +#include <QtQml/QQmlEngine> |
118 | +#include <QtQuick/QQuickView> |
119 | +#include <QtQuick/QQuickItem> |
120 | +#include <QVector3D> |
121 | +#include <QVector4D> |
122 | +#include <QQuaternion> |
123 | +#include <QMatrix4x4> |
124 | +#include <QtQuick/QQuickItem> |
125 | +#include <QtQml/QQmlProperty> |
126 | + |
127 | +class tst_OrientationTest : public QObject |
128 | +{ |
129 | + Q_OBJECT |
130 | +public: |
131 | + tst_OrientationTest() {} |
132 | + |
133 | +private: |
134 | + QString m_modulePath; |
135 | + |
136 | + QQuickView *createView(const QString &file, QSignalSpy **spy = 0) |
137 | + { |
138 | + QQuickView *view = new QQuickView(0); |
139 | + if (spy) { |
140 | + *spy = new QSignalSpy(view->engine(), SIGNAL(warnings(QList<QQmlError>))); |
141 | + (*spy)->setParent(view); |
142 | + } |
143 | + view->engine()->addImportPath(m_modulePath); |
144 | + view->setSource(QUrl::fromLocalFile(file)); |
145 | + if (!view->rootObject()) { |
146 | + return 0; |
147 | + } |
148 | + view->show(); |
149 | + QTest::qWaitForWindowExposed(view); |
150 | + return view; |
151 | + } |
152 | + |
153 | +private Q_SLOTS: |
154 | + |
155 | + void initTestCase() |
156 | + { |
157 | + QDir modules ("../../../modules"); |
158 | + QVERIFY(modules.exists()); |
159 | + m_modulePath = modules.absolutePath(); |
160 | + } |
161 | + |
162 | + void cleanupTestCase() |
163 | + { |
164 | + } |
165 | + |
166 | + void test_defaults() |
167 | + { |
168 | + QSignalSpy *spy; |
169 | + QQuickView *view = createView("Defaults.qml", &spy); |
170 | + QVERIFY(view); |
171 | + QQuickItem *helper = view->rootObject()->findChild<QQuickItem*>("helper"); |
172 | + QVERIFY(helper); |
173 | + QCOMPARE(helper->property("automaticOrientation").toBool(), true); |
174 | + // No warnings expected |
175 | + QCOMPARE(spy->count(), 0); |
176 | + delete view; |
177 | + } |
178 | + |
179 | + void test_manualAngle() |
180 | + { |
181 | + QSignalSpy *spy; |
182 | + QQuickView *view = createView("ManualAngle.qml", &spy); |
183 | + QVERIFY(view); |
184 | + QQuickItem *helper = view->rootObject()->findChild<QQuickItem*>("helper"); |
185 | + QVERIFY(helper); |
186 | + // No warning about "window" being undefined must appear |
187 | + QCOMPARE(spy->count(), 0); |
188 | + QCOMPARE(helper->property("orientationAngle").toInt(), 90); |
189 | + // Verify expected values |
190 | + QQuickItem *checkpoint = view->rootObject()->findChild<QQuickItem*>("checkpoint"); |
191 | + QVERIFY(checkpoint); |
192 | + // window.contentOrientation |
193 | + QCOMPARE(checkpoint->property("contentOrientation").toInt(), helper->property("orientationAngle").toInt()); |
194 | + // Screen.Orientation |
195 | + QCOMPARE(checkpoint->property("orientation").toInt(), helper->property("orientationAngle").toInt()); |
196 | + delete view; |
197 | + } |
198 | +}; |
199 | + |
200 | +QTEST_MAIN(tst_OrientationTest) |
201 | + |
202 | +#include "tst_orientation.moc" |
203 | + |
204 | + |
205 | + |
206 | |
207 | === added file 'tests/unit_x11/tst_orientation/tst_orientation.pro' |
208 | --- tests/unit_x11/tst_orientation/tst_orientation.pro 1970-01-01 00:00:00 +0000 |
209 | +++ tests/unit_x11/tst_orientation/tst_orientation.pro 2013-10-31 16:49:34 +0000 |
210 | @@ -0,0 +1,9 @@ |
211 | +include(../test-include.pri) |
212 | +DEFINES += SRCDIR=\\\"$$PWD/\\\" |
213 | + |
214 | +SOURCES += \ |
215 | + tst_orientation.cpp |
216 | + |
217 | +OTHER_FILES += \ |
218 | + Defaults.qml \ |
219 | + ManualOrientation.qml |
220 | |
221 | === modified file 'tests/unit_x11/unit_x11.pro' |
222 | --- tests/unit_x11/unit_x11.pro 2013-10-11 05:56:57 +0000 |
223 | +++ tests/unit_x11/unit_x11.pro 2013-10-31 16:49:34 +0000 |
224 | @@ -1,3 +1,3 @@ |
225 | TEMPLATE = subdirs |
226 | |
227 | -SUBDIRS += tst_components tst_test tst_inversemousearea tst_recreateview tst_statesaver tst_theme_engine |
228 | +SUBDIRS += tst_components tst_test tst_inversemousearea tst_recreateview tst_statesaver tst_theme_engine tst_orientation |
FAILED: Continuous integration, rev:794 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- ci/981/ jenkins. qa.ubuntu. com/job/ generic- mediumtests- saucy-vm/ 394 jenkins. qa.ubuntu. com/job/ generic- mediumtests- touch/2949 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- saucy-amd64- ci/838 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- saucy-armhf- ci/838 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- saucy-armhf- ci/838/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ autopilot- testrunner- vm-saucy/ 290 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- saucy-i386/ 4542 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- saucy-i386/ 4542/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- saucy-armhf/ 2951 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- saucy-armhf/ 2951/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- runner- maguro/ 2457 jenkins. qa.ubuntu. com/job/ generic- mediumtests- runner- mako/2500
http://
Executed test runs:
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
Click here to trigger a rebuild: 10.97.0. 26:8080/ job/ubuntu- ui-toolkit- ci/981/ rebuild
http://