Merge lp:~abreu-alexandre/unity-webapps-qml/fix-issues-uncovered-by-qmlplugindump into lp:unity-webapps-qml

Proposed by Alexandre Abreu
Status: Merged
Merged at revision: 125
Proposed branch: lp:~abreu-alexandre/unity-webapps-qml/fix-issues-uncovered-by-qmlplugindump
Merge into: lp:unity-webapps-qml
Diff against target: 1031 lines (+453/-253)
27 files modified
debian/unity-webapps-qml-autopilot.install (+1/-0)
src/Ubuntu/UnityWebApps/UnityWebApps.qml (+19/-1)
src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js (+4/-0)
src/Ubuntu/UnityWebApps/plugin/plugin.pro (+0/-2)
src/Ubuntu/UnityWebApps/plugin/qml-plugin.cpp (+0/-2)
src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-infos.cpp (+2/-1)
src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model-filter-proxy.cpp (+0/-76)
src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model-filter-proxy.h (+0/-87)
src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp (+1/-1)
src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h (+1/-1)
tests/integration/autopilot/autopilot.pro (+7/-2)
tests/integration/autopilot/data/all-in-same-folder/script.user.js (+1/-0)
tests/integration/autopilot/data/all-in-same-folder/webapp-properties.json (+8/-0)
tests/integration/autopilot/data/unity-webapps-normal/manifest.json (+7/-0)
tests/integration/autopilot/data/unity-webapps-normal/script.user.js (+1/-0)
tests/integration/autopilot/data/unity-webapps-with-altered-ua-string/manifest.json (+8/-0)
tests/integration/autopilot/data/unity-webapps-with-altered-ua-string/script.user.js (+1/-0)
tests/integration/autopilot/qml/FullWebViewApp.qml (+48/-23)
tests/integration/autopilot/qml/WebviewBackendOxide.qml (+87/-0)
tests/integration/autopilot/qml/WebviewBackendWebkit.qml (+19/-0)
tests/integration/autopilot/qml/message-server.js (+29/-0)
tests/integration/autopilot/unity_webapps_qml/emulators/__init__.py (+0/-7)
tests/integration/autopilot/unity_webapps_qml/tests/__init__.py (+66/-31)
tests/integration/autopilot/unity_webapps_qml/tests/fake_servers.py (+70/-0)
tests/integration/autopilot/unity_webapps_qml/tests/test_installedWebapp.py (+59/-0)
tests/integration/test-server.py (+0/-18)
tools/qml-launcher/qml-launcher.cpp (+14/-1)
To merge this branch: bzr merge lp:~abreu-alexandre/unity-webapps-qml/fix-issues-uncovered-by-qmlplugindump
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
WebApps Pending
Review via email: mp+226026@code.launchpad.net

Commit message

Fix issue with qmlplugindump using 100% cpu
Fix and expanded AP tests to properly test the installed webapps case

Description of the change

Fix issue with qmlplugindump using 100% cpu
Fix and expanded AP tests to properly test the installed webapps case

To post a comment you must log in.
128. By Alexandre Abreu

update debian install file

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
129. By Alexandre Abreu

forgotten files

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/unity-webapps-qml-autopilot.install'
--- debian/unity-webapps-qml-autopilot.install 2013-07-25 04:03:42 +0000
+++ debian/unity-webapps-qml-autopilot.install 2014-07-08 20:49:15 +0000
@@ -1,3 +1,4 @@
1tests/integration/autopilot/html/* usr/share/unity-webapps-qml/autopilot-tests/html/1tests/integration/autopilot/html/* usr/share/unity-webapps-qml/autopilot-tests/html/
2tests/integration/autopilot/data/* usr/share/unity-webapps-qml/autopilot-tests/data/
2tests/integration/autopilot/qml/* usr/share/unity-webapps-qml/autopilot-tests/qml/3tests/integration/autopilot/qml/* usr/share/unity-webapps-qml/autopilot-tests/qml/
3usr/lib/python*4usr/lib/python*
45
=== modified file 'src/Ubuntu/UnityWebApps/UnityWebApps.qml'
--- src/Ubuntu/UnityWebApps/UnityWebApps.qml 2014-06-26 01:46:36 +0000
+++ src/Ubuntu/UnityWebApps/UnityWebApps.qml 2014-07-08 20:49:15 +0000
@@ -150,6 +150,15 @@
150 */150 */
151 property var _opt_backendProxies: null151 property var _opt_backendProxies: null
152152
153 /*!
154 \qmlproperty string UnityWebApps::_opt_homepage
155
156 Used only for testing.
157 Allows an optional a homepage to be specified when running a local http server.
158
159 */
160 property string _opt_homepage: ""
161
153162
154 Settings {163 Settings {
155 id: settings164 id: settings
@@ -325,6 +334,9 @@
325 var idx = model.getWebappIndex(webappName);334 var idx = model.getWebappIndex(webappName);
326 var homepage = model.data(idx, UbuntuUnityWebApps.UnityWebappsAppModel.Homepage);335 var homepage = model.data(idx, UbuntuUnityWebApps.UnityWebappsAppModel.Homepage);
327336
337 if (!homepage || homepage.length === 0) {
338 homepage = _opt_homepage;
339 }
328 console.debug('Requesting the bindee to navigate to homepage: ' + homepage);340 console.debug('Requesting the bindee to navigate to homepage: ' + homepage);
329341
330 // We recreate a bindee object, but we call any function that requires342 // We recreate a bindee object, but we call any function that requires
@@ -352,7 +364,7 @@
352364
353 Component.onCompleted: {365 Component.onCompleted: {
354 if (model) {366 if (model) {
355 model.modelChanged.connect(function() { __setupNamedWebappEnvironment() });367 __setupNamedWebappEnvironment();
356 }368 }
357 }369 }
358370
@@ -360,6 +372,12 @@
360 \internal372 \internal
361373
362 */374 */
375 onModelChanged: model.modelContentChanged.connect(__setupNamedWebappEnvironment)
376
377 /*!
378 \internal
379
380 */
363 onBindeeChanged: {381 onBindeeChanged: {
364 // cleanup old refs & go382 // cleanup old refs & go
365 webapps.__unbind();383 webapps.__unbind();
366384
=== modified file 'src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js'
--- src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js 2014-06-26 01:48:23 +0000
+++ src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js 2014-07-08 20:49:15 +0000
@@ -71,6 +71,10 @@
71 return;71 return;
7272
73 var context = this.webview.context;73 var context = this.webview.context;
74 if (!context) {
75 console.error('No context found for the current Oxide webview. Cannot inject user scripts.');
76 return;
77 }
7478
75 for (var i = 0; i < userScriptUrls.length; ++i) {79 for (var i = 0; i < userScriptUrls.length; ++i) {
76 var scriptStart = "import com.canonical.Oxide 1.0 as Oxide; Oxide.UserScript { context:";80 var scriptStart = "import com.canonical.Oxide 1.0 as Oxide; Oxide.UserScript { context:";
7781
=== modified file 'src/Ubuntu/UnityWebApps/plugin/plugin.pro'
--- src/Ubuntu/UnityWebApps/plugin/plugin.pro 2014-03-25 20:56:01 +0000
+++ src/Ubuntu/UnityWebApps/plugin/plugin.pro 2014-07-08 20:49:15 +0000
@@ -35,7 +35,6 @@
35 unity-webapps-api-mediaplayer.cpp \35 unity-webapps-api-mediaplayer.cpp \
36 unity-webapps-app-model.cpp \36 unity-webapps-app-model.cpp \
37 unity-webapps-app-manifest-parser.cpp \37 unity-webapps-app-manifest-parser.cpp \
38 unity-webapps-app-model-filter-proxy.cpp \
39 unity-webapps-app-infos.cpp \38 unity-webapps-app-infos.cpp \
40 unity-webapps-desktop-infos.cpp \39 unity-webapps-desktop-infos.cpp \
41 unity-webapps-icon-utils.cpp \40 unity-webapps-icon-utils.cpp \
@@ -54,7 +53,6 @@
54 unity-webapps-app-model.h \53 unity-webapps-app-model.h \
55 unity-webapps-app-manifest-parser.h \54 unity-webapps-app-manifest-parser.h \
56 unity-webapps-common-priv.h \55 unity-webapps-common-priv.h \
57 unity-webapps-app-model-filter-proxy.h \
58 unity-webapps-app-infos.h \56 unity-webapps-app-infos.h \
59 unity-webapps-desktop-infos.h \57 unity-webapps-desktop-infos.h \
60 unity-webapps-icon-utils.h \58 unity-webapps-icon-utils.h \
6159
=== modified file 'src/Ubuntu/UnityWebApps/plugin/qml-plugin.cpp'
--- src/Ubuntu/UnityWebApps/plugin/qml-plugin.cpp 2014-03-21 20:07:16 +0000
+++ src/Ubuntu/UnityWebApps/plugin/qml-plugin.cpp 2014-07-08 20:49:15 +0000
@@ -26,7 +26,6 @@
26#include "unity-webapps-api-messaging-menu.h"26#include "unity-webapps-api-messaging-menu.h"
27#include "unity-webapps-api-launcher.h"27#include "unity-webapps-api-launcher.h"
28#include "unity-webapps-api-mediaplayer.h"28#include "unity-webapps-api-mediaplayer.h"
29#include "unity-webapps-app-model-filter-proxy.h"
30#include "unity-webapps-app-model.h"29#include "unity-webapps-app-model.h"
31#include "unity-webapps-app-infos.h"30#include "unity-webapps-app-infos.h"
3231
@@ -55,7 +54,6 @@
5554
56 // misc55 // misc
57 qmlRegisterType<UnityWebappsAppModel> (uri, 0, 1, "UnityWebappsAppModel");56 qmlRegisterType<UnityWebappsAppModel> (uri, 0, 1, "UnityWebappsAppModel");
58 qmlRegisterType<UnityWebappsAppModelFilterProxy> (uri, 0, 1, "UnityWebappsAppModelFilterProxy");
59 qmlRegisterType<UnityWebappsCallback> (uri, 0, 1, "UnityWebappsCallback");57 qmlRegisterType<UnityWebappsCallback> (uri, 0, 1, "UnityWebappsCallback");
60 qmlRegisterType<UnityWebappsAppInfos> (uri, 0, 1, "UnityWebappsAppInfos");58 qmlRegisterType<UnityWebappsAppInfos> (uri, 0, 1, "UnityWebappsAppInfos");
6159
6260
=== modified file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-infos.cpp'
--- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-infos.cpp 2014-03-07 16:48:42 +0000
+++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-infos.cpp 2014-07-08 20:49:15 +0000
@@ -28,7 +28,8 @@
2828
2929
30UnityWebappsAppInfos::UnityWebappsAppInfos(QObject *parent)30UnityWebappsAppInfos::UnityWebappsAppInfos(QObject *parent)
31 : QObject(parent)31 : QObject(parent),
32 _model(NULL)
32{}33{}
3334
34UnityWebappsAppInfos::~UnityWebappsAppInfos()35UnityWebappsAppInfos::~UnityWebappsAppInfos()
3536
=== removed file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model-filter-proxy.cpp'
--- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model-filter-proxy.cpp 2014-01-17 15:51:27 +0000
+++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model-filter-proxy.cpp 1970-01-01 00:00:00 +0000
@@ -1,76 +0,0 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This file is part of unity-webapps-qml.
5 *
6 * unity-webapps-qml is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * unity-webapps-qml is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "unity-webapps-app-model-filter-proxy.h"
20
21#include "unity-webapps-app-model.h"
22
23
24UnityWebappsAppModelFilterProxy::UnityWebappsAppModelFilterProxy(QObject *parent)
25 : QSortFilterProxyModel(parent)
26{}
27
28
29UnityWebappsAppModelFilterProxy::~UnityWebappsAppModelFilterProxy()
30{}
31
32
33UnityWebappsAppModel* UnityWebappsAppModelFilterProxy::sourceModel () const
34{
35 return sourceModel();
36}
37
38
39void UnityWebappsAppModelFilterProxy::setsourceModel (UnityWebappsAppModel * model)
40{
41 setSourceModel(model);
42
43 Q_EMIT sourceModelChanged();
44}
45
46
47QString UnityWebappsAppModelFilterProxy::webappName () const
48{
49 return _name;
50}
51
52
53void UnityWebappsAppModelFilterProxy::setwebappName (const QString& name)
54{
55 _name = name;
56
57 Q_EMIT webappNameChanged();
58}
59
60
61bool UnityWebappsAppModelFilterProxy::filterAcceptsRow(int source_row,
62 const QModelIndex &source_parent) const
63{
64 if (_name.isEmpty() || !sourceModel())
65 {
66 // filter out everything
67 return false;
68 }
69
70 QString rowName =
71 sourceModel()->data(sourceModel()->index(source_row, 0, source_parent),
72 UnityWebappsAppModel::Name).toString();
73
74 return 0 == _name.toLower().compare(rowName.toLower());
75}
76
770
=== removed file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model-filter-proxy.h'
--- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model-filter-proxy.h 2014-01-17 15:51:27 +0000
+++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model-filter-proxy.h 1970-01-01 00:00:00 +0000
@@ -1,87 +0,0 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This file is part of unity-webapps-qml.
5 *
6 * unity-webapps-qml is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * unity-webapps-qml is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#if !defined(__UNITY_WEBAPPS_APP_MODEL_FILTER_PROXY_H__)
20#define __UNITY_WEBAPPS_APP_MODEL_FILTER_PROXY_H__
21
22// Qt
23#include <QHash>
24#include <QSharedPointer>
25#include <QSortFilterProxyModel>
26
27
28class UnityWebappsAppModel;
29
30/*!
31 * \brief The UnityWebappsAppModelFilterProxy class
32 */
33class UnityWebappsAppModelFilterProxy : public QSortFilterProxyModel
34{
35 Q_OBJECT
36
37 Q_PROPERTY(QString webappName READ webappName WRITE setwebappName NOTIFY webappNameChanged)
38 Q_PROPERTY(UnityWebappsAppModel * sourceModel READ sourceModel WRITE setsourceModel NOTIFY sourceModelChanged)
39
40
41public:
42 UnityWebappsAppModelFilterProxy(QObject *parent = 0);
43 virtual ~UnityWebappsAppModelFilterProxy();
44
45 /*!
46 * \brief webappName
47 * \return
48 */
49 QString webappName () const;
50
51 /*!
52 * \brief setwebappName
53 * \param name
54 */
55 void setwebappName (const QString& name);
56
57 /*!
58 * \brief sourceModel
59 * \return
60 */
61 UnityWebappsAppModel * sourceModel() const;
62
63 /*!
64 * \brief setSourceModel
65 * \param model
66 */
67 void setsourceModel(UnityWebappsAppModel * model);
68
69
70Q_SIGNALS:
71
72 void webappNameChanged () const;
73 void sourceModelChanged () const;
74
75
76protected:
77
78 // From QSortFilterProxyModel::filterAcceptsRow
79 bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const;
80
81
82private:
83
84 QString _name;
85};
86
87#endif // __UNITY_WEBAPPS_APP_MODEL_FILTER_PROXY_H__
880
=== modified file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp'
--- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp 2014-05-22 08:54:56 +0000
+++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp 2014-07-08 20:49:15 +0000
@@ -301,7 +301,7 @@
301 content);301 content);
302 }302 }
303303
304 Q_EMIT modelChanged();304 Q_EMIT modelContentChanged();
305}305}
306306
307QString307QString
308308
=== modified file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h'
--- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h 2014-05-22 08:54:56 +0000
+++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h 2014-07-08 20:49:15 +0000
@@ -137,7 +137,7 @@
137Q_SIGNALS:137Q_SIGNALS:
138138
139 void searchPathChanged(const QString & path);139 void searchPathChanged(const QString & path);
140 void modelChanged();140 void modelContentChanged();
141141
142142
143private Q_SLOTS:143private Q_SLOTS:
144144
=== modified file 'tests/integration/autopilot/autopilot.pro'
--- tests/integration/autopilot/autopilot.pro 2013-08-26 20:16:16 +0000
+++ tests/integration/autopilot/autopilot.pro 2014-07-08 20:49:15 +0000
@@ -5,5 +5,10 @@
5 $$system(ls ./html/*) \5 $$system(ls ./html/*) \
6 $$system(ls ./unity_webapps_qml/emulators/*.py) \6 $$system(ls ./unity_webapps_qml/emulators/*.py) \
7 $$system(ls ./unity_webapps_qml/tests/*.py) \7 $$system(ls ./unity_webapps_qml/tests/*.py) \
8 $$system(ls ./data/installed-webapps/*)8 $$system(ls ./unity_webapps_qml/*.py) \
99 $$system(ls ./data/*/*) \
10 unity_webapps_qml/tests/test_installedWebapp.py \
11 unity_webapps_qml/tests/fake_servers.py \
12 qml/WebviewBackendWebkit.qml \
13 qml/WebviewBackendOxide.qml \
14 qml/message-server.js
1015
=== added directory 'tests/integration/autopilot/data'
=== added directory 'tests/integration/autopilot/data/all-in-same-folder'
=== added file 'tests/integration/autopilot/data/all-in-same-folder/script.user.js'
--- tests/integration/autopilot/data/all-in-same-folder/script.user.js 1970-01-01 00:00:00 +0000
+++ tests/integration/autopilot/data/all-in-same-folder/script.user.js 2014-07-08 20:49:15 +0000
@@ -0,0 +1,1 @@
1document.getElementById('content').innerHTML="WebApp Script Injected"
02
=== added file 'tests/integration/autopilot/data/all-in-same-folder/webapp-properties.json'
--- tests/integration/autopilot/data/all-in-same-folder/webapp-properties.json 1970-01-01 00:00:00 +0000
+++ tests/integration/autopilot/data/all-in-same-folder/webapp-properties.json 2014-07-08 20:49:15 +0000
@@ -0,0 +1,8 @@
1{
2 "includes": ["http://localhost:*/*"],
3 "name": "ExtendedWebappProperties",
4 "scripts": ["script.user.js"],
5 "domain":"",
6 "homepage":"",
7 "user-agent-override": "My Override"
8}
09
=== added directory 'tests/integration/autopilot/data/unity-webapps-normal'
=== added file 'tests/integration/autopilot/data/unity-webapps-normal/manifest.json'
--- tests/integration/autopilot/data/unity-webapps-normal/manifest.json 1970-01-01 00:00:00 +0000
+++ tests/integration/autopilot/data/unity-webapps-normal/manifest.json 2014-07-08 20:49:15 +0000
@@ -0,0 +1,7 @@
1{
2 "includes": ["http://localhost:*/*"],
3 "name": "Normal",
4 "scripts": ["script.user.js"],
5 "domain":"",
6 "homepage":""
7}
08
=== added file 'tests/integration/autopilot/data/unity-webapps-normal/script.user.js'
--- tests/integration/autopilot/data/unity-webapps-normal/script.user.js 1970-01-01 00:00:00 +0000
+++ tests/integration/autopilot/data/unity-webapps-normal/script.user.js 2014-07-08 20:49:15 +0000
@@ -0,0 +1,1 @@
1document.getElementById('content').innerHTML="WebApp Script Injected"
02
=== added directory 'tests/integration/autopilot/data/unity-webapps-with-altered-ua-string'
=== added file 'tests/integration/autopilot/data/unity-webapps-with-altered-ua-string/manifest.json'
--- tests/integration/autopilot/data/unity-webapps-with-altered-ua-string/manifest.json 1970-01-01 00:00:00 +0000
+++ tests/integration/autopilot/data/unity-webapps-with-altered-ua-string/manifest.json 2014-07-08 20:49:15 +0000
@@ -0,0 +1,8 @@
1{
2 "includes": ["http://localhost:*/*"],
3 "name": "AlteredUAWebapp",
4 "scripts": ["script.user.js"],
5 "domain":"",
6 "homepage":"",
7 "user-agent-override": "My Override"
8}
09
=== added file 'tests/integration/autopilot/data/unity-webapps-with-altered-ua-string/script.user.js'
--- tests/integration/autopilot/data/unity-webapps-with-altered-ua-string/script.user.js 1970-01-01 00:00:00 +0000
+++ tests/integration/autopilot/data/unity-webapps-with-altered-ua-string/script.user.js 2014-07-08 20:49:15 +0000
@@ -0,0 +1,1 @@
1document.getElementById('content').innerHTML="WebApp Script Injected"
02
=== modified file 'tests/integration/autopilot/qml/FullWebViewApp.qml'
--- tests/integration/autopilot/qml/FullWebViewApp.qml 2014-05-13 17:48:43 +0000
+++ tests/integration/autopilot/qml/FullWebViewApp.qml 2014-07-08 20:49:15 +0000
@@ -18,10 +18,9 @@
1818
19import QtQuick 2.019import QtQuick 2.0
20import QtQuick.Window 2.020import QtQuick.Window 2.0
21import QtWebKit 3.0
22import QtWebKit.experimental 1.0
23import Ubuntu.Unity.Action 1.0 as UnityActions21import Ubuntu.Unity.Action 1.0 as UnityActions
24import Ubuntu.UnityWebApps 0.122import Ubuntu.UnityWebApps 0.1
23import "."
2524
26import "dom-introspection-utils.js" as DomIntrospectionUtils25import "dom-introspection-utils.js" as DomIntrospectionUtils
2726
@@ -36,15 +35,25 @@
36 signal resultUpdated(string message)35 signal resultUpdated(string message)
3736
38 function evalInPageUnsafe(expr) {37 function evalInPageUnsafe(expr) {
39 var tid = DomIntrospectionUtils.gentid();38 if (webView && webView.experimental) {
40 console.log(DomIntrospectionUtils.wrapJsCommands(expr))39 webView.experimental.evaluateJavaScript(DomIntrospectionUtils.wrapJsCommands(expr),
41 webView.experimental.evaluateJavaScript(DomIntrospectionUtils.wrapJsCommands(expr),40 function(result) {
42 function(result) { console.log('Result: ' + result); root.resultUpdated(DomIntrospectionUtils.createResult(result)); });41 console.log('Result: ' + result);
42 root.resultUpdated(DomIntrospectionUtils.createResult(result));
43 });
44 }
45 else {
46 root.resultUpdated(DomIntrospectionUtils.createResult(webView.evaluateCode("return navigator.userAgent", true)))
47 }
43 }48 }
4449
45 property alias url: webView.url50 property var webView: null
51
52 property bool useOxide: false
53 property string url: ""
46 property string webappName: ""54 property string webappName: ""
47 property string webappSearchPath: ""55 property string webappSearchPath: ""
56 property string webappHomepage: ""
4857
49 UnityActions.ActionManager {58 UnityActions.ActionManager {
50 localContexts: [webappsActionsContext]59 localContexts: [webappsActionsContext]
@@ -54,21 +63,37 @@
54 active: true63 active: true
55 }64 }
5665
57 WebView {66 Loader {
58 id: webView67 id: webviewLoader
59 objectName: "webview"68 onLoaded: {
6069 webView = webviewLoader.item
70 }
71 }
72
73 Component.onCompleted: {
74 var webviewSource = useOxide ?
75 Qt.resolvedUrl("WebviewBackendOxide.qml")
76 : Qt.resolvedUrl("WebviewBackendWebkit.qml");
77 var override = webappName && webappModel.exists(webappName) ?
78 webappModel.userAgentOverrideFor(webappName) : ""
79 webviewLoader.setSource(webviewSource,
80 { url: root.url,
81 localUserAgentOverride: override})
82 }
83
84 Loader {
85 id: unityWebappsComponentLoader
61 anchors.fill: parent86 anchors.fill: parent
62 width: parent.width87 sourceComponent: webView !== null && webappName.length !== 0 ? unityWebappsComponent : null
63 height: parent.height88 }
6489
65 experimental.userScripts: []90 UnityWebappsAppModel {
66 experimental.preferences.navigatorQtObjectEnabled: true91 id: webappModel
67 experimental.preferences.developerExtrasEnabled: true92 searchPath: root.webappSearchPath
6893 }
69 function getUnityWebappsProxies() {94
70 return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView);95 Component {
71 }96 id: unityWebappsComponent
7297
73 UnityWebApps {98 UnityWebApps {
74 id: webapps99 id: webapps
@@ -76,8 +101,8 @@
76 actionsContext: webappsActionsContext101 actionsContext: webappsActionsContext
77 name: root.webappName102 name: root.webappName
78 bindee: webView103 bindee: webView
79 //searchPath: '/home/alex/dev/work/webapps/branches/webapps-qml/latest/examples/data/userscripts'104 _opt_homepage: root.webappHomepage
80 model: UnityWebappsAppModel { }105 model: webappModel
81 }106 }
82 }107 }
83}108}
84109
=== added file 'tests/integration/autopilot/qml/WebviewBackendOxide.qml'
--- tests/integration/autopilot/qml/WebviewBackendOxide.qml 1970-01-01 00:00:00 +0000
+++ tests/integration/autopilot/qml/WebviewBackendOxide.qml 2014-07-08 20:49:15 +0000
@@ -0,0 +1,87 @@
1import QtQuick 2.0
2import QtTest 1.0
3import com.canonical.Oxide 1.0 as Oxide
4import Ubuntu.UnityWebApps 0.1
5
6Oxide.WebView {
7 id: webView
8 objectName: "webview"
9
10 property string localUserAgentOverride: ""
11
12 function _waitForResult(req, timeout) {
13 var result;
14 var error;
15 req.onreply = function(response) {
16 result = response;
17 error = 0;
18 };
19 req.onerror = function(error_code, msg) {
20 result = msg;
21 error = error_code;
22 };
23 webView._waitFor(function() { return error !== undefined; },
24 timeout);
25
26 if (error > 0) {
27 console.error('Error:' + error + ', result:' + result)
28 } else if (error === 0) {
29 return result;
30 } else {
31 throw new Error("Message call timed out");
32 }
33 }
34
35 function _waitFor(predicate, timeout) {
36 timeout = timeout || 5000000;
37 var end = Date.now() + timeout;
38 var i = Date.now();
39 while (i < end && !predicate()) {
40 qtest_testResult.wait(50);
41 i = Date.now();
42 }
43 return predicate();
44 }
45
46 function evaluateCode(code, wrap) {
47 var value = webView._waitForResult(
48 webView.rootFrame.sendMessage(
49 "webview-oxide://test/",
50 "EVALUATE-CODE",
51 { code: code,
52 wrap: wrap === undefined ? false : wrap }));
53 return value ? value.result : undefined;
54 }
55
56 context: Oxide.WebContext {
57 userAgent: webView.localUserAgentOverride.length === 0 ? undefined : webView.localUserAgentOverride
58 userScripts: [
59 Oxide.UserScript {
60 context: "webview-oxide://test/"
61 url: Qt.resolvedUrl("message-server.js")
62 matchAllFrames: true
63 }
64 ]
65 }
66
67 function getUnityWebappsProxies() {
68 return UnityWebAppsUtils.makeProxiesForWebViewBindee(webView);
69 }
70
71 onJavaScriptConsoleMessage: {
72 var msg = "[JS] (%1:%2) %3".arg(sourceId).arg(lineNumber).arg(message)
73 if (level === Oxide.WebView.LogSeverityVerbose) {
74 console.log(msg)
75 } else if (level === Oxide.WebView.LogSeverityInfo) {
76 console.info(msg)
77 } else if (level === Oxide.WebView.LogSeverityWarning) {
78 console.warn(msg)
79 } else if ((level === Oxide.WebView.LogSeverityError) ||
80 (level === Oxide.WebView.LogSeverityErrorReport) ||
81 (level === Oxide.WebView.LogSeverityFatal)) {
82 console.error(msg)
83 }
84 }
85
86 TestResult { id: qtest_testResult }
87}
088
=== added file 'tests/integration/autopilot/qml/WebviewBackendWebkit.qml'
--- tests/integration/autopilot/qml/WebviewBackendWebkit.qml 1970-01-01 00:00:00 +0000
+++ tests/integration/autopilot/qml/WebviewBackendWebkit.qml 2014-07-08 20:49:15 +0000
@@ -0,0 +1,19 @@
1import QtQuick 2.0
2import QtWebKit 3.0
3import QtWebKit.experimental 1.0
4import Ubuntu.UnityWebApps 0.1
5
6WebView {
7 id: webView
8 objectName: "webview"
9
10 property string localUserAgentOverride: ""
11
12 experimental.userScripts: []
13 experimental.preferences.navigatorQtObjectEnabled: true
14 experimental.preferences.developerExtrasEnabled: true
15
16 function getUnityWebappsProxies() {
17 return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView);
18 }
19}
020
=== added file 'tests/integration/autopilot/qml/message-server.js'
--- tests/integration/autopilot/qml/message-server.js 1970-01-01 00:00:00 +0000
+++ tests/integration/autopilot/qml/message-server.js 2014-07-08 20:49:15 +0000
@@ -0,0 +1,29 @@
1// Copyright (C) 2014 Canonical Ltd.
2
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7
8// This library 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 GNU
11// Lesser General Public License for more details.
12
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17oxide.addMessageHandler("EVALUATE-CODE", function(msg) {
18 var code = msg.args.code;
19 if (msg.args.wrap) {
20 code = "(function() {" + code + "})()";
21 }
22 try {
23 var result = eval(code);
24 msg.reply({result: result});
25 } catch(e) {
26 msg.error("Code threw exception: \"" + e + "\"");
27 }
28});
29
030
=== removed directory 'tests/integration/autopilot/unity_webapps_qml/emulators'
=== removed file 'tests/integration/autopilot/unity_webapps_qml/emulators/__init__.py'
--- tests/integration/autopilot/unity_webapps_qml/emulators/__init__.py 2013-06-17 14:46:51 +0000
+++ tests/integration/autopilot/unity_webapps_qml/emulators/__init__.py 1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2013 Canonical
3#
4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
7
80
=== modified file 'tests/integration/autopilot/unity_webapps_qml/tests/__init__.py'
--- tests/integration/autopilot/unity_webapps_qml/tests/__init__.py 2014-04-22 15:40:04 +0000
+++ tests/integration/autopilot/unity_webapps_qml/tests/__init__.py 2014-07-08 20:49:15 +0000
@@ -15,62 +15,86 @@
1515
16from testtools.matchers import Contains, Equals, GreaterThan16from testtools.matchers import Contains, Equals, GreaterThan
17from autopilot.matchers import Eventually17from autopilot.matchers import Eventually
18from unity_webapps_qml.tests import fake_servers
1819
19from unity.emulators.unity import Unity20from unity.emulators.unity import Unity
2021
21from unity.tests import UnityTestCase22from unity.tests import UnityTestCase
2223
24LOCAL_QML_LAUNCHER_APP_PATH = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../../../../tools/qml-launcher/unity-webapps-qml-launcher')
25INSTALLED_QML_LAUNCHER_APP_PATH = 'unity-webapps-qml-launcher'
26
27# TODO create __init__.py.in
28LOCAL_BROWSER_CONTAINER_PATH = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../qml/FullWebViewApp.qml')
29INSTALLED_BROWSER_CONTAINER_PATH = '/usr/share/unity-webapps-qml/autopilot-tests/qml/FullWebViewApp.qml'
30
31BASE_URL = ''
32
23class UnityWebappsTestCaseBase(UnityTestCase):33class UnityWebappsTestCaseBase(UnityTestCase):
24 LOCAL_QML_LAUNCHER_APP_PATH = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../../../../tools/qml-launcher/unity-webapps-qml-launcher')34 def setUp(self):
25 INSTALLED_QML_LAUNCHER_APP_PATH = 'unity-webapps-qml-launcher'35 super(UnityWebappsTestCaseBase, self).setUp()
2636 self.use_oxide = False
27 # TODO create __init__.py.in37
28 LOCAL_BROWSER_CONTAINER_PATH = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../qml/FullWebViewApp.qml')38 def tearDown(self):
29 INSTALLED_BROWSER_CONTAINER_PATH = '/usr/share/unity-webapps-qml/autopilot-tests/qml/FullWebViewApp.qml'39 super(UnityWebappsTestCaseBase, self).tearDown()
30
31 BASE_URL = ''
3240
33 def create_file_url(self, path):41 def create_file_url(self, path):
34 return 'file://' + path42 return 'file://' + path
3543
36 def get_qml_browser_container_path(self):44 def get_qml_browser_container_path(self):
37 if os.path.exists(self.LOCAL_BROWSER_CONTAINER_PATH):45 if os.path.exists(LOCAL_BROWSER_CONTAINER_PATH):
38 return self.LOCAL_BROWSER_CONTAINER_PATH46 return LOCAL_BROWSER_CONTAINER_PATH
39 return self.INSTALLED_BROWSER_CONTAINER_PATH47 return INSTALLED_BROWSER_CONTAINER_PATH
4048
41 def get_qml_launcher_path(self):49 def get_qml_launcher_path(self):
42 if os.path.exists(self.LOCAL_QML_LAUNCHER_APP_PATH):50 if os.path.exists(LOCAL_QML_LAUNCHER_APP_PATH):
43 return self.LOCAL_QML_LAUNCHER_APP_PATH51 return LOCAL_QML_LAUNCHER_APP_PATH
44 return self.INSTALLED_QML_LAUNCHER_APP_PATH52 return INSTALLED_QML_LAUNCHER_APP_PATH
4553
46 def get_launch_params(self, url):54 def get_launch_params(self,
47 base_params = ['--qml=' + self.get_qml_browser_container_path(), '--url=' + url, '--app-id=unitywebappsqmllauncher', '--webappName=unitywebappsqmllauncher']55 url,
48 if os.path.exists(self.LOCAL_QML_LAUNCHER_APP_PATH):56 webapp_name='unitywebappsqmllauncher',
57 webapp_search_path="",
58 webapp_homepage="",
59 use_oxide=False):
60 base_params = ['--qml=' + self.get_qml_browser_container_path(),
61 '--app-id=' + webapp_name,
62 '--webappName=' + webapp_name,
63 '--webappSearchPath=' + webapp_search_path]
64
65 if len(webapp_homepage) != 0:
66 base_params.append('--webappHomepage=' + webapp_homepage)
67
68 if len(url) != 0:
69 base_params.append('--url=' + url)
70
71 if use_oxide:
72 base_params.append('--useOxide')
73
74 if os.path.exists(LOCAL_QML_LAUNCHER_APP_PATH):
49 # we are local75 # we are local
50 base_params.append('--import=' + os.path.join (os.path.dirname(os.path.realpath(__file__)), '../../../../../src'))76 base_params.append('--import=' + os.path.join (os.path.dirname(os.path.realpath(__file__)),
77 '../../../../../src'))
78
51 return base_params79 return base_params
5280
53 def launch_with_html_filepath(self, html_filepath):81 def launch_with_html_filepath(self, html_filepath):
54 self.assertThat(os.path.exists(html_filepath), Equals(True))82 self.assertThat(os.path.exists(html_filepath), Equals(True))
55
56 url = self.create_file_url(html_filepath)83 url = self.create_file_url(html_filepath)
57 params = self.get_launch_params(url)84
5885 self.launch_application(self.get_launch_params(url))
59 print 'Launching test with params:', params86 self.assert_url_eventually_loaded(url)
87
88 def launch_application(self, args):
89 print 'Launching test with params:', args, "with", self.get_qml_launcher_path()
90
60 self.app = self.launch_test_application(self.get_qml_launcher_path(),91 self.app = self.launch_test_application(self.get_qml_launcher_path(),
61 *params,92 *args,
62 app_type='qt')93 app_type='qt')
6394
64 self.assert_url_eventually_loaded(url)
65 self.webviewContainer = self.get_webviewContainer()95 self.webviewContainer = self.get_webviewContainer()
66 self.watcher = self.webviewContainer.watch_signal('resultUpdated(QString)')96 self.watcher = self.webviewContainer.watch_signal('resultUpdated(QString)')
6797
68 def setUp(self):
69 super(UnityWebappsTestCaseBase, self).setUp()
70
71 def tearDown(self):
72 super(UnityWebappsTestCaseBase, self).tearDown()
73
74 def pick_app_launcher(self, app_path):98 def pick_app_launcher(self, app_path):
75 # force Qt app introspection:99 # force Qt app introspection:
76 from autopilot.introspection.qt import QtApplicationLauncher100 from autopilot.introspection.qt import QtApplicationLauncher
@@ -99,3 +123,14 @@
99 results = json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])123 results = json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])
100 return results.has_key('result') and results['result'] or None124 return results.has_key('result') and results['result'] or None
101125
126class WebappsTestCaseBaseWithLocalHttpContentBase(UnityWebappsTestCaseBase):
127 def setUp(self):
128 super(WebappsTestCaseBaseWithLocalHttpContentBase, self).setUp()
129 self.http_server = fake_servers.WebappsQmlContentHttpServer()
130 self.addCleanup(self.http_server.shutdown)
131 self.base_url = "http://localhost:{}/".format(self.http_server.port)
132
133 def launch_with_webapp(self, name, webapp_search_path, use_oxide=False):
134 self.use_oxide = use_oxide
135 self.launch_application(self.get_launch_params("", name, webapp_search_path, self.base_url, use_oxide))
136 self.assert_url_eventually_loaded(self.base_url)
102137
=== added file 'tests/integration/autopilot/unity_webapps_qml/tests/fake_servers.py'
--- tests/integration/autopilot/unity_webapps_qml/tests/fake_servers.py 1970-01-01 00:00:00 +0000
+++ tests/integration/autopilot/unity_webapps_qml/tests/fake_servers.py 2014-07-08 20:49:15 +0000
@@ -0,0 +1,70 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2014 Canonical
3#
4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
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 General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16""" Autopilot tests for the unity_webapps_qml package """
17
18import BaseHTTPServer
19import logging
20import threading
21
22
23class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
24 def serve_content(self, content, mime_type='text/html'):
25 self.send_header('Content-type', mime_type)
26 self.end_headers()
27 self.wfile.write(content.encode())
28
29 def basic_html_content(self):
30 return """
31<html>
32<head>
33<title>Some content</title>
34</head>
35<body>
36<div id='content'>
37This is some content
38</div>
39</body>
40</html>
41 """
42
43 def do_GET(self):
44 if self.path == '/':
45 self.send_response(200)
46 self.serve_content(self.basic_html_content())
47 else:
48 self.send_error(404)
49
50
51class WebappsQmlContentHttpServer(object):
52 def __init__(self):
53 super(WebappsQmlContentHttpServer, self).__init__()
54 self.server = BaseHTTPServer.HTTPServer(("", 0), RequestHandler)
55 self.server.allow_reuse_address = True
56 self.server_thread = threading.Thread(target=self.server.serve_forever)
57 self.server_thread.start()
58 logging.info("now serving on port {}".format(self.server.server_port))
59
60 @property
61 def port(self):
62 return self.server.server_port
63
64 def run(self):
65 self.server.serve_forever()
66
67 def shutdown(self):
68 self.server.shutdown()
69 self.server.server_close()
70 self.server_thread.join()
071
=== added file 'tests/integration/autopilot/unity_webapps_qml/tests/test_installedWebapp.py'
--- tests/integration/autopilot/unity_webapps_qml/tests/test_installedWebapp.py 1970-01-01 00:00:00 +0000
+++ tests/integration/autopilot/unity_webapps_qml/tests/test_installedWebapp.py 2014-07-08 20:49:15 +0000
@@ -0,0 +1,59 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2013 Canonical
3#
4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
7
8from __future__ import absolute_import
9
10import time
11import os
12
13from testtools.matchers import Equals, GreaterThan, NotEquals
14from autopilot.matchers import Eventually
15
16from unity_webapps_qml.tests import WebappsTestCaseBaseWithLocalHttpContentBase
17
18LOCAL_HTML_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../data')
19INSTALLED_HTML_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/data'
20
21class InstalledWebappsTestCaseBase(WebappsTestCaseBaseWithLocalHttpContentBase):
22 def setUp(self):
23 super(InstalledWebappsTestCaseBase, self).setUp()
24
25 def get_webapp_install_folder(self):
26 if os.path.exists(LOCAL_HTML_TEST_FILE):
27 return os.path.abspath(LOCAL_HTML_TEST_FILE)
28 return INSTALLED_HTML_TEST_FILE
29
30 def test_normalWebappFound(self):
31 self.launch_with_webapp('Normal', self.get_webapp_install_folder())
32
33 self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True)))
34
35 expression = """
36 var contentElement = document.getElementById('content');
37 return contentElement.innerHTML;
38 """
39 self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(Equals("WebApp Script Injected")))
40
41 def test_webappWithUAOverrideFound(self):
42 self.launch_with_webapp('AlteredUAWebapp', self.get_webapp_install_folder(), True)
43 self.assertThat(lambda: self.eval_expression_in_page_unsafe('return navigator.userAgent;'), Eventually(Equals("My Override")))
44
45 def test_webappFoundWithSpecialWebappPropertiesFile(self):
46 self.launch_with_webapp('ExtendedWebappProperties', self.get_webapp_install_folder() + '/all-in-same-folder')
47
48 self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True)))
49
50 expression = """
51 var contentElement = document.getElementById('content');
52 return contentElement.innerHTML;
53 """
54 self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(Equals("WebApp Script Injected")))
55
56 def test_webappPropertiesFileWithUA(self):
57 self.launch_with_webapp('ExtendedWebappProperties', self.get_webapp_install_folder() + '/all-in-same-folder', True)
58 self.assertThat(lambda: self.eval_expression_in_page_unsafe('return navigator.userAgent;'), Eventually(Equals("My Override")))
59
060
=== removed file 'tests/integration/test-server.py'
--- tests/integration/test-server.py 2013-05-29 15:03:32 +0000
+++ tests/integration/test-server.py 1970-01-01 00:00:00 +0000
@@ -1,18 +0,0 @@
1#!/usr/bin/env python
2
3import SocketServer
4import SimpleHTTPServer
5import urllib
6
7PORT = 8181
8
9class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
10 def do_GET(self):
11 if self.path == '/':
12 self.path = '/unity-integration.html'
13 return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
14
15httpd = SocketServer.TCPServer(('0.0.0.0', PORT), Proxy)
16print "serving at port", PORT
17httpd.serve_forever()
18
190
=== modified file 'tools/qml-launcher/qml-launcher.cpp'
--- tools/qml-launcher/qml-launcher.cpp 2014-04-22 15:40:04 +0000
+++ tools/qml-launcher/qml-launcher.cpp 2014-07-08 20:49:15 +0000
@@ -68,6 +68,7 @@
68 const QString QML_FILE_IMPORT_ARG_HEADER = "--import=";68 const QString QML_FILE_IMPORT_ARG_HEADER = "--import=";
69 const QString QML_APP_ID_ARG_HEADER = "--app-id=";69 const QString QML_APP_ID_ARG_HEADER = "--app-id=";
70 const QString QML_INSPECTOR_ARG_HEADER = "--inspector=";70 const QString QML_INSPECTOR_ARG_HEADER = "--inspector=";
71 const QString QML_USE_OXIDE_ARG_HEADER = "--useOxide";
71 const QString ARG_HEADER = "--";72 const QString ARG_HEADER = "--";
72 const QString VALUE_HEADER = "=";73 const QString VALUE_HEADER = "=";
73 QHash<QString, QString> properties;74 QHash<QString, QString> properties;
@@ -75,6 +76,7 @@
75 QString appid;76 QString appid;
76 QString importPath;77 QString importPath;
77 QString inspector;78 QString inspector;
79 bool useOxide = false;
78 bool maximized = false;80 bool maximized = false;
7981
80 Q_FOREACH(QString argument, app.arguments())82 Q_FOREACH(QString argument, app.arguments())
@@ -99,6 +101,11 @@
99 inspector = argument.right(argument.count() - QML_INSPECTOR_ARG_HEADER.count());101 inspector = argument.right(argument.count() - QML_INSPECTOR_ARG_HEADER.count());
100 }102 }
101 else103 else
104 if (argument.contains(QML_USE_OXIDE_ARG_HEADER))
105 {
106 useOxide = true;
107 }
108 else
102 if (argument.contains(QML_MAXIMIZED_ARG))109 if (argument.contains(QML_MAXIMIZED_ARG))
103 {110 {
104 maximized = true;111 maximized = true;
@@ -169,7 +176,7 @@
169 QQmlContext *context = new QQmlContext(engine.rootContext());176 QQmlContext *context = new QQmlContext(engine.rootContext());
170177
171 QQmlComponent component(&engine, qmlfile);178 QQmlComponent component(&engine, qmlfile);
172 QObject *object = component.create(context);179 QObject *object = component.beginCreate(context);
173180
174 if (!component.isReady()) {181 if (!component.isReady()) {
175 qWarning() << component.errorString();182 qWarning() << component.errorString();
@@ -192,6 +199,12 @@
192 object->setProperty(it.key().toStdString().c_str(), QUrl(it.value()));199 object->setProperty(it.key().toStdString().c_str(), QUrl(it.value()));
193 }200 }
194201
202 if (useOxide) {
203 object->setProperty("useOxide", true);
204 }
205
206 component.completeCreate();
207
195 if (window)208 if (window)
196 {209 {
197 if (maximized)210 if (maximized)

Subscribers

People subscribed via source and target branches

to all changes: