Merge lp:~abreu-alexandre/unity-webapps-qml/cleanup-and-fix-bindee-init into lp:unity-webapps-qml

Proposed by Alexandre Abreu
Status: Merged
Merged at revision: 114
Proposed branch: lp:~abreu-alexandre/unity-webapps-qml/cleanup-and-fix-bindee-init
Merge into: lp:unity-webapps-qml
Diff against target: 696 lines (+170/-87)
21 files modified
src/Ubuntu/UnityWebApps/UnityWebApps.js (+14/-3)
src/Ubuntu/UnityWebApps/UnityWebApps.qml (+40/-43)
src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js (+1/-1)
src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-manifest-parser.cpp (+7/-0)
src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-manifest-parser.h (+2/-0)
src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp (+22/-0)
src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h (+9/-1)
tests/integration/autopilot/html/test_webapps_api_injected.html (+17/-0)
tests/integration/autopilot/html/test_webapps_hud.html (+2/-2)
tests/integration/autopilot/qml/FullWebViewApp.qml (+2/-1)
tests/integration/autopilot/unity_webapps_qml/tests/__init__.py (+2/-1)
tests/integration/autopilot/unity_webapps_qml/tests/test_hud.py (+4/-5)
tests/integration/autopilot/unity_webapps_qml/tests/test_injectedOnWebapp.py (+13/-13)
tests/unit/test_plugin/data/manifests/valid-with-ua-override.json (+15/-0)
tests/unit/test_plugin/test_plugin.pro (+2/-1)
tests/unit/test_plugin/tst_manifestParser.cpp (+8/-0)
tests/unit/test_plugin/tst_manifestParser.h (+1/-1)
tests/unit/test_qml/tst_cleanup.qml (+4/-5)
tests/unit/test_qml/tst_dispatch.qml (+1/-5)
tests/unit/test_qml/tst_init.qml (+1/-5)
tools/qml-launcher/qml-launcher.cpp (+3/-0)
To merge this branch: bzr merge lp:~abreu-alexandre/unity-webapps-qml/cleanup-and-fix-bindee-init
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
WebApps Pending
Review via email: mp+216750@code.launchpad.net

Commit message

Add UA override capabilities to webapps; clean some code and tests,

Description of the change

Add UA override capabilities to webapps; clean some code and tests,

