Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/windowLauncher into lp:ubuntu-ui-toolkit/staging
- windowLauncher
- Merge into staging
Status: | Merged |
---|---|
Approved by: | Tim Peeters |
Approved revision: | 2028 |
Merged at revision: | 2032 |
Proposed branch: | lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/windowLauncher |
Merge into: | lp:ubuntu-ui-toolkit/staging |
Diff against target: |
224 lines (+139/-26) 4 files modified
tests/autopilot/ubuntuuitoolkit/tests/test_launcher.py (+12/-0) tests/autopilot/ubuntuuitoolkit/tests/test_launcher.testcase.qml (+1/-1) tests/autopilot/ubuntuuitoolkit/tests/test_launcher.window.qml (+43/-0) ubuntu-ui-toolkit-launcher/launcher.cpp (+83/-25) |
To merge this branch: | bzr merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/windowLauncher |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
ubuntu-sdk-build-bot | continuous-integration | Needs Fixing | |
Tim Peeters | Approve | ||
Review via email: mp+299119@code.launchpad.net |
Commit message
Launcher: create QQuickView if no window provided
Description of the change
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2027
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2027
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2027
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2027
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Tim Peeters (tpeeters) wrote : | # |
Inline comments below.
Tim Peeters (tpeeters) wrote : | # |
Looks good. Happroving.
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2028
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2028
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2028
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2028
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2028
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2028
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2028
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2028
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2028
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2028
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2028
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2028
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2028
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2028
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/test_launcher.py' |
2 | --- tests/autopilot/ubuntuuitoolkit/tests/test_launcher.py 2015-04-14 21:02:06 +0000 |
3 | +++ tests/autopilot/ubuntuuitoolkit/tests/test_launcher.py 2016-07-12 12:06:33 +0000 |
4 | @@ -37,6 +37,18 @@ |
5 | self.assertThat(textfield.text, Eventually(Equals("Yes"))) |
6 | |
7 | |
8 | +class LauncherWindowTestCase(tests.QMLFileAppTestCase): |
9 | + path = os.path.abspath(__file__) |
10 | + dir_path = os.path.dirname(path) |
11 | + test_qml_file_path = os.path.join( |
12 | + dir_path, 'test_launcher.window.qml') |
13 | + |
14 | + def test_window_root_item(self): |
15 | + label = self.main_view.select_single(objectName="label") |
16 | + self.assertThat(label.text, |
17 | + Eventually(Equals("Lorem ipsum dolor sit amet"))) |
18 | + |
19 | + |
20 | class LauncherQtTestTestCase(tests.QMLFileAppTestCase): |
21 | path = os.path.abspath(__file__) |
22 | dir_path = os.path.dirname(path) |
23 | |
24 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/test_launcher.testcase.qml' |
25 | --- tests/autopilot/ubuntuuitoolkit/tests/test_launcher.testcase.qml 2015-03-03 13:20:06 +0000 |
26 | +++ tests/autopilot/ubuntuuitoolkit/tests/test_launcher.testcase.qml 2016-07-12 12:06:33 +0000 |
27 | @@ -17,7 +17,7 @@ |
28 | import QtQuick 2.0 |
29 | import QtTest 1.0 |
30 | import Ubuntu.Components 1.1 |
31 | -import Ubuntu.Test 1.0 |
32 | +import Ubuntu.Test 1.0 // UbuntuTestCase |
33 | |
34 | MainView { |
35 | width: units.gu(48) |
36 | |
37 | === added file 'tests/autopilot/ubuntuuitoolkit/tests/test_launcher.window.qml' |
38 | --- tests/autopilot/ubuntuuitoolkit/tests/test_launcher.window.qml 1970-01-01 00:00:00 +0000 |
39 | +++ tests/autopilot/ubuntuuitoolkit/tests/test_launcher.window.qml 2016-07-12 12:06:33 +0000 |
40 | @@ -0,0 +1,43 @@ |
41 | +/* |
42 | + * Copyright 2014-2016 Canonical Ltd. |
43 | + * |
44 | + * This program is free software; you can redistribute it and/or modify |
45 | + * it under the terms of the GNU Lesser General Public License as published by |
46 | + * the Free Software Foundation; version 3. |
47 | + * |
48 | + * This program is distributed in the hope that it will be useful, |
49 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
50 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
51 | + * GNU Lesser General Public License for more details. |
52 | + * |
53 | + * You should have received a copy of the GNU Lesser General Public License |
54 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
55 | + */ |
56 | + |
57 | +import QtQuick 2.4 |
58 | +import QtQuick.Window 2.2 // Not Ubuntu.Test |
59 | +import Ubuntu.Components 1.3 |
60 | + |
61 | +Window { |
62 | + title: "Hello World" |
63 | + minimumWidth: units.gu(30) |
64 | + minimumHeight: units.gu(50) |
65 | + maximumWidth: units.gu(90) |
66 | + maximumHeight: units.gu(120) |
67 | + MainView { |
68 | + objectName: "mainView" |
69 | + |
70 | + Page { |
71 | + title: "Launcher/Window" |
72 | + |
73 | + Column { |
74 | + Label { |
75 | + objectName: "label" |
76 | + text: "Lorem ipsum dolor sit amet" |
77 | + width: units.gu(25) |
78 | + height: units.gu(25) |
79 | + } |
80 | + } |
81 | + } |
82 | + } |
83 | +} |
84 | |
85 | === modified file 'ubuntu-ui-toolkit-launcher/launcher.cpp' |
86 | --- ubuntu-ui-toolkit-launcher/launcher.cpp 2016-07-07 15:33:34 +0000 |
87 | +++ ubuntu-ui-toolkit-launcher/launcher.cpp 2016-07-12 12:06:33 +0000 |
88 | @@ -21,10 +21,12 @@ |
89 | |
90 | #include <iostream> |
91 | #include <QtCore/qdebug.h> |
92 | +#include <QtQuick/QQuickItem> |
93 | #include <QtQuick/QQuickView> |
94 | #include <QtGui/QGuiApplication> |
95 | #include <QtQml/QQmlEngine> |
96 | #include <QtQml/QQmlContext> |
97 | +#include <QtQml/QQmlComponent> |
98 | #include <QtCore/QFileInfo> |
99 | #include <QLibrary> |
100 | #include <QOpenGLContext> |
101 | @@ -117,43 +119,99 @@ |
102 | // Allow manual execution of unit tests using Qt.Test |
103 | qmlRegisterSingletonType<QObject>("Qt.test.qtestroot", 1, 0, "QTestRootObject", testRootObject); |
104 | |
105 | - QQmlEngine* engine; |
106 | + QPointer<QQmlEngine> engine; |
107 | + QScopedPointer<QQuickWindow> window; |
108 | + QString testCaseImport; |
109 | + // Let's see if the source file exists |
110 | + QFile sourceCode(filename); |
111 | + if (!sourceCode.open(QIODevice::ReadOnly)) { |
112 | + qCritical("%s", qPrintable(sourceCode.errorString())); |
113 | + return 1; |
114 | + } |
115 | + while (!sourceCode.atEnd()) { |
116 | + QByteArray line(sourceCode.readLine()); |
117 | + if (line.contains("{")) |
118 | + break; |
119 | + // Hack to avoid assertion if QtTest or Ubuntu.Test is used: |
120 | + // ASSERT: "QTest::TestLoggers::loggerCount() != 0" in file qtestlog.cpp, line 278 |
121 | + if ((line.startsWith("import ") && QString(line).split("//")[0].split("/*")[0].contains("Test"))) { |
122 | + testCaseImport = line; |
123 | + break; |
124 | + } |
125 | + } |
126 | + QUrl source(QUrl::fromLocalFile(filename)); |
127 | + |
128 | // The default constructor affects the components tree (autopilot vis) |
129 | - QScopedPointer<QQuickView> view; |
130 | - if (args.isSet(_engine)) { |
131 | - view.reset(new QQuickView()); |
132 | + if (args.isSet(_engine) || !testCaseImport.isEmpty()) { |
133 | + QQuickView *view(new QQuickView()); |
134 | + if (args.isSet(_import)) { |
135 | + QStringList paths = args.values(_import); |
136 | + Q_FOREACH(const QString &path, paths) { |
137 | + engine->addImportPath(path); |
138 | + } |
139 | + } |
140 | + |
141 | + view->setSource(source); |
142 | + while (view->status() == QQuickView::Loading) |
143 | + QCoreApplication::processEvents(); |
144 | + if (view->errors().count() > 0) { |
145 | + args.showHelp(3); |
146 | + } |
147 | + // An unsupported root object is not technically an error |
148 | + if (!view->rootObject()) { |
149 | + if (!testCaseImport.isEmpty()) |
150 | + qCritical("Note: QtTest or Ubuntu.Test was detected here: %s", qPrintable(testCaseImport)); |
151 | + return 1; |
152 | + } |
153 | + |
154 | + window.reset(view); |
155 | engine = view->engine(); |
156 | } else { |
157 | engine = new QQmlEngine(); |
158 | - view.reset(new QQuickView(engine, NULL)); |
159 | - engine->setParent(view.data()); |
160 | - } |
161 | - |
162 | - if (args.isSet(_import)) { |
163 | - QStringList paths = args.values(_import); |
164 | - Q_FOREACH(const QString &path, paths) { |
165 | - engine->addImportPath(path); |
166 | - } |
167 | - } |
168 | - |
169 | - view->setResizeMode(QQuickView::SizeRootObjectToView); |
170 | - view->setTitle("UI Toolkit QQuickView"); |
171 | + if (args.isSet(_import)) { |
172 | + QStringList paths = args.values(_import); |
173 | + Q_FOREACH(const QString &path, paths) { |
174 | + engine->addImportPath(path); |
175 | + } |
176 | + } |
177 | + |
178 | + QObject::connect(engine, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit())); |
179 | + QPointer<QQmlComponent> component(new QQmlComponent(engine)); |
180 | + component->loadUrl(source, QQmlComponent::Asynchronous); |
181 | + while (component->isLoading()) |
182 | + QCoreApplication::processEvents(); |
183 | + QObject *toplevel(component->create()); |
184 | + if (!toplevel && component->isError()) { |
185 | + qCritical("%s", qPrintable(component->errorString())); |
186 | + return 1; |
187 | + } |
188 | + |
189 | + window.reset(qobject_cast<QQuickWindow *>(toplevel)); |
190 | + if (window) |
191 | + engine->setIncubationController(window->incubationController()); |
192 | + else { |
193 | + QQuickItem *rootItem = qobject_cast<QQuickItem *>(toplevel); |
194 | + if (rootItem) { |
195 | + QQuickView *view(new QQuickView(engine, 0)); |
196 | + window.reset(view); |
197 | + view->setResizeMode(QQuickView::SizeRootObjectToView); |
198 | + view->setContent(source, component, rootItem); |
199 | + } |
200 | + } |
201 | + } |
202 | + |
203 | + if (window->title().isEmpty()) |
204 | + window->setTitle("UI Toolkit QQuickView"); |
205 | if (args.isSet(_frameless)) { |
206 | - view->setFlags(Qt::FramelessWindowHint); |
207 | + window->setFlags(Qt::FramelessWindowHint); |
208 | } |
209 | + window->show(); |
210 | |
211 | if (args.isSet(_enableTouch)) { |
212 | // has no effect if we have touch screen |
213 | new UT_PREPEND_NAMESPACE(MouseTouchAdaptor)(&application); |
214 | } |
215 | |
216 | - QUrl source(QUrl::fromLocalFile(filename)); |
217 | - view->setSource(source); |
218 | - if (view->errors().count() > 0) { |
219 | - args.showHelp(3); |
220 | - } |
221 | - view->show(); |
222 | - |
223 | return application.exec(); |
224 | } |
225 |
PASSED: Continuous integration, rev:2027 /jenkins. ubuntu. com/ubuntu- sdk/job/ ubuntu- ui-toolkit- ci-amd64- stable/ 1033/ /jenkins. ubuntu. com/ubuntu- sdk/job/ generic- update- mp/4274/ console
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild: /jenkins. ubuntu. com/ubuntu- sdk/job/ ubuntu- ui-toolkit- ci-amd64- stable/ 1033/rebuild
https:/