Merge lp:~justinmcp/unity-chromium-extension/generic-extension into lp:unity-chromium-extension
- generic-extension
- Merge into 14.04
Proposed by
Justin McPherson
Status: | Work in progress |
---|---|
Proposed branch: | lp:~justinmcp/unity-chromium-extension/generic-extension |
Merge into: | lp:unity-chromium-extension |
Diff against target: |
4642 lines (+2399/-1482) 67 files modified
CMakeLists.txt (+32/-0) chromium-extension/CMakeLists.txt (+69/-0) chromium-extension/background-page.html (+2/-2) chromium-extension/background-page.js (+64/-61) chromium-extension/browser.js (+24/-24) chromium-extension/build.sh (+0/-27) chromium-extension/chromium-extension.pro (+0/-66) chromium-extension/infobar.css (+0/-20) chromium-extension/infobar.html (+0/-20) chromium-extension/infobar.js (+0/-33) chromium-extension/manifest.json.in (+41/-35) chromium-extension/options.html (+4/-6) chromium-extension/options.js (+3/-3) chromium-extension/popup.css (+21/-0) chromium-extension/popup.html (+20/-0) chromium-extension/popup.js (+36/-0) chromium-extension/unity-api-page-proxy.js (+1/-1) chromium-extension/unity-webapps.json.in (+2/-2) common-project-config.pri (+0/-41) common-vars.pri (+0/-6) coverage.pri (+0/-49) debian/changelog (+7/-0) debian/control (+13/-5) debian/unity-chromium-extension.install (+2/-3) debian/unity-webapps-extension-process.install (+1/-0) messaging-host/CMakeLists.txt (+101/-0) messaging-host/Makefile.am (+0/-2) messaging-host/click-handler.cpp (+386/-0) messaging-host/click-handler.h (+55/-0) messaging-host/com.canonical.webapp.extension.json.in (+9/-0) messaging-host/com.canonical.webapp.installer.json.in (+0/-9) messaging-host/main.cpp (+28/-8) messaging-host/messaging-host.pro (+0/-42) messaging-host/service-handler.cpp (+75/-0) messaging-host/service-handler.h (+54/-0) messaging-host/service.cpp (+18/-11) messaging-host/webapps-handler.cpp (+11/-17) messaging-host/webapps-handler.h (+0/-1) tests/CMakeLists.txt (+1/-0) tests/tests.pro (+0/-3) tests/unit/CMakeLists.txt (+1/-0) tests/unit/messaging-host/CMakeLists.txt (+5/-0) tests/unit/messaging-host/click-handler/CMakeLists.txt (+38/-0) tests/unit/messaging-host/click-handler/tst_click-handler.cpp (+291/-0) tests/unit/messaging-host/connection-host.cpp (+0/-71) tests/unit/messaging-host/connection/CMakeLists.txt (+40/-0) tests/unit/messaging-host/connection/connection-host.cpp (+71/-0) tests/unit/messaging-host/connection/tst_connection.cpp (+112/-0) tests/unit/messaging-host/inactivity-timer/CMakeLists.txt (+23/-0) tests/unit/messaging-host/inactivity-timer/tst_inactivity_timer.cpp (+125/-0) tests/unit/messaging-host/messaging-host.pri (+0/-9) tests/unit/messaging-host/messaging-host.pro (+0/-12) tests/unit/messaging-host/service/CMakeLists.txt (+23/-0) tests/unit/messaging-host/service/tst_service.cpp (+189/-0) tests/unit/messaging-host/tst_connection.cpp (+0/-112) tests/unit/messaging-host/tst_connection.pro (+0/-14) tests/unit/messaging-host/tst_connection_host.pro (+0/-14) tests/unit/messaging-host/tst_inactivity_timer.cpp (+0/-125) tests/unit/messaging-host/tst_inactivity_timer.pro (+0/-18) tests/unit/messaging-host/tst_service.cpp (+0/-189) tests/unit/messaging-host/tst_service.pro (+0/-18) tests/unit/messaging-host/tst_webapps-handler.cpp (+0/-354) tests/unit/messaging-host/tst_webapps-handler.pro (+0/-32) tests/unit/messaging-host/webapps-handler/CMakeLists.txt (+47/-0) tests/unit/messaging-host/webapps-handler/tst_webapps-handler.cpp (+354/-0) tests/unit/unit.pro (+0/-3) unity-chromium-extension.pro (+0/-14) |
To merge this branch: | bzr merge lp:~justinmcp/unity-chromium-extension/generic-extension |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
WebApps | Pending | ||
Review via email: mp+272066@code.launchpad.net |
Commit message
Signal available webapps while navigating with Chrome and Webbrowser-app.
Look for compatible webapps in the installed click packages.
Description of the change
Signal available webapps while navigating with Chrome and Webbrowser-app.
Look for compatible webapps in the installed click packages.
To post a comment you must log in.
- 251. By Justin McPherson
-
WIP
- 252. By Justin McPherson
-
WIP
- 253. By Justin McPherson
-
WIP
- 254. By Justin McPherson
-
WIP
- 255. By Justin McPherson
-
WIP
- 256. By Justin McPherson
-
WIP
- 257. By Justin McPherson
-
WIP
- 258. By Justin McPherson
-
Add tests
- 259. By Justin McPherson
-
Finish click related tests
- 260. By Justin McPherson
-
Make checking for maintainer configurable
- 261. By Justin McPherson
-
Fix leak
Unmerged revisions
- 261. By Justin McPherson
-
Fix leak
- 260. By Justin McPherson
-
Make checking for maintainer configurable
- 259. By Justin McPherson
-
Finish click related tests
- 258. By Justin McPherson
-
Add tests
- 257. By Justin McPherson
-
WIP
- 256. By Justin McPherson
-
WIP
- 255. By Justin McPherson
-
WIP
- 254. By Justin McPherson
-
WIP
- 253. By Justin McPherson
-
WIP
- 252. By Justin McPherson
-
WIP
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
3 | +++ CMakeLists.txt 2015-10-07 04:25:10 +0000 | |||
4 | @@ -0,0 +1,32 @@ | |||
5 | 1 | # vim:expandtab:shiftwidth=2:tabstop=2: | ||
6 | 2 | |||
7 | 3 | # Copyright (C) 2015 Canonical Ltd. | ||
8 | 4 | |||
9 | 5 | # This library is free software; you can redistribute it and/or | ||
10 | 6 | # modify it under the terms of the GNU Lesser General Public | ||
11 | 7 | # License as published by the Free Software Foundation; either | ||
12 | 8 | # version 2.1 of the License, or (at your option) any later version. | ||
13 | 9 | |||
14 | 10 | # This library is distributed in the hope that it will be useful, | ||
15 | 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | 13 | # Lesser General Public License for more details. | ||
18 | 14 | |||
19 | 15 | # You should have received a copy of the GNU Lesser GeneraGl Public | ||
20 | 16 | # License along with this library; if not, write to the Free Software | ||
21 | 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | 18 | |||
23 | 19 | cmake_minimum_required(VERSION 2.8.11) | ||
24 | 20 | |||
25 | 21 | project(unity-chromium-extension) | ||
26 | 22 | |||
27 | 23 | set(PROJECT_NAME "unity_webapps_chromium") | ||
28 | 24 | set(PROJECT_VERSION "3.3") | ||
29 | 25 | |||
30 | 26 | include(GNUInstallDirs) | ||
31 | 27 | |||
32 | 28 | add_subdirectory(chromium-extension) | ||
33 | 29 | add_subdirectory(messaging-host) | ||
34 | 30 | |||
35 | 31 | enable_testing() | ||
36 | 32 | add_subdirectory(tests) | ||
37 | 0 | 33 | ||
38 | === added file 'chromium-extension/CMakeLists.txt' | |||
39 | --- chromium-extension/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
40 | +++ chromium-extension/CMakeLists.txt 2015-10-07 04:25:10 +0000 | |||
41 | @@ -0,0 +1,69 @@ | |||
42 | 1 | |||
43 | 2 | set(PEMFILE unity-webapps.pem) | ||
44 | 3 | |||
45 | 4 | set(EXTENSION_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/libunity-chromium) | ||
46 | 5 | set(EXTENSION_NAME unity-webapps) | ||
47 | 6 | set(EXTENSION_FILE ${EXTENSION_NAME}.crx) | ||
48 | 7 | set(EXTENSION_WORKING_DIR ${CMAKE_CURRENT_BINARY_DIR}/${EXTENSION_NAME}) | ||
49 | 8 | set(EXTENSION_FILES) | ||
50 | 9 | |||
51 | 10 | list( | ||
52 | 11 | APPEND EXTENSION_FILES | ||
53 | 12 | background-page.html | ||
54 | 13 | background-page.js | ||
55 | 14 | base-content-script.js | ||
56 | 15 | browser.js | ||
57 | 16 | popup.css | ||
58 | 17 | popup.html | ||
59 | 18 | popup.js | ||
60 | 19 | _locales | ||
61 | 20 | options.html | ||
62 | 21 | options.js | ||
63 | 22 | skin | ||
64 | 23 | unity-api-page-proxy-builder-gen.js | ||
65 | 24 | unity-api-page-proxy.js | ||
66 | 25 | ) | ||
67 | 26 | |||
68 | 27 | # Create a directory for archiving+signing extension and copy in necessary files | ||
69 | 28 | file(MAKE_DIRECTORY ${EXTENSION_WORKING_DIR}) | ||
70 | 29 | file(COPY ${EXTENSION_FILES} DESTINATION ${EXTENSION_WORKING_DIR}) | ||
71 | 30 | |||
72 | 31 | # If we already have a signing key, copy it to the working directory | ||
73 | 32 | if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/${PEMFILE}) | ||
74 | 33 | file(COPY ${CMAKE_CURRENT_LIST_DIR}/${PEMFILE} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) | ||
75 | 34 | endif() | ||
76 | 35 | |||
77 | 36 | # fill out config files | ||
78 | 37 | configure_file(manifest.json.in ${EXTENSION_WORKING_DIR}/manifest.json) | ||
79 | 38 | configure_file(unity-webapps.json.in ${CMAKE_CURRENT_BINARY_DIR}/unity-webapps.json) | ||
80 | 39 | |||
81 | 40 | # If not using the included signing key, generate one TODO: use key id | ||
82 | 41 | add_custom_command( | ||
83 | 42 | OUTPUT ${PEMFILE} | ||
84 | 43 | COMMAND openssl genrsa 1024 > ${PEMFILE} | ||
85 | 44 | ) | ||
86 | 45 | |||
87 | 46 | # Prepare extension | ||
88 | 47 | add_custom_command( | ||
89 | 48 | OUTPUT ${EXTENSION_FILE} | ||
90 | 49 | COMMAND ${CMAKE_CURRENT_LIST_DIR}/crxmake.sh ${EXTENSION_NAME} ${PEMFILE} | ||
91 | 50 | DEPENDS ${PEMFILE} | ||
92 | 51 | ) | ||
93 | 52 | |||
94 | 53 | add_custom_target( | ||
95 | 54 | build-extension ALL | ||
96 | 55 | DEPENDS ${EXTENSION_FILE} | ||
97 | 56 | ) | ||
98 | 57 | |||
99 | 58 | # Install extension description in chrome data dir | ||
100 | 59 | # The crxmake.sh script writes this file to ./res | ||
101 | 60 | install( | ||
102 | 61 | DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/res/ | ||
103 | 62 | DESTINATION ${CMAKE_INSTALL_DATADIR}/chromium/extensions | ||
104 | 63 | FILES_MATCHING PATTERN "*.json" | ||
105 | 64 | ) | ||
106 | 65 | |||
107 | 66 | install( | ||
108 | 67 | FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXTENSION_FILE} | ||
109 | 68 | DESTINATION ${EXTENSION_DIR} | ||
110 | 69 | ) | ||
111 | 0 | 70 | ||
112 | === modified file 'chromium-extension/background-page.html' | |||
113 | --- chromium-extension/background-page.html 2014-05-20 13:40:09 +0000 | |||
114 | +++ chromium-extension/background-page.html 2015-10-07 04:25:10 +0000 | |||
115 | @@ -4,9 +4,9 @@ | |||
116 | 4 | 4 | ||
117 | 5 | <title>Unity Webapps Extension Background Page</title> | 5 | <title>Unity Webapps Extension Background Page</title> |
118 | 6 | <embed type="application/x-unity-webapps-npapi" id="unityChromiumExtensionId"/> | 6 | <embed type="application/x-unity-webapps-npapi" id="unityChromiumExtensionId"/> |
120 | 7 | 7 | ||
121 | 8 | <script src="background-page.js"></script> | 8 | <script src="background-page.js"></script> |
123 | 9 | 9 | ||
124 | 10 | </head> | 10 | </head> |
125 | 11 | 11 | ||
126 | 12 | <body> | 12 | <body> |
127 | 13 | 13 | ||
128 | === modified file 'chromium-extension/background-page.js' | |||
129 | --- chromium-extension/background-page.js 2014-06-20 06:16:48 +0000 | |||
130 | +++ chromium-extension/background-page.js 2015-10-07 04:25:10 +0000 | |||
131 | @@ -1,28 +1,28 @@ | |||
132 | 1 | /* Chromium Unity integration extension | 1 | /* Chromium Unity integration extension |
134 | 2 | * | 2 | * |
135 | 3 | * Copyright 2012 Canonical Ltd. | 3 | * Copyright 2012 Canonical Ltd. |
136 | 4 | * | 4 | * |
139 | 5 | * This program is free software: you can redistribute it and/or modify it | 5 | * This program is free software: you can redistribute it and/or modify it |
140 | 6 | * under the terms of the GNU General Public License version 3, as published | 6 | * under the terms of the GNU General Public License version 3, as published |
141 | 7 | * by the Free Software Foundation. | 7 | * by the Free Software Foundation. |
142 | 8 | * | 8 | * |
146 | 9 | * This program is distributed in the hope that it will be useful, but | 9 | * This program is distributed in the hope that it will be useful, but |
147 | 10 | * WITHOUT ANY WARRANTY; without even the implied warranties of | 10 | * WITHOUT ANY WARRANTY; without even the implied warranties of |
148 | 11 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | 11 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
149 | 12 | * PURPOSE. See the GNU General Public License for more details. | 12 | * PURPOSE. See the GNU General Public License for more details. |
150 | 13 | * | 13 | * |
152 | 14 | * You should have received a copy of the GNU General Public License along | 14 | * You should have received a copy of the GNU General Public License along |
153 | 15 | * with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
154 | 16 | **/ | 16 | **/ |
155 | 17 | 17 | ||
156 | 18 | var background_page = (function () { | 18 | var background_page = (function () { |
157 | 19 | // Native messaging support | 19 | // Native messaging support |
159 | 20 | var HOST_ADDRESS = 'com.canonical.webapp.installer'; | 20 | var HOST_ADDRESS = 'com.canonical.webapp.extension'; |
160 | 21 | var port = null; | 21 | var port = null; |
161 | 22 | var host_callbacks = []; | 22 | var host_callbacks = []; |
162 | 23 | 23 | ||
163 | 24 | var portListener = function (msg) { | 24 | var portListener = function (msg) { |
165 | 25 | callback = host_callbacks.pop(); | 25 | callback = host_callbacks.pop(); |
166 | 26 | if (callback === undefined) { | 26 | if (callback === undefined) { |
167 | 27 | return; | 27 | return; |
168 | 28 | } | 28 | } |
169 | @@ -30,12 +30,10 @@ | |||
170 | 30 | }; | 30 | }; |
171 | 31 | 31 | ||
172 | 32 | var portDisconnecter = function () { | 32 | var portDisconnecter = function () { |
175 | 33 | console.log('UCX: port disconnected'); | 33 | port = null; |
174 | 34 | port = null | ||
176 | 35 | }; | 34 | }; |
177 | 36 | 35 | ||
178 | 37 | var sendNativeMessage = function (msg, callback) { | 36 | var sendNativeMessage = function (msg, callback) { |
179 | 38 | console.log("UCX: sendnativemessage: port=" + port); | ||
180 | 39 | if (port === null) { | 37 | if (port === null) { |
181 | 40 | port = chrome.runtime.connectNative(HOST_ADDRESS); | 38 | port = chrome.runtime.connectNative(HOST_ADDRESS); |
182 | 41 | port.onMessage.addListener(portListener); | 39 | port.onMessage.addListener(portListener); |
183 | @@ -50,46 +48,42 @@ | |||
184 | 50 | 48 | ||
185 | 51 | 49 | ||
186 | 52 | ///////////////////////////////////////////////////////// | 50 | ///////////////////////////////////////////////////////// |
189 | 53 | // | 51 | // |
190 | 54 | // Scafolding to keep track of data associated w/ infobar requests | 52 | // Scafolding to keep track of data associated w/ pageaction requests |
191 | 55 | // (Chromium's structure imposes some kind of state being maintained | 53 | // (Chromium's structure imposes some kind of state being maintained |
194 | 56 | // in order to communicate data) | 54 | // in order to communicate data) |
195 | 57 | // | 55 | // |
196 | 58 | //////////////////////////////////////////////////////// | 56 | //////////////////////////////////////////////////////// |
198 | 59 | // | 57 | // |
199 | 60 | // list of callback that are to be called asynchronously | 58 | // list of callback that are to be called asynchronously |
200 | 61 | // per tab. Used in the user integration/installation resquests context. | 59 | // per tab. Used in the user integration/installation resquests context. |
201 | 62 | // | ||
202 | 63 | // One thing to keep in mind is that one constraint, that bring some amount of | ||
203 | 64 | // 'soundness' is that there is a hard limit (provided by the browser) of one infobar per tab. | ||
204 | 65 | 60 | ||
208 | 66 | var user_infobar_request_callbacks = {}; | 61 | var user_popup_request_callbacks = {}; |
209 | 67 | var addInfobarRequestCallbackFor = function (infobarRequestId, callback, message, details) { | 62 | var addPopupRequestCallbackFor = function (popupRequestId, callback, message, details) { |
210 | 68 | user_infobar_request_callbacks[infobarRequestId] = { | 63 | user_popup_request_callbacks[popupRequestId] = { |
211 | 69 | callback: callback, | 64 | callback: callback, |
212 | 70 | message: message, | 65 | message: message, |
213 | 71 | details: details | 66 | details: details |
214 | 72 | }; | 67 | }; |
215 | 73 | }; | 68 | }; |
216 | 74 | 69 | ||
219 | 75 | var getDataIfAnyFor = function (infobarRequestId) { | 70 | var getDataIfAnyFor = function (popupRequestId) { |
220 | 76 | if (user_infobar_request_callbacks[infobarRequestId] === undefined) { | 71 | if (user_popup_request_callbacks[popupRequestId] === undefined) { |
221 | 77 | return ""; | 72 | return ""; |
222 | 78 | } | 73 | } |
223 | 79 | return { | 74 | return { |
226 | 80 | message: user_infobar_request_callbacks[infobarRequestId].message, | 75 | message: user_popup_request_callbacks[popupRequestId].message, |
227 | 81 | details: user_infobar_request_callbacks[infobarRequestId].details | 76 | details: user_popup_request_callbacks[popupRequestId].details |
228 | 82 | }; | 77 | }; |
229 | 83 | }; | 78 | }; |
233 | 84 | 79 | var invokeAndRemoveCallbackIfAnyFor = function (popupRequestId, args) { | |
234 | 85 | var invokeAndRemoveCallbackIfAnyFor = function (infobarRequestId, arguments) { | 80 | if (user_popup_request_callbacks[popupRequestId] === undefined) { |
232 | 86 | if (user_infobar_request_callbacks[infobarRequestId] === undefined) { | ||
235 | 87 | return; | 81 | return; |
236 | 88 | } | 82 | } |
239 | 89 | var callback = user_infobar_request_callbacks[infobarRequestId].callback; | 83 | var callback = user_popup_request_callbacks[popupRequestId].callback; |
240 | 90 | user_infobar_request_callbacks[infobarRequestId] = undefined; | 84 | user_popup_request_callbacks[popupRequestId] = undefined; |
241 | 91 | if (typeof(callback) === 'function') { | 85 | if (typeof(callback) === 'function') { |
243 | 92 | callback(arguments); | 86 | callback(args); |
244 | 93 | } | 87 | } |
245 | 94 | }; | 88 | }; |
246 | 95 | 89 | ||
247 | @@ -106,35 +100,37 @@ | |||
248 | 106 | }, | 100 | }, |
249 | 107 | function (response) { | 101 | function (response) { |
250 | 108 | if (response.available) { | 102 | if (response.available) { |
252 | 109 | addInfobarRequestCallbackFor( | 103 | addPopupRequestCallbackFor( |
253 | 110 | windowInfos.tabId, | 104 | windowInfos.tabId, |
254 | 111 | function (result) { | 105 | function (result) { |
255 | 112 | if (result && result.integrate) { | 106 | if (result && result.integrate) { |
256 | 113 | sendNativeMessage({ | 107 | sendNativeMessage({ |
257 | 114 | "method" : "install", | 108 | "method" : "install", |
258 | 115 | "url" : url | 109 | "url" : url |
260 | 116 | }) | 110 | }); |
261 | 117 | } else { | 111 | } else { |
262 | 118 | sendNativeMessage({ | 112 | sendNativeMessage({ |
263 | 119 | "method" : "dont_ask", | 113 | "method" : "dont_ask", |
264 | 120 | "url" : url | 114 | "url" : url |
266 | 121 | }) | 115 | }); |
267 | 122 | } | 116 | } |
268 | 117 | |||
269 | 118 | chrome.pageAction.hide(windowInfos.tabId); | ||
270 | 123 | }, | 119 | }, |
271 | 124 | chrome.i18n.getMessage("integration_copy", [ response.appName, response.appDomain ]), | 120 | chrome.i18n.getMessage("integration_copy", [ response.appName, response.appDomain ]), |
272 | 125 | null); | 121 | null); |
273 | 126 | 122 | ||
275 | 127 | chrome.infobars.show({ tabId: windowInfos.tabId, path: "infobar.html" }); | 123 | chrome.pageAction.show(windowInfos.tabId); |
276 | 128 | } | 124 | } |
277 | 129 | }); | 125 | }); |
281 | 130 | }; | 126 | }; |
282 | 131 | 127 | ||
283 | 132 | 128 | ||
284 | 133 | // {{{ main request handler | 129 | // {{{ main request handler |
286 | 134 | 130 | ||
287 | 135 | /** | 131 | /** |
288 | 136 | * Handles & responds to content script requests. | 132 | * Handles & responds to content script requests. |
290 | 137 | * | 133 | * |
291 | 138 | */ | 134 | */ |
292 | 139 | var init_requested_stamps = {}; | 135 | var init_requested_stamps = {}; |
293 | 140 | var contentScriptsRequestHandler = function (request, sender, callback) { | 136 | var contentScriptsRequestHandler = function (request, sender, callback) { |
294 | @@ -144,10 +140,10 @@ | |||
295 | 144 | logging: false, | 140 | logging: false, |
296 | 145 | incognito: sender.tab.incognito | 141 | incognito: sender.tab.incognito |
297 | 146 | }; | 142 | }; |
299 | 147 | 143 | ||
300 | 148 | try { | 144 | try { |
301 | 149 | if (window.localStorage) { | 145 | if (window.localStorage) { |
303 | 150 | settings.logging = localStorage['logging']; | 146 | settings.logging = localStorage.logging; |
304 | 151 | } | 147 | } |
305 | 152 | } | 148 | } |
306 | 153 | catch (e) { | 149 | catch (e) { |
307 | @@ -156,8 +152,8 @@ | |||
308 | 156 | 152 | ||
309 | 157 | callback (settings); | 153 | callback (settings); |
310 | 158 | }, | 154 | }, |
313 | 159 | on_user_infobar_request_result: function (request, sender, callback) { | 155 | on_user_popup_request_result: function (request, sender, callback) { |
314 | 160 | invokeAndRemoveCallbackIfAnyFor (request.tabId, request); | 156 | invokeAndRemoveCallbackIfAnyFor(request.tabId, request); |
315 | 161 | }, | 157 | }, |
316 | 162 | init_requested: function (request, sender, callback) { | 158 | init_requested: function (request, sender, callback) { |
317 | 163 | sendNativeMessage({ | 159 | sendNativeMessage({ |
318 | @@ -166,30 +162,32 @@ | |||
319 | 166 | }, | 162 | }, |
320 | 167 | function (response) { | 163 | function (response) { |
321 | 168 | if (response.available) { | 164 | if (response.available) { |
323 | 169 | addInfobarRequestCallbackFor( | 165 | addPopupRequestCallbackFor( |
324 | 170 | sender.tab.id, | 166 | sender.tab.id, |
325 | 171 | function (result) { | 167 | function (result) { |
326 | 172 | if (result && result.integrate) { | 168 | if (result && result.integrate) { |
327 | 173 | sendNativeMessage({ | 169 | sendNativeMessage({ |
328 | 174 | "method" : "install", | 170 | "method" : "install", |
329 | 175 | "url" : request.options.url | 171 | "url" : request.options.url |
331 | 176 | }) | 172 | }); |
332 | 177 | } else { | 173 | } else { |
333 | 178 | sendNativeMessage({ | 174 | sendNativeMessage({ |
334 | 179 | "method" : "dont_ask", | 175 | "method" : "dont_ask", |
335 | 180 | "url" : request.options.url | 176 | "url" : request.options.url |
337 | 181 | }) | 177 | }); |
338 | 182 | } | 178 | } |
339 | 179 | |||
340 | 180 | chrome.pageAction.hide(windowInfos.tabId); | ||
341 | 183 | }, | 181 | }, |
342 | 184 | chrome.i18n.getMessage("integration_copy", [ response.appName, response.appDomain ]), | 182 | chrome.i18n.getMessage("integration_copy", [ response.appName, response.appDomain ]), |
343 | 185 | null); | 183 | null); |
344 | 186 | 184 | ||
346 | 187 | chrome.infobars.show({ tabId: windowInfos.tabId, path: "infobar.html" }); | 185 | chrome.pageAction.show(windowInfos.tabId); |
347 | 188 | } | 186 | } |
348 | 189 | }); | 187 | }); |
349 | 190 | } | 188 | } |
350 | 191 | }; | 189 | }; |
352 | 192 | 190 | ||
353 | 193 | // validate request | 191 | // validate request |
354 | 194 | if (!request || !request.method) { | 192 | if (!request || !request.method) { |
355 | 195 | callback({ error: "Invalid request structure" }); | 193 | callback({ error: "Invalid request structure" }); |
356 | @@ -200,20 +198,18 @@ | |||
357 | 200 | return true; | 198 | return true; |
358 | 201 | } | 199 | } |
359 | 202 | 200 | ||
361 | 203 | if (typeof(request.method) != 'string' || request.method.length == 0) { | 201 | if (typeof(request.method) != 'string' || request.method.length === 0) { |
362 | 204 | callback({ error: "Invalid request method" }); | 202 | callback({ error: "Invalid request method" }); |
363 | 205 | return true; | 203 | return true; |
364 | 206 | } | 204 | } |
365 | 207 | 205 | ||
366 | 208 | console.log('Got request: ' + request.method); | ||
367 | 209 | |||
368 | 210 | var handler = handlers [request.method]; | 206 | var handler = handlers [request.method]; |
369 | 211 | if (handler !== undefined && typeof(handler) == 'function') { | 207 | if (handler !== undefined && typeof(handler) == 'function') { |
370 | 212 | handler(request, sender, callback); | 208 | handler(request, sender, callback); |
371 | 213 | return true; | 209 | return true; |
372 | 214 | } | 210 | } |
373 | 215 | return false; | 211 | return false; |
375 | 216 | } | 212 | }; |
376 | 217 | 213 | ||
377 | 218 | // Main event handler and communication link | 214 | // Main event handler and communication link |
378 | 219 | // w/ content scripts | 215 | // w/ content scripts |
379 | @@ -221,18 +217,16 @@ | |||
380 | 221 | // }}} | 217 | // }}} |
381 | 222 | 218 | ||
382 | 223 | /////////////////////////////////////////////////////////////////////// | 219 | /////////////////////////////////////////////////////////////////////// |
384 | 224 | // | 220 | // |
385 | 225 | // Window management related functions. In chromeless mode, we have specific | 221 | // Window management related functions. In chromeless mode, we have specific |
386 | 226 | // rules for tab management to make webapps feel more "native" than plain | 222 | // rules for tab management to make webapps feel more "native" than plain |
387 | 227 | // web applications. | 223 | // web applications. |
389 | 228 | // | 224 | // |
390 | 229 | /////////////////////////////////////////////////////////////////////// | 225 | /////////////////////////////////////////////////////////////////////// |
391 | 230 | 226 | ||
392 | 231 | var onTabChanged = function (tabId, windowId, url) { | 227 | var onTabChanged = function (tabId, windowId, url) { |
393 | 232 | var onInstalled = function (installed, packageName, appName, appDomain) { }; | 228 | var onInstalled = function (installed, packageName, appName, appDomain) { }; |
394 | 233 | 229 | ||
395 | 234 | console.log("onTabChanged: " + url); | ||
396 | 235 | |||
397 | 236 | matchesIntegrationScripts( | 230 | matchesIntegrationScripts( |
398 | 237 | null, //plugin, | 231 | null, //plugin, |
399 | 238 | url, | 232 | url, |
400 | @@ -255,15 +249,24 @@ | |||
401 | 255 | 249 | ||
402 | 256 | chrome.tabs.onUpdated.addListener( | 250 | chrome.tabs.onUpdated.addListener( |
403 | 257 | function(tabId, changeInfo, tab) { | 251 | function(tabId, changeInfo, tab) { |
404 | 258 | console.log("onUpdated " + changeInfo.url); | ||
405 | 259 | if (changeInfo && changeInfo.url) { | 252 | if (changeInfo && changeInfo.url) { |
406 | 260 | onTabChanged(tabId, tab.windowId, changeInfo.url); | 253 | onTabChanged(tabId, tab.windowId, changeInfo.url); |
407 | 261 | } | 254 | } |
408 | 262 | } | 255 | } |
409 | 263 | ); | 256 | ); |
410 | 264 | 257 | ||
411 | 258 | chrome.tabs.onReplaced.addListener( | ||
412 | 259 | function(addedTabId, removedTabId) { | ||
413 | 260 | chrome.tabs.get(addedTabId, function(tab) { | ||
414 | 261 | if (tab && tab.url) { | ||
415 | 262 | onTabChanged(addedTabId, tab.windowId, tab.url); | ||
416 | 263 | } | ||
417 | 264 | }); | ||
418 | 265 | } | ||
419 | 266 | ); | ||
420 | 267 | |||
421 | 265 | /* | 268 | /* |
423 | 266 | * Returns a potential message associated with a tab id (infobar) | 269 | * Returns a potential message associated with a tab id (popup) |
424 | 267 | */ | 270 | */ |
425 | 268 | return { | 271 | return { |
426 | 269 | getMessageForTabId: function (tabId) { | 272 | getMessageForTabId: function (tabId) { |
427 | 270 | 273 | ||
428 | === modified file 'chromium-extension/browser.js' | |||
429 | --- chromium-extension/browser.js 2014-05-20 13:40:09 +0000 | |||
430 | +++ chromium-extension/browser.js 2015-10-07 04:25:10 +0000 | |||
431 | @@ -10,20 +10,21 @@ | |||
432 | 10 | var service = null; | 10 | var service = null; |
433 | 11 | var api = { | 11 | var api = { |
434 | 12 | init: function (options) { | 12 | init: function (options) { |
442 | 13 | options.url = window.location.href; | 13 | options.url = window.location.href; |
443 | 14 | options.hostname = window.location.hostname; | 14 | options.hostname = window.location.hostname; |
444 | 15 | options.host = window.location.host; | 15 | options.host = window.location.host; |
445 | 16 | options.protocol = window.location.protocol; | 16 | options.protocol = window.location.protocol; |
446 | 17 | chrome.runtime.sendMessage ( | 17 | chrome.runtime.sendMessage( |
447 | 18 | {method: "init_requested", options: options} | 18 | {method: "init_requested", options: options}, |
448 | 19 | , function (response) {}); | 19 | function (response) {} |
449 | 20 | ); | ||
450 | 20 | } | 21 | } |
451 | 21 | }; | 22 | }; |
452 | 22 | 23 | ||
453 | 23 | /** | 24 | /** |
454 | 24 | * Inserts a given script in the webpage. | 25 | * Inserts a given script in the webpage. |
455 | 25 | * Needs chrome.extension functionality. | 26 | * Needs chrome.extension functionality. |
457 | 26 | * | 27 | * |
458 | 27 | * @param path of file to be injected (part of the extension) | 28 | * @param path of file to be injected (part of the extension) |
459 | 28 | */ | 29 | */ |
460 | 29 | var insertScriptIntoWebpage = function (path) { | 30 | var insertScriptIntoWebpage = function (path) { |
461 | @@ -47,14 +48,14 @@ | |||
462 | 47 | var e = document.createEvent ("Events"); | 48 | var e = document.createEvent ("Events"); |
463 | 48 | d.style.cssText = "display:none;"; | 49 | d.style.cssText = "display:none;"; |
464 | 49 | d.value = id; | 50 | d.value = id; |
468 | 50 | d.addEventListener ("unity-webapps-chromium-api-com-link-callback-called-ack" | 51 | d.addEventListener("unity-webapps-chromium-api-com-link-callback-called-ack", |
469 | 51 | , function() { d.parentNode.removeChild (d); } | 52 | function() { d.parentNode.removeChild (d); }, |
470 | 52 | , true); | 53 | true); |
471 | 53 | document.body.appendChild (d); | 54 | document.body.appendChild (d); |
472 | 54 | e.initEvent ("unity-webapps-chromium-api-com-link-callback-called", false, true); | 55 | e.initEvent ("unity-webapps-chromium-api-com-link-callback-called", false, true); |
473 | 55 | d.dispatchEvent (e); | 56 | d.dispatchEvent (e); |
474 | 56 | }; | 57 | }; |
476 | 57 | }; | 58 | } |
477 | 58 | 59 | ||
478 | 59 | // TODO: should be shared / generated w/ web page code | 60 | // TODO: should be shared / generated w/ web page code |
479 | 60 | var isIterableObject = function(obj) { | 61 | var isIterableObject = function(obj) { |
480 | @@ -75,9 +76,9 @@ | |||
481 | 75 | if ( ! isIterableObject(obj)) { | 76 | if ( ! isIterableObject(obj)) { |
482 | 76 | return obj; | 77 | return obj; |
483 | 77 | } | 78 | } |
487 | 78 | if (obj | 79 | if (obj && |
488 | 79 | && obj.hasOwnProperty('callbackid') | 80 | obj.hasOwnProperty('callbackid') && |
489 | 80 | && obj.callbackid != null) { | 81 | obj.callbackid !== null) { |
490 | 81 | return makeWebpageCallback (obj.callbackid); | 82 | return makeWebpageCallback (obj.callbackid); |
491 | 82 | } | 83 | } |
492 | 83 | 84 | ||
493 | @@ -87,7 +88,7 @@ | |||
494 | 87 | 88 | ||
495 | 88 | if (isIterableObject (obj[key])) { | 89 | if (isIterableObject (obj[key])) { |
496 | 89 | 90 | ||
498 | 90 | if (obj[key].callbackid != null) { | 91 | if (obj[key].callbackid !== null) { |
499 | 91 | ret[key] = makeWebpageCallback (obj[key].callbackid); | 92 | ret[key] = makeWebpageCallback (obj[key].callbackid); |
500 | 92 | } | 93 | } |
501 | 93 | else { | 94 | else { |
502 | @@ -100,7 +101,7 @@ | |||
503 | 100 | } | 101 | } |
504 | 101 | } | 102 | } |
505 | 102 | return ret; | 103 | return ret; |
507 | 103 | }; | 104 | } |
508 | 104 | 105 | ||
509 | 105 | // 2. open the communication mean between the two | 106 | // 2. open the communication mean between the two |
510 | 106 | 107 | ||
511 | @@ -120,9 +121,9 @@ | |||
512 | 120 | console.log ('Error while dispatching call to ' + funcnames.join('.') + ': ' + err); | 121 | console.log ('Error while dispatching call to ' + funcnames.join('.') + ': ' + err); |
513 | 121 | } | 122 | } |
514 | 122 | }; | 123 | }; |
518 | 123 | 124 | ||
519 | 124 | document.addEventListener("unity-webapps-chromium-api-com-link" | 125 | document.addEventListener("unity-webapps-chromium-api-com-link", |
520 | 125 | , function(event) { | 126 | function(event) { |
521 | 126 | var from = event.target; | 127 | var from = event.target; |
522 | 127 | if (from) { | 128 | if (from) { |
523 | 128 | var type = from.getAttribute("data-eventType"); | 129 | var type = from.getAttribute("data-eventType"); |
524 | @@ -133,7 +134,7 @@ | |||
525 | 133 | // Actuall call, e.g. 'Notification.showNotification("a","b") | 134 | // Actuall call, e.g. 'Notification.showNotification("a","b") |
526 | 134 | // being reduces to successive calls to associated objects: | 135 | // being reduces to successive calls to associated objects: |
527 | 135 | // Notification, showNotification | 136 | // Notification, showNotification |
529 | 136 | // | 137 | // |
530 | 137 | // TODO add proper error handling | 138 | // TODO add proper error handling |
531 | 138 | dispatchActualFunctionCall(type, args); | 139 | dispatchActualFunctionCall(type, args); |
532 | 139 | } | 140 | } |
533 | @@ -142,8 +143,8 @@ | |||
534 | 142 | var ret = document.createEvent('Events'); | 143 | var ret = document.createEvent('Events'); |
535 | 143 | ret.initEvent('unity-webapps-chromium-api-com-link-ack', true, false); | 144 | ret.initEvent('unity-webapps-chromium-api-com-link-ack', true, false); |
536 | 144 | from.dispatchEvent(ret); | 145 | from.dispatchEvent(ret); |
539 | 145 | } | 146 | }, |
540 | 146 | , true); | 147 | true); |
541 | 147 | }; | 148 | }; |
542 | 148 | 149 | ||
543 | 149 | // handle the proxy side of the api which is being injected on the | 150 | // handle the proxy side of the api which is being injected on the |
544 | @@ -151,4 +152,3 @@ | |||
545 | 151 | injectApiProxy(); | 152 | injectApiProxy(); |
546 | 152 | } | 153 | } |
547 | 153 | )(window); | 154 | )(window); |
548 | 154 | |||
549 | 155 | 155 | ||
550 | === removed file 'chromium-extension/build.sh' | |||
551 | --- chromium-extension/build.sh 2012-04-27 19:34:47 +0000 | |||
552 | +++ chromium-extension/build.sh 1970-01-01 00:00:00 +0000 | |||
553 | @@ -1,27 +0,0 @@ | |||
554 | 1 | #!/bin/bash -e | ||
555 | 2 | |||
556 | 3 | |||
557 | 4 | CRX_FILENAME=`pwd`/../chromium-extension.crx | ||
558 | 5 | PEM_FILENAME=`pwd`/../chromium-extension.pem | ||
559 | 6 | |||
560 | 7 | if [ -e "$CRX_FILENAME" ] | ||
561 | 8 | then | ||
562 | 9 | rm -f "$CRX_FILENAME" | ||
563 | 10 | fi | ||
564 | 11 | |||
565 | 12 | #if [ -e "$PEM_FILENAME" ] | ||
566 | 13 | #then | ||
567 | 14 | # rm -f "$PEM_FILENAME" | ||
568 | 15 | #fi | ||
569 | 16 | |||
570 | 17 | if test -n "`which google-chrome`"; then | ||
571 | 18 | google-chrome --no-message-box --pack-extension=`pwd` --pack-extension-key=../chromium-extension.pem | ||
572 | 19 | else | ||
573 | 20 | chromium-browser --no-message-box --pack-extension=`pwd` | ||
574 | 21 | fi | ||
575 | 22 | |||
576 | 23 | # not necessary | ||
577 | 24 | # mv `pwd`/../unity-chromium-extension.crx . | ||
578 | 25 | |||
579 | 26 | |||
580 | 27 | |||
581 | 28 | 0 | ||
582 | === removed file 'chromium-extension/chromium-extension.pro' | |||
583 | --- chromium-extension/chromium-extension.pro 2014-05-21 12:53:43 +0000 | |||
584 | +++ chromium-extension/chromium-extension.pro 1970-01-01 00:00:00 +0000 | |||
585 | @@ -1,66 +0,0 @@ | |||
586 | 1 | include(../common-project-config.pri) | ||
587 | 2 | include($${TOP_SRC_DIR}/common-vars.pri) | ||
588 | 3 | |||
589 | 4 | TEMPLATE = aux | ||
590 | 5 | |||
591 | 6 | EXTENSION_DIR = $${INSTALL_LIBDIR}/libunity-chromium | ||
592 | 7 | EXTENSION_NAME = unity-webapps | ||
593 | 8 | EXTENSION_FILE = $${EXTENSION_NAME}.crx | ||
594 | 9 | |||
595 | 10 | STATIC_EXTENSION_FILES = \ | ||
596 | 11 | background-page.html \ | ||
597 | 12 | background-page.js \ | ||
598 | 13 | base-content-script.js \ | ||
599 | 14 | browser.js \ | ||
600 | 15 | infobar.css \ | ||
601 | 16 | infobar.html \ | ||
602 | 17 | infobar.js \ | ||
603 | 18 | _locales \ | ||
604 | 19 | options.html \ | ||
605 | 20 | options.js \ | ||
606 | 21 | skin \ | ||
607 | 22 | unity-api-page-proxy-builder-gen.js \ | ||
608 | 23 | unity-api-page-proxy.js \ | ||
609 | 24 | |||
610 | 25 | SCRIPT_FILES = \ | ||
611 | 26 | $${STATIC_EXTENSION_FILES} \ | ||
612 | 27 | manifest.json \ | ||
613 | 28 | unity-webapps.json | ||
614 | 29 | |||
615 | 30 | QMAKE_SUBSTITUTES += \ | ||
616 | 31 | manifest.json.in \ | ||
617 | 32 | unity-webapps.json.in | ||
618 | 33 | |||
619 | 34 | pemfile.target = unity-webapps.pem | ||
620 | 35 | pemfile.commands = "openssl genrsa 1024 > $${pemfile.target}" | ||
621 | 36 | |||
622 | 37 | static_files.depends = \ | ||
623 | 38 | $${SCRIPT_FILES} | ||
624 | 39 | static_files.commands = mkdir -p $${OUT_PWD}/$${EXTENSION_NAME} && ${COPY_DIR} $${SCRIPT_FILES} $${OUT_PWD}/$${EXTENSION_NAME} | ||
625 | 40 | |||
626 | 41 | static_files_stamp.target = buildstamp | ||
627 | 42 | static_files_stamp.depends = static_files | ||
628 | 43 | static_files_stamp.commands = touch $${static_files_stamp.target} | ||
629 | 44 | |||
630 | 45 | extension.target = res/$${EXTENSION_NAME}.crx | ||
631 | 46 | extension.commands = $${TOP_SRC_DIR}/chromium-extension/crxmake.sh $${OUT_PWD}/$${EXTENSION_NAME} $${pemfile.target} | ||
632 | 47 | extension.depends = pemfile static_files_stamp | ||
633 | 48 | |||
634 | 49 | QMAKE_EXTRA_TARGETS += \ | ||
635 | 50 | extension \ | ||
636 | 51 | pemfile \ | ||
637 | 52 | static_files \ | ||
638 | 53 | static_files_stamp | ||
639 | 54 | |||
640 | 55 | PRE_TARGETDEPS = $${extension.target} | ||
641 | 56 | |||
642 | 57 | manifest.files = \ | ||
643 | 58 | $${OUT_PWD}/res/*.json | ||
644 | 59 | manifest.path = $${INSTALL_PREFIX}/share/chromium/extensions/ | ||
645 | 60 | manifest.CONFIG = no_check_exist | ||
646 | 61 | INSTALLS += manifest | ||
647 | 62 | |||
648 | 63 | crx.files = res/$${EXTENSION_NAME}.crx | ||
649 | 64 | crx.path = $${EXTENSION_DIR} | ||
650 | 65 | crx.CONFIG = no_check_exist | ||
651 | 66 | INSTALLS += crx | ||
652 | 67 | 0 | ||
653 | === removed file 'chromium-extension/infobar.css' | |||
654 | --- chromium-extension/infobar.css 2012-05-16 18:19:03 +0000 | |||
655 | +++ chromium-extension/infobar.css 1970-01-01 00:00:00 +0000 | |||
656 | @@ -1,20 +0,0 @@ | |||
657 | 1 | body { | ||
658 | 2 | background: -webkit-linear-gradient(#E9E9E9, #DADADA); | ||
659 | 3 | font-family: Tahoma, Geneva, sans-serif; | ||
660 | 4 | font-size: 13px; | ||
661 | 5 | height: 36px; /* Infobars are limited to 36-72px */ | ||
662 | 6 | margin: 0; | ||
663 | 7 | overflow: hidden; | ||
664 | 8 | padding-left: 6px; | ||
665 | 9 | padding-right: 6px; | ||
666 | 10 | padding-top: 5px; | ||
667 | 11 | } | ||
668 | 12 | |||
669 | 13 | img { | ||
670 | 14 | padding-right: 6px; | ||
671 | 15 | } | ||
672 | 16 | |||
673 | 17 | button { | ||
674 | 18 | padding-right: 10px; | ||
675 | 19 | } | ||
676 | 20 | |||
677 | 21 | 0 | ||
678 | === removed file 'chromium-extension/infobar.html' | |||
679 | --- chromium-extension/infobar.html 2012-10-12 01:18:07 +0000 | |||
680 | +++ chromium-extension/infobar.html 1970-01-01 00:00:00 +0000 | |||
681 | @@ -1,20 +0,0 @@ | |||
682 | 1 | <html> | ||
683 | 2 | |||
684 | 3 | <head> | ||
685 | 4 | </head> | ||
686 | 5 | |||
687 | 6 | <link rel="stylesheet" type="text/css" href="infobar.css"></link> | ||
688 | 7 | <script src="infobar.js"></script> | ||
689 | 8 | |||
690 | 9 | <body> | ||
691 | 10 | |||
692 | 11 | <div id="content" style="display:none"> | ||
693 | 12 | <span id="message"></span> | ||
694 | 13 | <input type="button" id="notintegrate" value="Never for this site" /> | ||
695 | 14 | <input type="button" id="integrate" value="Yes" onclick="doIntegrate(true)"/> | ||
696 | 15 | </div> | ||
697 | 16 | |||
698 | 17 | </body> | ||
699 | 18 | |||
700 | 19 | |||
701 | 20 | </html> | ||
702 | 21 | 0 | ||
703 | === removed file 'chromium-extension/infobar.js' | |||
704 | --- chromium-extension/infobar.js 2014-11-18 07:07:15 +0000 | |||
705 | +++ chromium-extension/infobar.js 1970-01-01 00:00:00 +0000 | |||
706 | @@ -1,33 +0,0 @@ | |||
707 | 1 | var doIntegrate = function (integrate) { | ||
708 | 2 | chrome.tabs.query({currentWindow: true, active: true}, function (tabs) { | ||
709 | 3 | chrome.runtime.sendMessage({tabId: tabs[0].id, method: "on_user_infobar_request_result", integrate: integrate} | ||
710 | 4 | , function (response) {}); | ||
711 | 5 | window.close(); | ||
712 | 6 | }); | ||
713 | 7 | }; | ||
714 | 8 | |||
715 | 9 | window.onload = function () { | ||
716 | 10 | chrome.runtime.getBackgroundPage(function (bg) { | ||
717 | 11 | document.getElementById('notintegrate').onclick = function () { doIntegrate(false); }; | ||
718 | 12 | document.getElementById('integrate').onclick = function () { doIntegrate(true); }; | ||
719 | 13 | |||
720 | 14 | chrome.tabs.query({currentWindow: true, active: true}, function (tabs) { | ||
721 | 15 | if (tabs.length === 0) { | ||
722 | 16 | window.close(); | ||
723 | 17 | return; | ||
724 | 18 | } | ||
725 | 19 | if (!bg || !bg.background_page) { | ||
726 | 20 | window.close(); | ||
727 | 21 | return; | ||
728 | 22 | } | ||
729 | 23 | var msg = bg.background_page.getMessageForTabId(tabs[0].id); | ||
730 | 24 | if (msg == null) { | ||
731 | 25 | window.close(); | ||
732 | 26 | return; | ||
733 | 27 | } | ||
734 | 28 | document.getElementById ('content').style.display = "block"; | ||
735 | 29 | document.getElementById ('message').innerHTML = msg || ""; | ||
736 | 30 | }); | ||
737 | 31 | }); | ||
738 | 32 | }; | ||
739 | 33 | |||
740 | 34 | 0 | ||
741 | === modified file 'chromium-extension/manifest.json.in' | |||
742 | --- chromium-extension/manifest.json.in 2014-05-21 12:22:21 +0000 | |||
743 | +++ chromium-extension/manifest.json.in 2015-10-07 04:25:10 +0000 | |||
744 | @@ -1,42 +1,48 @@ | |||
745 | 1 | { | 1 | { |
761 | 2 | '"name": "Unity WebApps Chromium extension"', | 2 | "name": "Unity WebApps Chromium extension", |
762 | 3 | '"manifest_version"': 2, | 3 | "manifest_version": 2, |
763 | 4 | '"minimum_chrome_version": "34.0"', | 4 | "minimum_chrome_version": "34.0", |
764 | 5 | '"content_security_policy"': '"script-src \'self\' chrome-extension://infobar.js \'unsafe-eval\'; object-src \'self\'"', | 5 | "content_security_policy": "script-src \'self\' chrome-extension://infobar.js \'unsafe-eval\'; object-src \'self\'", |
765 | 6 | 6 | ||
766 | 7 | '"version": "$${PROJECT_VERSION}"', | 7 | "version": "${PROJECT_VERSION}", |
767 | 8 | 8 | ||
768 | 9 | '"description": "Unity Webapps Chromium integration"', | 9 | "description": "Unity Webapps Chromium integration", |
769 | 10 | 10 | ||
770 | 11 | '"web_accessible_resources"': [ | 11 | "web_accessible_resources": [ |
771 | 12 | '"browser.js"', | 12 | "browser.js", |
772 | 13 | '"unity-api-page-proxy-builder-gen.js"', | 13 | "unity-api-page-proxy-builder-gen.js", |
773 | 14 | '"unity-api-page-proxy.js"', | 14 | "unity-api-page-proxy.js", |
774 | 15 | '"infobar.js"', | 15 | "options.js" |
760 | 16 | '"options.js"' | ||
775 | 17 | ], | 16 | ], |
776 | 18 | 17 | ||
792 | 19 | '"icons"': { | 18 | "icons": { |
793 | 20 | '"16": "skin/cof-16.png"', | 19 | "16": "skin/cof-16.png", |
794 | 21 | '"48": "skin/cof-48.png"' | 20 | "48": "skin/cof-48.png" |
795 | 22 | }, | 21 | }, |
796 | 23 | 22 | ||
797 | 24 | '"default_locale": "en"', | 23 | "default_locale": "en", |
798 | 25 | 24 | ||
799 | 26 | '"background"': { | 25 | "background": { |
800 | 27 | '"page"': '"background-page.html"' | 26 | "page": "background-page.html" |
801 | 28 | }, | 27 | }, |
802 | 29 | 28 | ||
803 | 30 | '"permissions": ["tabs", "http://*/*", "infobars", "nativeMessaging"]', | 29 | "permissions": ["tabs", "http://*/*", "nativeMessaging"], |
804 | 31 | '"options_page": "options.html"', | 30 | "page_action": { |
805 | 32 | 31 | "default_icon": { | |
806 | 33 | '"content_scripts"': [ | 32 | "19": "skin/cof-16.png", |
807 | 33 | "38": "skin/cof-48.png" | ||
808 | 34 | }, | ||
809 | 35 | "default_title": "Unity Webapps", | ||
810 | 36 | "default_popup": "popup.html" | ||
811 | 37 | }, | ||
812 | 38 | "options_page": "options.html", | ||
813 | 39 | |||
814 | 40 | "content_scripts": [ | ||
815 | 34 | { | 41 | { |
820 | 35 | '"all_frames"': true, | 42 | "all_frames": true, |
821 | 36 | '"matches": [ "<all_urls>" ]', | 43 | "matches": [ "<all_urls>" ], |
822 | 37 | '"js": ["base-content-script.js"]', | 44 | "js": ["base-content-script.js"], |
823 | 38 | '"run_at": "document_end"' | 45 | "run_at": "document_end" |
824 | 39 | } | 46 | } |
825 | 40 | ] | 47 | ] |
826 | 41 | } | 48 | } |
827 | 42 | |||
828 | 43 | 49 | ||
829 | === modified file 'chromium-extension/options.html' | |||
830 | --- chromium-extension/options.html 2012-11-08 18:15:19 +0000 | |||
831 | +++ chromium-extension/options.html 2015-10-07 04:25:10 +0000 | |||
832 | @@ -8,23 +8,23 @@ | |||
833 | 8 | width: 600px; | 8 | width: 600px; |
834 | 9 | font-size: 13px; | 9 | font-size: 13px; |
835 | 10 | } | 10 | } |
837 | 11 | 11 | ||
838 | 12 | body { | 12 | body { |
839 | 13 | background-color: "#ebeff9"; | 13 | background-color: "#ebeff9"; |
840 | 14 | font-family: Arial, sans-serif; | 14 | font-family: Arial, sans-serif; |
841 | 15 | } | 15 | } |
843 | 16 | 16 | ||
844 | 17 | #logo { | 17 | #logo { |
845 | 18 | font-size: 20px; | 18 | font-size: 20px; |
846 | 19 | text-align: center; | 19 | text-align: center; |
847 | 20 | } | 20 | } |
849 | 21 | 21 | ||
850 | 22 | #extensionName { | 22 | #extensionName { |
851 | 23 | color: #444; | 23 | color: #444; |
852 | 24 | font-size: 16px; | 24 | font-size: 16px; |
853 | 25 | font-weight: 500; | 25 | font-weight: 500; |
854 | 26 | } | 26 | } |
856 | 27 | 27 | ||
857 | 28 | .setting { | 28 | .setting { |
858 | 29 | pagging-left: 20px; | 29 | pagging-left: 20px; |
859 | 30 | } | 30 | } |
860 | @@ -48,5 +48,3 @@ | |||
861 | 48 | 48 | ||
862 | 49 | </body> | 49 | </body> |
863 | 50 | </html> | 50 | </html> |
864 | 51 | |||
865 | 52 | |||
866 | 53 | 51 | ||
867 | === modified file 'chromium-extension/options.js' | |||
868 | --- chromium-extension/options.js 2012-11-08 18:15:19 +0000 | |||
869 | +++ chromium-extension/options.js 2015-10-07 04:25:10 +0000 | |||
870 | @@ -1,6 +1,6 @@ | |||
871 | 1 | function save_options() { | 1 | function save_options() { |
872 | 2 | var logging = document.getElementById("logging"); | 2 | var logging = document.getElementById("logging"); |
874 | 3 | localStorage["logging"] = logging.checked; | 3 | localStorage.logging = logging.checked; |
875 | 4 | } | 4 | } |
876 | 5 | 5 | ||
877 | 6 | function restore_options() { | 6 | function restore_options() { |
878 | @@ -9,8 +9,8 @@ | |||
879 | 9 | document.getElementById('logging').disabled = true; | 9 | document.getElementById('logging').disabled = true; |
880 | 10 | return; | 10 | return; |
881 | 11 | } | 11 | } |
884 | 12 | 12 | ||
885 | 13 | var logging = localStorage["logging"]; | 13 | var logging = localStorage.logging; |
886 | 14 | var loggingElt = document.getElementById("logging"); | 14 | var loggingElt = document.getElementById("logging"); |
887 | 15 | if (loggingElt) { | 15 | if (loggingElt) { |
888 | 16 | loggingElt.checked = (logging == "true"); | 16 | loggingElt.checked = (logging == "true"); |
889 | 17 | 17 | ||
890 | === added file 'chromium-extension/popup.css' | |||
891 | --- chromium-extension/popup.css 1970-01-01 00:00:00 +0000 | |||
892 | +++ chromium-extension/popup.css 2015-10-07 04:25:10 +0000 | |||
893 | @@ -0,0 +1,21 @@ | |||
894 | 1 | body { | ||
895 | 2 | background: -webkit-linear-gradient(#E9E9E9, #DADADA); | ||
896 | 3 | font-family: Tahoma, Geneva, sans-serif; | ||
897 | 4 | font-size: 13px; | ||
898 | 5 | height: 36px; | ||
899 | 6 | width: 300px; | ||
900 | 7 | margin: 0; | ||
901 | 8 | overflow: hidden; | ||
902 | 9 | padding-left: 6px; | ||
903 | 10 | padding-right: 6px; | ||
904 | 11 | padding-top: 5px; | ||
905 | 12 | } | ||
906 | 13 | |||
907 | 14 | img { | ||
908 | 15 | padding-right: 6px; | ||
909 | 16 | } | ||
910 | 17 | |||
911 | 18 | button { | ||
912 | 19 | padding-right: 10px; | ||
913 | 20 | } | ||
914 | 21 | |||
915 | 0 | 22 | ||
916 | === added file 'chromium-extension/popup.html' | |||
917 | --- chromium-extension/popup.html 1970-01-01 00:00:00 +0000 | |||
918 | +++ chromium-extension/popup.html 2015-10-07 04:25:10 +0000 | |||
919 | @@ -0,0 +1,20 @@ | |||
920 | 1 | <html> | ||
921 | 2 | |||
922 | 3 | <head> | ||
923 | 4 | </head> | ||
924 | 5 | |||
925 | 6 | <link rel="stylesheet" type="text/css" href="popup.css"></link> | ||
926 | 7 | <script src="popup.js"></script> | ||
927 | 8 | |||
928 | 9 | <body> | ||
929 | 10 | |||
930 | 11 | <div id="content" style="display:none"> | ||
931 | 12 | <span id="message"></span> | ||
932 | 13 | <input type="button" id="notintegrate" value="Never for this site" /> | ||
933 | 14 | <input type="button" id="integrate" value="Yes" onclick="doIntegrate(true)"/> | ||
934 | 15 | </div> | ||
935 | 16 | |||
936 | 17 | </body> | ||
937 | 18 | |||
938 | 19 | |||
939 | 20 | </html> | ||
940 | 0 | 21 | ||
941 | === added file 'chromium-extension/popup.js' | |||
942 | --- chromium-extension/popup.js 1970-01-01 00:00:00 +0000 | |||
943 | +++ chromium-extension/popup.js 2015-10-07 04:25:10 +0000 | |||
944 | @@ -0,0 +1,36 @@ | |||
945 | 1 | var doIntegrate = function (integrate) { | ||
946 | 2 | chrome.tabs.query({currentWindow: true, active: true}, function (tabs) { | ||
947 | 3 | chrome.runtime.sendMessage({ | ||
948 | 4 | tabId: tabs[0].id, | ||
949 | 5 | method: "on_user_popup_request_result", | ||
950 | 6 | integrate: integrate | ||
951 | 7 | }, | ||
952 | 8 | function (response) {}); | ||
953 | 9 | window.close(); | ||
954 | 10 | }); | ||
955 | 11 | }; | ||
956 | 12 | |||
957 | 13 | window.onload = function () { | ||
958 | 14 | chrome.runtime.getBackgroundPage(function (bg) { | ||
959 | 15 | document.getElementById('notintegrate').onclick = function () { doIntegrate(false); }; | ||
960 | 16 | document.getElementById('integrate').onclick = function () { doIntegrate(true); }; | ||
961 | 17 | |||
962 | 18 | chrome.tabs.query({currentWindow: true, active: true}, function (tabs) { | ||
963 | 19 | if (tabs.length === 0) { | ||
964 | 20 | window.close(); | ||
965 | 21 | return; | ||
966 | 22 | } | ||
967 | 23 | if (!bg || !bg.background_page) { | ||
968 | 24 | window.close(); | ||
969 | 25 | return; | ||
970 | 26 | } | ||
971 | 27 | var msg = bg.background_page.getMessageForTabId(tabs[0].id); | ||
972 | 28 | if (msg === null) { | ||
973 | 29 | window.close(); | ||
974 | 30 | return; | ||
975 | 31 | } | ||
976 | 32 | document.getElementById ('content').style.display = "block"; | ||
977 | 33 | document.getElementById ('message').innerHTML = msg || ""; | ||
978 | 34 | }); | ||
979 | 35 | }); | ||
980 | 36 | }; | ||
981 | 0 | 37 | ||
982 | === modified file 'chromium-extension/unity-api-page-proxy.js' | |||
983 | --- chromium-extension/unity-api-page-proxy.js 2014-05-20 13:40:09 +0000 | |||
984 | +++ chromium-extension/unity-api-page-proxy.js 2015-10-07 04:25:10 +0000 | |||
985 | @@ -1,5 +1,5 @@ | |||
986 | 1 | /** | 1 | /** |
988 | 2 | * | 2 | * |
989 | 3 | * | 3 | * |
990 | 4 | */ | 4 | */ |
991 | 5 | setTimeout ( | 5 | setTimeout ( |
992 | 6 | 6 | ||
993 | === modified file 'chromium-extension/unity-webapps.json.in' | |||
994 | --- chromium-extension/unity-webapps.json.in 2014-05-21 09:03:42 +0000 | |||
995 | +++ chromium-extension/unity-webapps.json.in 2015-10-07 04:25:10 +0000 | |||
996 | @@ -1,4 +1,4 @@ | |||
997 | 1 | { | 1 | { |
1000 | 2 | '"external_crx": "$${EXTENSION_DIR}/$${EXTENSION_FILE}"', | 2 | "external_crx": "${EXTENSION_DIR}/${EXTENSION_FILE}", |
1001 | 3 | '"external_version": "$${PROJECT_VERSION}"' | 3 | "external_version": "${PROJECT_VERSION}" |
1002 | 4 | } | 4 | } |
1003 | 5 | 5 | ||
1004 | === removed file 'common-project-config.pri' | |||
1005 | --- common-project-config.pri 2014-05-19 14:04:19 +0000 | |||
1006 | +++ common-project-config.pri 1970-01-01 00:00:00 +0000 | |||
1007 | @@ -1,41 +0,0 @@ | |||
1008 | 1 | #----------------------------------------------------------------------------- | ||
1009 | 2 | # Common configuration for all projects. | ||
1010 | 3 | #----------------------------------------------------------------------------- | ||
1011 | 4 | |||
1012 | 5 | # we don't like warnings... | ||
1013 | 6 | QMAKE_CXXFLAGS += -Werror | ||
1014 | 7 | # Disable RTTI | ||
1015 | 8 | QMAKE_CXXFLAGS += -fno-exceptions -fno-rtti | ||
1016 | 9 | |||
1017 | 10 | TOP_SRC_DIR = $$PWD | ||
1018 | 11 | TOP_BUILD_DIR = $${TOP_SRC_DIR}/$(BUILD_DIR) | ||
1019 | 12 | |||
1020 | 13 | include(coverage.pri) | ||
1021 | 14 | |||
1022 | 15 | #----------------------------------------------------------------------------- | ||
1023 | 16 | # setup the installation prefix | ||
1024 | 17 | #----------------------------------------------------------------------------- | ||
1025 | 18 | INSTALL_PREFIX = /usr # default installation prefix | ||
1026 | 19 | |||
1027 | 20 | # default prefix can be overriden by defining PREFIX when running qmake | ||
1028 | 21 | isEmpty(PREFIX) { | ||
1029 | 22 | message("====") | ||
1030 | 23 | message("==== NOTE: To override the installation path run: `qmake PREFIX=/custom/path'") | ||
1031 | 24 | message("==== (current installation path is `$${INSTALL_PREFIX}')") | ||
1032 | 25 | } else { | ||
1033 | 26 | INSTALL_PREFIX = $${PREFIX} | ||
1034 | 27 | message("====") | ||
1035 | 28 | message("==== install prefix set to `$${INSTALL_PREFIX}'") | ||
1036 | 29 | } | ||
1037 | 30 | |||
1038 | 31 | INSTALL_LIBDIR = $${INSTALL_PREFIX}/lib | ||
1039 | 32 | |||
1040 | 33 | isEmpty(LIBDIR) { | ||
1041 | 34 | message("====") | ||
1042 | 35 | message("==== NOTE: To override the library installation path run: `qmake LIBDIR=/custom/path'") | ||
1043 | 36 | message("==== (current installation path is `$${INSTALL_LIBDIR}')") | ||
1044 | 37 | } else { | ||
1045 | 38 | INSTALL_LIBDIR = $${LIBDIR} | ||
1046 | 39 | message("====") | ||
1047 | 40 | message("==== install prefix set to `$${INSTALL_LIBDIR}'") | ||
1048 | 41 | } | ||
1049 | 42 | 0 | ||
1050 | === removed file 'common-vars.pri' | |||
1051 | --- common-vars.pri 2014-06-02 06:53:38 +0000 | |||
1052 | +++ common-vars.pri 1970-01-01 00:00:00 +0000 | |||
1053 | @@ -1,6 +0,0 @@ | |||
1054 | 1 | #----------------------------------------------------------------------------- | ||
1055 | 2 | # Common variables for all projects. | ||
1056 | 3 | #----------------------------------------------------------------------------- | ||
1057 | 4 | |||
1058 | 5 | PROJECT_NAME = unity_webapps_chromium | ||
1059 | 6 | PROJECT_VERSION = 3.2 | ||
1060 | 7 | 0 | ||
1061 | === removed file 'coverage.pri' | |||
1062 | --- coverage.pri 2014-05-19 14:04:19 +0000 | |||
1063 | +++ coverage.pri 1970-01-01 00:00:00 +0000 | |||
1064 | @@ -1,49 +0,0 @@ | |||
1065 | 1 | # Coverage | ||
1066 | 2 | CONFIG(coverage) { | ||
1067 | 3 | OBJECTS_DIR = | ||
1068 | 4 | MOC_DIR = | ||
1069 | 5 | TOP_SRC_DIR = $$PWD | ||
1070 | 6 | |||
1071 | 7 | LIBS += -lgcov | ||
1072 | 8 | QMAKE_CXXFLAGS += --coverage | ||
1073 | 9 | QMAKE_LDFLAGS += --coverage | ||
1074 | 10 | |||
1075 | 11 | QMAKE_EXTRA_TARGETS += coverage cov | ||
1076 | 12 | QMAKE_EXTRA_TARGETS += clean-gcno clean-gcda coverage-html \ | ||
1077 | 13 | generate-coverage-html clean-coverage-html coverage-gcovr \ | ||
1078 | 14 | generate-gcovr generate-coverage-gcovr clean-coverage-gcovr | ||
1079 | 15 | |||
1080 | 16 | clean-gcno.commands = \ | ||
1081 | 17 | "@echo Removing old coverage instrumentation"; \ | ||
1082 | 18 | "find -name '*.gcno' -print | xargs -r rm" | ||
1083 | 19 | |||
1084 | 20 | clean-gcda.commands = \ | ||
1085 | 21 | "@echo Removing old coverage results"; \ | ||
1086 | 22 | "find -name '*.gcda' -print | xargs -r rm" | ||
1087 | 23 | |||
1088 | 24 | coverage-html.depends = clean-gcda check generate-coverage-html | ||
1089 | 25 | |||
1090 | 26 | generate-coverage-html.commands = \ | ||
1091 | 27 | "@echo Collecting coverage data"; \ | ||
1092 | 28 | "lcov --directory $${TOP_SRC_DIR} --capture --output-file coverage.info --no-checksum --compat-libtool"; \ | ||
1093 | 29 | "lcov --extract coverage.info \"*/messaging-host/*.cpp\" -o coverage.info"; \ | ||
1094 | 30 | "lcov --remove coverage.info \"moc_*.cpp\" --remove coverage.info \"tests/*.cpp\" -o coverage.info"; \ | ||
1095 | 31 | "LANG=C genhtml --prefix $${TOP_SRC_DIR} --output-directory coverage-html --title \"Code Coverage\" --legend --show-details coverage.info" | ||
1096 | 32 | |||
1097 | 33 | clean-coverage-html.depends = clean-gcda | ||
1098 | 34 | clean-coverage-html.commands = \ | ||
1099 | 35 | "lcov --directory $${TOP_SRC_DIR} -z"; \ | ||
1100 | 36 | "rm -rf coverage.info coverage-html" | ||
1101 | 37 | |||
1102 | 38 | coverage-gcovr.depends = clean-gcda check generate-coverage-gcovr | ||
1103 | 39 | |||
1104 | 40 | generate-coverage-gcovr.commands = \ | ||
1105 | 41 | "@echo Generating coverage GCOVR report"; \ | ||
1106 | 42 | "gcovr -x -r $${TOP_SRC_DIR} -o $${TOP_SRC_DIR}/coverage.xml -e \".*/moc_.*\" -e \"tests/.*\" -e \".*\\.h\"" | ||
1107 | 43 | |||
1108 | 44 | clean-coverage-gcovr.depends = clean-gcda | ||
1109 | 45 | clean-coverage-gcovr.commands = \ | ||
1110 | 46 | "rm -rf $${TOP_SRC_DIR}/coverage.xml" | ||
1111 | 47 | |||
1112 | 48 | QMAKE_CLEAN += *.gcda *.gcno coverage.info coverage.xml | ||
1113 | 49 | } | ||
1114 | 50 | 0 | ||
1115 | === modified file 'debian/changelog' | |||
1116 | --- debian/changelog 2015-01-19 16:49:41 +0000 | |||
1117 | +++ debian/changelog 2015-10-07 04:25:10 +0000 | |||
1118 | @@ -1,3 +1,10 @@ | |||
1119 | 1 | unity-chromium-extension (3.2.1+15.04.20150119-0ubuntu1) vivid; urgency=medium | ||
1120 | 2 | |||
1121 | 3 | * Fixes: 1469601, by changing the notification method to use the pageAction | ||
1122 | 4 | facility for display. | ||
1123 | 5 | |||
1124 | 6 | -- Justin McPherson <justin.mcpherson@canonical.com> Tue, 30 Jun 2015 13:18:59 +1000 | ||
1125 | 7 | |||
1126 | 1 | unity-chromium-extension (3.2.0+15.04.20150119-0ubuntu1) vivid; urgency=medium | 8 | unity-chromium-extension (3.2.0+15.04.20150119-0ubuntu1) vivid; urgency=medium |
1127 | 2 | 9 | ||
1128 | 3 | [ Justin McPherson ] | 10 | [ Justin McPherson ] |
1129 | 4 | 11 | ||
1130 | === modified file 'debian/control' | |||
1131 | --- debian/control 2014-12-17 14:18:53 +0000 | |||
1132 | +++ debian/control 2015-10-07 04:25:10 +0000 | |||
1133 | @@ -1,17 +1,19 @@ | |||
1134 | 1 | Source: unity-chromium-extension | 1 | Source: unity-chromium-extension |
1135 | 2 | Priority: optional | 2 | Priority: optional |
1139 | 3 | Maintainer: Ubuntu Desktop Team <ubuntu-desktop@lists.ubuntu.com> | 3 | Maintainer: Ubuntu Webapps Team <webapps@lists.ubuntu.com> |
1140 | 4 | Build-Depends: chromium-browser (>= 34.0.1847.116-0ubuntu2), | 4 | Build-Depends: debhelper (>= 9), |
1138 | 5 | debhelper (>= 9), | ||
1141 | 6 | dh-autoreconf, | 5 | dh-autoreconf, |
1142 | 7 | libglib2.0-dev, | 6 | libglib2.0-dev, |
1144 | 8 | libunity-webapps-dev (>= 1.8.0), | 7 | libunity-webapps-dev (>= 1.8.0) [!armhf], |
1145 | 8 | libjson-glib-dev, | ||
1146 | 9 | libclick-0.4-dev, | ||
1147 | 10 | libubuntu-app-launch2-dev, | ||
1148 | 9 | openssl, | 11 | openssl, |
1149 | 10 | pkg-config, | 12 | pkg-config, |
1150 | 11 | vim-common, | 13 | vim-common, |
1151 | 12 | zip, | 14 | zip, |
1152 | 13 | qt5-default, | 15 | qt5-default, |
1154 | 14 | qt5-qmake, | 16 | cmake, |
1155 | 15 | xvfb, | 17 | xvfb, |
1156 | 16 | Standards-Version: 3.9.5 | 18 | Standards-Version: 3.9.5 |
1157 | 17 | Section: gnome | 19 | Section: gnome |
1158 | @@ -25,9 +27,15 @@ | |||
1159 | 25 | Architecture: any | 27 | Architecture: any |
1160 | 26 | Depends: chromium-browser (>= 34.0.1847.116-0ubuntu2), | 28 | Depends: chromium-browser (>= 34.0.1847.116-0ubuntu2), |
1161 | 27 | unity-webapps-service, | 29 | unity-webapps-service, |
1162 | 30 | unity-webapps-extension-process, | ||
1163 | 28 | webbrowser-app, | 31 | webbrowser-app, |
1164 | 29 | ${misc:Depends}, | 32 | ${misc:Depends}, |
1165 | 30 | Breaks: libunity-webapps-chromium, | 33 | Breaks: libunity-webapps-chromium, |
1166 | 31 | Replaces: libunity-webapps-chromium, | 34 | Replaces: libunity-webapps-chromium, |
1167 | 32 | Description: Unity WebApp extension for the chromium browser | 35 | Description: Unity WebApp extension for the chromium browser |
1168 | 33 | Chromium browser extension for Unity WebApp integration | 36 | Chromium browser extension for Unity WebApp integration |
1169 | 37 | |||
1170 | 38 | Package: unity-webapps-extension-process | ||
1171 | 39 | Architecture: any | ||
1172 | 40 | Depends: ${misc:Depends}, | ||
1173 | 41 | Description: Unity WebApp extension for installing or activating local web apps. | ||
1174 | 34 | 42 | ||
1175 | === modified file 'debian/unity-chromium-extension.install' | |||
1176 | --- debian/unity-chromium-extension.install 2014-05-22 07:11:49 +0000 | |||
1177 | +++ debian/unity-chromium-extension.install 2015-10-07 04:25:10 +0000 | |||
1178 | @@ -1,4 +1,3 @@ | |||
1181 | 1 | etc/chromium/native-messaging-hosts/com.canonical.webapp.installer.json | 1 | etc/chromium/native-messaging-hosts/com.canonical.webapp.extension.json |
1182 | 2 | usr/lib/libunity-chromium/unity-webapps.crx | 2 | usr/lib/*/libunity-chromium/unity-webapps.crx |
1183 | 3 | usr/share/chromium/extensions/*.json | 3 | usr/share/chromium/extensions/*.json |
1184 | 4 | usr/share/unity-webapps/bin/unity-webapps-messaging-host | ||
1185 | 5 | 4 | ||
1186 | === added file 'debian/unity-webapps-extension-process.install' | |||
1187 | --- debian/unity-webapps-extension-process.install 1970-01-01 00:00:00 +0000 | |||
1188 | +++ debian/unity-webapps-extension-process.install 2015-10-07 04:25:10 +0000 | |||
1189 | @@ -0,0 +1,1 @@ | |||
1190 | 1 | usr/share/unity-webapps/bin/* | ||
1191 | 0 | 2 | ||
1192 | === added file 'messaging-host/CMakeLists.txt' | |||
1193 | --- messaging-host/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
1194 | +++ messaging-host/CMakeLists.txt 2015-10-07 04:25:10 +0000 | |||
1195 | @@ -0,0 +1,101 @@ | |||
1196 | 1 | # vim:expandtab:shiftwidth=2:tabstop=2: | ||
1197 | 2 | |||
1198 | 3 | # Copyright (C) 2015 Canonical Ltd. | ||
1199 | 4 | |||
1200 | 5 | # This library is free software; you can redistribute it and/or | ||
1201 | 6 | # modify it under the terms of the GNU Lesser General Public | ||
1202 | 7 | # License as published by the Free Software Foundation; either | ||
1203 | 8 | # version 2.1 of the License, or (at your option) any later version. | ||
1204 | 9 | |||
1205 | 10 | # This library is distributed in the hope that it will be useful, | ||
1206 | 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1207 | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1208 | 13 | # Lesser General Public License for more details. | ||
1209 | 14 | |||
1210 | 15 | # You should have received a copy of the GNU Lesser GeneraGl Public | ||
1211 | 16 | # License along with this library; if not, write to the Free Software | ||
1212 | 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
1213 | 18 | |||
1214 | 19 | cmake_minimum_required(VERSION 2.8.11) | ||
1215 | 20 | |||
1216 | 21 | project(messaging-host) | ||
1217 | 22 | |||
1218 | 23 | set(EXTENSION_NAME webapps-extension) | ||
1219 | 24 | set(EXTENSION_MANIFEST com.canonical.webapp.extension.json) | ||
1220 | 25 | set(WEBAPPS_BINDIR ${CMAKE_INSTALL_FULL_DATADIR}/unity-webapps/bin) | ||
1221 | 26 | |||
1222 | 27 | set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
1223 | 28 | set(CMAKE_AUTOMOC ON) | ||
1224 | 29 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | ||
1225 | 30 | set(SRC) | ||
1226 | 31 | |||
1227 | 32 | find_package(PkgConfig) | ||
1228 | 33 | find_package(Qt5Core) | ||
1229 | 34 | |||
1230 | 35 | pkg_check_modules(GLIB glib-2.0 REQUIRED) | ||
1231 | 36 | pkg_check_modules(GOBJECT gobject-2.0 REQUIRED) | ||
1232 | 37 | pkg_check_modules(JSON_GLIB json-glib-1.0 REQUIRED) | ||
1233 | 38 | pkg_check_modules(CLICK click-0.4 REQUIRED) | ||
1234 | 39 | pkg_check_modules(UBUNTU_APP_LAUNCH ubuntu-app-launch-2 REQUIRED) | ||
1235 | 40 | pkg_check_modules(WEBAPPS libunity_webapps-0.2) | ||
1236 | 41 | pkg_check_modules(WEBAPPS_REPO libunity-webapps-repository) | ||
1237 | 42 | |||
1238 | 43 | # Build and install chromium's extension manifest | ||
1239 | 44 | configure_file( | ||
1240 | 45 | ${EXTENSION_MANIFEST}.in | ||
1241 | 46 | ${CMAKE_CURRENT_BINARY_DIR}/${EXTENSION_MANIFEST} | ||
1242 | 47 | ) | ||
1243 | 48 | |||
1244 | 49 | install( | ||
1245 | 50 | FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXTENSION_MANIFEST} | ||
1246 | 51 | DESTINATION /etc/chromium/native-messaging-hosts | ||
1247 | 52 | ) | ||
1248 | 53 | |||
1249 | 54 | list( | ||
1250 | 55 | APPEND SRC | ||
1251 | 56 | main.cpp | ||
1252 | 57 | connection.cpp | ||
1253 | 58 | inactivity-timer.cpp | ||
1254 | 59 | service.cpp | ||
1255 | 60 | service-handler.cpp | ||
1256 | 61 | click-handler.cpp | ||
1257 | 62 | ) | ||
1258 | 63 | add_definitions(-DHAVE_CLICK_SUPPORT=1) | ||
1259 | 64 | |||
1260 | 65 | if(DEFINED WEBAPPS_FOUND AND WEBAPPS_FOUND EQUAL 1) | ||
1261 | 66 | if(DEFINED WEBAPPS_REPO_FOUND AND WEBAPPS_REPO_FOUND EQUAL 1) | ||
1262 | 67 | list(APPEND SRC webapps-handler.cpp webapps-process.cpp) | ||
1263 | 68 | add_definitions(-DHAVE_UNITY_WEBAPPS=1) | ||
1264 | 69 | endif() | ||
1265 | 70 | endif() | ||
1266 | 71 | |||
1267 | 72 | include_directories( | ||
1268 | 73 | ${GLIB_INCLUDE_DIRS} | ||
1269 | 74 | ${JSON_GLIB_INCLUDE_DIRS} | ||
1270 | 75 | ${UBUNTU_APP_LAUNCH_INCLUDE_DIRS} | ||
1271 | 76 | ${WEBAPPS_INCLUDE_DIRS} | ||
1272 | 77 | ${WEBAPPS_REPO_INCLUDE_DIRS} | ||
1273 | 78 | ) | ||
1274 | 79 | |||
1275 | 80 | add_executable( | ||
1276 | 81 | ${EXTENSION_NAME} | ||
1277 | 82 | |||
1278 | 83 | ${SRC} | ||
1279 | 84 | ) | ||
1280 | 85 | |||
1281 | 86 | target_link_libraries( | ||
1282 | 87 | ${EXTENSION_NAME} | ||
1283 | 88 | |||
1284 | 89 | Qt5::Core | ||
1285 | 90 | ${GLIB_LIBRARIES} | ||
1286 | 91 | ${WEBAPPS_LIBRARIES} | ||
1287 | 92 | ${WEBAPPS_REPO_LIBRARIES} | ||
1288 | 93 | ${JSON_GLIB_LIBRARIES} | ||
1289 | 94 | ${CLICK_LIBRARIES} | ||
1290 | 95 | ${UBUNTU_APP_LAUNCH_LIBRARIES} | ||
1291 | 96 | ) | ||
1292 | 97 | |||
1293 | 98 | install( | ||
1294 | 99 | TARGETS ${EXTENSION_NAME} | ||
1295 | 100 | RUNTIME DESTINATION ${WEBAPPS_BINDIR} | ||
1296 | 101 | ) | ||
1297 | 0 | 102 | ||
1298 | === removed file 'messaging-host/Makefile.am' | |||
1299 | --- messaging-host/Makefile.am 2014-05-14 07:59:30 +0000 | |||
1300 | +++ messaging-host/Makefile.am 1970-01-01 00:00:00 +0000 | |||
1301 | @@ -1,2 +0,0 @@ | |||
1302 | 1 | EXTRA_DIST += \ | ||
1303 | 2 | installation-host | ||
1304 | 3 | 0 | ||
1305 | === added file 'messaging-host/click-handler.cpp' | |||
1306 | --- messaging-host/click-handler.cpp 1970-01-01 00:00:00 +0000 | |||
1307 | +++ messaging-host/click-handler.cpp 2015-10-07 04:25:10 +0000 | |||
1308 | @@ -0,0 +1,386 @@ | |||
1309 | 1 | /* | ||
1310 | 2 | * Copyright (C) 2015 Canonical Ltd. | ||
1311 | 3 | * | ||
1312 | 4 | * This file is part of webapps-extension | ||
1313 | 5 | * | ||
1314 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
1315 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
1316 | 8 | * by the Free Software Foundation. | ||
1317 | 9 | * | ||
1318 | 10 | * This program is distributed in the hope that it will be useful, but | ||
1319 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1320 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1321 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
1322 | 14 | * | ||
1323 | 15 | * You should have received a copy of the GNU General Public License along | ||
1324 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1325 | 17 | * | ||
1326 | 18 | * Author: Justin McPherson <justin.mcpherson@canonical.com> | ||
1327 | 19 | * | ||
1328 | 20 | */ | ||
1329 | 21 | |||
1330 | 22 | #if defined(HAVE_UNITY_WEBAPPS) | ||
1331 | 23 | extern "C" { | ||
1332 | 24 | #include <unity-webapps-permissions.h> | ||
1333 | 25 | } | ||
1334 | 26 | #endif | ||
1335 | 27 | |||
1336 | 28 | #include <click-0.4/click.h> | ||
1337 | 29 | #include <ubuntu-app-launch.h> | ||
1338 | 30 | |||
1339 | 31 | #include "click-handler.h" | ||
1340 | 32 | |||
1341 | 33 | #include <QUrl> | ||
1342 | 34 | #include <QDebug> | ||
1343 | 35 | |||
1344 | 36 | namespace UnityWebapps { | ||
1345 | 37 | |||
1346 | 38 | namespace { | ||
1347 | 39 | static const gchar* maintainer_key = "maintainer"; | ||
1348 | 40 | static const gchar* title_key = "title"; | ||
1349 | 41 | static const gchar* name_key = "name"; | ||
1350 | 42 | static const gchar* version_key = "version"; | ||
1351 | 43 | static const gchar* maintainer_name = "Webapps Team <webapps@lists.launchpad.net>"; | ||
1352 | 44 | static const gchar* directory_key = "_directory"; | ||
1353 | 45 | static const gchar* hooks_key = "hooks"; | ||
1354 | 46 | static const gchar* urls_key = "urls"; | ||
1355 | 47 | static const gchar* desktop_key = "desktop"; | ||
1356 | 48 | static const gchar* domain_suffix_key = "domain-suffix"; | ||
1357 | 49 | static const gchar* launch_method = "launch_click"; | ||
1358 | 50 | static const gchar* available_method = "click_available"; | ||
1359 | 51 | |||
1360 | 52 | gchar* dispatcherFilenameFromManifest(JsonObject *manifest) | ||
1361 | 53 | { | ||
1362 | 54 | const gchar* directory = json_object_get_string_member(manifest, directory_key); | ||
1363 | 55 | JsonObject* hooks = json_object_get_object_member(manifest, hooks_key); | ||
1364 | 56 | if (directory == nullptr || hooks == nullptr) { | ||
1365 | 57 | return nullptr; | ||
1366 | 58 | } | ||
1367 | 59 | |||
1368 | 60 | const gchar* dispatcher_filename = nullptr; | ||
1369 | 61 | |||
1370 | 62 | // Search objects in hooks for urls key | ||
1371 | 63 | json_object_foreach_member(hooks, [](JsonObject* object, const gchar* member_name, JsonNode* member_node, gpointer user_data) { | ||
1372 | 64 | const gchar** df = static_cast<const gchar**>(user_data); | ||
1373 | 65 | if (*df != nullptr) | ||
1374 | 66 | return; | ||
1375 | 67 | if (json_node_get_node_type(member_node) != JSON_NODE_OBJECT) | ||
1376 | 68 | return; | ||
1377 | 69 | |||
1378 | 70 | JsonObject *member_object = json_node_get_object(member_node); | ||
1379 | 71 | json_object_foreach_member(member_object, [](JsonObject* object, const gchar* member_name, JsonNode* member_node, gpointer user_data) { | ||
1380 | 72 | if (g_ascii_strncasecmp(urls_key, member_name, strlen(urls_key)) == 0) { | ||
1381 | 73 | const gchar** df = static_cast<const gchar**>(user_data); | ||
1382 | 74 | *df = json_object_get_string_member(object, urls_key); | ||
1383 | 75 | } | ||
1384 | 76 | }, user_data); | ||
1385 | 77 | }, &dispatcher_filename); | ||
1386 | 78 | |||
1387 | 79 | if (dispatcher_filename == nullptr) { | ||
1388 | 80 | return nullptr; | ||
1389 | 81 | } | ||
1390 | 82 | |||
1391 | 83 | return g_strjoin("/", directory, dispatcher_filename, nullptr); | ||
1392 | 84 | } | ||
1393 | 85 | |||
1394 | 86 | gchar* appLaunchAppIdFromManifest(JsonObject *manifest) | ||
1395 | 87 | { | ||
1396 | 88 | JsonObject* hooks = json_object_get_object_member(manifest, hooks_key); | ||
1397 | 89 | if (hooks == nullptr) { | ||
1398 | 90 | return nullptr; | ||
1399 | 91 | } | ||
1400 | 92 | |||
1401 | 93 | // Find hook used in creation of desktop file | ||
1402 | 94 | gchar* hook_name = nullptr; | ||
1403 | 95 | json_object_foreach_member(hooks, [](JsonObject* object, const gchar* member_name, JsonNode* member_node, gpointer user_data) { | ||
1404 | 96 | gchar** hn = static_cast<gchar**>(user_data); | ||
1405 | 97 | if (*hn != nullptr) | ||
1406 | 98 | return; | ||
1407 | 99 | if (json_node_get_node_type(member_node) != JSON_NODE_OBJECT) | ||
1408 | 100 | return; | ||
1409 | 101 | |||
1410 | 102 | JsonObject *member_object = json_node_get_object(member_node); | ||
1411 | 103 | if (json_object_has_member(member_object, desktop_key)) { | ||
1412 | 104 | *hn = g_strdup(member_name); | ||
1413 | 105 | } | ||
1414 | 106 | }, &hook_name); | ||
1415 | 107 | |||
1416 | 108 | if (hook_name == nullptr) { | ||
1417 | 109 | return nullptr; | ||
1418 | 110 | } | ||
1419 | 111 | |||
1420 | 112 | const gchar* app_name = json_object_get_string_member(manifest, name_key); | ||
1421 | 113 | const gchar* app_version = json_object_get_string_member(manifest, version_key); | ||
1422 | 114 | if (app_name == nullptr || app_version == nullptr) { | ||
1423 | 115 | g_free(hook_name); | ||
1424 | 116 | return nullptr; | ||
1425 | 117 | } | ||
1426 | 118 | |||
1427 | 119 | gchar *result = g_strjoin("_", app_name, hook_name, app_version, nullptr); | ||
1428 | 120 | g_free(hook_name); | ||
1429 | 121 | return result; | ||
1430 | 122 | } | ||
1431 | 123 | |||
1432 | 124 | GList* domainsFromDispatcherFile(const gchar* dispatcher_filename) | ||
1433 | 125 | { | ||
1434 | 126 | GList *domains = nullptr; | ||
1435 | 127 | JsonParser* parser = json_parser_new(); | ||
1436 | 128 | GError* error = nullptr; | ||
1437 | 129 | if (!json_parser_load_from_file(parser, dispatcher_filename, &error)) { | ||
1438 | 130 | qDebug() << "Error parsing URL dispatched JSON" << error->message; | ||
1439 | 131 | return nullptr; | ||
1440 | 132 | } | ||
1441 | 133 | |||
1442 | 134 | JsonNode* root = json_parser_get_root(parser); | ||
1443 | 135 | if (json_node_get_node_type(root) != JSON_NODE_ARRAY) { | ||
1444 | 136 | qDebug() << "Unexpected contents of URL dispatcher JSON file"; | ||
1445 | 137 | return nullptr; | ||
1446 | 138 | } | ||
1447 | 139 | |||
1448 | 140 | JsonArray* domains_array = json_node_get_array(root); | ||
1449 | 141 | json_array_foreach_element(domains_array, [](JsonArray*, guint index, JsonNode* element_node, gpointer user_data) { | ||
1450 | 142 | if (json_node_get_node_type(element_node) == JSON_NODE_OBJECT) { | ||
1451 | 143 | JsonObject *object = json_node_get_object(element_node); | ||
1452 | 144 | const gchar *domain_suffix = json_object_get_string_member(object, domain_suffix_key); | ||
1453 | 145 | if (domain_suffix != nullptr) { | ||
1454 | 146 | GList** domains = static_cast<GList**>(user_data); | ||
1455 | 147 | *domains = g_list_append(*domains, g_strdup(domain_suffix)); | ||
1456 | 148 | } | ||
1457 | 149 | } | ||
1458 | 150 | }, &domains); | ||
1459 | 151 | |||
1460 | 152 | g_object_unref(parser); | ||
1461 | 153 | |||
1462 | 154 | return domains; | ||
1463 | 155 | } | ||
1464 | 156 | |||
1465 | 157 | } | ||
1466 | 158 | |||
1467 | 159 | class ClickHandlerPrivate | ||
1468 | 160 | { | ||
1469 | 161 | Q_DECLARE_PUBLIC(ClickHandler) | ||
1470 | 162 | |||
1471 | 163 | public: | ||
1472 | 164 | inline ClickHandlerPrivate(ClickHandler *service); | ||
1473 | 165 | inline ~ClickHandlerPrivate(); | ||
1474 | 166 | |||
1475 | 167 | GList* findMatchingApplications(const QUrl& url); | ||
1476 | 168 | |||
1477 | 169 | private: | ||
1478 | 170 | ClickDB* getDatabase(); | ||
1479 | 171 | |||
1480 | 172 | ClickHandler *q_ptr; | ||
1481 | 173 | ClickDB *clickDb; | ||
1482 | 174 | }; | ||
1483 | 175 | |||
1484 | 176 | |||
1485 | 177 | ClickHandlerPrivate::ClickHandlerPrivate(ClickHandler *service) | ||
1486 | 178 | : q_ptr(service) | ||
1487 | 179 | , clickDb(nullptr) | ||
1488 | 180 | { | ||
1489 | 181 | } | ||
1490 | 182 | |||
1491 | 183 | ClickHandlerPrivate::~ClickHandlerPrivate() | ||
1492 | 184 | { | ||
1493 | 185 | if (clickDb != nullptr) { | ||
1494 | 186 | g_object_unref(G_OBJECT(clickDb)); | ||
1495 | 187 | } | ||
1496 | 188 | } | ||
1497 | 189 | |||
1498 | 190 | GList* ClickHandlerPrivate::findMatchingApplications(const QUrl& url) | ||
1499 | 191 | { | ||
1500 | 192 | GError *error = nullptr; | ||
1501 | 193 | JsonArray *manifests = click_db_get_manifests(getDatabase(), true, &error); | ||
1502 | 194 | if (error != nullptr) { | ||
1503 | 195 | qDebug() << __func__ << "error: " << error->message; | ||
1504 | 196 | g_error_free(error); | ||
1505 | 197 | return nullptr; | ||
1506 | 198 | } | ||
1507 | 199 | |||
1508 | 200 | struct _context { | ||
1509 | 201 | GList *matching_apps; | ||
1510 | 202 | const QUrl& visited_url; | ||
1511 | 203 | } context{nullptr, url}; | ||
1512 | 204 | |||
1513 | 205 | json_array_foreach_element(manifests, [](JsonArray*, guint index, JsonNode* element_node, gpointer user_data) { | ||
1514 | 206 | _context* context = static_cast<_context*>(user_data); | ||
1515 | 207 | |||
1516 | 208 | if (json_node_get_node_type(element_node) != JSON_NODE_OBJECT) { | ||
1517 | 209 | return; | ||
1518 | 210 | } | ||
1519 | 211 | JsonObject *manifest = json_node_get_object(element_node); | ||
1520 | 212 | |||
1521 | 213 | // Look for maintainer == Webapps Team <webapps@lists.launchpad.net> | ||
1522 | 214 | if (qgetenv("UNITY_WEBAPPS_IGNORE_MAINTAINER") != QByteArrayLiteral("1")) { | ||
1523 | 215 | const gchar *maintainer = json_object_get_string_member(manifest, maintainer_key); | ||
1524 | 216 | if (maintainer == nullptr || | ||
1525 | 217 | g_ascii_strncasecmp(maintainer, maintainer_name, strlen(maintainer_name)) != 0) { | ||
1526 | 218 | return; | ||
1527 | 219 | } | ||
1528 | 220 | } | ||
1529 | 221 | |||
1530 | 222 | // Look at url dispatcher | ||
1531 | 223 | gchar* dispatcher_filename = dispatcherFilenameFromManifest(manifest); | ||
1532 | 224 | if (dispatcher_filename == nullptr) { | ||
1533 | 225 | return; | ||
1534 | 226 | } | ||
1535 | 227 | |||
1536 | 228 | GList* domains = domainsFromDispatcherFile(dispatcher_filename); | ||
1537 | 229 | if (domains == nullptr) { | ||
1538 | 230 | g_free(dispatcher_filename); | ||
1539 | 231 | return; | ||
1540 | 232 | } | ||
1541 | 233 | |||
1542 | 234 | for (GList *item = domains; item->next != nullptr; item = item->next) { | ||
1543 | 235 | QStringList visited_url_parts = context->visited_url.host().split("."); | ||
1544 | 236 | QStringList test_url_parts = QString::fromLatin1((gchar*)item->data).split("."); | ||
1545 | 237 | int visited_length = visited_url_parts.length(); | ||
1546 | 238 | int test_length = test_url_parts.length(); | ||
1547 | 239 | if (visited_length == test_length) { | ||
1548 | 240 | if (visited_url_parts == test_url_parts) { | ||
1549 | 241 | json_object_ref(manifest); | ||
1550 | 242 | context->matching_apps = g_list_append(context->matching_apps, manifest); | ||
1551 | 243 | } | ||
1552 | 244 | } else { | ||
1553 | 245 | // Every part of test url must match | ||
1554 | 246 | if (visited_length >= test_length) { | ||
1555 | 247 | bool match = true; | ||
1556 | 248 | for (int i = 1; i < test_length + 1; ++i) { | ||
1557 | 249 | if (test_url_parts.at(test_length - i) != visited_url_parts.at(visited_length - i)) { | ||
1558 | 250 | match = false; | ||
1559 | 251 | break; | ||
1560 | 252 | } | ||
1561 | 253 | } | ||
1562 | 254 | if (match) { | ||
1563 | 255 | json_object_ref(manifest); | ||
1564 | 256 | context->matching_apps = g_list_append(context->matching_apps, manifest); | ||
1565 | 257 | } | ||
1566 | 258 | } | ||
1567 | 259 | } | ||
1568 | 260 | } | ||
1569 | 261 | g_list_free_full(domains, g_free); | ||
1570 | 262 | g_free(dispatcher_filename); | ||
1571 | 263 | }, &context); | ||
1572 | 264 | |||
1573 | 265 | return context.matching_apps; | ||
1574 | 266 | } | ||
1575 | 267 | |||
1576 | 268 | |||
1577 | 269 | |||
1578 | 270 | ClickDB* ClickHandlerPrivate::getDatabase() | ||
1579 | 271 | { | ||
1580 | 272 | if (clickDb == nullptr) { | ||
1581 | 273 | GError *error = nullptr; | ||
1582 | 274 | clickDb = click_db_new(); | ||
1583 | 275 | click_db_read(clickDb, nullptr, &error); | ||
1584 | 276 | if (error != nullptr) { | ||
1585 | 277 | qDebug() << __func__ << "error: " << error->message; | ||
1586 | 278 | g_error_free(error); | ||
1587 | 279 | g_object_unref(clickDb); | ||
1588 | 280 | clickDb = nullptr; | ||
1589 | 281 | } | ||
1590 | 282 | } | ||
1591 | 283 | |||
1592 | 284 | return clickDb; | ||
1593 | 285 | } | ||
1594 | 286 | |||
1595 | 287 | |||
1596 | 288 | ClickHandler::ClickHandler(QObject *parent) | ||
1597 | 289 | : QObject(parent) | ||
1598 | 290 | , d_ptr(new ClickHandlerPrivate(this)) | ||
1599 | 291 | { | ||
1600 | 292 | } | ||
1601 | 293 | |||
1602 | 294 | ClickHandler::~ClickHandler() | ||
1603 | 295 | { | ||
1604 | 296 | delete d_ptr; | ||
1605 | 297 | } | ||
1606 | 298 | |||
1607 | 299 | QVariantMap ClickHandler::click_available(const QVariantMap &message) | ||
1608 | 300 | { | ||
1609 | 301 | Q_D(ClickHandler); | ||
1610 | 302 | |||
1611 | 303 | QVariantMap reply; | ||
1612 | 304 | reply.insert("method", available_method); | ||
1613 | 305 | if (!message.contains("url")) { | ||
1614 | 306 | reply.insert("error", QStringLiteral("malformed request")); | ||
1615 | 307 | return reply; | ||
1616 | 308 | } | ||
1617 | 309 | |||
1618 | 310 | QString url = message.value("url").toString(); | ||
1619 | 311 | |||
1620 | 312 | GList *matching_apps = d->findMatchingApplications(QUrl(url)); | ||
1621 | 313 | |||
1622 | 314 | if (matching_apps == nullptr) { | ||
1623 | 315 | reply.insert("available", false); | ||
1624 | 316 | return reply; | ||
1625 | 317 | } | ||
1626 | 318 | |||
1627 | 319 | // First element is OK | ||
1628 | 320 | JsonObject* package_object = static_cast<JsonObject*>(matching_apps->data); | ||
1629 | 321 | |||
1630 | 322 | const gchar *appName = json_object_get_string_member(package_object, title_key); | ||
1631 | 323 | const gchar *appDomain = nullptr; /* something from url dispatcher?*/ | ||
1632 | 324 | const gchar *appVersion = json_object_get_string_member(package_object, version_key); | ||
1633 | 325 | |||
1634 | 326 | #if defined(HAVE_UNITY_WEBAPPS) | ||
1635 | 327 | if (unity_webapps_permissions_get_domain_dontask(appDomain) || | ||
1636 | 328 | unity_webapps_permissions_get_domain_allowed(appDomain)) { | ||
1637 | 329 | reply.insert("available", false); | ||
1638 | 330 | for (GList *item = matching_apps; item->next != nullptr; item = item->next) { | ||
1639 | 331 | json_object_unref(static_cast<JsonObject*>(item->data)); | ||
1640 | 332 | } | ||
1641 | 333 | return reply; | ||
1642 | 334 | } | ||
1643 | 335 | #endif | ||
1644 | 336 | reply.insert("available", true); | ||
1645 | 337 | reply.insert("appName", QString::fromUtf8(appName)); | ||
1646 | 338 | reply.insert("appDomain", QString::fromUtf8(appDomain)); | ||
1647 | 339 | reply.insert("appVersion", QString::fromUtf8(appVersion)); | ||
1648 | 340 | |||
1649 | 341 | for (GList *item = matching_apps; item->next != nullptr; item = item->next) { | ||
1650 | 342 | json_object_unref(static_cast<JsonObject*>(item->data)); | ||
1651 | 343 | } | ||
1652 | 344 | |||
1653 | 345 | return reply; | ||
1654 | 346 | } | ||
1655 | 347 | |||
1656 | 348 | QVariantMap ClickHandler::launch_click(const QVariantMap& message) | ||
1657 | 349 | { | ||
1658 | 350 | Q_D(ClickHandler); | ||
1659 | 351 | |||
1660 | 352 | QVariantMap reply; | ||
1661 | 353 | reply.insert("method", launch_method); | ||
1662 | 354 | |||
1663 | 355 | if (!message.contains("url")) { | ||
1664 | 356 | reply.insert("error", QLatin1String("malformed request")); | ||
1665 | 357 | return reply; | ||
1666 | 358 | } | ||
1667 | 359 | |||
1668 | 360 | QString url = message.value("url").toString(); | ||
1669 | 361 | reply.insert("url", url); | ||
1670 | 362 | |||
1671 | 363 | GList *matching_apps = d->findMatchingApplications(QUrl(url)); | ||
1672 | 364 | if (matching_apps == nullptr) { | ||
1673 | 365 | reply.insert("launched", false); | ||
1674 | 366 | reply.insert("available", false); | ||
1675 | 367 | return reply; | ||
1676 | 368 | } | ||
1677 | 369 | |||
1678 | 370 | // Grab first, convert to an "app id" | ||
1679 | 371 | JsonObject* manifest = (JsonObject*)matching_apps->data; | ||
1680 | 372 | |||
1681 | 373 | gchar* app_id = appLaunchAppIdFromManifest(manifest); | ||
1682 | 374 | if (app_id == nullptr) { | ||
1683 | 375 | reply.insert("launched", false); | ||
1684 | 376 | return reply; | ||
1685 | 377 | } | ||
1686 | 378 | |||
1687 | 379 | gboolean app_launched = ubuntu_app_launch_start_application(app_id, nullptr); | ||
1688 | 380 | g_free(app_id); | ||
1689 | 381 | |||
1690 | 382 | reply.insert("launched", bool(app_launched)); | ||
1691 | 383 | return reply; | ||
1692 | 384 | } | ||
1693 | 385 | |||
1694 | 386 | } // namespace | ||
1695 | 0 | 387 | ||
1696 | === added file 'messaging-host/click-handler.h' | |||
1697 | --- messaging-host/click-handler.h 1970-01-01 00:00:00 +0000 | |||
1698 | +++ messaging-host/click-handler.h 2015-10-07 04:25:10 +0000 | |||
1699 | @@ -0,0 +1,55 @@ | |||
1700 | 1 | /* | ||
1701 | 2 | * Copyright (C) 2015 Canonical Ltd. | ||
1702 | 3 | * | ||
1703 | 4 | * This file is part of unity-chromium-extension | ||
1704 | 5 | * | ||
1705 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
1706 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
1707 | 8 | * by the Free Software Foundation. | ||
1708 | 9 | * | ||
1709 | 10 | * This program is distributed in the hope that it will be useful, but | ||
1710 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1711 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1712 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
1713 | 14 | * | ||
1714 | 15 | * You should have received a copy of the GNU General Public License along | ||
1715 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1716 | 17 | * | ||
1717 | 18 | * Author: Justin McPherson <justin.mcpherson@canonical.com> | ||
1718 | 19 | * | ||
1719 | 20 | */ | ||
1720 | 21 | |||
1721 | 22 | #ifndef UNITY_WEBAPPS_CLICK_HANDLER | ||
1722 | 23 | #define UNITY_WEBAPPS_CLICK_HANDLER | ||
1723 | 24 | |||
1724 | 25 | #include <QObject> | ||
1725 | 26 | #include <QVariantMap> | ||
1726 | 27 | |||
1727 | 28 | namespace UnityWebapps { | ||
1728 | 29 | |||
1729 | 30 | class ClickHandlerPrivate; | ||
1730 | 31 | class ClickHandler : public QObject | ||
1731 | 32 | { | ||
1732 | 33 | Q_OBJECT | ||
1733 | 34 | |||
1734 | 35 | public: | ||
1735 | 36 | explicit ClickHandler(QObject *parent = 0); | ||
1736 | 37 | ~ClickHandler(); | ||
1737 | 38 | |||
1738 | 39 | public Q_SLOTS: | ||
1739 | 40 | QVariantMap click_available(const QVariantMap& message); | ||
1740 | 41 | QVariantMap launch_click(const QVariantMap& message); | ||
1741 | 42 | |||
1742 | 43 | #if defined(UCX_UNDER_TEST) | ||
1743 | 44 | public: | ||
1744 | 45 | #else | ||
1745 | 46 | private: | ||
1746 | 47 | #endif | ||
1747 | 48 | |||
1748 | 49 | ClickHandlerPrivate *d_ptr; | ||
1749 | 50 | Q_DECLARE_PRIVATE(ClickHandler) | ||
1750 | 51 | }; | ||
1751 | 52 | |||
1752 | 53 | } // namespace | ||
1753 | 54 | |||
1754 | 55 | #endif // UNITY_WEBAPPS_CLICK_HANDLER | ||
1755 | 0 | 56 | ||
1756 | === added file 'messaging-host/com.canonical.webapp.extension.json.in' | |||
1757 | --- messaging-host/com.canonical.webapp.extension.json.in 1970-01-01 00:00:00 +0000 | |||
1758 | +++ messaging-host/com.canonical.webapp.extension.json.in 2015-10-07 04:25:10 +0000 | |||
1759 | @@ -0,0 +1,9 @@ | |||
1760 | 1 | { | ||
1761 | 2 | "name": "com.canonical.webapp.extension", | ||
1762 | 3 | "description": "Canonical WebApp Extension Host", | ||
1763 | 4 | "path": "${WEBAPPS_BINDIR}/${EXTENSION_NAME}", | ||
1764 | 5 | "type": "stdio", | ||
1765 | 6 | "allowed_origins": [ | ||
1766 | 7 | "chrome-extension://pmoflmbbcfgacopiikdcpmbiellfihdg/" | ||
1767 | 8 | ] | ||
1768 | 9 | } | ||
1769 | 0 | 10 | ||
1770 | === removed file 'messaging-host/com.canonical.webapp.installer.json.in' | |||
1771 | --- messaging-host/com.canonical.webapp.installer.json.in 2014-05-21 12:32:50 +0000 | |||
1772 | +++ messaging-host/com.canonical.webapp.installer.json.in 1970-01-01 00:00:00 +0000 | |||
1773 | @@ -1,9 +0,0 @@ | |||
1774 | 1 | { | ||
1775 | 2 | '"name": "com.canonical.webapp.installer"', | ||
1776 | 3 | '"description": "Canonical WebApp Installation Host"', | ||
1777 | 4 | '"path": "$${target.path}/$${TARGET}"', | ||
1778 | 5 | '"type": "stdio"', | ||
1779 | 6 | '"allowed_origins"': [ | ||
1780 | 7 | '"chrome-extension://pmoflmbbcfgacopiikdcpmbiellfihdg/"' | ||
1781 | 8 | ] | ||
1782 | 9 | } | ||
1783 | 10 | 0 | ||
1784 | === modified file 'messaging-host/main.cpp' | |||
1785 | --- messaging-host/main.cpp 2014-06-20 06:16:48 +0000 | |||
1786 | +++ messaging-host/main.cpp 2015-10-07 04:25:10 +0000 | |||
1787 | @@ -21,12 +21,22 @@ | |||
1788 | 21 | #include "connection.h" | 21 | #include "connection.h" |
1789 | 22 | #include "inactivity-timer.h" | 22 | #include "inactivity-timer.h" |
1790 | 23 | #include "service.h" | 23 | #include "service.h" |
1791 | 24 | #include "service-handler.h" | ||
1792 | 25 | #if defined(HAVE_UNITY_WEBAPPS) | ||
1793 | 26 | #include "webapps-process.h" | ||
1794 | 24 | #include "webapps-handler.h" | 27 | #include "webapps-handler.h" |
1796 | 25 | #include "webapps-process.h" | 28 | #endif |
1797 | 29 | #if defined(HAVE_CLICK_SUPPORT) | ||
1798 | 30 | #include "click-handler.h" | ||
1799 | 31 | #endif | ||
1800 | 26 | 32 | ||
1801 | 27 | #include <QCoreApplication> | 33 | #include <QCoreApplication> |
1802 | 28 | #include <QDebug> | 34 | #include <QDebug> |
1803 | 29 | 35 | ||
1804 | 36 | namespace { | ||
1805 | 37 | // Time in milliseconds before process exits from timeout. | ||
1806 | 38 | const int INACTIVE_TIMEOUT = 2 * 60 * 1000; | ||
1807 | 39 | } | ||
1808 | 30 | 40 | ||
1809 | 31 | void syslogOutputHandler(QtMsgType type, const QMessageLogContext &, const QString &msg) | 41 | void syslogOutputHandler(QtMsgType type, const QMessageLogContext &, const QString &msg) |
1810 | 32 | { | 42 | { |
1811 | @@ -61,13 +71,24 @@ | |||
1812 | 61 | 71 | ||
1813 | 62 | QCoreApplication app(argc, argv); | 72 | QCoreApplication app(argc, argv); |
1814 | 63 | 73 | ||
1815 | 74 | UnityWebapps::Service service; | ||
1816 | 75 | |||
1817 | 76 | // Handle service wide messages | ||
1818 | 77 | UnityWebapps::ServiceHandler service_handler; | ||
1819 | 78 | service.addHandler(&service_handler); | ||
1820 | 79 | |||
1821 | 80 | #if defined(HAVE_UNITY_WEBAPPS) | ||
1822 | 64 | UnityWebapps::Process process; | 81 | UnityWebapps::Process process; |
1829 | 65 | 82 | UnityWebapps::WebappsHandler apt_handler; | |
1830 | 66 | UnityWebapps::Service service; | 83 | service.addHandler(&apt_handler); |
1831 | 67 | UnityWebapps::WebappsHandler handler; | 84 | #endif |
1832 | 68 | service.addHandler(&handler); | 85 | |
1833 | 69 | 86 | #if defined(HAVE_CLICK_SUPPORT) | |
1834 | 70 | UnityWebapps::InactivityTimer inactivityTimer(2 * 60 * 1000); | 87 | UnityWebapps::ClickHandler click_handler; |
1835 | 88 | service.addHandler(&click_handler); | ||
1836 | 89 | #endif | ||
1837 | 90 | |||
1838 | 91 | UnityWebapps::InactivityTimer inactivityTimer(INACTIVE_TIMEOUT); | ||
1839 | 71 | QObject::connect(&inactivityTimer, SIGNAL(timeout()), &app, SLOT(quit())); | 92 | QObject::connect(&inactivityTimer, SIGNAL(timeout()), &app, SLOT(quit())); |
1840 | 72 | inactivityTimer.watchObject(&service); | 93 | inactivityTimer.watchObject(&service); |
1841 | 73 | 94 | ||
1842 | @@ -88,4 +109,3 @@ | |||
1843 | 88 | 109 | ||
1844 | 89 | return r; | 110 | return r; |
1845 | 90 | } | 111 | } |
1846 | 91 | |||
1847 | 92 | 112 | ||
1848 | === removed file 'messaging-host/messaging-host.pro' | |||
1849 | --- messaging-host/messaging-host.pro 2014-06-20 06:16:48 +0000 | |||
1850 | +++ messaging-host/messaging-host.pro 1970-01-01 00:00:00 +0000 | |||
1851 | @@ -1,42 +0,0 @@ | |||
1852 | 1 | include(../common-project-config.pri) | ||
1853 | 2 | |||
1854 | 3 | TEMPLATE = app | ||
1855 | 4 | TARGET = unity-webapps-messaging-host | ||
1856 | 5 | |||
1857 | 6 | CONFIG += \ | ||
1858 | 7 | link_pkgconfig \ | ||
1859 | 8 | qt | ||
1860 | 9 | |||
1861 | 10 | QT += \ | ||
1862 | 11 | core | ||
1863 | 12 | |||
1864 | 13 | PKGCONFIG += \ | ||
1865 | 14 | glib-2.0 \ | ||
1866 | 15 | gobject-2.0 \ | ||
1867 | 16 | libunity_webapps-0.2 \ | ||
1868 | 17 | libunity-webapps-repository \ | ||
1869 | 18 | |||
1870 | 19 | SOURCES = \ | ||
1871 | 20 | connection.cpp \ | ||
1872 | 21 | inactivity-timer.cpp \ | ||
1873 | 22 | main.cpp \ | ||
1874 | 23 | service.cpp \ | ||
1875 | 24 | webapps-handler.cpp \ | ||
1876 | 25 | webapps-process.cpp \ | ||
1877 | 26 | |||
1878 | 27 | HEADERS = \ | ||
1879 | 28 | connection.h \ | ||
1880 | 29 | inactivity-timer.h \ | ||
1881 | 30 | service.h \ | ||
1882 | 31 | webapps-handler.h \ | ||
1883 | 32 | webapps-process.h \ | ||
1884 | 33 | |||
1885 | 34 | target.path = $${INSTALL_PREFIX}/share/unity-webapps/bin | ||
1886 | 35 | INSTALLS += target | ||
1887 | 36 | |||
1888 | 37 | QMAKE_SUBSTITUTES += \ | ||
1889 | 38 | com.canonical.webapp.installer.json.in | ||
1890 | 39 | |||
1891 | 40 | manifest.path = "/etc/chromium/native-messaging-hosts" | ||
1892 | 41 | manifest.files = com.canonical.webapp.installer.json | ||
1893 | 42 | INSTALLS += manifest | ||
1894 | 43 | 0 | ||
1895 | === added file 'messaging-host/service-handler.cpp' | |||
1896 | --- messaging-host/service-handler.cpp 1970-01-01 00:00:00 +0000 | |||
1897 | +++ messaging-host/service-handler.cpp 2015-10-07 04:25:10 +0000 | |||
1898 | @@ -0,0 +1,75 @@ | |||
1899 | 1 | /* | ||
1900 | 2 | * Copyright (C) 2015 Canonical Ltd. | ||
1901 | 3 | * | ||
1902 | 4 | * This file is part of webapps-extension | ||
1903 | 5 | * | ||
1904 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
1905 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
1906 | 8 | * by the Free Software Foundation. | ||
1907 | 9 | * | ||
1908 | 10 | * This program is distributed in the hope that it will be useful, but | ||
1909 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1910 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1911 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
1912 | 14 | * | ||
1913 | 15 | * You should have received a copy of the GNU General Public License along | ||
1914 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1915 | 17 | * | ||
1916 | 18 | * Author: Justin McPherson <justin.mcpherson@canonical.com> | ||
1917 | 19 | * | ||
1918 | 20 | */ | ||
1919 | 21 | |||
1920 | 22 | #include "service-handler.h" | ||
1921 | 23 | |||
1922 | 24 | #include <QDebug> | ||
1923 | 25 | #include <QRegularExpression> | ||
1924 | 26 | |||
1925 | 27 | |||
1926 | 28 | namespace UnityWebapps { | ||
1927 | 29 | |||
1928 | 30 | class ServiceHandlerPrivate | ||
1929 | 31 | { | ||
1930 | 32 | Q_DECLARE_PUBLIC(ServiceHandler) | ||
1931 | 33 | |||
1932 | 34 | public: | ||
1933 | 35 | ServiceHandlerPrivate(ServiceHandler *service); | ||
1934 | 36 | ~ServiceHandlerPrivate(); | ||
1935 | 37 | |||
1936 | 38 | private: | ||
1937 | 39 | mutable ServiceHandler *q_ptr; | ||
1938 | 40 | }; | ||
1939 | 41 | |||
1940 | 42 | |||
1941 | 43 | ServiceHandlerPrivate::ServiceHandlerPrivate(ServiceHandler *service) | ||
1942 | 44 | : q_ptr(service) | ||
1943 | 45 | { | ||
1944 | 46 | } | ||
1945 | 47 | |||
1946 | 48 | ServiceHandlerPrivate::~ServiceHandlerPrivate() | ||
1947 | 49 | { | ||
1948 | 50 | } | ||
1949 | 51 | |||
1950 | 52 | |||
1951 | 53 | ServiceHandler::ServiceHandler(QObject *parent) | ||
1952 | 54 | : QObject(parent) | ||
1953 | 55 | , d_ptr(new ServiceHandlerPrivate(this)) | ||
1954 | 56 | { | ||
1955 | 57 | } | ||
1956 | 58 | |||
1957 | 59 | ServiceHandler::~ServiceHandler() | ||
1958 | 60 | { | ||
1959 | 61 | delete d_ptr; | ||
1960 | 62 | } | ||
1961 | 63 | |||
1962 | 64 | QVariantMap ServiceHandler::ping(const QVariantMap &message) | ||
1963 | 65 | { | ||
1964 | 66 | Q_UNUSED(message); | ||
1965 | 67 | |||
1966 | 68 | QVariantMap reply; | ||
1967 | 69 | |||
1968 | 70 | reply.insert("pong", QLatin1String("alive")); | ||
1969 | 71 | |||
1970 | 72 | return reply; | ||
1971 | 73 | } | ||
1972 | 74 | |||
1973 | 75 | } // namespace | ||
1974 | 0 | 76 | ||
1975 | === added file 'messaging-host/service-handler.h' | |||
1976 | --- messaging-host/service-handler.h 1970-01-01 00:00:00 +0000 | |||
1977 | +++ messaging-host/service-handler.h 2015-10-07 04:25:10 +0000 | |||
1978 | @@ -0,0 +1,54 @@ | |||
1979 | 1 | /* | ||
1980 | 2 | * Copyright (C) 2015 Canonical Ltd. | ||
1981 | 3 | * | ||
1982 | 4 | * This file is part of unity-chromium-extension | ||
1983 | 5 | * | ||
1984 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
1985 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
1986 | 8 | * by the Free Software Foundation. | ||
1987 | 9 | * | ||
1988 | 10 | * This program is distributed in the hope that it will be useful, but | ||
1989 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1990 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1991 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
1992 | 14 | * | ||
1993 | 15 | * You should have received a copy of the GNU General Public License along | ||
1994 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1995 | 17 | * | ||
1996 | 18 | * Author: Justin McPherson <justin.mcpherson@canonical.com> | ||
1997 | 19 | * | ||
1998 | 20 | */ | ||
1999 | 21 | |||
2000 | 22 | #ifndef UNITY_WEBAPPS_SERVICE_HANDLER | ||
2001 | 23 | #define UNITY_WEBAPPS_SERVICE_HANDLER | ||
2002 | 24 | |||
2003 | 25 | #include <QObject> | ||
2004 | 26 | #include <QVariantMap> | ||
2005 | 27 | |||
2006 | 28 | namespace UnityWebapps { | ||
2007 | 29 | |||
2008 | 30 | class ServiceHandlerPrivate; | ||
2009 | 31 | class ServiceHandler : public QObject | ||
2010 | 32 | { | ||
2011 | 33 | Q_OBJECT | ||
2012 | 34 | |||
2013 | 35 | public: | ||
2014 | 36 | explicit ServiceHandler(QObject *parent = 0); | ||
2015 | 37 | ~ServiceHandler(); | ||
2016 | 38 | |||
2017 | 39 | public Q_SLOTS: | ||
2018 | 40 | QVariantMap ping(const QVariantMap &message); | ||
2019 | 41 | |||
2020 | 42 | #if defined(UCX_UNDER_TEST) | ||
2021 | 43 | public: | ||
2022 | 44 | #else | ||
2023 | 45 | private: | ||
2024 | 46 | #endif | ||
2025 | 47 | ServiceHandlerPrivate *d_ptr; | ||
2026 | 48 | Q_DECLARE_PRIVATE(ServiceHandler) | ||
2027 | 49 | }; | ||
2028 | 50 | |||
2029 | 51 | } // namespace | ||
2030 | 52 | |||
2031 | 53 | #endif // UNITY_WEBAPPS_SERVICE_HANDLER | ||
2032 | 54 | |||
2033 | 0 | 55 | ||
2034 | === modified file 'messaging-host/service.cpp' | |||
2035 | --- messaging-host/service.cpp 2014-05-21 08:18:12 +0000 | |||
2036 | +++ messaging-host/service.cpp 2015-10-07 04:25:10 +0000 | |||
2037 | @@ -45,9 +45,9 @@ | |||
2038 | 45 | 45 | ||
2039 | 46 | } // namespace | 46 | } // namespace |
2040 | 47 | 47 | ||
2044 | 48 | ServicePrivate::ServicePrivate(Service *service): | 48 | ServicePrivate::ServicePrivate(Service *service) |
2045 | 49 | m_isIdle(true), | 49 | : m_isIdle(true) |
2046 | 50 | q_ptr(service) | 50 | , q_ptr(service) |
2047 | 51 | { | 51 | { |
2048 | 52 | } | 52 | } |
2049 | 53 | 53 | ||
2050 | @@ -59,14 +59,16 @@ | |||
2051 | 59 | { | 59 | { |
2052 | 60 | Q_Q(Service); | 60 | Q_Q(Service); |
2053 | 61 | 61 | ||
2055 | 62 | if (m_isIdle == isIdle) return; | 62 | if (m_isIdle == isIdle) { |
2056 | 63 | return; | ||
2057 | 64 | } | ||
2058 | 63 | m_isIdle = isIdle; | 65 | m_isIdle = isIdle; |
2059 | 64 | Q_EMIT q->isIdleChanged(); | 66 | Q_EMIT q->isIdleChanged(); |
2060 | 65 | } | 67 | } |
2061 | 66 | 68 | ||
2065 | 67 | Service::Service(QObject *parent): | 69 | Service::Service(QObject *parent) |
2066 | 68 | QObject(parent), | 70 | : QObject(parent) |
2067 | 69 | d_ptr(new ServicePrivate(this)) | 71 | , d_ptr(new ServicePrivate(this)) |
2068 | 70 | { | 72 | { |
2069 | 71 | } | 73 | } |
2070 | 72 | 74 | ||
2071 | @@ -83,7 +85,6 @@ | |||
2072 | 83 | void Service::addHandler(QObject *handler) | 85 | void Service::addHandler(QObject *handler) |
2073 | 84 | { | 86 | { |
2074 | 85 | Q_D(Service); | 87 | Q_D(Service); |
2075 | 86 | |||
2076 | 87 | d->m_handlers.append(handler); | 88 | d->m_handlers.append(handler); |
2077 | 88 | } | 89 | } |
2078 | 89 | 90 | ||
2079 | @@ -92,7 +93,9 @@ | |||
2080 | 92 | Q_D(Service); | 93 | Q_D(Service); |
2081 | 93 | 94 | ||
2082 | 94 | QByteArray method = message.value(QStringLiteral("method")).toString().toLatin1(); | 95 | QByteArray method = message.value(QStringLiteral("method")).toString().toLatin1(); |
2084 | 95 | if (Q_UNLIKELY(method.isEmpty())) return; | 96 | if (Q_UNLIKELY(method.isEmpty())) { |
2085 | 97 | return; | ||
2086 | 98 | } | ||
2087 | 96 | 99 | ||
2088 | 97 | QByteArray methodSignature = method + "(QVariantMap)"; | 100 | QByteArray methodSignature = method + "(QVariantMap)"; |
2089 | 98 | 101 | ||
2090 | @@ -103,13 +106,17 @@ | |||
2091 | 103 | Q_FOREACH(QObject *handler, d->m_handlers) { | 106 | Q_FOREACH(QObject *handler, d->m_handlers) { |
2092 | 104 | const QMetaObject *metaObject = handler->metaObject(); | 107 | const QMetaObject *metaObject = handler->metaObject(); |
2093 | 105 | int index = metaObject->indexOfMethod(methodSignature); | 108 | int index = metaObject->indexOfMethod(methodSignature); |
2095 | 106 | if (index == -1) continue; | 109 | if (index == -1) { |
2096 | 110 | continue; | ||
2097 | 111 | } | ||
2098 | 107 | 112 | ||
2099 | 108 | QMetaMethod metaMethod = metaObject->method(index); | 113 | QMetaMethod metaMethod = metaObject->method(index); |
2100 | 109 | ok = metaMethod.invoke(handler, | 114 | ok = metaMethod.invoke(handler, |
2101 | 110 | Q_RETURN_ARG(QVariantMap, reply), | 115 | Q_RETURN_ARG(QVariantMap, reply), |
2102 | 111 | Q_ARG(QVariantMap, message)); | 116 | Q_ARG(QVariantMap, message)); |
2104 | 112 | if (ok) break; | 117 | if (ok) { |
2105 | 118 | break; | ||
2106 | 119 | } | ||
2107 | 113 | } | 120 | } |
2108 | 114 | 121 | ||
2109 | 115 | if (ok) { | 122 | if (ok) { |
2110 | 116 | 123 | ||
2111 | === modified file 'messaging-host/webapps-handler.cpp' | |||
2112 | --- messaging-host/webapps-handler.cpp 2014-06-23 06:49:03 +0000 | |||
2113 | +++ messaging-host/webapps-handler.cpp 2015-10-07 04:25:10 +0000 | |||
2114 | @@ -48,24 +48,30 @@ | |||
2115 | 48 | UnityWebappsApplicationStatus status, | 48 | UnityWebappsApplicationStatus status, |
2116 | 49 | gpointer user_data); | 49 | gpointer user_data); |
2117 | 50 | 50 | ||
2119 | 51 | mutable WebappsHandler *q_ptr; | 51 | WebappsHandler *q_ptr; |
2120 | 52 | UnityWebappsService *service; | ||
2121 | 52 | UnityWebappsApplicationRepository *applicationRepository; | 53 | UnityWebappsApplicationRepository *applicationRepository; |
2122 | 53 | }; | 54 | }; |
2123 | 54 | 55 | ||
2124 | 55 | } // namespace | 56 | } // namespace |
2125 | 56 | 57 | ||
2126 | 57 | 58 | ||
2130 | 58 | WebappsHandlerPrivate::WebappsHandlerPrivate(WebappsHandler *service): | 59 | WebappsHandlerPrivate::WebappsHandlerPrivate(WebappsHandler *handler) |
2131 | 59 | q_ptr(service), | 60 | : q_ptr(handler) |
2132 | 60 | applicationRepository(0) | 61 | , service(nullptr) |
2133 | 62 | , applicationRepository(nullptr) | ||
2134 | 61 | { | 63 | { |
2135 | 64 | service = unity_webapps_service_new(); | ||
2136 | 62 | } | 65 | } |
2137 | 63 | 66 | ||
2138 | 64 | WebappsHandlerPrivate::~WebappsHandlerPrivate() | 67 | WebappsHandlerPrivate::~WebappsHandlerPrivate() |
2139 | 65 | { | 68 | { |
2141 | 66 | if (applicationRepository != 0) { | 69 | if (applicationRepository != nullptr) { |
2142 | 67 | g_object_unref(G_OBJECT(applicationRepository)); | 70 | g_object_unref(G_OBJECT(applicationRepository)); |
2143 | 68 | } | 71 | } |
2144 | 72 | if (service != nullptr) { | ||
2145 | 73 | g_object_unref(service); | ||
2146 | 74 | } | ||
2147 | 69 | } | 75 | } |
2148 | 70 | 76 | ||
2149 | 71 | UnityWebappsApplicationRepository *WebappsHandlerPrivate::getRepository() | 77 | UnityWebappsApplicationRepository *WebappsHandlerPrivate::getRepository() |
2150 | @@ -285,17 +291,6 @@ | |||
2151 | 285 | return reply; | 291 | return reply; |
2152 | 286 | } | 292 | } |
2153 | 287 | 293 | ||
2154 | 288 | QVariantMap WebappsHandler::ping(const QVariantMap &message) | ||
2155 | 289 | { | ||
2156 | 290 | Q_UNUSED(message); | ||
2157 | 291 | |||
2158 | 292 | QVariantMap reply; | ||
2159 | 293 | |||
2160 | 294 | reply.insert("pong", QLatin1String("alive")); | ||
2161 | 295 | |||
2162 | 296 | return reply; | ||
2163 | 297 | } | ||
2164 | 298 | |||
2165 | 299 | /* | 294 | /* |
2166 | 300 | \fn createApplicationDesktopName(QString, QString) | 295 | \fn createApplicationDesktopName(QString, QString) |
2167 | 301 | 296 | ||
2168 | @@ -321,4 +316,3 @@ | |||
2169 | 321 | 316 | ||
2170 | 322 | return QStringLiteral("application://%1.desktop").arg(basename); | 317 | return QStringLiteral("application://%1.desktop").arg(basename); |
2171 | 323 | } | 318 | } |
2172 | 324 | |||
2173 | 325 | 319 | ||
2174 | === modified file 'messaging-host/webapps-handler.h' | |||
2175 | --- messaging-host/webapps-handler.h 2014-06-23 07:32:13 +0000 | |||
2176 | +++ messaging-host/webapps-handler.h 2015-10-07 04:25:10 +0000 | |||
2177 | @@ -38,7 +38,6 @@ | |||
2178 | 38 | QVariantMap url_loaded(const QVariantMap &message); | 38 | QVariantMap url_loaded(const QVariantMap &message); |
2179 | 39 | QVariantMap dont_ask(const QVariantMap &message); | 39 | QVariantMap dont_ask(const QVariantMap &message); |
2180 | 40 | QVariantMap install(const QVariantMap &message); | 40 | QVariantMap install(const QVariantMap &message); |
2181 | 41 | QVariantMap ping(const QVariantMap &message); | ||
2182 | 42 | 41 | ||
2183 | 43 | #if defined(UCX_UNDER_TEST) | 42 | #if defined(UCX_UNDER_TEST) |
2184 | 44 | public: | 43 | public: |
2185 | 45 | 44 | ||
2186 | === added file 'tests/CMakeLists.txt' | |||
2187 | --- tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
2188 | +++ tests/CMakeLists.txt 2015-10-07 04:25:10 +0000 | |||
2189 | @@ -0,0 +1,1 @@ | |||
2190 | 1 | add_subdirectory(unit) | ||
2191 | 0 | 2 | ||
2192 | === removed file 'tests/tests.pro' | |||
2193 | --- tests/tests.pro 2014-05-19 14:04:19 +0000 | |||
2194 | +++ tests/tests.pro 1970-01-01 00:00:00 +0000 | |||
2195 | @@ -1,3 +0,0 @@ | |||
2196 | 1 | TEMPLATE = subdirs | ||
2197 | 2 | SUBDIRS = \ | ||
2198 | 3 | unit | ||
2199 | 4 | 0 | ||
2200 | === added file 'tests/unit/CMakeLists.txt' | |||
2201 | --- tests/unit/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
2202 | +++ tests/unit/CMakeLists.txt 2015-10-07 04:25:10 +0000 | |||
2203 | @@ -0,0 +1,1 @@ | |||
2204 | 1 | add_subdirectory(messaging-host) | ||
2205 | 0 | 2 | ||
2206 | === added file 'tests/unit/messaging-host/CMakeLists.txt' | |||
2207 | --- tests/unit/messaging-host/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
2208 | +++ tests/unit/messaging-host/CMakeLists.txt 2015-10-07 04:25:10 +0000 | |||
2209 | @@ -0,0 +1,5 @@ | |||
2210 | 1 | add_subdirectory(connection) | ||
2211 | 2 | add_subdirectory(inactivity-timer) | ||
2212 | 3 | add_subdirectory(webapps-handler) | ||
2213 | 4 | add_subdirectory(click-handler) | ||
2214 | 5 | add_subdirectory(service) | ||
2215 | 0 | 6 | ||
2216 | === added directory 'tests/unit/messaging-host/click-handler' | |||
2217 | === added file 'tests/unit/messaging-host/click-handler/CMakeLists.txt' | |||
2218 | --- tests/unit/messaging-host/click-handler/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
2219 | +++ tests/unit/messaging-host/click-handler/CMakeLists.txt 2015-10-07 04:25:10 +0000 | |||
2220 | @@ -0,0 +1,38 @@ | |||
2221 | 1 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | ||
2222 | 2 | set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
2223 | 3 | set(CMAKE_AUTOMOC ON) | ||
2224 | 4 | |||
2225 | 5 | find_package(PkgConfig) | ||
2226 | 6 | find_package(Qt5Core REQUIRED) | ||
2227 | 7 | find_package(Qt5Test REQUIRED) | ||
2228 | 8 | |||
2229 | 9 | pkg_check_modules(GLIB glib-2.0 REQUIRED) | ||
2230 | 10 | pkg_check_modules(GOBJECT gobject-2.0 REQUIRED) | ||
2231 | 11 | pkg_check_modules(JSON_GLIB json-glib-1.0 REQUIRED) | ||
2232 | 12 | pkg_check_modules(CLICK click-0.4 REQUIRED) | ||
2233 | 13 | pkg_check_modules(UBUNTU_APP_LAUNCH ubuntu-app-launch-2 REQUIRED) | ||
2234 | 14 | |||
2235 | 15 | |||
2236 | 16 | set(TEST tst_ClickHandler) | ||
2237 | 17 | set(SOURCES | ||
2238 | 18 | ${messaging-host_SOURCE_DIR}/click-handler.cpp | ||
2239 | 19 | tst_click-handler.cpp | ||
2240 | 20 | ) | ||
2241 | 21 | |||
2242 | 22 | include_directories( | ||
2243 | 23 | ${messaging-host_SOURCE_DIR} | ||
2244 | 24 | ${GLIB_INCLUDE_DIRS} | ||
2245 | 25 | ${JSON_GLIB_INCLUDE_DIRS} | ||
2246 | 26 | ${UBUNTU_APP_LAUNCH_INCLUDE_DIRS} | ||
2247 | 27 | ) | ||
2248 | 28 | |||
2249 | 29 | add_executable(${TEST} ${SOURCES}) | ||
2250 | 30 | |||
2251 | 31 | target_link_libraries(${TEST} | ||
2252 | 32 | Qt5::Core | ||
2253 | 33 | Qt5::Test | ||
2254 | 34 | ${GLIB_LIBRARIES} | ||
2255 | 35 | ${JSON_GLIB_LIBRARIES} | ||
2256 | 36 | ) | ||
2257 | 37 | |||
2258 | 38 | add_test(${TEST} ${CMAKE_CURRENT_BINARY_DIR}/${TEST} -xunitxml -o ${TEST}.xml) | ||
2259 | 0 | 39 | ||
2260 | === added file 'tests/unit/messaging-host/click-handler/tst_click-handler.cpp' | |||
2261 | --- tests/unit/messaging-host/click-handler/tst_click-handler.cpp 1970-01-01 00:00:00 +0000 | |||
2262 | +++ tests/unit/messaging-host/click-handler/tst_click-handler.cpp 2015-10-07 04:25:10 +0000 | |||
2263 | @@ -0,0 +1,291 @@ | |||
2264 | 1 | /* | ||
2265 | 2 | * Copyright (C) 2015 Canonical Ltd. | ||
2266 | 3 | * | ||
2267 | 4 | * This file is part of unity-chromium-extension | ||
2268 | 5 | * | ||
2269 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
2270 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
2271 | 8 | * by the Free Software Foundation. | ||
2272 | 9 | * | ||
2273 | 10 | * This program is distributed in the hope that it will be useful, but | ||
2274 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2275 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
2276 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
2277 | 14 | * | ||
2278 | 15 | * You should have received a copy of the GNU General Public License along | ||
2279 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2280 | 17 | */ | ||
2281 | 18 | |||
2282 | 19 | #include <click-0.4/click.h> | ||
2283 | 20 | #include <ubuntu-app-launch.h> | ||
2284 | 21 | |||
2285 | 22 | #include "click-handler.h" | ||
2286 | 23 | |||
2287 | 24 | #include <QDebug> | ||
2288 | 25 | #include <QSignalSpy> | ||
2289 | 26 | #include <QTest> | ||
2290 | 27 | |||
2291 | 28 | |||
2292 | 29 | // {{{ mock implementations | ||
2293 | 30 | ClickDB* click_db_new(void) | ||
2294 | 31 | { | ||
2295 | 32 | return (ClickDB*)g_object_new(G_TYPE_OBJECT, 0); | ||
2296 | 33 | } | ||
2297 | 34 | |||
2298 | 35 | void click_db_read(ClickDB* self, const gchar* db_dir, GError** error) | ||
2299 | 36 | { | ||
2300 | 37 | } | ||
2301 | 38 | |||
2302 | 39 | JsonArray* click_db_get_manifests(ClickDB* self, gboolean all_versions, GError** error) | ||
2303 | 40 | { | ||
2304 | 41 | const gchar* example_json = | ||
2305 | 42 | "[" | ||
2306 | 43 | "{" | ||
2307 | 44 | " \"_directory\": \"/custom/click/.click/users/@all/com.ubuntu.developer.webapps.webapp-gmail\"," | ||
2308 | 45 | " \"_removable\": 1," | ||
2309 | 46 | " \"architecture\": \"all\"," | ||
2310 | 47 | " \"description\": \"Gmail (webapp version)\"," | ||
2311 | 48 | " \"framework\": \"ubuntu-sdk-14.10-dev2\"," | ||
2312 | 49 | " \"hooks\": {" | ||
2313 | 50 | " \"webapp-gmail\": {" | ||
2314 | 51 | " \"account-application\": \"webapp-gmail.application\"," | ||
2315 | 52 | " \"account-service\": \"webapp-gmail.service\"," | ||
2316 | 53 | " \"apparmor\": \"webapp-gmail.json\"," | ||
2317 | 54 | " \"desktop\": \"webapp-gmail.desktop\"," | ||
2318 | 55 | " \"urls\": \"gmail.url-dispatcher\"" | ||
2319 | 56 | " }," | ||
2320 | 57 | " \"webapp-gmail-helper\": {" | ||
2321 | 58 | " \"apparmor\": \"gmail-helper-apparmor.json\"," | ||
2322 | 59 | " \"push-helper\": \"gmail-helper.json\"" | ||
2323 | 60 | " }" | ||
2324 | 61 | " }," | ||
2325 | 62 | " \"installed-size\": \"22\"," | ||
2326 | 63 | " \"maintainer\": \"Webapps Team <webapps@lists.launchpad.net>\"," | ||
2327 | 64 | " \"name\": \"com.ubuntu.developer.webapps.webapp-gmail\"," | ||
2328 | 65 | " \"title\": \"webapp-gmail\"," | ||
2329 | 66 | " \"version\": \"1.0.25\"" | ||
2330 | 67 | "}," | ||
2331 | 68 | "{" | ||
2332 | 69 | " \"_directory\": \"/custom/click/.click/users/@all/com.ubuntu.developer.webapps.webapp-facebook\"," | ||
2333 | 70 | " \"_removable\": 1," | ||
2334 | 71 | " \"architecture\": \"all\"," | ||
2335 | 72 | " \"description\": \"Facebook (webapp version)\"," | ||
2336 | 73 | " \"framework\": \"ubuntu-sdk-14.10\"," | ||
2337 | 74 | " \"hooks\": {" | ||
2338 | 75 | " \"webapp-facebook\": {" | ||
2339 | 76 | " \"account-application\": \"webapp-facebook.application\"," | ||
2340 | 77 | " \"account-service\": \"webapp-facebook.service\"," | ||
2341 | 78 | " \"apparmor\": \"webapp-facebook.json\"," | ||
2342 | 79 | " \"content-hub\": \"content-hub/webapp-facebook.json\"," | ||
2343 | 80 | " \"desktop\": \"webapp-facebook.desktop\"," | ||
2344 | 81 | " \"urls\": \"facebook.url-dispatcher\"" | ||
2345 | 82 | " }," | ||
2346 | 83 | " \"webapp-facebook-helper\": {" | ||
2347 | 84 | " \"apparmor\": \"facebook-helper-apparmor.json\"," | ||
2348 | 85 | " \"push-helper\": \"facebook-helper.json\"" | ||
2349 | 86 | " }" | ||
2350 | 87 | " }," | ||
2351 | 88 | " \"installed-size\": \"887\"," | ||
2352 | 89 | " \"maintainer\": \"Webapps Team <webapps@lists.launchpad.net>\"," | ||
2353 | 90 | " \"name\": \"com.ubuntu.developer.webapps.webapp-facebook\"," | ||
2354 | 91 | " \"title\": \"Facebook\"," | ||
2355 | 92 | " \"version\": \"1.2\"" | ||
2356 | 93 | "}" | ||
2357 | 94 | "]"; | ||
2358 | 95 | |||
2359 | 96 | JsonParser* parser = json_parser_new(); | ||
2360 | 97 | if (!json_parser_load_from_data(parser, example_json, strlen(example_json), error)) { | ||
2361 | 98 | qDebug() << "Error parsing URL dispatched JSON" << (*error)->message; | ||
2362 | 99 | return nullptr; | ||
2363 | 100 | } | ||
2364 | 101 | |||
2365 | 102 | JsonNode *root_node = json_parser_get_root(parser); | ||
2366 | 103 | if (json_node_get_node_type(root_node) != JSON_NODE_ARRAY) { | ||
2367 | 104 | return nullptr; | ||
2368 | 105 | } | ||
2369 | 106 | |||
2370 | 107 | return json_node_get_array(root_node); | ||
2371 | 108 | } | ||
2372 | 109 | |||
2373 | 110 | gboolean json_parser_load_from_file(JsonParser *parser, const gchar* filename, GError **error) | ||
2374 | 111 | { | ||
2375 | 112 | const gchar* dispatcher_template = | ||
2376 | 113 | "[" | ||
2377 | 114 | " {" | ||
2378 | 115 | " \"protocol\": \"http\"," | ||
2379 | 116 | " \"domain-suffix\": \"%s.com\"" | ||
2380 | 117 | " }," | ||
2381 | 118 | " {" | ||
2382 | 119 | " \"protocol\": \"https\"," | ||
2383 | 120 | " \"domain-suffix\": \"%s.com\"" | ||
2384 | 121 | " }" | ||
2385 | 122 | "]"; | ||
2386 | 123 | |||
2387 | 124 | gchar *dispatcher_json = nullptr; | ||
2388 | 125 | if (g_strrstr(filename, "gmail") != NULL) { | ||
2389 | 126 | dispatcher_json = g_strdup_printf(dispatcher_template, "google"); | ||
2390 | 127 | } else if (g_strrstr(filename, "facebook") != NULL) { | ||
2391 | 128 | dispatcher_json = g_strdup_printf(dispatcher_template, "facebook"); | ||
2392 | 129 | } | ||
2393 | 130 | |||
2394 | 131 | if (!json_parser_load_from_data(parser, dispatcher_json, strlen(dispatcher_json), error)) { | ||
2395 | 132 | qDebug() << "Error parsing URL dispatched JSON" << (*error)->message; | ||
2396 | 133 | g_free(dispatcher_json); | ||
2397 | 134 | return false; | ||
2398 | 135 | } | ||
2399 | 136 | |||
2400 | 137 | g_free(dispatcher_json); | ||
2401 | 138 | |||
2402 | 139 | return true; | ||
2403 | 140 | } | ||
2404 | 141 | |||
2405 | 142 | gboolean ubuntu_app_launch_start_application(const gchar* appid, const gchar* const* uris) | ||
2406 | 143 | { | ||
2407 | 144 | return true; | ||
2408 | 145 | } | ||
2409 | 146 | // }}} | ||
2410 | 147 | |||
2411 | 148 | class ClickHandlerTest : public QObject | ||
2412 | 149 | { | ||
2413 | 150 | Q_OBJECT | ||
2414 | 151 | |||
2415 | 152 | public: | ||
2416 | 153 | ClickHandlerTest(); | ||
2417 | 154 | |||
2418 | 155 | private Q_SLOTS: | ||
2419 | 156 | void testClickAvailableReturnsMethodName(); | ||
2420 | 157 | void testClickAvailableUrlMustBeValid(); | ||
2421 | 158 | void testClickAvailableApps_data(); | ||
2422 | 159 | void testClickAvailableApps(); | ||
2423 | 160 | void testLaunchClickReturnsMethodName(); | ||
2424 | 161 | void testLaunchClickUrlMustBeValid(); | ||
2425 | 162 | void testLaunchClick_data(); | ||
2426 | 163 | void testLaunchClick(); | ||
2427 | 164 | }; | ||
2428 | 165 | |||
2429 | 166 | ClickHandlerTest::ClickHandlerTest(): | ||
2430 | 167 | QObject(nullptr) | ||
2431 | 168 | { | ||
2432 | 169 | } | ||
2433 | 170 | |||
2434 | 171 | void ClickHandlerTest::testClickAvailableReturnsMethodName() | ||
2435 | 172 | { | ||
2436 | 173 | UnityWebapps::ClickHandler handler; | ||
2437 | 174 | |||
2438 | 175 | QVariantMap message; | ||
2439 | 176 | message.insert("method", "click_available"); | ||
2440 | 177 | |||
2441 | 178 | QVariantMap reply = handler.click_available(message); | ||
2442 | 179 | |||
2443 | 180 | QVERIFY(!reply.empty()); | ||
2444 | 181 | QCOMPARE(reply.value("method").toString(), QStringLiteral("click_available")); | ||
2445 | 182 | } | ||
2446 | 183 | |||
2447 | 184 | void ClickHandlerTest::testClickAvailableUrlMustBeValid() | ||
2448 | 185 | { | ||
2449 | 186 | UnityWebapps::ClickHandler handler; | ||
2450 | 187 | |||
2451 | 188 | QVariantMap message; | ||
2452 | 189 | message.insert("method", "click_available"); | ||
2453 | 190 | |||
2454 | 191 | QVariantMap reply = handler.click_available(message); | ||
2455 | 192 | |||
2456 | 193 | QVERIFY(!reply.empty()); | ||
2457 | 194 | QCOMPARE(reply.value("error").toString(), QStringLiteral("malformed request")); | ||
2458 | 195 | } | ||
2459 | 196 | |||
2460 | 197 | void ClickHandlerTest::testClickAvailableApps_data() | ||
2461 | 198 | { | ||
2462 | 199 | QTest::addColumn<QString>("url"); | ||
2463 | 200 | QTest::addColumn<bool>("available"); | ||
2464 | 201 | QTest::addColumn<QString>("appName"); | ||
2465 | 202 | QTest::addColumn<QString>("appDomain"); | ||
2466 | 203 | QTest::addColumn<QString>("appVersion"); | ||
2467 | 204 | |||
2468 | 205 | QTest::newRow("available") << "https://mail.google.com/" << true << "webapp-gmail" << "mail.google.com" << "1.0.25"; | ||
2469 | 206 | QTest::newRow("available") << "https://m.facebook.com/" << true << "Facebook" << "m.facebook.com" << "1.2"; | ||
2470 | 207 | QTest::newRow("not_available") << "http://www.example.com/" << false << "None" << "None" << "0.0.0"; | ||
2471 | 208 | } | ||
2472 | 209 | |||
2473 | 210 | void ClickHandlerTest::testClickAvailableApps() | ||
2474 | 211 | { | ||
2475 | 212 | QFETCH(QString, url); | ||
2476 | 213 | QFETCH(bool, available); | ||
2477 | 214 | QFETCH(QString, appName); | ||
2478 | 215 | QFETCH(QString, appDomain); | ||
2479 | 216 | QFETCH(QString, appVersion); | ||
2480 | 217 | |||
2481 | 218 | UnityWebapps::ClickHandler handler; | ||
2482 | 219 | |||
2483 | 220 | QVariantMap message; | ||
2484 | 221 | message.insert("method", "click_available"); | ||
2485 | 222 | message.insert("url", url); | ||
2486 | 223 | |||
2487 | 224 | QVariantMap reply = handler.click_available(message); | ||
2488 | 225 | |||
2489 | 226 | QVERIFY(!reply.empty()); | ||
2490 | 227 | QCOMPARE(reply.value("available").toBool(), available); | ||
2491 | 228 | if (available) { | ||
2492 | 229 | QCOMPARE(appName, reply.value("appName").toString()); | ||
2493 | 230 | // QCOMPARE(appDomain, reply.value("appDomain").toString()); // Not currently available | ||
2494 | 231 | QCOMPARE(appVersion, reply.value("appVersion").toString()); | ||
2495 | 232 | } | ||
2496 | 233 | } | ||
2497 | 234 | |||
2498 | 235 | void ClickHandlerTest::testLaunchClickReturnsMethodName() | ||
2499 | 236 | { | ||
2500 | 237 | UnityWebapps::ClickHandler handler; | ||
2501 | 238 | |||
2502 | 239 | QVariantMap message; | ||
2503 | 240 | message.insert("method", "launch_click"); | ||
2504 | 241 | |||
2505 | 242 | QVariantMap reply = handler.launch_click(message); | ||
2506 | 243 | |||
2507 | 244 | QVERIFY(!reply.empty()); | ||
2508 | 245 | QCOMPARE(reply.value("method").toString(), QStringLiteral("launch_click")); | ||
2509 | 246 | } | ||
2510 | 247 | |||
2511 | 248 | void ClickHandlerTest::testLaunchClickUrlMustBeValid() | ||
2512 | 249 | { | ||
2513 | 250 | UnityWebapps::ClickHandler handler; | ||
2514 | 251 | |||
2515 | 252 | QVariantMap message; | ||
2516 | 253 | message.insert("method", "launch_click"); | ||
2517 | 254 | |||
2518 | 255 | QVariantMap reply = handler.click_available(message); | ||
2519 | 256 | |||
2520 | 257 | QVERIFY(!reply.empty()); | ||
2521 | 258 | QCOMPARE(reply.value("error").toString(), QStringLiteral("malformed request")); | ||
2522 | 259 | } | ||
2523 | 260 | |||
2524 | 261 | void ClickHandlerTest::testLaunchClick_data() | ||
2525 | 262 | { | ||
2526 | 263 | QTest::addColumn<QString>("url"); | ||
2527 | 264 | QTest::addColumn<bool>("success"); | ||
2528 | 265 | |||
2529 | 266 | QTest::newRow("launchable") << "https://mail.google.com/" << true; | ||
2530 | 267 | QTest::newRow("launchable") << "https://m.facebook.com/" << true; | ||
2531 | 268 | QTest::newRow("not_launchable") << "http://www.example.com/" << false; | ||
2532 | 269 | } | ||
2533 | 270 | |||
2534 | 271 | void ClickHandlerTest::testLaunchClick() | ||
2535 | 272 | { | ||
2536 | 273 | QFETCH(QString, url); | ||
2537 | 274 | QFETCH(bool, success); | ||
2538 | 275 | |||
2539 | 276 | UnityWebapps::ClickHandler handler; | ||
2540 | 277 | |||
2541 | 278 | QVariantMap message; | ||
2542 | 279 | message.insert("method", "launch_click"); | ||
2543 | 280 | message.insert("url", url); | ||
2544 | 281 | |||
2545 | 282 | QVariantMap reply = handler.launch_click(message); | ||
2546 | 283 | |||
2547 | 284 | QVERIFY(!reply.empty()); | ||
2548 | 285 | QCOMPARE(reply.value("launched").toBool(), success); | ||
2549 | 286 | } | ||
2550 | 287 | |||
2551 | 288 | |||
2552 | 289 | QTEST_MAIN(ClickHandlerTest); | ||
2553 | 290 | |||
2554 | 291 | #include "tst_click-handler.moc" | ||
2555 | 0 | 292 | ||
2556 | === added directory 'tests/unit/messaging-host/connection' | |||
2557 | === removed file 'tests/unit/messaging-host/connection-host.cpp' | |||
2558 | --- tests/unit/messaging-host/connection-host.cpp 2014-05-20 12:21:50 +0000 | |||
2559 | +++ tests/unit/messaging-host/connection-host.cpp 1970-01-01 00:00:00 +0000 | |||
2560 | @@ -1,71 +0,0 @@ | |||
2561 | 1 | /* | ||
2562 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
2563 | 3 | * | ||
2564 | 4 | * This file is part of unity-chromium-extension | ||
2565 | 5 | * | ||
2566 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
2567 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
2568 | 8 | * by the Free Software Foundation. | ||
2569 | 9 | * | ||
2570 | 10 | * This program is distributed in the hope that it will be useful, but | ||
2571 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2572 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
2573 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
2574 | 14 | * | ||
2575 | 15 | * You should have received a copy of the GNU General Public License along | ||
2576 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2577 | 17 | */ | ||
2578 | 18 | |||
2579 | 19 | #include <QCoreApplication> | ||
2580 | 20 | #include <QDebug> | ||
2581 | 21 | #include "connection.h" | ||
2582 | 22 | |||
2583 | 23 | class Handler: public QObject | ||
2584 | 24 | { | ||
2585 | 25 | Q_OBJECT | ||
2586 | 26 | |||
2587 | 27 | public: | ||
2588 | 28 | Handler(): QObject() {} | ||
2589 | 29 | |||
2590 | 30 | bool openConnection(); | ||
2591 | 31 | |||
2592 | 32 | public Q_SLOTS: | ||
2593 | 33 | void onMessageReceived(const QVariantMap &message); | ||
2594 | 34 | |||
2595 | 35 | private: | ||
2596 | 36 | UnityWebapps::Connection m_connection; | ||
2597 | 37 | }; | ||
2598 | 38 | |||
2599 | 39 | bool Handler::openConnection() | ||
2600 | 40 | { | ||
2601 | 41 | QObject::connect(&m_connection, | ||
2602 | 42 | SIGNAL(messageReceived(const QVariantMap &)), | ||
2603 | 43 | this, | ||
2604 | 44 | SLOT(onMessageReceived(const QVariantMap &))); | ||
2605 | 45 | return m_connection.open(); | ||
2606 | 46 | } | ||
2607 | 47 | |||
2608 | 48 | void Handler::onMessageReceived(const QVariantMap &message) | ||
2609 | 49 | { | ||
2610 | 50 | // Generate a predictable reply | ||
2611 | 51 | QVariantMap reply; | ||
2612 | 52 | reply.insert("count", message.count()); | ||
2613 | 53 | QStringList keys = message.uniqueKeys(); | ||
2614 | 54 | reply.insert("keys", keys); | ||
2615 | 55 | m_connection.postMessage(reply); | ||
2616 | 56 | } | ||
2617 | 57 | |||
2618 | 58 | int main(int argc, char **argv) | ||
2619 | 59 | { | ||
2620 | 60 | QCoreApplication app(argc, argv); | ||
2621 | 61 | Handler handler; | ||
2622 | 62 | |||
2623 | 63 | if (!handler.openConnection()) { | ||
2624 | 64 | qCritical() << "Connection::open() failed!"; | ||
2625 | 65 | return EXIT_FAILURE; | ||
2626 | 66 | } | ||
2627 | 67 | |||
2628 | 68 | return app.exec(); | ||
2629 | 69 | } | ||
2630 | 70 | |||
2631 | 71 | #include "connection-host.moc" | ||
2632 | 72 | 0 | ||
2633 | === added file 'tests/unit/messaging-host/connection/CMakeLists.txt' | |||
2634 | --- tests/unit/messaging-host/connection/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
2635 | +++ tests/unit/messaging-host/connection/CMakeLists.txt 2015-10-07 04:25:10 +0000 | |||
2636 | @@ -0,0 +1,40 @@ | |||
2637 | 1 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | ||
2638 | 2 | set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
2639 | 3 | set(CMAKE_AUTOMOC ON) | ||
2640 | 4 | |||
2641 | 5 | find_package(Qt5Core REQUIRED) | ||
2642 | 6 | find_package(Qt5Test REQUIRED) | ||
2643 | 7 | |||
2644 | 8 | # Test server process | ||
2645 | 9 | add_executable( | ||
2646 | 10 | connection-host | ||
2647 | 11 | |||
2648 | 12 | ${messaging-host_SOURCE_DIR}/connection.cpp | ||
2649 | 13 | connection-host.cpp | ||
2650 | 14 | ) | ||
2651 | 15 | |||
2652 | 16 | target_link_libraries( | ||
2653 | 17 | connection-host | ||
2654 | 18 | |||
2655 | 19 | Qt5::Core | ||
2656 | 20 | ) | ||
2657 | 21 | |||
2658 | 22 | # Test proper | ||
2659 | 23 | set(TEST tst_Connection) | ||
2660 | 24 | set(SOURCES | ||
2661 | 25 | tst_connection.cpp | ||
2662 | 26 | ) | ||
2663 | 27 | |||
2664 | 28 | add_executable(${TEST} ${SOURCES}) | ||
2665 | 29 | add_dependencies(${TEST} connection-host) | ||
2666 | 30 | |||
2667 | 31 | include_directories(${messaging-host_SOURCE_DIR}) | ||
2668 | 32 | |||
2669 | 33 | target_link_libraries( | ||
2670 | 34 | ${TEST} | ||
2671 | 35 | |||
2672 | 36 | Qt5::Core | ||
2673 | 37 | Qt5::Test | ||
2674 | 38 | ) | ||
2675 | 39 | |||
2676 | 40 | add_test(${TEST} ${CMAKE_CURRENT_BINARY_DIR}/${TEST} -xunitxml -o ${TEST}.xml) | ||
2677 | 0 | 41 | ||
2678 | === added file 'tests/unit/messaging-host/connection/connection-host.cpp' | |||
2679 | --- tests/unit/messaging-host/connection/connection-host.cpp 1970-01-01 00:00:00 +0000 | |||
2680 | +++ tests/unit/messaging-host/connection/connection-host.cpp 2015-10-07 04:25:10 +0000 | |||
2681 | @@ -0,0 +1,71 @@ | |||
2682 | 1 | /* | ||
2683 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
2684 | 3 | * | ||
2685 | 4 | * This file is part of unity-chromium-extension | ||
2686 | 5 | * | ||
2687 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
2688 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
2689 | 8 | * by the Free Software Foundation. | ||
2690 | 9 | * | ||
2691 | 10 | * This program is distributed in the hope that it will be useful, but | ||
2692 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2693 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
2694 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
2695 | 14 | * | ||
2696 | 15 | * You should have received a copy of the GNU General Public License along | ||
2697 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2698 | 17 | */ | ||
2699 | 18 | |||
2700 | 19 | #include <QCoreApplication> | ||
2701 | 20 | #include <QDebug> | ||
2702 | 21 | #include "connection.h" | ||
2703 | 22 | |||
2704 | 23 | class Handler: public QObject | ||
2705 | 24 | { | ||
2706 | 25 | Q_OBJECT | ||
2707 | 26 | |||
2708 | 27 | public: | ||
2709 | 28 | Handler(): QObject() {} | ||
2710 | 29 | |||
2711 | 30 | bool openConnection(); | ||
2712 | 31 | |||
2713 | 32 | public Q_SLOTS: | ||
2714 | 33 | void onMessageReceived(const QVariantMap &message); | ||
2715 | 34 | |||
2716 | 35 | private: | ||
2717 | 36 | UnityWebapps::Connection m_connection; | ||
2718 | 37 | }; | ||
2719 | 38 | |||
2720 | 39 | bool Handler::openConnection() | ||
2721 | 40 | { | ||
2722 | 41 | QObject::connect(&m_connection, | ||
2723 | 42 | SIGNAL(messageReceived(const QVariantMap &)), | ||
2724 | 43 | this, | ||
2725 | 44 | SLOT(onMessageReceived(const QVariantMap &))); | ||
2726 | 45 | return m_connection.open(); | ||
2727 | 46 | } | ||
2728 | 47 | |||
2729 | 48 | void Handler::onMessageReceived(const QVariantMap &message) | ||
2730 | 49 | { | ||
2731 | 50 | // Generate a predictable reply | ||
2732 | 51 | QVariantMap reply; | ||
2733 | 52 | reply.insert("count", message.count()); | ||
2734 | 53 | QStringList keys = message.uniqueKeys(); | ||
2735 | 54 | reply.insert("keys", keys); | ||
2736 | 55 | m_connection.postMessage(reply); | ||
2737 | 56 | } | ||
2738 | 57 | |||
2739 | 58 | int main(int argc, char **argv) | ||
2740 | 59 | { | ||
2741 | 60 | QCoreApplication app(argc, argv); | ||
2742 | 61 | Handler handler; | ||
2743 | 62 | |||
2744 | 63 | if (!handler.openConnection()) { | ||
2745 | 64 | qCritical() << "Connection::open() failed!"; | ||
2746 | 65 | return EXIT_FAILURE; | ||
2747 | 66 | } | ||
2748 | 67 | |||
2749 | 68 | return app.exec(); | ||
2750 | 69 | } | ||
2751 | 70 | |||
2752 | 71 | #include "connection-host.moc" | ||
2753 | 0 | 72 | ||
2754 | === added file 'tests/unit/messaging-host/connection/tst_connection.cpp' | |||
2755 | --- tests/unit/messaging-host/connection/tst_connection.cpp 1970-01-01 00:00:00 +0000 | |||
2756 | +++ tests/unit/messaging-host/connection/tst_connection.cpp 2015-10-07 04:25:10 +0000 | |||
2757 | @@ -0,0 +1,112 @@ | |||
2758 | 1 | /* | ||
2759 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
2760 | 3 | * | ||
2761 | 4 | * This file is part of unity-chromium-extension | ||
2762 | 5 | * | ||
2763 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
2764 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
2765 | 8 | * by the Free Software Foundation. | ||
2766 | 9 | * | ||
2767 | 10 | * This program is distributed in the hope that it will be useful, but | ||
2768 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2769 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
2770 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
2771 | 14 | * | ||
2772 | 15 | * You should have received a copy of the GNU General Public License along | ||
2773 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2774 | 17 | */ | ||
2775 | 18 | |||
2776 | 19 | #include <QByteArray> | ||
2777 | 20 | #include <QDebug> | ||
2778 | 21 | #include <QJsonDocument> | ||
2779 | 22 | #include <QProcess> | ||
2780 | 23 | #include <QSet> | ||
2781 | 24 | #include <QSignalSpy> | ||
2782 | 25 | #include <QTest> | ||
2783 | 26 | |||
2784 | 27 | class ConnectionTest: public QObject | ||
2785 | 28 | { | ||
2786 | 29 | Q_OBJECT | ||
2787 | 30 | |||
2788 | 31 | public: | ||
2789 | 32 | ConnectionTest(); | ||
2790 | 33 | |||
2791 | 34 | void postMessage(const QByteArray &message); | ||
2792 | 35 | QByteArray readReply(); | ||
2793 | 36 | QVariantMap jsonToMap(const QByteArray &json); | ||
2794 | 37 | |||
2795 | 38 | private Q_SLOTS: | ||
2796 | 39 | void init(); | ||
2797 | 40 | void cleanup(); | ||
2798 | 41 | void testMessaging(); | ||
2799 | 42 | |||
2800 | 43 | private: | ||
2801 | 44 | QProcess m_process; | ||
2802 | 45 | }; | ||
2803 | 46 | |||
2804 | 47 | ConnectionTest::ConnectionTest(): | ||
2805 | 48 | QObject(0) | ||
2806 | 49 | { | ||
2807 | 50 | m_process.setProgram("./connection-host"); | ||
2808 | 51 | m_process.setProcessChannelMode(QProcess::ForwardedErrorChannel); | ||
2809 | 52 | m_process.setReadChannel(QProcess::StandardOutput); | ||
2810 | 53 | } | ||
2811 | 54 | |||
2812 | 55 | void ConnectionTest::postMessage(const QByteArray &message) | ||
2813 | 56 | { | ||
2814 | 57 | quint32 length = message.length(); | ||
2815 | 58 | |||
2816 | 59 | m_process.write((char *)&length, sizeof(length)); | ||
2817 | 60 | m_process.write(message); | ||
2818 | 61 | } | ||
2819 | 62 | |||
2820 | 63 | QByteArray ConnectionTest::readReply() | ||
2821 | 64 | { | ||
2822 | 65 | quint32 length; | ||
2823 | 66 | m_process.waitForReadyRead(); | ||
2824 | 67 | m_process.read((char *)&length, sizeof(length)); | ||
2825 | 68 | return m_process.read(length); | ||
2826 | 69 | } | ||
2827 | 70 | |||
2828 | 71 | QVariantMap ConnectionTest::jsonToMap(const QByteArray &json) | ||
2829 | 72 | { | ||
2830 | 73 | QJsonDocument doc = QJsonDocument::fromJson(json); | ||
2831 | 74 | return doc.toVariant().toMap(); | ||
2832 | 75 | } | ||
2833 | 76 | |||
2834 | 77 | void ConnectionTest::init() | ||
2835 | 78 | { | ||
2836 | 79 | m_process.start(); | ||
2837 | 80 | m_process.waitForStarted(); | ||
2838 | 81 | } | ||
2839 | 82 | |||
2840 | 83 | void ConnectionTest::cleanup() | ||
2841 | 84 | { | ||
2842 | 85 | m_process.kill(); | ||
2843 | 86 | m_process.waitForFinished(); | ||
2844 | 87 | } | ||
2845 | 88 | |||
2846 | 89 | void ConnectionTest::testMessaging() | ||
2847 | 90 | { | ||
2848 | 91 | postMessage("{\"msg\":\"hi\"}"); | ||
2849 | 92 | QVariantMap reply = jsonToMap(readReply()); | ||
2850 | 93 | QCOMPARE(reply.count(), 2); | ||
2851 | 94 | QCOMPARE(reply.value("count").toInt(), 1); | ||
2852 | 95 | QCOMPARE(reply.value("keys").toStringList(), QStringList() << "msg"); | ||
2853 | 96 | |||
2854 | 97 | postMessage("{\"list\": [\"one\", \"two\"]," | ||
2855 | 98 | "\"name\": \"Tom\"," | ||
2856 | 99 | "\"number\": 23}"); | ||
2857 | 100 | reply = jsonToMap(readReply()); | ||
2858 | 101 | QCOMPARE(reply.count(), 2); | ||
2859 | 102 | QCOMPARE(reply.value("count").toInt(), 3); | ||
2860 | 103 | QSet<QString> expectedKeys; | ||
2861 | 104 | expectedKeys << "list" << "name" << "number"; | ||
2862 | 105 | QCOMPARE(reply.value("keys").toStringList().toSet(), expectedKeys); | ||
2863 | 106 | |||
2864 | 107 | m_process.terminate(); | ||
2865 | 108 | } | ||
2866 | 109 | |||
2867 | 110 | QTEST_MAIN(ConnectionTest); | ||
2868 | 111 | |||
2869 | 112 | #include "tst_connection.moc" | ||
2870 | 0 | 113 | ||
2871 | === added directory 'tests/unit/messaging-host/inactivity-timer' | |||
2872 | === added file 'tests/unit/messaging-host/inactivity-timer/CMakeLists.txt' | |||
2873 | --- tests/unit/messaging-host/inactivity-timer/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
2874 | +++ tests/unit/messaging-host/inactivity-timer/CMakeLists.txt 2015-10-07 04:25:10 +0000 | |||
2875 | @@ -0,0 +1,23 @@ | |||
2876 | 1 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | ||
2877 | 2 | set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
2878 | 3 | set(CMAKE_AUTOMOC ON) | ||
2879 | 4 | |||
2880 | 5 | find_package(Qt5Core REQUIRED) | ||
2881 | 6 | find_package(Qt5Test REQUIRED) | ||
2882 | 7 | |||
2883 | 8 | set(TEST tst_InactivityTimer) | ||
2884 | 9 | set(SOURCES | ||
2885 | 10 | ${messaging-host_SOURCE_DIR}/inactivity-timer.cpp | ||
2886 | 11 | tst_inactivity_timer.cpp | ||
2887 | 12 | ) | ||
2888 | 13 | |||
2889 | 14 | add_executable(${TEST} ${SOURCES}) | ||
2890 | 15 | |||
2891 | 16 | include_directories(${messaging-host_SOURCE_DIR}) | ||
2892 | 17 | |||
2893 | 18 | target_link_libraries(${TEST} | ||
2894 | 19 | Qt5::Core | ||
2895 | 20 | Qt5::Test | ||
2896 | 21 | ) | ||
2897 | 22 | |||
2898 | 23 | add_test(${TEST} ${CMAKE_CURRENT_BINARY_DIR}/${TEST} -xunitxml -o ${TEST}.xml) | ||
2899 | 0 | 24 | ||
2900 | === added file 'tests/unit/messaging-host/inactivity-timer/tst_inactivity_timer.cpp' | |||
2901 | --- tests/unit/messaging-host/inactivity-timer/tst_inactivity_timer.cpp 1970-01-01 00:00:00 +0000 | |||
2902 | +++ tests/unit/messaging-host/inactivity-timer/tst_inactivity_timer.cpp 2015-10-07 04:25:10 +0000 | |||
2903 | @@ -0,0 +1,125 @@ | |||
2904 | 1 | /* | ||
2905 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
2906 | 3 | * | ||
2907 | 4 | * This file is part of unity-chromium-extension | ||
2908 | 5 | * | ||
2909 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
2910 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
2911 | 8 | * by the Free Software Foundation. | ||
2912 | 9 | * | ||
2913 | 10 | * This program is distributed in the hope that it will be useful, but | ||
2914 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2915 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
2916 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
2917 | 14 | * | ||
2918 | 15 | * You should have received a copy of the GNU General Public License along | ||
2919 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2920 | 17 | */ | ||
2921 | 18 | |||
2922 | 19 | #include "inactivity-timer.h" | ||
2923 | 20 | |||
2924 | 21 | #include <QDebug> | ||
2925 | 22 | #include <QSignalSpy> | ||
2926 | 23 | #include <QTest> | ||
2927 | 24 | |||
2928 | 25 | using namespace UnityWebapps; | ||
2929 | 26 | |||
2930 | 27 | class Service: public QObject | ||
2931 | 28 | { | ||
2932 | 29 | Q_OBJECT | ||
2933 | 30 | Q_PROPERTY(bool isIdle READ isIdle NOTIFY isIdleChanged) | ||
2934 | 31 | |||
2935 | 32 | public: | ||
2936 | 33 | Service(): QObject(), m_isIdle(true) {} | ||
2937 | 34 | |||
2938 | 35 | bool isIdle() const { return m_isIdle; } | ||
2939 | 36 | |||
2940 | 37 | void setIdle(bool idle) { | ||
2941 | 38 | if (idle == m_isIdle) return; | ||
2942 | 39 | m_isIdle = idle; | ||
2943 | 40 | Q_EMIT isIdleChanged(); | ||
2944 | 41 | } | ||
2945 | 42 | |||
2946 | 43 | Q_SIGNALS: | ||
2947 | 44 | void isIdleChanged(); | ||
2948 | 45 | |||
2949 | 46 | private: | ||
2950 | 47 | bool m_isIdle; | ||
2951 | 48 | }; | ||
2952 | 49 | |||
2953 | 50 | class InactivityTimerTest: public QObject | ||
2954 | 51 | { | ||
2955 | 52 | Q_OBJECT | ||
2956 | 53 | |||
2957 | 54 | public: | ||
2958 | 55 | InactivityTimerTest(); | ||
2959 | 56 | |||
2960 | 57 | private Q_SLOTS: | ||
2961 | 58 | void testAlwaysIdle(); | ||
2962 | 59 | void testBecomeIdle(); | ||
2963 | 60 | void testManyServices(); | ||
2964 | 61 | }; | ||
2965 | 62 | |||
2966 | 63 | InactivityTimerTest::InactivityTimerTest(): | ||
2967 | 64 | QObject(0) | ||
2968 | 65 | { | ||
2969 | 66 | } | ||
2970 | 67 | |||
2971 | 68 | void InactivityTimerTest::testAlwaysIdle() | ||
2972 | 69 | { | ||
2973 | 70 | InactivityTimer timer(10); | ||
2974 | 71 | QSignalSpy timeout(&timer, SIGNAL(timeout())); | ||
2975 | 72 | |||
2976 | 73 | Service service; | ||
2977 | 74 | timer.watchObject(&service); | ||
2978 | 75 | |||
2979 | 76 | QVERIFY(timeout.wait(100)); | ||
2980 | 77 | } | ||
2981 | 78 | |||
2982 | 79 | void InactivityTimerTest::testBecomeIdle() | ||
2983 | 80 | { | ||
2984 | 81 | InactivityTimer timer(10); | ||
2985 | 82 | QSignalSpy timeout(&timer, SIGNAL(timeout())); | ||
2986 | 83 | |||
2987 | 84 | Service service; | ||
2988 | 85 | service.setIdle(false); | ||
2989 | 86 | timer.watchObject(&service); | ||
2990 | 87 | |||
2991 | 88 | /* No signal should be emitted, as the service is not idle */ | ||
2992 | 89 | QVERIFY(!timeout.wait(100)); | ||
2993 | 90 | |||
2994 | 91 | service.setIdle(true); | ||
2995 | 92 | QVERIFY(timeout.wait(100)); | ||
2996 | 93 | } | ||
2997 | 94 | |||
2998 | 95 | void InactivityTimerTest::testManyServices() | ||
2999 | 96 | { | ||
3000 | 97 | InactivityTimer timer(50); | ||
3001 | 98 | QSignalSpy timeout(&timer, SIGNAL(timeout())); | ||
3002 | 99 | |||
3003 | 100 | Service service1; | ||
3004 | 101 | timer.watchObject(&service1); | ||
3005 | 102 | |||
3006 | 103 | Service service2; | ||
3007 | 104 | timer.watchObject(&service2); | ||
3008 | 105 | |||
3009 | 106 | Service service3; | ||
3010 | 107 | service3.setIdle(false); | ||
3011 | 108 | timer.watchObject(&service3); | ||
3012 | 109 | |||
3013 | 110 | /* No signal should be emitted, as service3 is not idle */ | ||
3014 | 111 | QVERIFY(!timeout.wait(100)); | ||
3015 | 112 | |||
3016 | 113 | /* Now set it is as idle, but soon afterwards set service1 as busy */ | ||
3017 | 114 | service3.setIdle(true); | ||
3018 | 115 | QTest::qWait(10); | ||
3019 | 116 | service1.setIdle(false); | ||
3020 | 117 | QVERIFY(!timeout.wait(100)); | ||
3021 | 118 | |||
3022 | 119 | service1.setIdle(true); | ||
3023 | 120 | QVERIFY(timeout.wait(100)); | ||
3024 | 121 | } | ||
3025 | 122 | |||
3026 | 123 | QTEST_MAIN(InactivityTimerTest); | ||
3027 | 124 | |||
3028 | 125 | #include "tst_inactivity_timer.moc" | ||
3029 | 0 | 126 | ||
3030 | === removed file 'tests/unit/messaging-host/messaging-host.pri' | |||
3031 | --- tests/unit/messaging-host/messaging-host.pri 2014-05-21 08:18:12 +0000 | |||
3032 | +++ tests/unit/messaging-host/messaging-host.pri 1970-01-01 00:00:00 +0000 | |||
3033 | @@ -1,9 +0,0 @@ | |||
3034 | 1 | include(../../../common-project-config.pri) | ||
3035 | 2 | |||
3036 | 3 | CONFIG += \ | ||
3037 | 4 | debug | ||
3038 | 5 | |||
3039 | 6 | SRC_DIR = $${TOP_SRC_DIR}/messaging-host | ||
3040 | 7 | |||
3041 | 8 | INCLUDEPATH += \ | ||
3042 | 9 | $${SRC_DIR} | ||
3043 | 10 | 0 | ||
3044 | === removed file 'tests/unit/messaging-host/messaging-host.pro' | |||
3045 | --- tests/unit/messaging-host/messaging-host.pro 2014-05-23 10:16:49 +0000 | |||
3046 | +++ tests/unit/messaging-host/messaging-host.pro 1970-01-01 00:00:00 +0000 | |||
3047 | @@ -1,12 +0,0 @@ | |||
3048 | 1 | TEMPLATE = subdirs | ||
3049 | 2 | SUBDIRS = \ | ||
3050 | 3 | tst_connection \ | ||
3051 | 4 | tst_connection_host \ | ||
3052 | 5 | tst_inactivity_timer.pro \ | ||
3053 | 6 | tst_service.pro \ | ||
3054 | 7 | tst_webapps-handler.pro \ | ||
3055 | 8 | |||
3056 | 9 | tst_connection.file = tst_connection.pro | ||
3057 | 10 | tst_connection_host.file = tst_connection_host.pro | ||
3058 | 11 | |||
3059 | 12 | tst_connection.depends = tst_connection_host | ||
3060 | 13 | 0 | ||
3061 | === added directory 'tests/unit/messaging-host/service' | |||
3062 | === added file 'tests/unit/messaging-host/service/CMakeLists.txt' | |||
3063 | --- tests/unit/messaging-host/service/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
3064 | +++ tests/unit/messaging-host/service/CMakeLists.txt 2015-10-07 04:25:10 +0000 | |||
3065 | @@ -0,0 +1,23 @@ | |||
3066 | 1 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | ||
3067 | 2 | set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
3068 | 3 | set(CMAKE_AUTOMOC ON) | ||
3069 | 4 | |||
3070 | 5 | find_package(Qt5Core REQUIRED) | ||
3071 | 6 | find_package(Qt5Test REQUIRED) | ||
3072 | 7 | |||
3073 | 8 | set(TEST tst_Service) | ||
3074 | 9 | set(SOURCES | ||
3075 | 10 | ${messaging-host_SOURCE_DIR}/service.cpp | ||
3076 | 11 | tst_service.cpp | ||
3077 | 12 | ) | ||
3078 | 13 | |||
3079 | 14 | add_executable(${TEST} ${SOURCES}) | ||
3080 | 15 | |||
3081 | 16 | include_directories(${messaging-host_SOURCE_DIR}) | ||
3082 | 17 | |||
3083 | 18 | target_link_libraries(${TEST} | ||
3084 | 19 | Qt5::Core | ||
3085 | 20 | Qt5::Test | ||
3086 | 21 | ) | ||
3087 | 22 | |||
3088 | 23 | add_test(${TEST} ${CMAKE_CURRENT_BINARY_DIR}/${TEST} -xunitxml -o ${TEST}.xml) | ||
3089 | 0 | 24 | ||
3090 | === added file 'tests/unit/messaging-host/service/tst_service.cpp' | |||
3091 | --- tests/unit/messaging-host/service/tst_service.cpp 1970-01-01 00:00:00 +0000 | |||
3092 | +++ tests/unit/messaging-host/service/tst_service.cpp 2015-10-07 04:25:10 +0000 | |||
3093 | @@ -0,0 +1,189 @@ | |||
3094 | 1 | /* | ||
3095 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
3096 | 3 | * | ||
3097 | 4 | * This file is part of unity-chromium-extension | ||
3098 | 5 | * | ||
3099 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
3100 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
3101 | 8 | * by the Free Software Foundation. | ||
3102 | 9 | * | ||
3103 | 10 | * This program is distributed in the hope that it will be useful, but | ||
3104 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
3105 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
3106 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
3107 | 14 | * | ||
3108 | 15 | * You should have received a copy of the GNU General Public License along | ||
3109 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3110 | 17 | */ | ||
3111 | 18 | |||
3112 | 19 | #include "service.h" | ||
3113 | 20 | |||
3114 | 21 | #include <QDebug> | ||
3115 | 22 | #include <QSignalSpy> | ||
3116 | 23 | #include <QTest> | ||
3117 | 24 | |||
3118 | 25 | class Handler1: public QObject | ||
3119 | 26 | { | ||
3120 | 27 | Q_OBJECT | ||
3121 | 28 | |||
3122 | 29 | public: | ||
3123 | 30 | Handler1() {} | ||
3124 | 31 | |||
3125 | 32 | public Q_SLOTS: | ||
3126 | 33 | QVariantMap sayHello(const QVariantMap ¶ms); | ||
3127 | 34 | QVariantMap countArguments(const QVariantMap ¶ms); | ||
3128 | 35 | }; | ||
3129 | 36 | |||
3130 | 37 | QVariantMap Handler1::sayHello(const QVariantMap ¶ms) | ||
3131 | 38 | { | ||
3132 | 39 | QVariantMap reply; | ||
3133 | 40 | reply.insert("greeting", | ||
3134 | 41 | QString("Hello %1").arg(params.value("name").toString())); | ||
3135 | 42 | return reply; | ||
3136 | 43 | } | ||
3137 | 44 | |||
3138 | 45 | QVariantMap Handler1::countArguments(const QVariantMap ¶ms) | ||
3139 | 46 | { | ||
3140 | 47 | QVariantMap reply; | ||
3141 | 48 | // We subtract one, because that's the "method" field | ||
3142 | 49 | reply.insert("count", params.count() - 1); | ||
3143 | 50 | return reply; | ||
3144 | 51 | } | ||
3145 | 52 | |||
3146 | 53 | class Handler2: public QObject | ||
3147 | 54 | { | ||
3148 | 55 | Q_OBJECT | ||
3149 | 56 | |||
3150 | 57 | public: | ||
3151 | 58 | Handler2() {} | ||
3152 | 59 | |||
3153 | 60 | public Q_SLOTS: | ||
3154 | 61 | QVariantMap listArguments(const QVariantMap ¶ms); | ||
3155 | 62 | }; | ||
3156 | 63 | |||
3157 | 64 | QVariantMap Handler2::listArguments(const QVariantMap ¶ms) | ||
3158 | 65 | { | ||
3159 | 66 | QVariantMap reply; | ||
3160 | 67 | QStringList arguments = params.keys(); | ||
3161 | 68 | arguments.removeAll("method"); | ||
3162 | 69 | reply.insert("arguments", arguments); | ||
3163 | 70 | return reply; | ||
3164 | 71 | } | ||
3165 | 72 | |||
3166 | 73 | class ServiceTest: public QObject | ||
3167 | 74 | { | ||
3168 | 75 | Q_OBJECT | ||
3169 | 76 | |||
3170 | 77 | public: | ||
3171 | 78 | ServiceTest(); | ||
3172 | 79 | |||
3173 | 80 | private Q_SLOTS: | ||
3174 | 81 | void testNoHandlers(); | ||
3175 | 82 | void testNonExisting(); | ||
3176 | 83 | void testHandling(); | ||
3177 | 84 | }; | ||
3178 | 85 | |||
3179 | 86 | ServiceTest::ServiceTest(): | ||
3180 | 87 | QObject(0) | ||
3181 | 88 | { | ||
3182 | 89 | } | ||
3183 | 90 | |||
3184 | 91 | void ServiceTest::testNoHandlers() | ||
3185 | 92 | { | ||
3186 | 93 | UnityWebapps::Service service; | ||
3187 | 94 | QSignalSpy messageHandled(&service, SIGNAL(messageHandled(const QVariantMap &))); | ||
3188 | 95 | |||
3189 | 96 | QVariantMap message; | ||
3190 | 97 | message.insert("method", QString("sayHello")); | ||
3191 | 98 | message.insert("name", QString("Tom")); | ||
3192 | 99 | service.handleMessage(message); | ||
3193 | 100 | |||
3194 | 101 | QCOMPARE(messageHandled.count(), 0); | ||
3195 | 102 | QVERIFY(service.isIdle()); | ||
3196 | 103 | } | ||
3197 | 104 | |||
3198 | 105 | void ServiceTest::testNonExisting() | ||
3199 | 106 | { | ||
3200 | 107 | UnityWebapps::Service service; | ||
3201 | 108 | QSignalSpy messageHandled(&service, SIGNAL(messageHandled(const QVariantMap &))); | ||
3202 | 109 | |||
3203 | 110 | Handler1 handler1; | ||
3204 | 111 | service.addHandler(&handler1); | ||
3205 | 112 | |||
3206 | 113 | QVariantMap message; | ||
3207 | 114 | message.insert("method", QString("nonExistingMethod")); | ||
3208 | 115 | service.handleMessage(message); | ||
3209 | 116 | |||
3210 | 117 | QCOMPARE(messageHandled.count(), 0); | ||
3211 | 118 | QVERIFY(service.isIdle()); | ||
3212 | 119 | |||
3213 | 120 | // Add the second service (it still should fail) | ||
3214 | 121 | Handler2 handler2; | ||
3215 | 122 | service.addHandler(&handler2); | ||
3216 | 123 | |||
3217 | 124 | service.handleMessage(message); | ||
3218 | 125 | |||
3219 | 126 | QCOMPARE(messageHandled.count(), 0); | ||
3220 | 127 | QVERIFY(service.isIdle()); | ||
3221 | 128 | } | ||
3222 | 129 | |||
3223 | 130 | void ServiceTest::testHandling() | ||
3224 | 131 | { | ||
3225 | 132 | UnityWebapps::Service service; | ||
3226 | 133 | QSignalSpy messageHandled(&service, SIGNAL(messageHandled(const QVariantMap &))); | ||
3227 | 134 | QSignalSpy isIdleChanged(&service, SIGNAL(isIdleChanged())); | ||
3228 | 135 | QVERIFY(service.isIdle()); | ||
3229 | 136 | |||
3230 | 137 | Handler1 handler1; | ||
3231 | 138 | service.addHandler(&handler1); | ||
3232 | 139 | |||
3233 | 140 | QVariantMap message; | ||
3234 | 141 | message.insert("method", QString("sayHello")); | ||
3235 | 142 | message.insert("name", QString("Tom")); | ||
3236 | 143 | service.handleMessage(message); | ||
3237 | 144 | |||
3238 | 145 | QCOMPARE(messageHandled.count(), 1); | ||
3239 | 146 | QVariantMap reply = messageHandled.at(0).at(0).toMap(); | ||
3240 | 147 | QCOMPARE(reply.value("greeting").toString(), QString("Hello Tom")); | ||
3241 | 148 | messageHandled.clear(); | ||
3242 | 149 | QCOMPARE(isIdleChanged.count(), 2); | ||
3243 | 150 | isIdleChanged.clear(); | ||
3244 | 151 | QVERIFY(service.isIdle()); | ||
3245 | 152 | |||
3246 | 153 | // Make sure it continues to work when we add a second handler | ||
3247 | 154 | Handler2 handler2; | ||
3248 | 155 | service.addHandler(&handler2); | ||
3249 | 156 | service.handleMessage(message); | ||
3250 | 157 | |||
3251 | 158 | QCOMPARE(messageHandled.count(), 1); | ||
3252 | 159 | reply = messageHandled.at(0).at(0).toMap(); | ||
3253 | 160 | QCOMPARE(reply.value("greeting").toString(), QString("Hello Tom")); | ||
3254 | 161 | messageHandled.clear(); | ||
3255 | 162 | QCOMPARE(isIdleChanged.count(), 2); | ||
3256 | 163 | isIdleChanged.clear(); | ||
3257 | 164 | QVERIFY(service.isIdle()); | ||
3258 | 165 | |||
3259 | 166 | // Test a method from the second handler | ||
3260 | 167 | message.clear(); | ||
3261 | 168 | message.insert("method", QString("listArguments")); | ||
3262 | 169 | message.insert("number", 1); | ||
3263 | 170 | message.insert("string", QString("Hello")); | ||
3264 | 171 | message.insert("boolean", false); | ||
3265 | 172 | service.handleMessage(message); | ||
3266 | 173 | |||
3267 | 174 | QCOMPARE(messageHandled.count(), 1); | ||
3268 | 175 | reply = messageHandled.at(0).at(0).toMap(); | ||
3269 | 176 | QVERIFY(reply.contains("arguments")); | ||
3270 | 177 | QStringList expectedArguments; | ||
3271 | 178 | expectedArguments << "number" << "string" << "boolean"; | ||
3272 | 179 | QCOMPARE(reply.value("arguments").toStringList().toSet(), | ||
3273 | 180 | expectedArguments.toSet()); | ||
3274 | 181 | messageHandled.clear(); | ||
3275 | 182 | QCOMPARE(isIdleChanged.count(), 2); | ||
3276 | 183 | isIdleChanged.clear(); | ||
3277 | 184 | QVERIFY(service.isIdle()); | ||
3278 | 185 | } | ||
3279 | 186 | |||
3280 | 187 | QTEST_MAIN(ServiceTest); | ||
3281 | 188 | |||
3282 | 189 | #include "tst_service.moc" | ||
3283 | 0 | 190 | ||
3284 | === removed file 'tests/unit/messaging-host/tst_connection.cpp' | |||
3285 | --- tests/unit/messaging-host/tst_connection.cpp 2014-05-20 12:21:50 +0000 | |||
3286 | +++ tests/unit/messaging-host/tst_connection.cpp 1970-01-01 00:00:00 +0000 | |||
3287 | @@ -1,112 +0,0 @@ | |||
3288 | 1 | /* | ||
3289 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
3290 | 3 | * | ||
3291 | 4 | * This file is part of unity-chromium-extension | ||
3292 | 5 | * | ||
3293 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
3294 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
3295 | 8 | * by the Free Software Foundation. | ||
3296 | 9 | * | ||
3297 | 10 | * This program is distributed in the hope that it will be useful, but | ||
3298 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
3299 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
3300 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
3301 | 14 | * | ||
3302 | 15 | * You should have received a copy of the GNU General Public License along | ||
3303 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3304 | 17 | */ | ||
3305 | 18 | |||
3306 | 19 | #include <QByteArray> | ||
3307 | 20 | #include <QDebug> | ||
3308 | 21 | #include <QJsonDocument> | ||
3309 | 22 | #include <QProcess> | ||
3310 | 23 | #include <QSet> | ||
3311 | 24 | #include <QSignalSpy> | ||
3312 | 25 | #include <QTest> | ||
3313 | 26 | |||
3314 | 27 | class ConnectionTest: public QObject | ||
3315 | 28 | { | ||
3316 | 29 | Q_OBJECT | ||
3317 | 30 | |||
3318 | 31 | public: | ||
3319 | 32 | ConnectionTest(); | ||
3320 | 33 | |||
3321 | 34 | void postMessage(const QByteArray &message); | ||
3322 | 35 | QByteArray readReply(); | ||
3323 | 36 | QVariantMap jsonToMap(const QByteArray &json); | ||
3324 | 37 | |||
3325 | 38 | private Q_SLOTS: | ||
3326 | 39 | void init(); | ||
3327 | 40 | void cleanup(); | ||
3328 | 41 | void testMessaging(); | ||
3329 | 42 | |||
3330 | 43 | private: | ||
3331 | 44 | QProcess m_process; | ||
3332 | 45 | }; | ||
3333 | 46 | |||
3334 | 47 | ConnectionTest::ConnectionTest(): | ||
3335 | 48 | QObject(0) | ||
3336 | 49 | { | ||
3337 | 50 | m_process.setProgram("./connection-host"); | ||
3338 | 51 | m_process.setProcessChannelMode(QProcess::ForwardedErrorChannel); | ||
3339 | 52 | m_process.setReadChannel(QProcess::StandardOutput); | ||
3340 | 53 | } | ||
3341 | 54 | |||
3342 | 55 | void ConnectionTest::postMessage(const QByteArray &message) | ||
3343 | 56 | { | ||
3344 | 57 | quint32 length = message.length(); | ||
3345 | 58 | |||
3346 | 59 | m_process.write((char *)&length, sizeof(length)); | ||
3347 | 60 | m_process.write(message); | ||
3348 | 61 | } | ||
3349 | 62 | |||
3350 | 63 | QByteArray ConnectionTest::readReply() | ||
3351 | 64 | { | ||
3352 | 65 | quint32 length; | ||
3353 | 66 | m_process.waitForReadyRead(); | ||
3354 | 67 | m_process.read((char *)&length, sizeof(length)); | ||
3355 | 68 | return m_process.read(length); | ||
3356 | 69 | } | ||
3357 | 70 | |||
3358 | 71 | QVariantMap ConnectionTest::jsonToMap(const QByteArray &json) | ||
3359 | 72 | { | ||
3360 | 73 | QJsonDocument doc = QJsonDocument::fromJson(json); | ||
3361 | 74 | return doc.toVariant().toMap(); | ||
3362 | 75 | } | ||
3363 | 76 | |||
3364 | 77 | void ConnectionTest::init() | ||
3365 | 78 | { | ||
3366 | 79 | m_process.start(); | ||
3367 | 80 | m_process.waitForStarted(); | ||
3368 | 81 | } | ||
3369 | 82 | |||
3370 | 83 | void ConnectionTest::cleanup() | ||
3371 | 84 | { | ||
3372 | 85 | m_process.kill(); | ||
3373 | 86 | m_process.waitForFinished(); | ||
3374 | 87 | } | ||
3375 | 88 | |||
3376 | 89 | void ConnectionTest::testMessaging() | ||
3377 | 90 | { | ||
3378 | 91 | postMessage("{\"msg\":\"hi\"}"); | ||
3379 | 92 | QVariantMap reply = jsonToMap(readReply()); | ||
3380 | 93 | QCOMPARE(reply.count(), 2); | ||
3381 | 94 | QCOMPARE(reply.value("count").toInt(), 1); | ||
3382 | 95 | QCOMPARE(reply.value("keys").toStringList(), QStringList() << "msg"); | ||
3383 | 96 | |||
3384 | 97 | postMessage("{\"list\": [\"one\", \"two\"]," | ||
3385 | 98 | "\"name\": \"Tom\"," | ||
3386 | 99 | "\"number\": 23}"); | ||
3387 | 100 | reply = jsonToMap(readReply()); | ||
3388 | 101 | QCOMPARE(reply.count(), 2); | ||
3389 | 102 | QCOMPARE(reply.value("count").toInt(), 3); | ||
3390 | 103 | QSet<QString> expectedKeys; | ||
3391 | 104 | expectedKeys << "list" << "name" << "number"; | ||
3392 | 105 | QCOMPARE(reply.value("keys").toStringList().toSet(), expectedKeys); | ||
3393 | 106 | |||
3394 | 107 | m_process.terminate(); | ||
3395 | 108 | } | ||
3396 | 109 | |||
3397 | 110 | QTEST_MAIN(ConnectionTest); | ||
3398 | 111 | |||
3399 | 112 | #include "tst_connection.moc" | ||
3400 | 113 | 0 | ||
3401 | === removed file 'tests/unit/messaging-host/tst_connection.pro' | |||
3402 | --- tests/unit/messaging-host/tst_connection.pro 2014-05-21 08:18:12 +0000 | |||
3403 | +++ tests/unit/messaging-host/tst_connection.pro 1970-01-01 00:00:00 +0000 | |||
3404 | @@ -1,14 +0,0 @@ | |||
3405 | 1 | include(messaging-host.pri) | ||
3406 | 2 | |||
3407 | 3 | TARGET = tst_connection | ||
3408 | 4 | |||
3409 | 5 | QT += \ | ||
3410 | 6 | core \ | ||
3411 | 7 | testlib | ||
3412 | 8 | |||
3413 | 9 | SOURCES += \ | ||
3414 | 10 | tst_connection.cpp | ||
3415 | 11 | |||
3416 | 12 | check.commands = "xvfb-run -s '-screen 0 640x480x24' -a ./$${TARGET}" | ||
3417 | 13 | check.depends = $${TARGET} | ||
3418 | 14 | QMAKE_EXTRA_TARGETS += check | ||
3419 | 15 | 0 | ||
3420 | === removed file 'tests/unit/messaging-host/tst_connection_host.pro' | |||
3421 | --- tests/unit/messaging-host/tst_connection_host.pro 2014-05-21 08:18:12 +0000 | |||
3422 | +++ tests/unit/messaging-host/tst_connection_host.pro 1970-01-01 00:00:00 +0000 | |||
3423 | @@ -1,14 +0,0 @@ | |||
3424 | 1 | include(messaging-host.pri) | ||
3425 | 2 | |||
3426 | 3 | TEMPLATE = app | ||
3427 | 4 | TARGET = connection-host | ||
3428 | 5 | |||
3429 | 6 | QT += \ | ||
3430 | 7 | core | ||
3431 | 8 | |||
3432 | 9 | SOURCES = \ | ||
3433 | 10 | $${SRC_DIR}/connection.cpp \ | ||
3434 | 11 | connection-host.cpp | ||
3435 | 12 | |||
3436 | 13 | HEADERS = \ | ||
3437 | 14 | $${SRC_DIR}/connection.h \ | ||
3438 | 15 | 0 | ||
3439 | === removed file 'tests/unit/messaging-host/tst_inactivity_timer.cpp' | |||
3440 | --- tests/unit/messaging-host/tst_inactivity_timer.cpp 2014-05-21 08:18:12 +0000 | |||
3441 | +++ tests/unit/messaging-host/tst_inactivity_timer.cpp 1970-01-01 00:00:00 +0000 | |||
3442 | @@ -1,125 +0,0 @@ | |||
3443 | 1 | /* | ||
3444 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
3445 | 3 | * | ||
3446 | 4 | * This file is part of unity-chromium-extension | ||
3447 | 5 | * | ||
3448 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
3449 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
3450 | 8 | * by the Free Software Foundation. | ||
3451 | 9 | * | ||
3452 | 10 | * This program is distributed in the hope that it will be useful, but | ||
3453 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
3454 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
3455 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
3456 | 14 | * | ||
3457 | 15 | * You should have received a copy of the GNU General Public License along | ||
3458 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3459 | 17 | */ | ||
3460 | 18 | |||
3461 | 19 | #include "inactivity-timer.h" | ||
3462 | 20 | |||
3463 | 21 | #include <QDebug> | ||
3464 | 22 | #include <QSignalSpy> | ||
3465 | 23 | #include <QTest> | ||
3466 | 24 | |||
3467 | 25 | using namespace UnityWebapps; | ||
3468 | 26 | |||
3469 | 27 | class Service: public QObject | ||
3470 | 28 | { | ||
3471 | 29 | Q_OBJECT | ||
3472 | 30 | Q_PROPERTY(bool isIdle READ isIdle NOTIFY isIdleChanged) | ||
3473 | 31 | |||
3474 | 32 | public: | ||
3475 | 33 | Service(): QObject(), m_isIdle(true) {} | ||
3476 | 34 | |||
3477 | 35 | bool isIdle() const { return m_isIdle; } | ||
3478 | 36 | |||
3479 | 37 | void setIdle(bool idle) { | ||
3480 | 38 | if (idle == m_isIdle) return; | ||
3481 | 39 | m_isIdle = idle; | ||
3482 | 40 | Q_EMIT isIdleChanged(); | ||
3483 | 41 | } | ||
3484 | 42 | |||
3485 | 43 | Q_SIGNALS: | ||
3486 | 44 | void isIdleChanged(); | ||
3487 | 45 | |||
3488 | 46 | private: | ||
3489 | 47 | bool m_isIdle; | ||
3490 | 48 | }; | ||
3491 | 49 | |||
3492 | 50 | class InactivityTimerTest: public QObject | ||
3493 | 51 | { | ||
3494 | 52 | Q_OBJECT | ||
3495 | 53 | |||
3496 | 54 | public: | ||
3497 | 55 | InactivityTimerTest(); | ||
3498 | 56 | |||
3499 | 57 | private Q_SLOTS: | ||
3500 | 58 | void testAlwaysIdle(); | ||
3501 | 59 | void testBecomeIdle(); | ||
3502 | 60 | void testManyServices(); | ||
3503 | 61 | }; | ||
3504 | 62 | |||
3505 | 63 | InactivityTimerTest::InactivityTimerTest(): | ||
3506 | 64 | QObject(0) | ||
3507 | 65 | { | ||
3508 | 66 | } | ||
3509 | 67 | |||
3510 | 68 | void InactivityTimerTest::testAlwaysIdle() | ||
3511 | 69 | { | ||
3512 | 70 | InactivityTimer timer(10); | ||
3513 | 71 | QSignalSpy timeout(&timer, SIGNAL(timeout())); | ||
3514 | 72 | |||
3515 | 73 | Service service; | ||
3516 | 74 | timer.watchObject(&service); | ||
3517 | 75 | |||
3518 | 76 | QVERIFY(timeout.wait(100)); | ||
3519 | 77 | } | ||
3520 | 78 | |||
3521 | 79 | void InactivityTimerTest::testBecomeIdle() | ||
3522 | 80 | { | ||
3523 | 81 | InactivityTimer timer(10); | ||
3524 | 82 | QSignalSpy timeout(&timer, SIGNAL(timeout())); | ||
3525 | 83 | |||
3526 | 84 | Service service; | ||
3527 | 85 | service.setIdle(false); | ||
3528 | 86 | timer.watchObject(&service); | ||
3529 | 87 | |||
3530 | 88 | /* No signal should be emitted, as the service is not idle */ | ||
3531 | 89 | QVERIFY(!timeout.wait(100)); | ||
3532 | 90 | |||
3533 | 91 | service.setIdle(true); | ||
3534 | 92 | QVERIFY(timeout.wait(100)); | ||
3535 | 93 | } | ||
3536 | 94 | |||
3537 | 95 | void InactivityTimerTest::testManyServices() | ||
3538 | 96 | { | ||
3539 | 97 | InactivityTimer timer(50); | ||
3540 | 98 | QSignalSpy timeout(&timer, SIGNAL(timeout())); | ||
3541 | 99 | |||
3542 | 100 | Service service1; | ||
3543 | 101 | timer.watchObject(&service1); | ||
3544 | 102 | |||
3545 | 103 | Service service2; | ||
3546 | 104 | timer.watchObject(&service2); | ||
3547 | 105 | |||
3548 | 106 | Service service3; | ||
3549 | 107 | service3.setIdle(false); | ||
3550 | 108 | timer.watchObject(&service3); | ||
3551 | 109 | |||
3552 | 110 | /* No signal should be emitted, as service3 is not idle */ | ||
3553 | 111 | QVERIFY(!timeout.wait(100)); | ||
3554 | 112 | |||
3555 | 113 | /* Now set it is as idle, but soon afterwards set service1 as busy */ | ||
3556 | 114 | service3.setIdle(true); | ||
3557 | 115 | QTest::qWait(10); | ||
3558 | 116 | service1.setIdle(false); | ||
3559 | 117 | QVERIFY(!timeout.wait(100)); | ||
3560 | 118 | |||
3561 | 119 | service1.setIdle(true); | ||
3562 | 120 | QVERIFY(timeout.wait(100)); | ||
3563 | 121 | } | ||
3564 | 122 | |||
3565 | 123 | QTEST_MAIN(InactivityTimerTest); | ||
3566 | 124 | |||
3567 | 125 | #include "tst_inactivity_timer.moc" | ||
3568 | 126 | 0 | ||
3569 | === removed file 'tests/unit/messaging-host/tst_inactivity_timer.pro' | |||
3570 | --- tests/unit/messaging-host/tst_inactivity_timer.pro 2014-05-21 08:18:12 +0000 | |||
3571 | +++ tests/unit/messaging-host/tst_inactivity_timer.pro 1970-01-01 00:00:00 +0000 | |||
3572 | @@ -1,18 +0,0 @@ | |||
3573 | 1 | include(messaging-host.pri) | ||
3574 | 2 | |||
3575 | 3 | TARGET = tst_inactivity_timer | ||
3576 | 4 | |||
3577 | 5 | QT += \ | ||
3578 | 6 | core \ | ||
3579 | 7 | testlib | ||
3580 | 8 | |||
3581 | 9 | SOURCES += \ | ||
3582 | 10 | $${SRC_DIR}/inactivity-timer.cpp \ | ||
3583 | 11 | tst_inactivity_timer.cpp | ||
3584 | 12 | |||
3585 | 13 | HEADERS += \ | ||
3586 | 14 | $${SRC_DIR}/inactivity-timer.h | ||
3587 | 15 | |||
3588 | 16 | check.commands = "xvfb-run -s '-screen 0 640x480x24' -a ./$${TARGET}" | ||
3589 | 17 | check.depends = $${TARGET} | ||
3590 | 18 | QMAKE_EXTRA_TARGETS += check | ||
3591 | 19 | 0 | ||
3592 | === removed file 'tests/unit/messaging-host/tst_service.cpp' | |||
3593 | --- tests/unit/messaging-host/tst_service.cpp 2014-05-21 08:18:12 +0000 | |||
3594 | +++ tests/unit/messaging-host/tst_service.cpp 1970-01-01 00:00:00 +0000 | |||
3595 | @@ -1,189 +0,0 @@ | |||
3596 | 1 | /* | ||
3597 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
3598 | 3 | * | ||
3599 | 4 | * This file is part of unity-chromium-extension | ||
3600 | 5 | * | ||
3601 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
3602 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
3603 | 8 | * by the Free Software Foundation. | ||
3604 | 9 | * | ||
3605 | 10 | * This program is distributed in the hope that it will be useful, but | ||
3606 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
3607 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
3608 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
3609 | 14 | * | ||
3610 | 15 | * You should have received a copy of the GNU General Public License along | ||
3611 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3612 | 17 | */ | ||
3613 | 18 | |||
3614 | 19 | #include "service.h" | ||
3615 | 20 | |||
3616 | 21 | #include <QDebug> | ||
3617 | 22 | #include <QSignalSpy> | ||
3618 | 23 | #include <QTest> | ||
3619 | 24 | |||
3620 | 25 | class Handler1: public QObject | ||
3621 | 26 | { | ||
3622 | 27 | Q_OBJECT | ||
3623 | 28 | |||
3624 | 29 | public: | ||
3625 | 30 | Handler1() {} | ||
3626 | 31 | |||
3627 | 32 | public Q_SLOTS: | ||
3628 | 33 | QVariantMap sayHello(const QVariantMap ¶ms); | ||
3629 | 34 | QVariantMap countArguments(const QVariantMap ¶ms); | ||
3630 | 35 | }; | ||
3631 | 36 | |||
3632 | 37 | QVariantMap Handler1::sayHello(const QVariantMap ¶ms) | ||
3633 | 38 | { | ||
3634 | 39 | QVariantMap reply; | ||
3635 | 40 | reply.insert("greeting", | ||
3636 | 41 | QString("Hello %1").arg(params.value("name").toString())); | ||
3637 | 42 | return reply; | ||
3638 | 43 | } | ||
3639 | 44 | |||
3640 | 45 | QVariantMap Handler1::countArguments(const QVariantMap ¶ms) | ||
3641 | 46 | { | ||
3642 | 47 | QVariantMap reply; | ||
3643 | 48 | // We subtract one, because that's the "method" field | ||
3644 | 49 | reply.insert("count", params.count() - 1); | ||
3645 | 50 | return reply; | ||
3646 | 51 | } | ||
3647 | 52 | |||
3648 | 53 | class Handler2: public QObject | ||
3649 | 54 | { | ||
3650 | 55 | Q_OBJECT | ||
3651 | 56 | |||
3652 | 57 | public: | ||
3653 | 58 | Handler2() {} | ||
3654 | 59 | |||
3655 | 60 | public Q_SLOTS: | ||
3656 | 61 | QVariantMap listArguments(const QVariantMap ¶ms); | ||
3657 | 62 | }; | ||
3658 | 63 | |||
3659 | 64 | QVariantMap Handler2::listArguments(const QVariantMap ¶ms) | ||
3660 | 65 | { | ||
3661 | 66 | QVariantMap reply; | ||
3662 | 67 | QStringList arguments = params.keys(); | ||
3663 | 68 | arguments.removeAll("method"); | ||
3664 | 69 | reply.insert("arguments", arguments); | ||
3665 | 70 | return reply; | ||
3666 | 71 | } | ||
3667 | 72 | |||
3668 | 73 | class ServiceTest: public QObject | ||
3669 | 74 | { | ||
3670 | 75 | Q_OBJECT | ||
3671 | 76 | |||
3672 | 77 | public: | ||
3673 | 78 | ServiceTest(); | ||
3674 | 79 | |||
3675 | 80 | private Q_SLOTS: | ||
3676 | 81 | void testNoHandlers(); | ||
3677 | 82 | void testNonExisting(); | ||
3678 | 83 | void testHandling(); | ||
3679 | 84 | }; | ||
3680 | 85 | |||
3681 | 86 | ServiceTest::ServiceTest(): | ||
3682 | 87 | QObject(0) | ||
3683 | 88 | { | ||
3684 | 89 | } | ||
3685 | 90 | |||
3686 | 91 | void ServiceTest::testNoHandlers() | ||
3687 | 92 | { | ||
3688 | 93 | UnityWebapps::Service service; | ||
3689 | 94 | QSignalSpy messageHandled(&service, SIGNAL(messageHandled(const QVariantMap &))); | ||
3690 | 95 | |||
3691 | 96 | QVariantMap message; | ||
3692 | 97 | message.insert("method", QString("sayHello")); | ||
3693 | 98 | message.insert("name", QString("Tom")); | ||
3694 | 99 | service.handleMessage(message); | ||
3695 | 100 | |||
3696 | 101 | QCOMPARE(messageHandled.count(), 0); | ||
3697 | 102 | QVERIFY(service.isIdle()); | ||
3698 | 103 | } | ||
3699 | 104 | |||
3700 | 105 | void ServiceTest::testNonExisting() | ||
3701 | 106 | { | ||
3702 | 107 | UnityWebapps::Service service; | ||
3703 | 108 | QSignalSpy messageHandled(&service, SIGNAL(messageHandled(const QVariantMap &))); | ||
3704 | 109 | |||
3705 | 110 | Handler1 handler1; | ||
3706 | 111 | service.addHandler(&handler1); | ||
3707 | 112 | |||
3708 | 113 | QVariantMap message; | ||
3709 | 114 | message.insert("method", QString("nonExistingMethod")); | ||
3710 | 115 | service.handleMessage(message); | ||
3711 | 116 | |||
3712 | 117 | QCOMPARE(messageHandled.count(), 0); | ||
3713 | 118 | QVERIFY(service.isIdle()); | ||
3714 | 119 | |||
3715 | 120 | // Add the second service (it still should fail) | ||
3716 | 121 | Handler2 handler2; | ||
3717 | 122 | service.addHandler(&handler2); | ||
3718 | 123 | |||
3719 | 124 | service.handleMessage(message); | ||
3720 | 125 | |||
3721 | 126 | QCOMPARE(messageHandled.count(), 0); | ||
3722 | 127 | QVERIFY(service.isIdle()); | ||
3723 | 128 | } | ||
3724 | 129 | |||
3725 | 130 | void ServiceTest::testHandling() | ||
3726 | 131 | { | ||
3727 | 132 | UnityWebapps::Service service; | ||
3728 | 133 | QSignalSpy messageHandled(&service, SIGNAL(messageHandled(const QVariantMap &))); | ||
3729 | 134 | QSignalSpy isIdleChanged(&service, SIGNAL(isIdleChanged())); | ||
3730 | 135 | QVERIFY(service.isIdle()); | ||
3731 | 136 | |||
3732 | 137 | Handler1 handler1; | ||
3733 | 138 | service.addHandler(&handler1); | ||
3734 | 139 | |||
3735 | 140 | QVariantMap message; | ||
3736 | 141 | message.insert("method", QString("sayHello")); | ||
3737 | 142 | message.insert("name", QString("Tom")); | ||
3738 | 143 | service.handleMessage(message); | ||
3739 | 144 | |||
3740 | 145 | QCOMPARE(messageHandled.count(), 1); | ||
3741 | 146 | QVariantMap reply = messageHandled.at(0).at(0).toMap(); | ||
3742 | 147 | QCOMPARE(reply.value("greeting").toString(), QString("Hello Tom")); | ||
3743 | 148 | messageHandled.clear(); | ||
3744 | 149 | QCOMPARE(isIdleChanged.count(), 2); | ||
3745 | 150 | isIdleChanged.clear(); | ||
3746 | 151 | QVERIFY(service.isIdle()); | ||
3747 | 152 | |||
3748 | 153 | // Make sure it continues to work when we add a second handler | ||
3749 | 154 | Handler2 handler2; | ||
3750 | 155 | service.addHandler(&handler2); | ||
3751 | 156 | service.handleMessage(message); | ||
3752 | 157 | |||
3753 | 158 | QCOMPARE(messageHandled.count(), 1); | ||
3754 | 159 | reply = messageHandled.at(0).at(0).toMap(); | ||
3755 | 160 | QCOMPARE(reply.value("greeting").toString(), QString("Hello Tom")); | ||
3756 | 161 | messageHandled.clear(); | ||
3757 | 162 | QCOMPARE(isIdleChanged.count(), 2); | ||
3758 | 163 | isIdleChanged.clear(); | ||
3759 | 164 | QVERIFY(service.isIdle()); | ||
3760 | 165 | |||
3761 | 166 | // Test a method from the second handler | ||
3762 | 167 | message.clear(); | ||
3763 | 168 | message.insert("method", QString("listArguments")); | ||
3764 | 169 | message.insert("number", 1); | ||
3765 | 170 | message.insert("string", QString("Hello")); | ||
3766 | 171 | message.insert("boolean", false); | ||
3767 | 172 | service.handleMessage(message); | ||
3768 | 173 | |||
3769 | 174 | QCOMPARE(messageHandled.count(), 1); | ||
3770 | 175 | reply = messageHandled.at(0).at(0).toMap(); | ||
3771 | 176 | QVERIFY(reply.contains("arguments")); | ||
3772 | 177 | QStringList expectedArguments; | ||
3773 | 178 | expectedArguments << "number" << "string" << "boolean"; | ||
3774 | 179 | QCOMPARE(reply.value("arguments").toStringList().toSet(), | ||
3775 | 180 | expectedArguments.toSet()); | ||
3776 | 181 | messageHandled.clear(); | ||
3777 | 182 | QCOMPARE(isIdleChanged.count(), 2); | ||
3778 | 183 | isIdleChanged.clear(); | ||
3779 | 184 | QVERIFY(service.isIdle()); | ||
3780 | 185 | } | ||
3781 | 186 | |||
3782 | 187 | QTEST_MAIN(ServiceTest); | ||
3783 | 188 | |||
3784 | 189 | #include "tst_service.moc" | ||
3785 | 190 | 0 | ||
3786 | === removed file 'tests/unit/messaging-host/tst_service.pro' | |||
3787 | --- tests/unit/messaging-host/tst_service.pro 2014-05-21 08:18:12 +0000 | |||
3788 | +++ tests/unit/messaging-host/tst_service.pro 1970-01-01 00:00:00 +0000 | |||
3789 | @@ -1,18 +0,0 @@ | |||
3790 | 1 | include(messaging-host.pri) | ||
3791 | 2 | |||
3792 | 3 | TARGET = tst_service | ||
3793 | 4 | |||
3794 | 5 | QT += \ | ||
3795 | 6 | core \ | ||
3796 | 7 | testlib | ||
3797 | 8 | |||
3798 | 9 | SOURCES += \ | ||
3799 | 10 | $${SRC_DIR}/service.cpp \ | ||
3800 | 11 | tst_service.cpp | ||
3801 | 12 | |||
3802 | 13 | HEADERS += \ | ||
3803 | 14 | $${SRC_DIR}/service.h | ||
3804 | 15 | |||
3805 | 16 | check.commands = "xvfb-run -s '-screen 0 640x480x24' -a ./$${TARGET}" | ||
3806 | 17 | check.depends = $${TARGET} | ||
3807 | 18 | QMAKE_EXTRA_TARGETS += check | ||
3808 | 19 | 0 | ||
3809 | === removed file 'tests/unit/messaging-host/tst_webapps-handler.cpp' | |||
3810 | --- tests/unit/messaging-host/tst_webapps-handler.cpp 2014-06-23 07:32:13 +0000 | |||
3811 | +++ tests/unit/messaging-host/tst_webapps-handler.cpp 1970-01-01 00:00:00 +0000 | |||
3812 | @@ -1,354 +0,0 @@ | |||
3813 | 1 | /* | ||
3814 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
3815 | 3 | * | ||
3816 | 4 | * This file is part of unity-chromium-extension | ||
3817 | 5 | * | ||
3818 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
3819 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
3820 | 8 | * by the Free Software Foundation. | ||
3821 | 9 | * | ||
3822 | 10 | * This program is distributed in the hope that it will be useful, but | ||
3823 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
3824 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
3825 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
3826 | 14 | * | ||
3827 | 15 | * You should have received a copy of the GNU General Public License along | ||
3828 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3829 | 17 | */ | ||
3830 | 18 | |||
3831 | 19 | extern "C" { | ||
3832 | 20 | #include <unity-webapps-permissions.h> | ||
3833 | 21 | #include <unity-webapps-application-repository.h> | ||
3834 | 22 | } | ||
3835 | 23 | |||
3836 | 24 | #include "webapps-handler.h" | ||
3837 | 25 | |||
3838 | 26 | #include <QDebug> | ||
3839 | 27 | #include <QSignalSpy> | ||
3840 | 28 | #include <QTest> | ||
3841 | 29 | |||
3842 | 30 | |||
3843 | 31 | // {{{ mock implementations | ||
3844 | 32 | struct AppInfo { | ||
3845 | 33 | bool install; | ||
3846 | 34 | bool allowed; | ||
3847 | 35 | bool dontask; | ||
3848 | 36 | UnityWebappsApplicationStatus status; | ||
3849 | 37 | QString name; | ||
3850 | 38 | QString domain; | ||
3851 | 39 | }; | ||
3852 | 40 | |||
3853 | 41 | QMap<QString, AppInfo> _mock_app_info; | ||
3854 | 42 | |||
3855 | 43 | UnityWebappsApplicationRepository *unity_webapps_application_repository_new_default() | ||
3856 | 44 | { | ||
3857 | 45 | return (UnityWebappsApplicationRepository*)g_object_new(G_TYPE_OBJECT, 0); | ||
3858 | 46 | } | ||
3859 | 47 | |||
3860 | 48 | gboolean unity_webapps_application_repository_prepare(UnityWebappsApplicationRepository *repository) | ||
3861 | 49 | { | ||
3862 | 50 | Q_UNUSED(repository); | ||
3863 | 51 | |||
3864 | 52 | return true; | ||
3865 | 53 | } | ||
3866 | 54 | |||
3867 | 55 | GList * unity_webapps_application_repository_resolve_url(UnityWebappsApplicationRepository *repository, const gchar *url) | ||
3868 | 56 | { | ||
3869 | 57 | Q_UNUSED(repository); | ||
3870 | 58 | |||
3871 | 59 | if (!_mock_app_info.contains(QString::fromUtf8(url))) { | ||
3872 | 60 | return 0; | ||
3873 | 61 | } | ||
3874 | 62 | |||
3875 | 63 | return g_list_append((GList*)0, (gpointer)g_strdup(url)); | ||
3876 | 64 | } | ||
3877 | 65 | |||
3878 | 66 | UnityWebappsApplicationStatus | ||
3879 | 67 | unity_webapps_application_repository_get_resolved_application_status( | ||
3880 | 68 | UnityWebappsApplicationRepository *repository, | ||
3881 | 69 | const gchar *application | ||
3882 | 70 | ) | ||
3883 | 71 | { | ||
3884 | 72 | Q_UNUSED(repository); | ||
3885 | 73 | |||
3886 | 74 | if (!_mock_app_info.contains(QString::fromUtf8(application))) { | ||
3887 | 75 | return UNITY_WEBAPPS_APPLICATION_STATUS_UNRESOLVED; | ||
3888 | 76 | } | ||
3889 | 77 | |||
3890 | 78 | return _mock_app_info.value(QString::fromUtf8(application)).status; | ||
3891 | 79 | } | ||
3892 | 80 | |||
3893 | 81 | const gchar * | ||
3894 | 82 | unity_webapps_application_repository_get_resolved_application_name(UnityWebappsApplicationRepository *repository, | ||
3895 | 83 | const gchar *application) | ||
3896 | 84 | { | ||
3897 | 85 | Q_UNUSED(repository); | ||
3898 | 86 | |||
3899 | 87 | if (!_mock_app_info.contains(QString::fromUtf8(application))) { | ||
3900 | 88 | return 0; | ||
3901 | 89 | } | ||
3902 | 90 | |||
3903 | 91 | return g_strdup(_mock_app_info.value(QString::fromUtf8(application)).name.toLocal8Bit().constData()); | ||
3904 | 92 | } | ||
3905 | 93 | |||
3906 | 94 | const gchar * | ||
3907 | 95 | unity_webapps_application_repository_get_resolved_application_domain(UnityWebappsApplicationRepository *repository, | ||
3908 | 96 | const gchar *application) | ||
3909 | 97 | { | ||
3910 | 98 | Q_UNUSED(repository); | ||
3911 | 99 | |||
3912 | 100 | if (!_mock_app_info.contains(QString::fromUtf8(application))) { | ||
3913 | 101 | return 0; | ||
3914 | 102 | } | ||
3915 | 103 | |||
3916 | 104 | return g_strdup(_mock_app_info.value(QString::fromUtf8(application)).domain.toLocal8Bit().constData()); | ||
3917 | 105 | } | ||
3918 | 106 | |||
3919 | 107 | |||
3920 | 108 | gboolean unity_webapps_permissions_get_domain_allowed(const gchar *domain) | ||
3921 | 109 | { | ||
3922 | 110 | Q_FOREACH(const QString &key, _mock_app_info.keys()) { | ||
3923 | 111 | AppInfo appInfo = _mock_app_info.value(key); | ||
3924 | 112 | if (appInfo.domain == QLatin1String(domain)) { | ||
3925 | 113 | return appInfo.allowed; | ||
3926 | 114 | } | ||
3927 | 115 | } | ||
3928 | 116 | |||
3929 | 117 | return false; | ||
3930 | 118 | } | ||
3931 | 119 | |||
3932 | 120 | gboolean unity_webapps_permissions_get_domain_dontask(const gchar *domain) | ||
3933 | 121 | { | ||
3934 | 122 | Q_FOREACH(const QString &key, _mock_app_info.keys()) { | ||
3935 | 123 | AppInfo appInfo = _mock_app_info.value(key); | ||
3936 | 124 | if (appInfo.domain == QLatin1String(domain)) { | ||
3937 | 125 | return appInfo.dontask; | ||
3938 | 126 | } | ||
3939 | 127 | } | ||
3940 | 128 | |||
3941 | 129 | return false; | ||
3942 | 130 | } | ||
3943 | 131 | |||
3944 | 132 | void unity_webapps_permissions_dontask_domain(const gchar *domain) | ||
3945 | 133 | { | ||
3946 | 134 | Q_UNUSED(domain); | ||
3947 | 135 | } | ||
3948 | 136 | |||
3949 | 137 | void | ||
3950 | 138 | unity_webapps_application_repository_install_application(UnityWebappsApplicationRepository *repository, const gchar *name, | ||
3951 | 139 | UnityWebappsApplicationRepositoryInstallCallback callback, gpointer user_data) | ||
3952 | 140 | { | ||
3953 | 141 | Q_UNUSED(repository); | ||
3954 | 142 | Q_UNUSED(name); | ||
3955 | 143 | Q_UNUSED(callback); | ||
3956 | 144 | Q_UNUSED(user_data); | ||
3957 | 145 | } | ||
3958 | 146 | |||
3959 | 147 | // }}} | ||
3960 | 148 | |||
3961 | 149 | |||
3962 | 150 | class WebappsHandlerTest : public QObject | ||
3963 | 151 | { | ||
3964 | 152 | Q_OBJECT | ||
3965 | 153 | |||
3966 | 154 | public: | ||
3967 | 155 | WebappsHandlerTest(); | ||
3968 | 156 | |||
3969 | 157 | private Q_SLOTS: | ||
3970 | 158 | void initTestCase(); | ||
3971 | 159 | void cleanupTestCase(); | ||
3972 | 160 | void testUrlLoadedMalformedRequest(); | ||
3973 | 161 | void testUrlLoaded_data(); | ||
3974 | 162 | void testUrlLoaded(); | ||
3975 | 163 | void testDontAskMalformedRequest(); | ||
3976 | 164 | void testDontAsk_data(); | ||
3977 | 165 | void testDontAsk(); | ||
3978 | 166 | void testInstallMalformedRequest(); | ||
3979 | 167 | void testInstall_data(); | ||
3980 | 168 | void testInstall(); | ||
3981 | 169 | void testCreateApplicationDesktopName_data(); | ||
3982 | 170 | void testCreateApplicationDesktopName(); | ||
3983 | 171 | }; | ||
3984 | 172 | |||
3985 | 173 | WebappsHandlerTest::WebappsHandlerTest(): | ||
3986 | 174 | QObject(0) | ||
3987 | 175 | { | ||
3988 | 176 | } | ||
3989 | 177 | |||
3990 | 178 | |||
3991 | 179 | void WebappsHandlerTest::initTestCase() | ||
3992 | 180 | { | ||
3993 | 181 | _mock_app_info.insert("https://mail.google.com/", { true, false, false, UNITY_WEBAPPS_APPLICATION_STATUS_AVAILABLE, "Gmail", "mail.google.com" }); | ||
3994 | 182 | _mock_app_info.insert("http://www.tumblr.com/", { false, true, true, UNITY_WEBAPPS_APPLICATION_STATUS_AVAILABLE, "Tumblr", "www.tumblr.com" }); | ||
3995 | 183 | } | ||
3996 | 184 | |||
3997 | 185 | void WebappsHandlerTest::cleanupTestCase() | ||
3998 | 186 | { | ||
3999 | 187 | } | ||
4000 | 188 | |||
4001 | 189 | void WebappsHandlerTest::testUrlLoadedMalformedRequest() | ||
4002 | 190 | { | ||
4003 | 191 | UnityWebapps::WebappsHandler handler; | ||
4004 | 192 | |||
4005 | 193 | QVariantMap message; | ||
4006 | 194 | message.insert("method", QString("url_loaded")); | ||
4007 | 195 | |||
4008 | 196 | QVariantMap reply = handler.url_loaded(message); | ||
4009 | 197 | |||
4010 | 198 | QVERIFY(!reply.empty()); | ||
4011 | 199 | QCOMPARE(reply.value("error").toString(), QStringLiteral("malformed request")); | ||
4012 | 200 | } | ||
4013 | 201 | |||
4014 | 202 | void WebappsHandlerTest::testUrlLoaded_data() | ||
4015 | 203 | { | ||
4016 | 204 | QTest::addColumn<QString>("url"); | ||
4017 | 205 | QTest::addColumn<bool>("available"); | ||
4018 | 206 | QTest::addColumn<QString>("appName"); | ||
4019 | 207 | QTest::addColumn<QString>("appDomain"); | ||
4020 | 208 | |||
4021 | 209 | QTest::newRow("available") << "https://mail.google.com/" << true << "Gmail" << "mail.google.com"; | ||
4022 | 210 | QTest::newRow("not_available") << "http://www.example.com/" << false << "None" << "None"; | ||
4023 | 211 | } | ||
4024 | 212 | |||
4025 | 213 | void WebappsHandlerTest::testUrlLoaded() | ||
4026 | 214 | { | ||
4027 | 215 | QFETCH(QString, url); | ||
4028 | 216 | QFETCH(bool, available); | ||
4029 | 217 | QFETCH(QString, appName); | ||
4030 | 218 | QFETCH(QString, appDomain); | ||
4031 | 219 | |||
4032 | 220 | QVariantMap message; | ||
4033 | 221 | message.insert("method", QString("url_loaded")); | ||
4034 | 222 | message.insert("url", url); | ||
4035 | 223 | |||
4036 | 224 | UnityWebapps::WebappsHandler handler; | ||
4037 | 225 | QVariantMap reply = handler.url_loaded(message); | ||
4038 | 226 | |||
4039 | 227 | QVERIFY(!reply.empty()); | ||
4040 | 228 | QCOMPARE(reply.value("available").toBool(), available); | ||
4041 | 229 | if (available) { | ||
4042 | 230 | QCOMPARE(appName, reply.value("appName").toString()); | ||
4043 | 231 | QCOMPARE(appDomain, reply.value("appDomain").toString()); | ||
4044 | 232 | } | ||
4045 | 233 | } | ||
4046 | 234 | |||
4047 | 235 | void WebappsHandlerTest::testDontAskMalformedRequest() | ||
4048 | 236 | { | ||
4049 | 237 | UnityWebapps::WebappsHandler handler; | ||
4050 | 238 | |||
4051 | 239 | QVariantMap message; | ||
4052 | 240 | message.insert("method", QString("dont_ask")); | ||
4053 | 241 | |||
4054 | 242 | QVariantMap reply = handler.url_loaded(message); | ||
4055 | 243 | |||
4056 | 244 | QVERIFY(!reply.empty()); | ||
4057 | 245 | QCOMPARE(reply.value("error").toString(), QStringLiteral("malformed request")); | ||
4058 | 246 | } | ||
4059 | 247 | |||
4060 | 248 | void WebappsHandlerTest::testDontAsk_data() | ||
4061 | 249 | { | ||
4062 | 250 | QTest::addColumn<QString>("url"); | ||
4063 | 251 | QTest::addColumn<bool>("available"); | ||
4064 | 252 | |||
4065 | 253 | QTest::newRow("ask") << "https://mail.google.com/" << true; | ||
4066 | 254 | QTest::newRow("dont_ask") << "http://www.tumblr.com/" << true; | ||
4067 | 255 | QTest::newRow("no app") << "http://www.example.com/" << false; | ||
4068 | 256 | } | ||
4069 | 257 | |||
4070 | 258 | void WebappsHandlerTest::testDontAsk() | ||
4071 | 259 | { | ||
4072 | 260 | QFETCH(QString, url); | ||
4073 | 261 | QFETCH(bool, available); | ||
4074 | 262 | |||
4075 | 263 | UnityWebapps::WebappsHandler handler; | ||
4076 | 264 | |||
4077 | 265 | QVariantMap message; | ||
4078 | 266 | message.insert("method", QString("dont_ask")); | ||
4079 | 267 | message.insert("url", url); | ||
4080 | 268 | |||
4081 | 269 | QVariantMap reply = handler.dont_ask(message); | ||
4082 | 270 | |||
4083 | 271 | QVERIFY(!reply.empty()); | ||
4084 | 272 | if (available) { | ||
4085 | 273 | QCOMPARE(reply.value("dont_ask").toBool(), true); | ||
4086 | 274 | } else { | ||
4087 | 275 | QCOMPARE(reply.value("dont_ask").toBool(), false); | ||
4088 | 276 | QCOMPARE(reply.value("available").toBool(), false); | ||
4089 | 277 | } | ||
4090 | 278 | } | ||
4091 | 279 | |||
4092 | 280 | void WebappsHandlerTest::testInstallMalformedRequest() | ||
4093 | 281 | { | ||
4094 | 282 | UnityWebapps::WebappsHandler handler; | ||
4095 | 283 | |||
4096 | 284 | QVariantMap message; | ||
4097 | 285 | message.insert("method", QString("install")); | ||
4098 | 286 | |||
4099 | 287 | QVariantMap reply = handler.url_loaded(message); | ||
4100 | 288 | |||
4101 | 289 | QVERIFY(!reply.empty()); | ||
4102 | 290 | QCOMPARE(reply.value("error").toString(), QStringLiteral("malformed request")); | ||
4103 | 291 | } | ||
4104 | 292 | |||
4105 | 293 | void WebappsHandlerTest::testInstall_data() | ||
4106 | 294 | { | ||
4107 | 295 | QTest::addColumn<QString>("url"); | ||
4108 | 296 | QTest::addColumn<bool>("available"); | ||
4109 | 297 | QTest::addColumn<bool>("installed"); | ||
4110 | 298 | |||
4111 | 299 | QTest::newRow("installs") << "https://mail.google.com/" << true << true; | ||
4112 | 300 | QTest::newRow("wont install") << "http://www.tumblr.com/" << true << false; | ||
4113 | 301 | QTest::newRow("no app") << "http://www.example.com/" << false << false; | ||
4114 | 302 | } | ||
4115 | 303 | |||
4116 | 304 | void WebappsHandlerTest::testInstall() | ||
4117 | 305 | { | ||
4118 | 306 | QFETCH(QString, url); | ||
4119 | 307 | QFETCH(bool, available); | ||
4120 | 308 | QFETCH(bool, installed); | ||
4121 | 309 | |||
4122 | 310 | QVariantMap message; | ||
4123 | 311 | message.insert("method", QString("install")); | ||
4124 | 312 | message.insert("url", url); | ||
4125 | 313 | |||
4126 | 314 | UnityWebapps::WebappsHandler handler; | ||
4127 | 315 | QVariantMap reply = handler.install(message); | ||
4128 | 316 | |||
4129 | 317 | QVERIFY(!reply.empty()); | ||
4130 | 318 | QCOMPARE(reply.value("installed").toBool(), installed); | ||
4131 | 319 | if (!available) { | ||
4132 | 320 | QCOMPARE(reply.value("available").toBool(), false); | ||
4133 | 321 | } | ||
4134 | 322 | } | ||
4135 | 323 | |||
4136 | 324 | void WebappsHandlerTest::testCreateApplicationDesktopName_data() | ||
4137 | 325 | { | ||
4138 | 326 | QTest::addColumn<QString>("appName"); | ||
4139 | 327 | QTest::addColumn<QString>("appDomain"); | ||
4140 | 328 | QTest::addColumn<QString>("expected_uri"); | ||
4141 | 329 | |||
4142 | 330 | // Behaviour | ||
4143 | 331 | QTest::newRow("strip whitespace") << "White Space Name" << "example.com" << "application://WhiteSpaceNameexamplecom.desktop"; | ||
4144 | 332 | QTest::newRow("strip special chars") << "%$special%^" << "example.com" << "application://specialexamplecom.desktop"; | ||
4145 | 333 | QTest::newRow("numbers allowed") << "13monkeys" << "example.com" << "application://13monkeysexamplecom.desktop"; | ||
4146 | 334 | QTest::newRow("combined") << "##12combined test$%67" << "example.com" << "application://12combinedtest67examplecom.desktop"; | ||
4147 | 335 | |||
4148 | 336 | // Examples | ||
4149 | 337 | QTest::newRow("live example 1") << "FacebookMessanger" << "facebook.com" << "application://FacebookMessangerfacebookcom.desktop"; | ||
4150 | 338 | QTest::newRow("live example 2") << "Gmail" << "mail.google.com" << "application://Gmailmailgooglecom.desktop"; | ||
4151 | 339 | QTest::newRow("live example 3") << "GooglePlus" << "plus.google.com" << "application://GooglePlusplusgooglecom.desktop"; | ||
4152 | 340 | } | ||
4153 | 341 | |||
4154 | 342 | void WebappsHandlerTest::testCreateApplicationDesktopName() | ||
4155 | 343 | { | ||
4156 | 344 | QFETCH(QString, appName); | ||
4157 | 345 | QFETCH(QString, appDomain); | ||
4158 | 346 | QFETCH(QString, expected_uri); | ||
4159 | 347 | |||
4160 | 348 | UnityWebapps::WebappsHandler handler; | ||
4161 | 349 | QCOMPARE(handler.createApplicationDesktopName(appName, appDomain), expected_uri); | ||
4162 | 350 | } | ||
4163 | 351 | |||
4164 | 352 | QTEST_MAIN(WebappsHandlerTest); | ||
4165 | 353 | |||
4166 | 354 | #include "tst_webapps-handler.moc" | ||
4167 | 355 | 0 | ||
4168 | === removed file 'tests/unit/messaging-host/tst_webapps-handler.pro' | |||
4169 | --- tests/unit/messaging-host/tst_webapps-handler.pro 2014-06-23 07:32:13 +0000 | |||
4170 | +++ tests/unit/messaging-host/tst_webapps-handler.pro 1970-01-01 00:00:00 +0000 | |||
4171 | @@ -1,32 +0,0 @@ | |||
4172 | 1 | include(messaging-host.pri) | ||
4173 | 2 | |||
4174 | 3 | TARGET = tst_webapps-handler | ||
4175 | 4 | |||
4176 | 5 | QMAKE_CXXFLAGS += -std=c++11 | ||
4177 | 6 | |||
4178 | 7 | CONFIG += \ | ||
4179 | 8 | link_pkgconfig \ | ||
4180 | 9 | qt | ||
4181 | 10 | |||
4182 | 11 | QT += \ | ||
4183 | 12 | core \ | ||
4184 | 13 | testlib | ||
4185 | 14 | |||
4186 | 15 | PKGCONFIG += \ | ||
4187 | 16 | glib-2.0 \ | ||
4188 | 17 | gobject-2.0 \ | ||
4189 | 18 | libunity_webapps-0.2 \ | ||
4190 | 19 | libunity-webapps-repository \ | ||
4191 | 20 | |||
4192 | 21 | DEFINES += UCX_UNDER_TEST | ||
4193 | 22 | |||
4194 | 23 | SOURCES += \ | ||
4195 | 24 | $${SRC_DIR}/webapps-handler.cpp \ | ||
4196 | 25 | tst_webapps-handler.cpp | ||
4197 | 26 | |||
4198 | 27 | HEADERS += \ | ||
4199 | 28 | $${SRC_DIR}/webapps-handler.h | ||
4200 | 29 | |||
4201 | 30 | check.commands = "xvfb-run -s '-screen 0 640x480x24' -a ./$${TARGET}" | ||
4202 | 31 | check.depends = $${TARGET} | ||
4203 | 32 | QMAKE_EXTRA_TARGETS += check | ||
4204 | 33 | 0 | ||
4205 | === added directory 'tests/unit/messaging-host/webapps-handler' | |||
4206 | === added file 'tests/unit/messaging-host/webapps-handler/CMakeLists.txt' | |||
4207 | --- tests/unit/messaging-host/webapps-handler/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
4208 | +++ tests/unit/messaging-host/webapps-handler/CMakeLists.txt 2015-10-07 04:25:10 +0000 | |||
4209 | @@ -0,0 +1,47 @@ | |||
4210 | 1 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | ||
4211 | 2 | set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
4212 | 3 | set(CMAKE_AUTOMOC ON) | ||
4213 | 4 | |||
4214 | 5 | find_package(PkgConfig) | ||
4215 | 6 | find_package(Qt5Core REQUIRED) | ||
4216 | 7 | find_package(Qt5Test REQUIRED) | ||
4217 | 8 | |||
4218 | 9 | pkg_check_modules(GLIB glib-2.0 REQUIRED) | ||
4219 | 10 | pkg_check_modules(GOBJECT gobject-2.0 REQUIRED) | ||
4220 | 11 | pkg_check_modules(WEBAPPS libunity_webapps-0.2) | ||
4221 | 12 | pkg_check_modules(WEBAPPS_REPO libunity-webapps-repository) | ||
4222 | 13 | |||
4223 | 14 | set(TEST tst_WebappsHandler) | ||
4224 | 15 | set(SOURCES | ||
4225 | 16 | ${messaging-host_SOURCE_DIR}/webapps-handler.cpp | ||
4226 | 17 | tst_webapps-handler.cpp | ||
4227 | 18 | ) | ||
4228 | 19 | |||
4229 | 20 | |||
4230 | 21 | include_directories( | ||
4231 | 22 | ${messaging-host_SOURCE_DIR} | ||
4232 | 23 | ${GLIB_INCLUDE_DIRS} | ||
4233 | 24 | ${WEBAPPS_INCLUDE_DIRS} | ||
4234 | 25 | ${WEBAPPS_REPO_INCLUDE_DIRS} | ||
4235 | 26 | ) | ||
4236 | 27 | |||
4237 | 28 | if(DEFINED WEBAPPS_FOUND AND WEBAPPS_FOUND EQUAL 1) | ||
4238 | 29 | if(DEFINED WEBAPPS_REPO_FOUND AND WEBAPPS_REPO_FOUND EQUAL 1) | ||
4239 | 30 | add_definitions( | ||
4240 | 31 | -DHAVE_UNITY_WEBAPPS=1 | ||
4241 | 32 | -DUCX_UNDER_TEST=1 | ||
4242 | 33 | ) | ||
4243 | 34 | add_executable(${TEST} ${SOURCES}) | ||
4244 | 35 | target_link_libraries( | ||
4245 | 36 | ${TEST} | ||
4246 | 37 | |||
4247 | 38 | Qt5::Core | ||
4248 | 39 | Qt5::Test | ||
4249 | 40 | ${GLIB_LIBRARIES} | ||
4250 | 41 | ${GOBJECT_LIBRARIES} | ||
4251 | 42 | ${WEBAPPS_LIBRARIES} | ||
4252 | 43 | ${WEBAPPS_REPO_LIBRARIES} | ||
4253 | 44 | ) | ||
4254 | 45 | add_test(${TEST} ${CMAKE_CURRENT_BINARY_DIR}/${TEST} -xunitxml -o ${TEST}.xml) | ||
4255 | 46 | endif() | ||
4256 | 47 | endif() | ||
4257 | 0 | 48 | ||
4258 | === added file 'tests/unit/messaging-host/webapps-handler/tst_webapps-handler.cpp' | |||
4259 | --- tests/unit/messaging-host/webapps-handler/tst_webapps-handler.cpp 1970-01-01 00:00:00 +0000 | |||
4260 | +++ tests/unit/messaging-host/webapps-handler/tst_webapps-handler.cpp 2015-10-07 04:25:10 +0000 | |||
4261 | @@ -0,0 +1,354 @@ | |||
4262 | 1 | /* | ||
4263 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
4264 | 3 | * | ||
4265 | 4 | * This file is part of unity-chromium-extension | ||
4266 | 5 | * | ||
4267 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
4268 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
4269 | 8 | * by the Free Software Foundation. | ||
4270 | 9 | * | ||
4271 | 10 | * This program is distributed in the hope that it will be useful, but | ||
4272 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
4273 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
4274 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
4275 | 14 | * | ||
4276 | 15 | * You should have received a copy of the GNU General Public License along | ||
4277 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4278 | 17 | */ | ||
4279 | 18 | |||
4280 | 19 | extern "C" { | ||
4281 | 20 | #include <unity-webapps-permissions.h> | ||
4282 | 21 | #include <unity-webapps-application-repository.h> | ||
4283 | 22 | } | ||
4284 | 23 | |||
4285 | 24 | #include "webapps-handler.h" | ||
4286 | 25 | |||
4287 | 26 | #include <QDebug> | ||
4288 | 27 | #include <QSignalSpy> | ||
4289 | 28 | #include <QTest> | ||
4290 | 29 | |||
4291 | 30 | |||
4292 | 31 | // {{{ mock implementations | ||
4293 | 32 | struct AppInfo { | ||
4294 | 33 | bool install; | ||
4295 | 34 | bool allowed; | ||
4296 | 35 | bool dontask; | ||
4297 | 36 | UnityWebappsApplicationStatus status; | ||
4298 | 37 | QString name; | ||
4299 | 38 | QString domain; | ||
4300 | 39 | }; | ||
4301 | 40 | |||
4302 | 41 | QMap<QString, AppInfo> _mock_app_info; | ||
4303 | 42 | |||
4304 | 43 | UnityWebappsApplicationRepository *unity_webapps_application_repository_new_default() | ||
4305 | 44 | { | ||
4306 | 45 | return (UnityWebappsApplicationRepository*)g_object_new(G_TYPE_OBJECT, 0); | ||
4307 | 46 | } | ||
4308 | 47 | |||
4309 | 48 | gboolean unity_webapps_application_repository_prepare(UnityWebappsApplicationRepository *repository) | ||
4310 | 49 | { | ||
4311 | 50 | Q_UNUSED(repository); | ||
4312 | 51 | |||
4313 | 52 | return true; | ||
4314 | 53 | } | ||
4315 | 54 | |||
4316 | 55 | GList * unity_webapps_application_repository_resolve_url(UnityWebappsApplicationRepository *repository, const gchar *url) | ||
4317 | 56 | { | ||
4318 | 57 | Q_UNUSED(repository); | ||
4319 | 58 | |||
4320 | 59 | if (!_mock_app_info.contains(QString::fromUtf8(url))) { | ||
4321 | 60 | return 0; | ||
4322 | 61 | } | ||
4323 | 62 | |||
4324 | 63 | return g_list_append((GList*)0, (gpointer)g_strdup(url)); | ||
4325 | 64 | } | ||
4326 | 65 | |||
4327 | 66 | UnityWebappsApplicationStatus | ||
4328 | 67 | unity_webapps_application_repository_get_resolved_application_status( | ||
4329 | 68 | UnityWebappsApplicationRepository *repository, | ||
4330 | 69 | const gchar *application | ||
4331 | 70 | ) | ||
4332 | 71 | { | ||
4333 | 72 | Q_UNUSED(repository); | ||
4334 | 73 | |||
4335 | 74 | if (!_mock_app_info.contains(QString::fromUtf8(application))) { | ||
4336 | 75 | return UNITY_WEBAPPS_APPLICATION_STATUS_UNRESOLVED; | ||
4337 | 76 | } | ||
4338 | 77 | |||
4339 | 78 | return _mock_app_info.value(QString::fromUtf8(application)).status; | ||
4340 | 79 | } | ||
4341 | 80 | |||
4342 | 81 | const gchar * | ||
4343 | 82 | unity_webapps_application_repository_get_resolved_application_name(UnityWebappsApplicationRepository *repository, | ||
4344 | 83 | const gchar *application) | ||
4345 | 84 | { | ||
4346 | 85 | Q_UNUSED(repository); | ||
4347 | 86 | |||
4348 | 87 | if (!_mock_app_info.contains(QString::fromUtf8(application))) { | ||
4349 | 88 | return 0; | ||
4350 | 89 | } | ||
4351 | 90 | |||
4352 | 91 | return g_strdup(_mock_app_info.value(QString::fromUtf8(application)).name.toLocal8Bit().constData()); | ||
4353 | 92 | } | ||
4354 | 93 | |||
4355 | 94 | const gchar * | ||
4356 | 95 | unity_webapps_application_repository_get_resolved_application_domain(UnityWebappsApplicationRepository *repository, | ||
4357 | 96 | const gchar *application) | ||
4358 | 97 | { | ||
4359 | 98 | Q_UNUSED(repository); | ||
4360 | 99 | |||
4361 | 100 | if (!_mock_app_info.contains(QString::fromUtf8(application))) { | ||
4362 | 101 | return 0; | ||
4363 | 102 | } | ||
4364 | 103 | |||
4365 | 104 | return g_strdup(_mock_app_info.value(QString::fromUtf8(application)).domain.toLocal8Bit().constData()); | ||
4366 | 105 | } | ||
4367 | 106 | |||
4368 | 107 | |||
4369 | 108 | gboolean unity_webapps_permissions_get_domain_allowed(const gchar *domain) | ||
4370 | 109 | { | ||
4371 | 110 | Q_FOREACH(const QString &key, _mock_app_info.keys()) { | ||
4372 | 111 | AppInfo appInfo = _mock_app_info.value(key); | ||
4373 | 112 | if (appInfo.domain == QLatin1String(domain)) { | ||
4374 | 113 | return appInfo.allowed; | ||
4375 | 114 | } | ||
4376 | 115 | } | ||
4377 | 116 | |||
4378 | 117 | return false; | ||
4379 | 118 | } | ||
4380 | 119 | |||
4381 | 120 | gboolean unity_webapps_permissions_get_domain_dontask(const gchar *domain) | ||
4382 | 121 | { | ||
4383 | 122 | Q_FOREACH(const QString &key, _mock_app_info.keys()) { | ||
4384 | 123 | AppInfo appInfo = _mock_app_info.value(key); | ||
4385 | 124 | if (appInfo.domain == QLatin1String(domain)) { | ||
4386 | 125 | return appInfo.dontask; | ||
4387 | 126 | } | ||
4388 | 127 | } | ||
4389 | 128 | |||
4390 | 129 | return false; | ||
4391 | 130 | } | ||
4392 | 131 | |||
4393 | 132 | void unity_webapps_permissions_dontask_domain(const gchar *domain) | ||
4394 | 133 | { | ||
4395 | 134 | Q_UNUSED(domain); | ||
4396 | 135 | } | ||
4397 | 136 | |||
4398 | 137 | void | ||
4399 | 138 | unity_webapps_application_repository_install_application(UnityWebappsApplicationRepository *repository, const gchar *name, | ||
4400 | 139 | UnityWebappsApplicationRepositoryInstallCallback callback, gpointer user_data) | ||
4401 | 140 | { | ||
4402 | 141 | Q_UNUSED(repository); | ||
4403 | 142 | Q_UNUSED(name); | ||
4404 | 143 | Q_UNUSED(callback); | ||
4405 | 144 | Q_UNUSED(user_data); | ||
4406 | 145 | } | ||
4407 | 146 | |||
4408 | 147 | // }}} | ||
4409 | 148 | |||
4410 | 149 | |||
4411 | 150 | class WebappsHandlerTest : public QObject | ||
4412 | 151 | { | ||
4413 | 152 | Q_OBJECT | ||
4414 | 153 | |||
4415 | 154 | public: | ||
4416 | 155 | WebappsHandlerTest(); | ||
4417 | 156 | |||
4418 | 157 | private Q_SLOTS: | ||
4419 | 158 | void initTestCase(); | ||
4420 | 159 | void cleanupTestCase(); | ||
4421 | 160 | void testUrlLoadedMalformedRequest(); | ||
4422 | 161 | void testUrlLoaded_data(); | ||
4423 | 162 | void testUrlLoaded(); | ||
4424 | 163 | void testDontAskMalformedRequest(); | ||
4425 | 164 | void testDontAsk_data(); | ||
4426 | 165 | void testDontAsk(); | ||
4427 | 166 | void testInstallMalformedRequest(); | ||
4428 | 167 | void testInstall_data(); | ||
4429 | 168 | void testInstall(); | ||
4430 | 169 | void testCreateApplicationDesktopName_data(); | ||
4431 | 170 | void testCreateApplicationDesktopName(); | ||
4432 | 171 | }; | ||
4433 | 172 | |||
4434 | 173 | WebappsHandlerTest::WebappsHandlerTest(): | ||
4435 | 174 | QObject(0) | ||
4436 | 175 | { | ||
4437 | 176 | } | ||
4438 | 177 | |||
4439 | 178 | |||
4440 | 179 | void WebappsHandlerTest::initTestCase() | ||
4441 | 180 | { | ||
4442 | 181 | _mock_app_info.insert("https://mail.google.com/", { true, false, false, UNITY_WEBAPPS_APPLICATION_STATUS_AVAILABLE, "Gmail", "mail.google.com" }); | ||
4443 | 182 | _mock_app_info.insert("http://www.tumblr.com/", { false, true, true, UNITY_WEBAPPS_APPLICATION_STATUS_AVAILABLE, "Tumblr", "www.tumblr.com" }); | ||
4444 | 183 | } | ||
4445 | 184 | |||
4446 | 185 | void WebappsHandlerTest::cleanupTestCase() | ||
4447 | 186 | { | ||
4448 | 187 | } | ||
4449 | 188 | |||
4450 | 189 | void WebappsHandlerTest::testUrlLoadedMalformedRequest() | ||
4451 | 190 | { | ||
4452 | 191 | UnityWebapps::WebappsHandler handler; | ||
4453 | 192 | |||
4454 | 193 | QVariantMap message; | ||
4455 | 194 | message.insert("method", QString("url_loaded")); | ||
4456 | 195 | |||
4457 | 196 | QVariantMap reply = handler.url_loaded(message); | ||
4458 | 197 | |||
4459 | 198 | QVERIFY(!reply.empty()); | ||
4460 | 199 | QCOMPARE(reply.value("error").toString(), QStringLiteral("malformed request")); | ||
4461 | 200 | } | ||
4462 | 201 | |||
4463 | 202 | void WebappsHandlerTest::testUrlLoaded_data() | ||
4464 | 203 | { | ||
4465 | 204 | QTest::addColumn<QString>("url"); | ||
4466 | 205 | QTest::addColumn<bool>("available"); | ||
4467 | 206 | QTest::addColumn<QString>("appName"); | ||
4468 | 207 | QTest::addColumn<QString>("appDomain"); | ||
4469 | 208 | |||
4470 | 209 | QTest::newRow("available") << "https://mail.google.com/" << true << "Gmail" << "mail.google.com"; | ||
4471 | 210 | QTest::newRow("not_available") << "http://www.example.com/" << false << "None" << "None"; | ||
4472 | 211 | } | ||
4473 | 212 | |||
4474 | 213 | void WebappsHandlerTest::testUrlLoaded() | ||
4475 | 214 | { | ||
4476 | 215 | QFETCH(QString, url); | ||
4477 | 216 | QFETCH(bool, available); | ||
4478 | 217 | QFETCH(QString, appName); | ||
4479 | 218 | QFETCH(QString, appDomain); | ||
4480 | 219 | |||
4481 | 220 | QVariantMap message; | ||
4482 | 221 | message.insert("method", QString("url_loaded")); | ||
4483 | 222 | message.insert("url", url); | ||
4484 | 223 | |||
4485 | 224 | UnityWebapps::WebappsHandler handler; | ||
4486 | 225 | QVariantMap reply = handler.url_loaded(message); | ||
4487 | 226 | |||
4488 | 227 | QVERIFY(!reply.empty()); | ||
4489 | 228 | QCOMPARE(reply.value("available").toBool(), available); | ||
4490 | 229 | if (available) { | ||
4491 | 230 | QCOMPARE(appName, reply.value("appName").toString()); | ||
4492 | 231 | QCOMPARE(appDomain, reply.value("appDomain").toString()); | ||
4493 | 232 | } | ||
4494 | 233 | } | ||
4495 | 234 | |||
4496 | 235 | void WebappsHandlerTest::testDontAskMalformedRequest() | ||
4497 | 236 | { | ||
4498 | 237 | UnityWebapps::WebappsHandler handler; | ||
4499 | 238 | |||
4500 | 239 | QVariantMap message; | ||
4501 | 240 | message.insert("method", QString("dont_ask")); | ||
4502 | 241 | |||
4503 | 242 | QVariantMap reply = handler.url_loaded(message); | ||
4504 | 243 | |||
4505 | 244 | QVERIFY(!reply.empty()); | ||
4506 | 245 | QCOMPARE(reply.value("error").toString(), QStringLiteral("malformed request")); | ||
4507 | 246 | } | ||
4508 | 247 | |||
4509 | 248 | void WebappsHandlerTest::testDontAsk_data() | ||
4510 | 249 | { | ||
4511 | 250 | QTest::addColumn<QString>("url"); | ||
4512 | 251 | QTest::addColumn<bool>("available"); | ||
4513 | 252 | |||
4514 | 253 | QTest::newRow("ask") << "https://mail.google.com/" << true; | ||
4515 | 254 | QTest::newRow("dont_ask") << "http://www.tumblr.com/" << true; | ||
4516 | 255 | QTest::newRow("no app") << "http://www.example.com/" << false; | ||
4517 | 256 | } | ||
4518 | 257 | |||
4519 | 258 | void WebappsHandlerTest::testDontAsk() | ||
4520 | 259 | { | ||
4521 | 260 | QFETCH(QString, url); | ||
4522 | 261 | QFETCH(bool, available); | ||
4523 | 262 | |||
4524 | 263 | UnityWebapps::WebappsHandler handler; | ||
4525 | 264 | |||
4526 | 265 | QVariantMap message; | ||
4527 | 266 | message.insert("method", QString("dont_ask")); | ||
4528 | 267 | message.insert("url", url); | ||
4529 | 268 | |||
4530 | 269 | QVariantMap reply = handler.dont_ask(message); | ||
4531 | 270 | |||
4532 | 271 | QVERIFY(!reply.empty()); | ||
4533 | 272 | if (available) { | ||
4534 | 273 | QCOMPARE(reply.value("dont_ask").toBool(), true); | ||
4535 | 274 | } else { | ||
4536 | 275 | QCOMPARE(reply.value("dont_ask").toBool(), false); | ||
4537 | 276 | QCOMPARE(reply.value("available").toBool(), false); | ||
4538 | 277 | } | ||
4539 | 278 | } | ||
4540 | 279 | |||
4541 | 280 | void WebappsHandlerTest::testInstallMalformedRequest() | ||
4542 | 281 | { | ||
4543 | 282 | UnityWebapps::WebappsHandler handler; | ||
4544 | 283 | |||
4545 | 284 | QVariantMap message; | ||
4546 | 285 | message.insert("method", QString("install")); | ||
4547 | 286 | |||
4548 | 287 | QVariantMap reply = handler.url_loaded(message); | ||
4549 | 288 | |||
4550 | 289 | QVERIFY(!reply.empty()); | ||
4551 | 290 | QCOMPARE(reply.value("error").toString(), QStringLiteral("malformed request")); | ||
4552 | 291 | } | ||
4553 | 292 | |||
4554 | 293 | void WebappsHandlerTest::testInstall_data() | ||
4555 | 294 | { | ||
4556 | 295 | QTest::addColumn<QString>("url"); | ||
4557 | 296 | QTest::addColumn<bool>("available"); | ||
4558 | 297 | QTest::addColumn<bool>("installed"); | ||
4559 | 298 | |||
4560 | 299 | QTest::newRow("installs") << "https://mail.google.com/" << true << true; | ||
4561 | 300 | QTest::newRow("wont install") << "http://www.tumblr.com/" << true << false; | ||
4562 | 301 | QTest::newRow("no app") << "http://www.example.com/" << false << false; | ||
4563 | 302 | } | ||
4564 | 303 | |||
4565 | 304 | void WebappsHandlerTest::testInstall() | ||
4566 | 305 | { | ||
4567 | 306 | QFETCH(QString, url); | ||
4568 | 307 | QFETCH(bool, available); | ||
4569 | 308 | QFETCH(bool, installed); | ||
4570 | 309 | |||
4571 | 310 | QVariantMap message; | ||
4572 | 311 | message.insert("method", QString("install")); | ||
4573 | 312 | message.insert("url", url); | ||
4574 | 313 | |||
4575 | 314 | UnityWebapps::WebappsHandler handler; | ||
4576 | 315 | QVariantMap reply = handler.install(message); | ||
4577 | 316 | |||
4578 | 317 | QVERIFY(!reply.empty()); | ||
4579 | 318 | QCOMPARE(reply.value("installed").toBool(), installed); | ||
4580 | 319 | if (!available) { | ||
4581 | 320 | QCOMPARE(reply.value("available").toBool(), false); | ||
4582 | 321 | } | ||
4583 | 322 | } | ||
4584 | 323 | |||
4585 | 324 | void WebappsHandlerTest::testCreateApplicationDesktopName_data() | ||
4586 | 325 | { | ||
4587 | 326 | QTest::addColumn<QString>("appName"); | ||
4588 | 327 | QTest::addColumn<QString>("appDomain"); | ||
4589 | 328 | QTest::addColumn<QString>("expected_uri"); | ||
4590 | 329 | |||
4591 | 330 | // Behaviour | ||
4592 | 331 | QTest::newRow("strip whitespace") << "White Space Name" << "example.com" << "application://WhiteSpaceNameexamplecom.desktop"; | ||
4593 | 332 | QTest::newRow("strip special chars") << "%$special%^" << "example.com" << "application://specialexamplecom.desktop"; | ||
4594 | 333 | QTest::newRow("numbers allowed") << "13monkeys" << "example.com" << "application://13monkeysexamplecom.desktop"; | ||
4595 | 334 | QTest::newRow("combined") << "##12combined test$%67" << "example.com" << "application://12combinedtest67examplecom.desktop"; | ||
4596 | 335 | |||
4597 | 336 | // Examples | ||
4598 | 337 | QTest::newRow("live example 1") << "FacebookMessanger" << "facebook.com" << "application://FacebookMessangerfacebookcom.desktop"; | ||
4599 | 338 | QTest::newRow("live example 2") << "Gmail" << "mail.google.com" << "application://Gmailmailgooglecom.desktop"; | ||
4600 | 339 | QTest::newRow("live example 3") << "GooglePlus" << "plus.google.com" << "application://GooglePlusplusgooglecom.desktop"; | ||
4601 | 340 | } | ||
4602 | 341 | |||
4603 | 342 | void WebappsHandlerTest::testCreateApplicationDesktopName() | ||
4604 | 343 | { | ||
4605 | 344 | QFETCH(QString, appName); | ||
4606 | 345 | QFETCH(QString, appDomain); | ||
4607 | 346 | QFETCH(QString, expected_uri); | ||
4608 | 347 | |||
4609 | 348 | UnityWebapps::WebappsHandler handler; | ||
4610 | 349 | QCOMPARE(handler.createApplicationDesktopName(appName, appDomain), expected_uri); | ||
4611 | 350 | } | ||
4612 | 351 | |||
4613 | 352 | QTEST_MAIN(WebappsHandlerTest); | ||
4614 | 353 | |||
4615 | 354 | #include "tst_webapps-handler.moc" | ||
4616 | 0 | 355 | ||
4617 | === removed file 'tests/unit/unit.pro' | |||
4618 | --- tests/unit/unit.pro 2014-05-20 12:21:50 +0000 | |||
4619 | +++ tests/unit/unit.pro 1970-01-01 00:00:00 +0000 | |||
4620 | @@ -1,3 +0,0 @@ | |||
4621 | 1 | TEMPLATE = subdirs | ||
4622 | 2 | SUBDIRS = \ | ||
4623 | 3 | messaging-host | ||
4624 | 4 | 0 | ||
4625 | === removed file 'unity-chromium-extension.pro' | |||
4626 | --- unity-chromium-extension.pro 2014-05-19 14:04:19 +0000 | |||
4627 | +++ unity-chromium-extension.pro 1970-01-01 00:00:00 +0000 | |||
4628 | @@ -1,14 +0,0 @@ | |||
4629 | 1 | include(common-project-config.pri) | ||
4630 | 2 | include(common-vars.pri) | ||
4631 | 3 | |||
4632 | 4 | TEMPLATE = subdirs | ||
4633 | 5 | SUBDIRS = \ | ||
4634 | 6 | chromium-extension \ | ||
4635 | 7 | messaging-host \ | ||
4636 | 8 | tests | ||
4637 | 9 | |||
4638 | 10 | tests.depends = messaging-host | ||
4639 | 11 | |||
4640 | 12 | DISTNAME = $${PROJECT_NAME}-$${PROJECT_VERSION} | ||
4641 | 13 | dist.commands = "bzr export $${DISTNAME}.tar.bz2" | ||
4642 | 14 | QMAKE_EXTRA_TARGETS += dist |