To post a comment you must log in.
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
1=== modified file 'src/Ubuntu/UnityWebApps/UnityWebApps.js'
2--- src/Ubuntu/UnityWebApps/UnityWebApps.js 2014-03-18 18:52:11 +0000
3+++ src/Ubuntu/UnityWebApps/UnityWebApps.js 2014-04-22 15:41:19 +0000
4@@ -36,11 +36,11 @@
5 * \param backends
6 * \param userscriptContent
7 */
8- function _UnityWebApps(parentItem, bindeeProxies, backends, userscripts) {
9+ function _UnityWebApps(parentItem, bindeeProxies) {
10 this._injected_unity_api_path = Qt.resolvedUrl('unity-webapps-api.js');
11 this._bindeeProxies = bindeeProxies;
12- this._backends = backends;
13- this._userscripts = userscripts || [];
14+ this._backends = null;
15+ this._userscripts = [];
16
17 this._bind();
18 };
19@@ -56,6 +56,14 @@
20 return this._bindeeProxies;
21 },
22
23+ setUserScriptsToInject: function(userscripts) {
24+ this._userscripts = userscripts;
25+ },
26+
27+ setBackends: function(backends) {
28+ this._backends = backends;
29+ },
30+
31 /**
32 * \internal
33 *
34@@ -168,6 +176,9 @@
35 *
36 */
37 _dispatchApiCall: function (name, args) {
38+ if ( ! this._backends)
39+ return;
40+
41 var names = name.split('.');
42 var reducetarget = this._backends;
43 try {
44
45=== modified file 'src/Ubuntu/UnityWebApps/UnityWebApps.qml'
46--- src/Ubuntu/UnityWebApps/UnityWebApps.qml 2014-03-26 15:52:46 +0000
47+++ src/Ubuntu/UnityWebApps/UnityWebApps.qml 2014-04-22 15:41:19 +0000
48@@ -201,15 +201,13 @@
49 return;
50 }
51
52- var backends = __createBackendsIfNeeded();
53-
54 var instance = new UnityWebAppsJs.UnityWebApps(webapps,
55- bindeeProxies,
56- backends,
57- webappUserscripts);
58-
59- internal.backends = backends;
60+ bindeeProxies,
61+ webappUserscripts);
62 internal.instance = instance;
63+
64+ if (internal.backends)
65+ internal.instance.setBackends(internal.backends)
66 }
67
68 /*!
69@@ -229,6 +227,18 @@
70 /*!
71 \internal
72
73+ */
74+ function __initBackends() {
75+ if (__isValidWebAppName(webapps.name)) {
76+ internal.backends = __createBackendsIfNeeded();
77+ if (internal.backends && internal.instance)
78+ internal.instance.setBackends(internal.backends);
79+ }
80+ }
81+
82+ /*!
83+ \internal
84+
85 PRIVATE FUNCTION: __isValidBindee
86 */
87 function __isValidBindee(bindee) {
88@@ -258,26 +268,12 @@
89 /*!
90 \internal
91
92- PRIVATE FUNCTION: __reset
93- */
94- function __reset() {
95- __unbind();
96-
97- if (typeof(name) === 'string' && name !== "")
98- UnityBackends.clearAll();
99- }
100-
101- /*!
102- \internal
103-
104 PRIVATE FUNCTION: __unbind
105 */
106 function __unbind() {
107- //TODO: make sure that now leaks here
108 if (internal.instance)
109 internal.instance.cleanup();
110 internal.instance = null;
111- internal.backends = null;
112 }
113
114 /*!
115@@ -334,31 +330,23 @@
116 /*!
117 \internal
118
119+ If running as a known webapp, setup the scripts are that to be injected
120+ (and provided by the model), and navigate to the proper homepage.
121 */
122- function __initWebappForName(name) {
123- webapps.__unbind();
124-
125- if (bindee != null)
126- webapps.__bind(bindee, __isValidWebAppForModel(name) ? __gatherWebAppUserscriptsIfAny(name) : null);
127-
128- if (__isValidWebAppName(name)) {
129+ function __setupNamedWebappEnvironment() {
130+ if (__isValidWebAppForModel(name)) {
131+ if (internal.instance) {
132+ var userScripts = __gatherWebAppUserscriptsIfAny(name);
133+ internal.instance.setUserScriptsToInject(userScripts);
134+ }
135 __navigateToWebappHomepageInBindee(name);
136 }
137-
138 }
139
140 Component.onCompleted: {
141- function oncompleted() {
142- __initWebappForName(name);
143- }
144- if ( ! internal.instance)
145- oncompleted();
146-
147 if (model) {
148- model.modelChanged.connect(oncompleted);
149+ model.modelChanged.connect(function() { __setupNamedWebappEnvironment() });
150 }
151-
152- internal.componentComplete = true;
153 }
154
155 /*!
156@@ -366,7 +354,15 @@
157
158 */
159 onBindeeChanged: {
160- //FIXME: we shouldn't allow bindee to change
161+ // cleanup old refs & go
162+ webapps.__unbind();
163+
164+ if (bindee != null) {
165+ webapps.__bind(bindee);
166+
167+ // if we are running as a named webapp
168+ __setupNamedWebappEnvironment();
169+ }
170 }
171
172 /*!
173@@ -374,9 +370,10 @@
174
175 */
176 onNameChanged: {
177- //FIXME: we shouldn't allow webapp names to change
178- if (internal.componentComplete)
179- __initWebappForName(name);
180+ __initBackends(webapps.name);
181+
182+ // if we are running as a proper named webapp
183+ __setupNamedWebappEnvironment();
184 }
185
186 /*!
187@@ -387,7 +384,6 @@
188 id: internal
189 property var instance: null
190 property var backends: null
191- property bool componentComplete: false
192 }
193
194
195@@ -449,6 +445,7 @@
196 return params.__unity_webapps_hidden.hostname.indexOf(params.domain) !== -1;
197 };
198
199+ UnityBackends.clearAll();
200 UnityBackends.createBackendDelegate(webapps);
201
202 return {
203
204=== modified file 'src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js'
205--- src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js 2014-04-02 18:16:34 +0000
206+++ src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js 2014-04-22 15:41:19 +0000
207@@ -221,7 +221,7 @@
208 * property is an object w/ a 'name' and 'type' (as in typeof()).
209 */
210 function formatUnityWebappsCall(type, serialized_args) {
211- return {target: "unity-webapps-call", name: type, args: serialized_args};
212+ return {target: "ubuntu-webapps-binding-call", name: type, args: serialized_args};
213 }
214
215
216
217=== modified file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-manifest-parser.cpp'
218--- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-manifest-parser.cpp 2014-01-17 15:51:27 +0000
219+++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-manifest-parser.cpp 2014-04-22 15:41:19 +0000
220@@ -111,6 +111,13 @@
221 }
222 infos->chromeOptions = parseChromeOptions(chromeOption);
223
224+ QString userAgentOverride;
225+ if (object.contains("user-agent-override")
226+ && object.value("user-agent-override").isString())
227+ {
228+ infos->userAgentOverride = object.value("user-agent-override").toString();
229+ }
230+
231 return true;
232 }
233
234
235=== modified file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-manifest-parser.h'
236--- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-manifest-parser.h 2014-01-17 15:51:27 +0000
237+++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-manifest-parser.h 2014-04-22 15:41:19 +0000
238@@ -46,6 +46,8 @@
239 QStringList requires;
240 // The currently selected chrome option for this WebApp
241 QStringList chromeOptions;
242+ // (optional) A User Agent override string to be used for the current webapp
243+ QString userAgentOverride;
244 };
245
246 /*!
247
248=== modified file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp'
249--- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp 2014-01-17 15:51:27 +0000
250+++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp 2014-04-22 15:41:19 +0000
251@@ -154,6 +154,8 @@
252 roles[Urls] = "urls";
253 roles[ScriptsContent] = "content";
254 roles[Scripts] = "scripts";
255+ roles[Chrome] = "chrome";
256+ roles[UserAgentOverride] = "useragent";
257 }
258 return roles;
259 }
260@@ -301,6 +303,22 @@
261 return script;
262 }
263
264+QString
265+UnityWebappsAppModel::userAgentOverrideFor(const QString & webappName) const
266+{
267+ if (!exists(webappName))
268+ return QString();
269+
270+ int idx = getWebappIndex(webappName);
271+ if (Q_UNLIKELY(idx == -1))
272+ {
273+ qDebug() << "Invalid index for a supposedly existing webapp: " << webappName;
274+ return QString();
275+ }
276+
277+ return data(idx, UserAgentOverride).toString();
278+}
279+
280 QStringList
281 UnityWebappsAppModel::getChromeOptionsFor(const QString & webappName) const
282 {
283@@ -488,8 +506,12 @@
284 }
285 return scripts;
286 }
287+
288 case ScriptsContent:
289 return webapp.data.content;
290+
291+ case UserAgentOverride:
292+ return webapp.data.manifest.userAgentOverride;
293 }
294
295 return QVariant();
296
297=== modified file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h'
298--- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h 2014-01-17 15:51:27 +0000
299+++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h 2014-04-22 15:41:19 +0000
300@@ -57,7 +57,8 @@
301 Homepage,
302 Scripts,
303 ScriptsContent,
304- Chrome
305+ Chrome,
306+ UserAgentOverride
307 };
308
309 // QAbstractListModel implementation
310@@ -101,6 +102,13 @@
311 */
312 Q_INVOKABLE QStringList getChromeOptionsFor(const QString & webappName) const;
313
314+
315+ /*!
316+ * \brief
317+ */
318+ Q_INVOKABLE QString userAgentOverrideFor(const QString & webappName) const;
319+
320+
321 /*!
322 * \brief
323 */
324
325=== modified file 'tests/integration/autopilot/html/test_webapps_api_injected.html'
326--- tests/integration/autopilot/html/test_webapps_api_injected.html 2013-07-09 12:45:17 +0000
327+++ tests/integration/autopilot/html/test_webapps_api_injected.html 2014-04-22 15:41:19 +0000
328@@ -4,6 +4,23 @@
329 <title>Unity Webapps QML test</title>
330
331 <script>
332+
333+var unity;
334+function onInit() {
335+ document.getElementById('content').innerHTML = 'initialized';
336+}
337+
338+var UBUNTU_WEBAPPS_API_READY_KEY = 'ubuntu-webapps-api-ready-key';
339+document.addEventListener('ubuntu-webapps-api-ready', function () {
340+ if ( ! window.localStorage[UBUNTU_WEBAPPS_API_READY_KEY]) {
341+ window.localStorage[UBUNTU_WEBAPPS_API_READY_KEY] = 0;
342+ }
343+ window.localStorage[UBUNTU_WEBAPPS_API_READY_KEY] ++;
344+
345+ unity = window.external.getUnityObject('1.0');
346+ unity.init({name: 'unity-webapps-qml-launcher', onInit: onInit});
347+}, false);
348+
349 </script>
350
351 </head>
352
353=== modified file 'tests/integration/autopilot/html/test_webapps_hud.html'
354--- tests/integration/autopilot/html/test_webapps_hud.html 2013-09-05 21:38:15 +0000
355+++ tests/integration/autopilot/html/test_webapps_hud.html 2014-04-22 15:41:19 +0000
356@@ -1,4 +1,4 @@
357-<html>
358+ <html>
359
360 <head>
361 <title>Unity Webapps QML test: HUD</title>
362@@ -7,7 +7,7 @@
363
364 var unity;
365 function onInit() {
366- unity.addAction('This is an action', function() {
367+ unity.addAction('Hello', function() {
368 document.getElementById('content').style.display = 'none';
369 });
370 unity.addAction('Another action', function() {
371
372=== modified file 'tests/integration/autopilot/qml/FullWebViewApp.qml'
373--- tests/integration/autopilot/qml/FullWebViewApp.qml 2013-07-31 16:29:07 +0000
374+++ tests/integration/autopilot/qml/FullWebViewApp.qml 2014-04-22 15:41:19 +0000
375@@ -37,6 +37,7 @@
376
377 function evalInPageUnsafe(expr) {
378 var tid = DomIntrospectionUtils.gentid();
379+ console.log(DomIntrospectionUtils.wrapJsCommands(expr))
380 webView.experimental.evaluateJavaScript(DomIntrospectionUtils.wrapJsCommands(expr),
381 function(result) { console.log('Result: ' + result); root.resultUpdated(DomIntrospectionUtils.createResult(result)); });
382 }
383@@ -61,7 +62,7 @@
384 width: parent.width
385 height: parent.height
386
387- experimental.userScripts: [Qt.resolvedUrl("injected-script.js")]
388+ experimental.userScripts: []
389 experimental.preferences.navigatorQtObjectEnabled: true
390 experimental.preferences.developerExtrasEnabled: true
391
392
393=== modified file 'tests/integration/autopilot/unity_webapps_qml/tests/__init__.py'
394--- tests/integration/autopilot/unity_webapps_qml/tests/__init__.py 2013-09-19 01:07:00 +0000
395+++ tests/integration/autopilot/unity_webapps_qml/tests/__init__.py 2014-04-22 15:41:19 +0000
396@@ -96,5 +96,6 @@
397 prev_emissions = self.watcher.num_emissions
398 webview.slots.evalInPageUnsafe(expr)
399 self.assertThat(lambda: self.watcher.num_emissions, Eventually(GreaterThan(prev_emissions)))
400- return json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])['result']
401+ results = json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])
402+ return results.has_key('result') and results['result'] or None
403
404
405=== modified file 'tests/integration/autopilot/unity_webapps_qml/tests/test_hud.py'
406--- tests/integration/autopilot/unity_webapps_qml/tests/test_hud.py 2013-09-23 19:59:29 +0000
407+++ tests/integration/autopilot/unity_webapps_qml/tests/test_hud.py 2014-04-22 15:41:19 +0000
408@@ -40,7 +40,7 @@
409 self.unity.hud.ensure_visible()
410 self.addCleanup(self.unity.hud.ensure_hidden)
411
412- self.keyboard.type("This is an action")
413+ self.keyboard.type("Hello")
414 self.keyboard.press_and_release("Enter")
415
416 self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('content').style.display;"), Eventually(Equals('none')))
417@@ -48,7 +48,7 @@
418 def test_clearAction(self):
419 self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('actionadded')))
420 expr = """
421- var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'clearAction', 'args': ['This is an action']})});
422+ var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'clearAction', 'args': ['Hello']})});
423 document.dispatchEvent (e);
424 return true;
425 """
426@@ -57,9 +57,8 @@
427 self.unity.hud.ensure_visible()
428 self.addCleanup(self.unity.hud.ensure_hidden)
429
430- self.keyboard.type("This is an action")
431+ self.keyboard.type("Hello")
432 self.keyboard.press_and_release("Enter")
433-
434 self.assertThat(self.eval_expression_in_page_unsafe("return document.getElementById('content').style.display;"), NotEquals('none'))
435
436 def test_clearActions(self):
437@@ -72,7 +71,7 @@
438
439 self.eval_expression_in_page_unsafe(expr)
440
441- actions = ['This is an action', 'Another action']
442+ actions = ['Hello', 'Another action']
443 for action in actions:
444 self.unity.hud.ensure_visible()
445 self.addCleanup(self.unity.hud.ensure_hidden)
446
447=== modified file 'tests/integration/autopilot/unity_webapps_qml/tests/test_injectedOnWebapp.py'
448--- tests/integration/autopilot/unity_webapps_qml/tests/test_injectedOnWebapp.py 2013-09-05 21:38:15 +0000
449+++ tests/integration/autopilot/unity_webapps_qml/tests/test_injectedOnWebapp.py 2014-04-22 15:41:19 +0000
450@@ -30,46 +30,46 @@
451 self.launch_with_html_filepath(self.get_html_test_file())
452
453 def test_getUnityObjectFound(self):
454- self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject(1.0) != null;'), Eventually(NotEquals(None)))
455+ self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null'), Eventually(Equals(True)))
456
457 def test_actionsApiFound(self):
458- self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject(1.0) != null;'), Eventually(NotEquals(None)))
459+ self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True)))
460
461 expression = """
462- var unity = window.external.getUnityObject(1.0);
463- return unity.addAction != null && unity.clearAction && unity.clearActions != null;
464+ var unity = window.external.getUnityObject("1.0");
465+ return unity.addAction != null && unity.clearActions != null && unity.clearAction != null;
466 """
467- self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(NotEquals(None)))
468+ self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(Equals(True)))
469
470 def test_notificationApiFound(self):
471- self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject(1.0) != null;'), Eventually(NotEquals(None)))
472+ self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True)))
473
474 expression = """
475- var unity = window.external.getUnityObject(1.0);
476+ var unity = window.external.getUnityObject("1.0");
477 return unity.Notification != null && unity.Notification.showNotification != null;
478 """
479- self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(NotEquals(None)))
480+ self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(Equals(True)))
481
482 def test_messagingIndicatorApiFound(self):
483- self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject(1.0) != null;'), Eventually(NotEquals(None)))
484+ self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True)))
485
486 expression = """
487- var unity = window.external.getUnityObject(1.0);
488+ var unity = window.external.getUnityObject("1.0");
489 return unity.MessagingIndicator != null &&
490 unity.MessagingIndicator.addAction != null &&
491 unity.MessagingIndicator.clearIndicator != null &&
492 unity.MessagingIndicator.clearIndicators != null &&
493 unity.MessagingIndicator.showIndicator != null;
494 """
495- self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(NotEquals(None)))
496+ self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(Equals(True)))
497
498 def test_ubuntuReadyEventSent(self):
499- self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject(1.0) != null;'), Eventually(NotEquals(None)))
500+ self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True)))
501
502 expression = """
503 var api_ready_count = window.localStorage['ubuntu-webapps-api-ready-key'];
504 return api_ready_count != null && api_ready_count > 0;
505 """
506- self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(NotEquals(None)))
507+ self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(Equals(True)))
508
509
510
511=== added file 'tests/unit/test_plugin/data/manifests/valid-with-ua-override.json'
512--- tests/unit/test_plugin/data/manifests/valid-with-ua-override.json 1970-01-01 00:00:00 +0000
513+++ tests/unit/test_plugin/data/manifests/valid-with-ua-override.json 2014-04-22 15:41:19 +0000
514@@ -0,0 +1,15 @@
515+{
516+ "includes": ["http://www.bbc.co.uk/news/", "http://www.bbc.com/news/"],
517+ "requires": ["utils.js"],
518+ "name": "BBCNews",
519+ "scripts": ["BBCNews.user.js"],
520+ "maintainer": "Webapps Team <webapps@lists.launchpad.net>",
521+ "manifest-version": "1.0",
522+ "integration-version": "2.3",
523+ "package-name": "BBCNews",
524+ "icons": {"128":"128/unity-webapps-bbc.png"},
525+ "domain":"bbc.co.uk",
526+ "homepage":"http://www.bbc.co.uk/news/",
527+ "license":"GPL-3",
528+ "user-agent-override": "My Override"
529+}
530
531=== modified file 'tests/unit/test_plugin/test_plugin.pro'
532--- tests/unit/test_plugin/test_plugin.pro 2014-01-17 15:51:27 +0000
533+++ tests/unit/test_plugin/test_plugin.pro 2014-04-22 15:41:19 +0000
534@@ -42,7 +42,8 @@
535 OTHER_FILES += \
536 $$system(ls ./data/*/*) \
537 $$system(ls ./data/*/*/*) \
538- $$system(ls *.sh)
539+ $$system(ls *.sh) \
540+ data/manifests/valid-with-ua-override.json
541
542 # manually add the 'check' target
543 check.depends = $${TARGET}
544
545=== modified file 'tests/unit/test_plugin/tst_manifestParser.cpp'
546--- tests/unit/test_plugin/tst_manifestParser.cpp 2014-01-17 15:51:27 +0000
547+++ tests/unit/test_plugin/tst_manifestParser.cpp 2014-04-22 15:41:19 +0000
548@@ -118,3 +118,11 @@
549 verifyChrome(filename, result);
550 }
551 }
552+
553+void ManifestParserTest::testParseUserOverride()
554+{
555+ UnityWebappsAppManifestParser parser;
556+ ManifestFileInfoOption result =
557+ parser.parse(manifestsDataPath + "/valid-with-ua-override.json");
558+ QVERIFY(result.value().userAgentOverride == "My Override");
559+}
560
561=== modified file 'tests/unit/test_plugin/tst_manifestParser.h'
562--- tests/unit/test_plugin/tst_manifestParser.h 2014-01-17 15:51:27 +0000
563+++ tests/unit/test_plugin/tst_manifestParser.h 2014-04-22 15:41:19 +0000
564@@ -37,7 +37,7 @@
565 // tests
566 void testParseManifest();
567 void testParseChromeOptions();
568-
569+ void testParseUserOverride();
570
571 private:
572
573
574=== modified file 'tests/unit/test_qml/tst_cleanup.qml'
575--- tests/unit/test_qml/tst_cleanup.qml 2013-07-26 18:47:08 +0000
576+++ tests/unit/test_qml/tst_cleanup.qml 2014-04-22 15:41:19 +0000
577@@ -47,11 +47,10 @@
578 function createWebAppsDispatcherWithSimpleBackend(mockedwebview) {
579 var simple_backend = {This: { Is: { A: {Backend: function (args) { mockedWebView.called(args) } } } } };
580
581- var bindeeProxies = UnityWebAppsUtils.makeProxiesForQtWebViewBindee(mockedwebview);
582- return new UnityWebAppsJs.UnityWebApps(null,
583- bindeeProxies,
584- simple_backend,
585- []);
586+ var bindeeProxies = UnityWebAppsUtils.makeProxiesForWebViewBindee(mockedwebview);
587+ var bridge = new UnityWebAppsJs.UnityWebApps(null, bindeeProxies);
588+ bridge.setBackends(simple_backend);
589+ return bridge;
590 }
591
592 function test_cleanupOnce() {
593
594=== modified file 'tests/unit/test_qml/tst_dispatch.qml'
595--- tests/unit/test_qml/tst_dispatch.qml 2013-09-12 17:45:05 +0000
596+++ tests/unit/test_qml/tst_dispatch.qml 2014-04-22 15:41:19 +0000
597@@ -6,7 +6,7 @@
598 name: "WebAppsDispatchTest"
599
600 function setup() {
601- webapps.__reset();
602+ webapps.__unbind();
603 mockedWebView.disconnectAll();
604 }
605
606@@ -22,7 +22,6 @@
607 webapps._opt_backendProxies = simple_backend;
608 webapps.name = "test_properBackendDispatched";
609 webapps.bindee = mockedWebView;
610- webapps.__bind(webapps.bindee, []);
611
612 mockedWebView.messageReceived(UnityWebAppsUtils.formatUnityWebappsCall('This.Is.A.Backend', JSON.stringify([1, 2, "AAU"])));
613
614@@ -51,7 +50,6 @@
615 webapps._opt_backendProxies = simple_backend;
616 webapps.name = "test_backendDispatchedWithProperArguments";
617 webapps.bindee = mockedWebView;
618- webapps.__bind(webapps.bindee);
619
620 mockedWebView.messageReceived(UnityWebAppsUtils.formatUnityWebappsCall('This.Is.A.Backend', JSON.stringify(params)));
621
622@@ -70,7 +68,6 @@
623 webapps._opt_backendProxies = invalid_backend;
624 webapps.name = "test_invalidBackendNotDispatched";
625 webapps.bindee = mockedWebView;
626- webapps.__bind(webapps.bindee);
627
628 mockedWebView.messageReceived(UnityWebAppsUtils.formatUnityWebappsCall('This.Is.A.Backend', JSON.stringify([1, 2, "AAU"])));
629
630@@ -100,7 +97,6 @@
631 webapps._opt_backendProxies = backend;
632 webapps.name = "test_callbacksAreWrapped";
633 webapps.bindee = mockedWebView;
634- webapps.__bind(webapps.bindee);
635
636 //We assume a bit about the implementation there ('callbackid')
637 mockedWebView.messageReceived(UnityWebAppsUtils.formatUnityWebappsCall('This.Is.A.Backend', JSON.stringify([1, {'callbackid': 1}, "AAU"])));
638
639=== modified file 'tests/unit/test_qml/tst_init.qml'
640--- tests/unit/test_qml/tst_init.qml 2013-09-12 17:45:05 +0000
641+++ tests/unit/test_qml/tst_init.qml 2014-04-22 15:41:19 +0000
642@@ -6,7 +6,7 @@
643 name: "WebAppsComponentInitTests"
644
645 function setup() {
646- webapps.__reset();
647+ webapps.__unbind();
648 mockedWebView.disconnectAll();
649 }
650
651@@ -18,7 +18,6 @@
652 spy.signalName = "injected";
653
654 webapps.name = "test_nullInit";
655- webapps.__bind(webapps.bindee, []);
656
657 compare(spy.count, 0, "Invalid (null) init call");
658 }
659@@ -32,7 +31,6 @@
660
661 webapps.name = "test_initAndInjected";
662 webapps.bindee = mockedWebView;
663- webapps.__bind(webapps.bindee, []);
664
665 mockedWebView.loadingStarted();
666
667@@ -48,7 +46,6 @@
668
669 webapps.name = "test_initAndMessageHandlerAdded";
670 webapps.bindee = mockedWebView;
671- webapps.__bind(webapps.bindee, []);
672
673 compare(spy.count, 1, "WebApp message connected on load started");
674 }
675@@ -62,7 +59,6 @@
676
677 webapps.name = "test_initWithNoName";
678 webapps.bindee = mockedWebView;
679- webapps.__bind(webapps.bindee, []);
680
681 compare(spy.count, 1, "WebApp message received connected");
682 }
683
684=== modified file 'tools/qml-launcher/qml-launcher.cpp'
685--- tools/qml-launcher/qml-launcher.cpp 2014-01-17 15:51:27 +0000
686+++ tools/qml-launcher/qml-launcher.cpp 2014-04-22 15:41:19 +0000
687@@ -153,6 +153,9 @@
688 if ( ! appid.isEmpty())
689 {
690 qputenv("APP_ID", appid.toLatin1());
691+ QCoreApplication::setApplicationName(appid.toLatin1());
692+
693+ qDebug() << "Using:" << appid.toLatin1();
694 }
695
696 if ( ! inspector.isEmpty())

Subscribers

People subscribed via source and target branches

to all changes: