Merge lp:~dobey/unity-scope-click/merge-devel into lp:unity-scope-click
- merge-devel
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 227 |
Proposed branch: | lp:~dobey/unity-scope-click/merge-devel |
Merge into: | lp:unity-scope-click |
Diff against target: |
1856 lines (+562/-235) 43 files modified
CMakeLists.txt (+8/-0) HACKING (+67/-0) README (+16/-0) autopilot/CMakeLists.txt (+2/-2) autopilot/unityclickscope/fake_servers.py (+13/-13) autopilot/unityclickscope/test_click_scope.py (+47/-21) autopilot/unityclickscope/test_fixture_setup.py (+5/-5) debian/control (+7/-6) libclickscope/CMakeLists.txt (+1/-0) libclickscope/click/CMakeLists.txt (+3/-2) libclickscope/click/configuration.cpp (+15/-0) libclickscope/click/configuration.h (+2/-0) libclickscope/tests/CMakeLists.txt (+54/-0) libclickscope/tests/test_configuration.cpp (+12/-0) libclickscope/tests/test_smartconnect.cpp (+1/-1) po/ar.po (+5/-5) po/de.po (+4/-4) po/fr.po (+5/-5) po/gd.po (+6/-6) po/he.po (+9/-9) po/it.po (+5/-5) po/nb.po (+5/-5) po/ru.po (+20/-20) scope/click/CMakeLists.txt (+0/-4) scope/click/download-manager.h (+2/-1) scope/click/index.cpp (+25/-9) scope/click/index.h (+5/-2) scope/click/package.cpp (+49/-14) scope/click/package.h (+7/-0) scope/click/preview.h (+2/-1) scope/click/query.cpp (+36/-33) scope/click/query.h (+2/-1) scope/click/reviews.cpp (+9/-2) scope/click/scope.cpp (+2/-2) scope/click/scope.h (+2/-1) scope/click/webclient.cpp (+4/-3) scope/tests/CMakeLists.txt (+1/-10) scope/tests/fake_json.h (+38/-16) scope/tests/test_download_manager.cpp (+1/-1) scope/tests/test_index.cpp (+14/-9) scope/tests/test_query.cpp (+16/-10) scope/tests/test_reviews.cpp (+30/-3) scope/tests/test_webclient.cpp (+5/-4) |
To merge this branch: | bzr merge lp:~dobey/unity-scope-click/merge-devel |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Unity Team | Pending | ||
Review via email: mp+220696@code.launchpad.net |
Commit message
- Handle some languages differently when submitting reviews. (LP: #1321154)
- Add runtime dependency on ubuntu-sdk-libs for the frameworks list. (LP: #1320975)
- Support hal+json in the search request.
- Fix issues in autopilot tests.
- Port autopilot tests to python3.
- Add README and HACKING files. (LP: #1226111)
- Translations updates.
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:228
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 227. By dobey
-
- Handle some languages differently when submitting reviews. (LP: #1321154)
- Add runtime dependency on ubuntu-sdk-libs for the frameworks list. (LP: #1320975)
- Support hal+json in the search request.
- Fix issues in autopilot tests.
- Port autopilot tests to python3.
- Add README and HACKING files. (LP: #1226111)
- Translations updates.
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2014-05-14 21:50:52 +0000 |
3 | +++ CMakeLists.txt 2014-05-23 14:58:59 +0000 |
4 | @@ -35,6 +35,14 @@ |
5 | SET (SCOPE_LIB_UNVERSIONED clickscope) |
6 | SET (SCOPE_LIB_NAME ${SCOPE_LIB_UNVERSIONED}-${SCOPE_LIB_API_VERSION}) |
7 | |
8 | +# Build with system gmock and embedded gtest |
9 | +set (GMOCK_INCLUDE_DIR "/usr/include/gmock/include" CACHE PATH "gmock source include directory") |
10 | +set (GMOCK_SOURCE_DIR "/usr/src/gmock" CACHE PATH "gmock source directory") |
11 | +set (GTEST_INCLUDE_DIR "${GMOCK_SOURCE_DIR}/gtest/include" CACHE PATH "gtest source include directory") |
12 | + |
13 | +add_subdirectory(${GMOCK_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock") |
14 | + |
15 | +# Add our own subdirectories. |
16 | add_subdirectory(autopilot) |
17 | add_subdirectory(libclickscope) |
18 | add_subdirectory(scope) |
19 | |
20 | === added file 'HACKING' |
21 | --- HACKING 1970-01-01 00:00:00 +0000 |
22 | +++ HACKING 2014-05-23 14:58:59 +0000 |
23 | @@ -0,0 +1,67 @@ |
24 | +unity-scope-click hacking guide |
25 | +=============================== |
26 | + |
27 | +Getting unity-scope-click |
28 | +------------------------- |
29 | + |
30 | +To get the main development branch of unity-scope-click: |
31 | + |
32 | + $ bzr branch lp:unity-scope-click/devel |
33 | + |
34 | + |
35 | +Getting dependencies |
36 | +-------------------- |
37 | + |
38 | +To succesfully build the scope there are a few packages required: |
39 | + |
40 | + $ sudo apt-get build-dep unity-scope-click |
41 | + |
42 | + |
43 | +Building the scope |
44 | +------------------ |
45 | + |
46 | +This scope is built using cmake. Here's an example on how to build it: |
47 | + |
48 | + $ mkdir build |
49 | + $ cd build |
50 | + $ cmake .. |
51 | + $ make -j 8 |
52 | + |
53 | + |
54 | +Running the unit tests |
55 | +---------------------- |
56 | + |
57 | + $ make check |
58 | + |
59 | +Or, if you want to run the tests under valgrind: |
60 | + |
61 | + $ make check-valgrind |
62 | + |
63 | + |
64 | +Running the autopilot tests |
65 | +--------------------------- |
66 | + |
67 | + $ make test-click-scope-autopilot-fake-servers |
68 | + |
69 | + |
70 | +Running the scope |
71 | +----------------- |
72 | + |
73 | +You will usually run the scope inside a unity8 session, but when developing |
74 | +a good way to test it is with unity-scope-tool. Inside the build directory do: |
75 | + |
76 | + $ mkdir clickscope |
77 | + $ (cd clickscope;ln -s ../scope/click/libclickscope.so .; ln -s ../data/clickscope.ini .) |
78 | + $ U1_DEBUG=true unity-scope-tool clickscope/clickscope.ini |
79 | + |
80 | + |
81 | +Running the coverage tests |
82 | +-------------------------- |
83 | + |
84 | +To run the coverage tests you'll need to install the gcovr and lcov packages. |
85 | +Then you need to compile with coverage enabled, like this: |
86 | + |
87 | + $ cmake .. -DCMAKE_BUILD_TYPE=coverage |
88 | + $ make coverage-html |
89 | + |
90 | +The html will be left on the coveragereport directory. |
91 | |
92 | === modified file 'README' |
93 | --- README 2013-07-18 18:25:34 +0000 |
94 | +++ README 2014-05-23 14:58:59 +0000 |
95 | @@ -0,0 +1,16 @@ |
96 | +Readme |
97 | +====== |
98 | + |
99 | +unity-scope-click - Click Packages Scope for Unity |
100 | +-------------------------------------------------- |
101 | + |
102 | +This scope shows the list of installed applications, and the list of |
103 | +applications available to download from the appstore webservice. |
104 | +To authenticate downloads, this scope uses Ubuntu Online Accounts to |
105 | +get credentials for the logged in user. |
106 | +Since scopes are short lived, ubuntu-download-manager is used to do |
107 | +the actual download. |
108 | + |
109 | +You can find information on how to compile and run this program in |
110 | +the HACKING file, and you can find licensing information in the |
111 | +COPYING file. |
112 | |
113 | === modified file 'autopilot/CMakeLists.txt' |
114 | --- autopilot/CMakeLists.txt 2014-02-06 17:15:05 +0000 |
115 | +++ autopilot/CMakeLists.txt 2014-05-23 14:58:59 +0000 |
116 | @@ -13,7 +13,7 @@ |
117 | DESTINATION ${PYTHON_PACKAGE_DIR} |
118 | ) |
119 | |
120 | -add_custom_target(test-click-scope-autopilot-local |
121 | - COMMAND U1_SEARCH_BASE_URL=fake DOWNLOAD_BASE_URL=fake autopilot run ${AUTOPILOT_DIR} |
122 | +add_custom_target(test-click-scope-autopilot-fake-servers |
123 | + COMMAND U1_SEARCH_BASE_URL=fake DOWNLOAD_BASE_URL=fake BUILD_DIR=${CMAKE_BINARY_DIR} autopilot3 run -v ${AUTOPILOT_DIR} |
124 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
125 | ) |
126 | |
127 | === modified file 'autopilot/unityclickscope/fake_servers.py' |
128 | --- autopilot/unityclickscope/fake_servers.py 2014-02-01 12:31:42 +0000 |
129 | +++ autopilot/unityclickscope/fake_servers.py 2014-05-23 14:58:59 +0000 |
130 | @@ -14,28 +14,28 @@ |
131 | # You should have received a copy of the GNU General Public License |
132 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
133 | |
134 | -import BaseHTTPServer |
135 | import copy |
136 | +import http.server |
137 | import json |
138 | import os |
139 | import tempfile |
140 | -import urlparse |
141 | - |
142 | - |
143 | -class BaseFakeHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): |
144 | +import urllib.parse |
145 | + |
146 | + |
147 | +class BaseFakeHTTPRequestHandler(http.server.BaseHTTPRequestHandler): |
148 | |
149 | def send_json_reply(self, code, reply_json): |
150 | self.send_response(code) |
151 | self.send_header('Content-Type', 'application/json') |
152 | self.end_headers() |
153 | - self.wfile.write(reply_json) |
154 | + self.wfile.write(reply_json.encode()) |
155 | |
156 | def send_file(self, file_path, send_body=True, extra_headers={}): |
157 | with open(file_path) as file_: |
158 | data = file_.read() |
159 | self.send_response(200) |
160 | self.send_header('Content-Length', str(len(data))) |
161 | - for key, value in extra_headers.iteritems(): |
162 | + for key, value in extra_headers.items(): |
163 | self.send_header(key, value) |
164 | self.end_headers() |
165 | if send_body: |
166 | @@ -45,7 +45,7 @@ |
167 | self.send_file(file_path, send_body=False, extra_headers=extra_headers) |
168 | |
169 | |
170 | -class FakeSearchServer(BaseHTTPServer.HTTPServer, object): |
171 | +class FakeSearchServer(http.server.HTTPServer, object): |
172 | |
173 | def __init__(self, server_address): |
174 | super(FakeSearchServer, self).__init__( |
175 | @@ -102,7 +102,7 @@ |
176 | } |
177 | |
178 | def do_GET(self): |
179 | - parsed_path = urlparse.urlparse(self.path) |
180 | + parsed_path = urllib.parse.urlparse(self.path) |
181 | if parsed_path.path.startswith(self._SEARCH_PATH): |
182 | self.send_json_reply(200, self._get_fake_search_response()) |
183 | elif parsed_path.path.startswith('/extra/'): |
184 | @@ -131,7 +131,7 @@ |
185 | raise NotImplementedError(package) |
186 | |
187 | |
188 | -class FakeDownloadServer(BaseHTTPServer.HTTPServer, object): |
189 | +class FakeDownloadServer(http.server.HTTPServer, object): |
190 | |
191 | def __init__(self, server_address): |
192 | super(FakeDownloadServer, self).__init__( |
193 | @@ -141,7 +141,7 @@ |
194 | class FakeDownloadRequestHandler(BaseFakeHTTPRequestHandler): |
195 | |
196 | def do_HEAD(self): |
197 | - parsed_path = urlparse.urlparse(self.path) |
198 | + parsed_path = urllib.parse.urlparse(self.path) |
199 | if parsed_path.path.startswith('/download/'): |
200 | self._send_dummy_file_headers(parsed_path.path[10:]) |
201 | else: |
202 | @@ -156,7 +156,7 @@ |
203 | def _make_dummy_file(self, name): |
204 | dummy_file = tempfile.NamedTemporaryFile( |
205 | prefix='dummy', suffix='.click', delete=False) |
206 | - dummy_file.write('Dummy click file.') |
207 | - dummy_file.write(name) |
208 | + dummy_file.write('Dummy click file.'.encode()) |
209 | + dummy_file.write(name.encode()) |
210 | dummy_file.close() |
211 | return dummy_file.name |
212 | |
213 | === modified file 'autopilot/unityclickscope/test_click_scope.py' |
214 | --- autopilot/unityclickscope/test_click_scope.py 2014-05-13 05:52:34 +0000 |
215 | +++ autopilot/unityclickscope/test_click_scope.py 2014-05-23 14:58:59 +0000 |
216 | @@ -15,14 +15,15 @@ |
217 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
218 | |
219 | import logging |
220 | +import os |
221 | +import shutil |
222 | import subprocess |
223 | -import os |
224 | |
225 | import dbusmock |
226 | import fixtures |
227 | from autopilot.introspection import dbus as autopilot_dbus |
228 | from autopilot.matchers import Eventually |
229 | -from testtools.matchers import Equals, MatchesAny |
230 | +from testtools.matchers import Equals |
231 | from unity8 import process_helpers |
232 | from unity8.shell import tests as unity_tests |
233 | from unity8.shell.emulators import dash |
234 | @@ -106,15 +107,40 @@ |
235 | def _restart_scope(self): |
236 | logging.info('Restarting click scope.') |
237 | os.system('pkill -f -9 clickscope.ini') |
238 | - lib_path = '/usr/lib/$DEB_HOST_MULTIARCH/' |
239 | - scoperunner_path = os.path.join(lib_path, 'unity-scopes/scoperunner') |
240 | - clickscope_config_ini_path = os.path.join( |
241 | - lib_path, 'unity-scopes/clickscope/clickscope.ini') |
242 | os.system( |
243 | "dpkg-architecture -c " |
244 | "'{scoperunner} \"\" {clickscope}' &".format( |
245 | - scoperunner=scoperunner_path, |
246 | - clickscope=clickscope_config_ini_path)) |
247 | + scoperunner=self._get_scoperunner_path(), |
248 | + clickscope=self._get_scope_ini_path())) |
249 | + |
250 | + def _get_scoperunner_path(self): |
251 | + return os.path.join( |
252 | + self._get_installed_unity_scopes_lib_dir(), 'scoperunner') |
253 | + |
254 | + def _get_installed_unity_scopes_lib_dir(self): |
255 | + return os.path.join('/usr/lib/$DEB_HOST_MULTIARCH/', 'unity-scopes') |
256 | + |
257 | + def _get_scope_ini_path(self): |
258 | + build_dir = os.environ.get('BUILD_DIR', None) |
259 | + if build_dir is not None: |
260 | + return self._get_built_scope_ini_path(build_dir) |
261 | + else: |
262 | + return os.path.join( |
263 | + self._get_installed_unity_scopes_lib_dir(), |
264 | + 'clickscope', 'clickscope.ini') |
265 | + |
266 | + def _get_built_scope_ini_path(self, build_dir): |
267 | + # The ini and the so files need to be on the same directory. |
268 | + # We copy them to a temp directory. |
269 | + temp_dir_fixture = fixtures.TempDir() |
270 | + self.useFixture(temp_dir_fixture) |
271 | + shutil.copy( |
272 | + os.path.join(build_dir, 'data', 'clickscope.ini'), |
273 | + temp_dir_fixture.path) |
274 | + shutil.copy( |
275 | + os.path.join(build_dir, 'scope', 'click', 'libclickscope.so'), |
276 | + temp_dir_fixture.path) |
277 | + return os.path.join(temp_dir_fixture.path, 'clickscope.ini') |
278 | |
279 | def _unlock_screen(self): |
280 | self.main_window.get_greeter().swipe() |
281 | @@ -125,18 +151,10 @@ |
282 | return scope |
283 | |
284 | def search(self, query): |
285 | - # TODO move this to the unity8 main view emulator. |
286 | - # --elopio - 2013-12-27 |
287 | search_indicator = self._proxy.select_single( |
288 | 'SearchIndicator', objectName='search') |
289 | self.touch.tap_object(search_indicator) |
290 | - page_header = self._proxy.select_single( |
291 | - 'PageHeader', objectName='pageHeader') |
292 | - search_container = page_header.select_single( |
293 | - 'QQuickItem', objectName='searchContainer') |
294 | - search_container.state.wait_for( |
295 | - MatchesAny(Equals('narrowActive'), Equals('active'))) |
296 | - self.keyboard.type(query) |
297 | + self.dash.enter_search_query(query) |
298 | |
299 | def open_app_preview(self, category, name): |
300 | self.search(name) |
301 | @@ -182,7 +200,6 @@ |
302 | class ClickScopeTestCaseWithCredentials(BaseClickScopeTestCase): |
303 | |
304 | def setUp(self): |
305 | -# self.skipTest('segfaults. TODO in following branches.') |
306 | self.add_u1_credentials() |
307 | super(ClickScopeTestCaseWithCredentials, self).setUp() |
308 | self.scope = self.open_scope() |
309 | @@ -191,7 +208,12 @@ |
310 | def add_u1_credentials(self): |
311 | account_manager = credentials.AccountManager() |
312 | account = account_manager.add_u1_credentials( |
313 | - 'dummy@example.com', 'dummy') |
314 | + 'dummy@example.com', |
315 | + 'name=Ubuntu+One+%40+bollo&' |
316 | + 'consumer_secret=*********&' |
317 | + 'token=**************&' |
318 | + 'consumer_key=*******&' |
319 | + 'token_secret=************') |
320 | self.addCleanup(account_manager.delete_account, account) |
321 | |
322 | def test_install_with_credentials_must_start_download(self): |
323 | @@ -211,9 +233,13 @@ |
324 | |
325 | def get_details(self): |
326 | """Return the details of the application whose preview is open.""" |
327 | - card_header = self.select_single('CardHeader', objectName='cardHeader') |
328 | + header_widget = self.select_single('PreviewWidget', objectName='hdr') |
329 | + title_label = header_widget.select_single( |
330 | + 'Label', objectName='titleLabel') |
331 | + subtitle_label = header_widget.select_single( |
332 | + 'Label', objectName='subtitleLabel') |
333 | return dict( |
334 | - title=card_header.title, subtitle=card_header.subtitle) |
335 | + title=title_label.text, subtitle=subtitle_label.text) |
336 | |
337 | def install(self): |
338 | parent = self.get_parent() |
339 | |
340 | === modified file 'autopilot/unityclickscope/test_fixture_setup.py' |
341 | --- autopilot/unityclickscope/test_fixture_setup.py 2014-01-28 05:21:19 +0000 |
342 | +++ autopilot/unityclickscope/test_fixture_setup.py 2014-05-23 14:58:59 +0000 |
343 | @@ -14,8 +14,8 @@ |
344 | # You should have received a copy of the GNU General Public License |
345 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
346 | |
347 | -import httplib |
348 | -import urlparse |
349 | +import http.client |
350 | +import urllib.parse |
351 | |
352 | import testscenarios |
353 | import testtools |
354 | @@ -39,14 +39,14 @@ |
355 | fake_server = self.fixture() |
356 | self.addCleanup(self._assert_server_not_running) |
357 | self.useFixture(fake_server) |
358 | - self.netloc = urlparse.urlparse(fake_server.url).netloc |
359 | - connection = httplib.HTTPConnection(self.netloc) |
360 | + self.netloc = urllib.parse.urlparse(fake_server.url).netloc |
361 | + connection = http.client.HTTPConnection(self.netloc) |
362 | self.addCleanup(connection.close) |
363 | self._do_request(connection) |
364 | self.assertEqual(connection.getresponse().status, 200) |
365 | |
366 | def _assert_server_not_running(self): |
367 | - connection = httplib.HTTPConnection(self.netloc) |
368 | + connection = http.client.HTTPConnection(self.netloc) |
369 | self.assertRaises(Exception, self._do_request, connection) |
370 | |
371 | def _do_request(self, connection): |
372 | |
373 | === modified file 'debian/control' |
374 | --- debian/control 2014-05-05 19:40:20 +0000 |
375 | +++ debian/control 2014-05-23 14:58:59 +0000 |
376 | @@ -26,6 +26,7 @@ |
377 | packagekit-tools, |
378 | ubuntu-download-manager, |
379 | ubuntu-purchase-service, |
380 | + ubuntu-sdk-libs, |
381 | ${misc:Depends}, |
382 | ${shlibs:Depends}, |
383 | Breaks: unity (<< 7.0), |
384 | @@ -39,12 +40,12 @@ |
385 | Package: unity-scope-click-autopilot |
386 | Architecture: all |
387 | Depends: libautopilot-qt (>= 1.4), |
388 | - python-autopilot, |
389 | - python-dbus, |
390 | - python-dbusmock, |
391 | - python-fixtures, |
392 | - python-testscenarios, |
393 | - python-testtools, |
394 | + python3-autopilot, |
395 | + python3-dbus, |
396 | + python3-dbusmock, |
397 | + python3-fixtures, |
398 | + python3-testscenarios, |
399 | + python3-testtools, |
400 | ubuntu-ui-toolkit-autopilot, |
401 | unity8-autopilot, |
402 | ${misc:Depends}, |
403 | |
404 | === modified file 'libclickscope/CMakeLists.txt' |
405 | --- libclickscope/CMakeLists.txt 2014-05-13 19:32:29 +0000 |
406 | +++ libclickscope/CMakeLists.txt 2014-05-23 14:58:59 +0000 |
407 | @@ -1,1 +1,2 @@ |
408 | add_subdirectory(click) |
409 | +add_subdirectory(tests) |
410 | |
411 | === modified file 'libclickscope/click/CMakeLists.txt' |
412 | --- libclickscope/click/CMakeLists.txt 2014-05-13 19:32:29 +0000 |
413 | +++ libclickscope/click/CMakeLists.txt 2014-05-23 14:58:59 +0000 |
414 | @@ -9,15 +9,16 @@ |
415 | ) |
416 | |
417 | add_library(${SCOPE_LIB_NAME} STATIC |
418 | + configuration.cpp |
419 | key_file_locator.cpp |
420 | + network_access_manager.cpp |
421 | + smartconnect.cpp |
422 | ) |
423 | |
424 | include_directories( |
425 | ${JSON_CPP_INCLUDE_DIRS} |
426 | ) |
427 | |
428 | -qt5_use_modules (${SCOPE_LIB_NAME} Network) |
429 | - |
430 | target_link_libraries (${SCOPE_LIB_NAME} |
431 | ${JSON_CPP_LDFLAGS} |
432 | ${UNITY_SCOPES_LDFLAGS} |
433 | |
434 | === renamed file 'scope/click/configuration.cpp' => 'libclickscope/click/configuration.cpp' |
435 | --- scope/click/configuration.cpp 2014-05-01 21:04:23 +0000 |
436 | +++ libclickscope/click/configuration.cpp 2014-05-23 14:58:59 +0000 |
437 | @@ -40,6 +40,15 @@ |
438 | |
439 | namespace click { |
440 | |
441 | +/* NOTE: The list of languages we need to use the full language code for. |
442 | + * Please keep this list in a-z order. |
443 | + */ |
444 | +const std::vector<const char*> Configuration::FULL_LANG_CODES = { |
445 | + "pt_BR", |
446 | + "zh_CN", |
447 | + "zh_TW", |
448 | +}; |
449 | + |
450 | std::vector<std::string> Configuration::list_folder(const std::string& folder, const std::string& pattern) |
451 | { |
452 | std::vector<std::string> result; |
453 | @@ -121,4 +130,10 @@ |
454 | return result; |
455 | } |
456 | |
457 | +bool Configuration::is_full_lang_code(const std::string& language) |
458 | +{ |
459 | + return std::find(FULL_LANG_CODES.begin(), FULL_LANG_CODES.end(), language) |
460 | + != FULL_LANG_CODES.end(); |
461 | +} |
462 | + |
463 | } // namespace click |
464 | |
465 | === renamed file 'scope/click/configuration.h' => 'libclickscope/click/configuration.h' |
466 | --- scope/click/configuration.h 2014-05-01 21:04:23 +0000 |
467 | +++ libclickscope/click/configuration.h 2014-05-23 14:58:59 +0000 |
468 | @@ -43,6 +43,7 @@ |
469 | constexpr static const char* FRAMEWORKS_PATTERN {"*.framework"}; |
470 | constexpr static const int FRAMEWORKS_EXTENSION_LENGTH = 10; // strlen(".framework") |
471 | constexpr static const char* LANGUAGE_ENVVAR {"LANGUAGE"}; |
472 | + static const std::vector<const char*> FULL_LANG_CODES; |
473 | |
474 | virtual std::vector<std::string> get_available_frameworks(); |
475 | virtual std::string get_architecture(); |
476 | @@ -50,6 +51,7 @@ |
477 | virtual std::string get_language_base(); |
478 | virtual std::string get_language(); |
479 | virtual std::string get_accept_languages(); |
480 | + static bool is_full_lang_code(const std::string& language); |
481 | |
482 | virtual ~Configuration() {} |
483 | protected: |
484 | |
485 | === renamed file 'scope/click/network_access_manager.cpp' => 'libclickscope/click/network_access_manager.cpp' |
486 | === renamed file 'scope/click/network_access_manager.h' => 'libclickscope/click/network_access_manager.h' |
487 | === renamed file 'scope/click/smartconnect.cpp' => 'libclickscope/click/smartconnect.cpp' |
488 | === renamed file 'scope/click/smartconnect.h' => 'libclickscope/click/smartconnect.h' |
489 | === added file 'libclickscope/tests/CMakeLists.txt' |
490 | --- libclickscope/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
491 | +++ libclickscope/tests/CMakeLists.txt 2014-05-23 14:58:59 +0000 |
492 | @@ -0,0 +1,54 @@ |
493 | +set (LIBCLICKSCOPE_TESTS_TARGET libclick-scope-tests) |
494 | +find_package(Threads) |
495 | + |
496 | +# Qt5 bits |
497 | +SET (CMAKE_INCLUDE_CURRENT_DIR ON) |
498 | +SET (CMAKE_AUTOMOC ON) |
499 | + |
500 | +find_package(Qt5Core REQUIRED) |
501 | + |
502 | +include_directories ( |
503 | + ${CMAKE_SOURCE_DIR}/libclickscope |
504 | + ${JSON_CPP_INCLUDE_DIRS} |
505 | + ${GTEST_INCLUDE_DIR} |
506 | + ${GMOCK_INCLUDE_DIR} |
507 | +) |
508 | + |
509 | +add_executable (${LIBCLICKSCOPE_TESTS_TARGET} |
510 | + mock_network_access_manager.h |
511 | + |
512 | + test_configuration.cpp |
513 | + test_smartconnect.cpp |
514 | +) |
515 | + |
516 | +qt5_use_modules(${LIBCLICKSCOPE_TESTS_TARGET} Core) |
517 | + |
518 | +target_link_libraries(${LIBCLICKSCOPE_TESTS_TARGET} |
519 | + ${SCOPE_LIB_NAME} |
520 | + |
521 | + ${UNITY_SCOPES_LDFLAGS} |
522 | + ${UBUNTUONE_LDFLAGS} |
523 | + ${UBUNTU_DOWNLOAD_MANAGER_CLIENT_LDFLAGS} |
524 | + ${UBUNTU_DOWNLOAD_MANAGER_COMMON_LDFLAGS} |
525 | + ${JSON_CPP_LDFLAGS} |
526 | + |
527 | + gmock |
528 | + gmock_main |
529 | + |
530 | + ${CMAKE_THREAD_LIBS_INIT} |
531 | +) |
532 | + |
533 | +add_custom_target (test-libclickscope |
534 | + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${LIBCLICKSCOPE_TESTS_TARGET} |
535 | + DEPENDS ${LIBCLICKSCOPE_TESTS_TARGET} |
536 | +) |
537 | + |
538 | +add_custom_target (test-libclickscope-valgrind |
539 | + COMMAND valgrind --tool=memcheck ${CMAKE_CURRENT_BINARY_DIR}/${LIBCLICKSCOPE_TESTS_TARGET} |
540 | + DEPENDS ${LIBCLICKSCOPE_TESTS_TARGET} |
541 | +) |
542 | + |
543 | +add_custom_target (test-libclickscope-leaks |
544 | + COMMAND valgrind --tool=memcheck --track-origins=yes --num-callers=40 --leak-resolution=high --leak-check=full ${CMAKE_CURRENT_BINARY_DIR}/${LIBCLICKSCOPE_TESTS_TARGET} |
545 | + DEPENDS ${LIBCLICKSCOPE_TESTS_TARGET} |
546 | +) |
547 | |
548 | === renamed file 'scope/tests/mock_network_access_manager.h' => 'libclickscope/tests/mock_network_access_manager.h' |
549 | === renamed file 'scope/tests/test_configuration.cpp' => 'libclickscope/tests/test_configuration.cpp' |
550 | --- scope/tests/test_configuration.cpp 2014-05-01 21:04:23 +0000 |
551 | +++ libclickscope/tests/test_configuration.cpp 2014-05-23 14:58:59 +0000 |
552 | @@ -172,3 +172,15 @@ |
553 | EXPECT_EQ(Configuration().get_accept_languages(), "en"); |
554 | ASSERT_EQ(unsetenv(Configuration::LANGUAGE_ENVVAR), 0); |
555 | } |
556 | + |
557 | +TEST(Configuration, isFullLangCodeTestAllFullLangCodes) |
558 | +{ |
559 | + for (auto lang: Configuration::FULL_LANG_CODES) { |
560 | + EXPECT_TRUE(Configuration::is_full_lang_code(lang)); |
561 | + } |
562 | +} |
563 | + |
564 | +TEST(Configuration, isFullLangCodeReturnsFalseForEN) |
565 | +{ |
566 | + ASSERT_FALSE(Configuration::is_full_lang_code("en_US")); |
567 | +} |
568 | |
569 | === renamed file 'scope/tests/test_smartconnect.cpp' => 'libclickscope/tests/test_smartconnect.cpp' |
570 | --- scope/tests/test_smartconnect.cpp 2014-03-08 03:05:28 +0000 |
571 | +++ libclickscope/tests/test_smartconnect.cpp 2014-05-23 14:58:59 +0000 |
572 | @@ -27,7 +27,7 @@ |
573 | * files in the program, then also delete it here. |
574 | */ |
575 | |
576 | -#include "click/smartconnect.h" |
577 | +#include <click/smartconnect.h> |
578 | |
579 | #include <gtest/gtest.h> |
580 | #include <gmock/gmock.h> |
581 | |
582 | === modified file 'po/ar.po' |
583 | --- po/ar.po 2014-05-13 06:36:54 +0000 |
584 | +++ po/ar.po 2014-05-23 14:58:59 +0000 |
585 | @@ -8,14 +8,14 @@ |
586 | "Project-Id-Version: unity-scope-click\n" |
587 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" |
588 | "POT-Creation-Date: 2014-05-09 15:06-0400\n" |
589 | -"PO-Revision-Date: 2014-05-01 19:32+0000\n" |
590 | +"PO-Revision-Date: 2014-05-16 23:33+0000\n" |
591 | "Last-Translator: Ibrahim Saed <ibraheem5000@gmail.com>\n" |
592 | "Language-Team: Arabic <ar@li.org>\n" |
593 | "MIME-Version: 1.0\n" |
594 | "Content-Type: text/plain; charset=UTF-8\n" |
595 | "Content-Transfer-Encoding: 8bit\n" |
596 | -"X-Launchpad-Export-Date: 2014-05-13 06:36+0000\n" |
597 | -"X-Generator: Launchpad (build 17002)\n" |
598 | +"X-Launchpad-Export-Date: 2014-05-17 07:17+0000\n" |
599 | +"X-Generator: Launchpad (build 17007)\n" |
600 | |
601 | #: ../data/clickscope.ini.in.in.h:1 |
602 | msgid "Apps" |
603 | @@ -65,12 +65,12 @@ |
604 | #. TRANSLATORS: Do NOT translate ${title} here. |
605 | #: ../scope/click/preview.cpp:602 |
606 | msgid "Uninstall ${title}?" |
607 | -msgstr "" |
608 | +msgstr "إزالة تثبيت ${title}؟" |
609 | |
610 | #. TODO: see bug LP: #1289434 |
611 | #: ../scope/click/preview.cpp:611 |
612 | msgid "Cancel" |
613 | -msgstr "" |
614 | +msgstr "إلغاء" |
615 | |
616 | #: ../scope/click/preview.cpp:663 |
617 | msgid "Install" |
618 | |
619 | === modified file 'po/de.po' |
620 | --- po/de.po 2014-05-13 06:36:54 +0000 |
621 | +++ po/de.po 2014-05-23 14:58:59 +0000 |
622 | @@ -8,14 +8,14 @@ |
623 | "Project-Id-Version: unity-scope-click\n" |
624 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" |
625 | "POT-Creation-Date: 2014-05-09 15:06-0400\n" |
626 | -"PO-Revision-Date: 2014-04-29 21:45+0000\n" |
627 | +"PO-Revision-Date: 2014-05-20 13:54+0000\n" |
628 | "Last-Translator: Phillip Sz <Unknown>\n" |
629 | "Language-Team: German <de@li.org>\n" |
630 | "MIME-Version: 1.0\n" |
631 | "Content-Type: text/plain; charset=UTF-8\n" |
632 | "Content-Transfer-Encoding: 8bit\n" |
633 | -"X-Launchpad-Export-Date: 2014-05-13 06:36+0000\n" |
634 | -"X-Generator: Launchpad (build 17002)\n" |
635 | +"X-Launchpad-Export-Date: 2014-05-22 06:53+0000\n" |
636 | +"X-Generator: Launchpad (build 17017)\n" |
637 | |
638 | #: ../data/clickscope.ini.in.in.h:1 |
639 | msgid "Apps" |
640 | @@ -70,7 +70,7 @@ |
641 | #. TODO: see bug LP: #1289434 |
642 | #: ../scope/click/preview.cpp:611 |
643 | msgid "Cancel" |
644 | -msgstr "" |
645 | +msgstr "Abbrechen" |
646 | |
647 | #: ../scope/click/preview.cpp:663 |
648 | msgid "Install" |
649 | |
650 | === modified file 'po/fr.po' |
651 | --- po/fr.po 2014-05-13 06:36:54 +0000 |
652 | +++ po/fr.po 2014-05-23 14:58:59 +0000 |
653 | @@ -8,14 +8,14 @@ |
654 | "Project-Id-Version: unity-scope-click\n" |
655 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" |
656 | "POT-Creation-Date: 2014-05-09 15:06-0400\n" |
657 | -"PO-Revision-Date: 2014-05-05 20:05+0000\n" |
658 | +"PO-Revision-Date: 2014-05-16 19:24+0000\n" |
659 | "Last-Translator: Anne <anneonyme017@gmail.com>\n" |
660 | "Language-Team: French <fr@li.org>\n" |
661 | "MIME-Version: 1.0\n" |
662 | "Content-Type: text/plain; charset=UTF-8\n" |
663 | "Content-Transfer-Encoding: 8bit\n" |
664 | -"X-Launchpad-Export-Date: 2014-05-13 06:36+0000\n" |
665 | -"X-Generator: Launchpad (build 17002)\n" |
666 | +"X-Launchpad-Export-Date: 2014-05-17 07:17+0000\n" |
667 | +"X-Generator: Launchpad (build 17007)\n" |
668 | |
669 | #: ../data/clickscope.ini.in.in.h:1 |
670 | msgid "Apps" |
671 | @@ -65,12 +65,12 @@ |
672 | #. TRANSLATORS: Do NOT translate ${title} here. |
673 | #: ../scope/click/preview.cpp:602 |
674 | msgid "Uninstall ${title}?" |
675 | -msgstr "" |
676 | +msgstr "Désinstaller ${title} ?" |
677 | |
678 | #. TODO: see bug LP: #1289434 |
679 | #: ../scope/click/preview.cpp:611 |
680 | msgid "Cancel" |
681 | -msgstr "" |
682 | +msgstr "Annuler" |
683 | |
684 | #: ../scope/click/preview.cpp:663 |
685 | msgid "Install" |
686 | |
687 | === modified file 'po/gd.po' |
688 | --- po/gd.po 2014-05-13 06:36:54 +0000 |
689 | +++ po/gd.po 2014-05-23 14:58:59 +0000 |
690 | @@ -8,14 +8,14 @@ |
691 | "Project-Id-Version: unity-scope-click\n" |
692 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" |
693 | "POT-Creation-Date: 2014-05-09 15:06-0400\n" |
694 | -"PO-Revision-Date: 2014-05-01 13:41+0000\n" |
695 | -"Last-Translator: GunChleoc <Unknown>\n" |
696 | +"PO-Revision-Date: 2014-05-16 13:26+0000\n" |
697 | +"Last-Translator: Akerbeltz <fios@akerbeltz.org>\n" |
698 | "Language-Team: Gaelic; Scottish <gd@li.org>\n" |
699 | "MIME-Version: 1.0\n" |
700 | "Content-Type: text/plain; charset=UTF-8\n" |
701 | "Content-Transfer-Encoding: 8bit\n" |
702 | -"X-Launchpad-Export-Date: 2014-05-13 06:36+0000\n" |
703 | -"X-Generator: Launchpad (build 17002)\n" |
704 | +"X-Launchpad-Export-Date: 2014-05-17 07:17+0000\n" |
705 | +"X-Generator: Launchpad (build 17007)\n" |
706 | |
707 | #: ../data/clickscope.ini.in.in.h:1 |
708 | msgid "Apps" |
709 | @@ -67,12 +67,12 @@ |
710 | #. TRANSLATORS: Do NOT translate ${title} here. |
711 | #: ../scope/click/preview.cpp:602 |
712 | msgid "Uninstall ${title}?" |
713 | -msgstr "" |
714 | +msgstr "A bheil thu airson ${title} a dhì-stàladh?" |
715 | |
716 | #. TODO: see bug LP: #1289434 |
717 | #: ../scope/click/preview.cpp:611 |
718 | msgid "Cancel" |
719 | -msgstr "" |
720 | +msgstr "Sguir dheth" |
721 | |
722 | #: ../scope/click/preview.cpp:663 |
723 | msgid "Install" |
724 | |
725 | === modified file 'po/he.po' |
726 | --- po/he.po 2014-05-13 06:36:54 +0000 |
727 | +++ po/he.po 2014-05-23 14:58:59 +0000 |
728 | @@ -8,14 +8,14 @@ |
729 | "Project-Id-Version: unity-scope-click\n" |
730 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" |
731 | "POT-Creation-Date: 2014-05-09 15:06-0400\n" |
732 | -"PO-Revision-Date: 2014-05-01 14:52+0000\n" |
733 | +"PO-Revision-Date: 2014-05-18 07:02+0000\n" |
734 | "Last-Translator: Yaron <sh.yaron@gmail.com>\n" |
735 | "Language-Team: Hebrew <he@li.org>\n" |
736 | "MIME-Version: 1.0\n" |
737 | "Content-Type: text/plain; charset=UTF-8\n" |
738 | "Content-Transfer-Encoding: 8bit\n" |
739 | -"X-Launchpad-Export-Date: 2014-05-13 06:36+0000\n" |
740 | -"X-Generator: Launchpad (build 17002)\n" |
741 | +"X-Launchpad-Export-Date: 2014-05-19 06:50+0000\n" |
742 | +"X-Generator: Launchpad (build 17007)\n" |
743 | |
744 | #: ../data/clickscope.ini.in.in.h:1 |
745 | msgid "Apps" |
746 | @@ -60,26 +60,26 @@ |
747 | |
748 | #: ../scope/click/preview.cpp:599 |
749 | msgid "Confirmation" |
750 | -msgstr "" |
751 | +msgstr "אימות" |
752 | |
753 | #. TRANSLATORS: Do NOT translate ${title} here. |
754 | #: ../scope/click/preview.cpp:602 |
755 | msgid "Uninstall ${title}?" |
756 | -msgstr "" |
757 | +msgstr "האם להסיר את ${title}?" |
758 | |
759 | #. TODO: see bug LP: #1289434 |
760 | #: ../scope/click/preview.cpp:611 |
761 | msgid "Cancel" |
762 | -msgstr "" |
763 | +msgstr "ביטול" |
764 | |
765 | #: ../scope/click/preview.cpp:663 |
766 | msgid "Install" |
767 | -msgstr "" |
768 | +msgstr "התקנה" |
769 | |
770 | #: ../scope/click/query.cpp:95 |
771 | msgid "My apps" |
772 | -msgstr "" |
773 | +msgstr "היישומים שלי" |
774 | |
775 | #: ../scope/click/query.cpp:189 |
776 | msgid "Available" |
777 | -msgstr "" |
778 | +msgstr "זמין" |
779 | |
780 | === modified file 'po/it.po' |
781 | --- po/it.po 2014-05-13 06:36:54 +0000 |
782 | +++ po/it.po 2014-05-23 14:58:59 +0000 |
783 | @@ -8,14 +8,14 @@ |
784 | "Project-Id-Version: unity-scope-click\n" |
785 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" |
786 | "POT-Creation-Date: 2014-05-09 15:06-0400\n" |
787 | -"PO-Revision-Date: 2014-04-30 12:04+0000\n" |
788 | +"PO-Revision-Date: 2014-05-23 06:48+0000\n" |
789 | "Last-Translator: Claudio Arseni <claudio.arseni@gmail.com>\n" |
790 | "Language-Team: Italian <it@li.org>\n" |
791 | "MIME-Version: 1.0\n" |
792 | "Content-Type: text/plain; charset=UTF-8\n" |
793 | "Content-Transfer-Encoding: 8bit\n" |
794 | -"X-Launchpad-Export-Date: 2014-05-13 06:36+0000\n" |
795 | -"X-Generator: Launchpad (build 17002)\n" |
796 | +"X-Launchpad-Export-Date: 2014-05-23 09:16+0000\n" |
797 | +"X-Generator: Launchpad (build 17017)\n" |
798 | |
799 | #: ../data/clickscope.ini.in.in.h:1 |
800 | msgid "Apps" |
801 | @@ -65,12 +65,12 @@ |
802 | #. TRANSLATORS: Do NOT translate ${title} here. |
803 | #: ../scope/click/preview.cpp:602 |
804 | msgid "Uninstall ${title}?" |
805 | -msgstr "" |
806 | +msgstr "Rimuovere ${title}?" |
807 | |
808 | #. TODO: see bug LP: #1289434 |
809 | #: ../scope/click/preview.cpp:611 |
810 | msgid "Cancel" |
811 | -msgstr "" |
812 | +msgstr "Annulla" |
813 | |
814 | #: ../scope/click/preview.cpp:663 |
815 | msgid "Install" |
816 | |
817 | === modified file 'po/nb.po' |
818 | --- po/nb.po 2014-05-13 06:36:54 +0000 |
819 | +++ po/nb.po 2014-05-23 14:58:59 +0000 |
820 | @@ -8,14 +8,14 @@ |
821 | "Project-Id-Version: unity-scope-click\n" |
822 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" |
823 | "POT-Creation-Date: 2014-05-09 15:06-0400\n" |
824 | -"PO-Revision-Date: 2014-05-01 11:24+0000\n" |
825 | +"PO-Revision-Date: 2014-05-19 03:40+0000\n" |
826 | "Last-Translator: Åka Sikrom <Unknown>\n" |
827 | "Language-Team: Norwegian Bokmal <nb@li.org>\n" |
828 | "MIME-Version: 1.0\n" |
829 | "Content-Type: text/plain; charset=UTF-8\n" |
830 | "Content-Transfer-Encoding: 8bit\n" |
831 | -"X-Launchpad-Export-Date: 2014-05-13 06:36+0000\n" |
832 | -"X-Generator: Launchpad (build 17002)\n" |
833 | +"X-Launchpad-Export-Date: 2014-05-22 06:53+0000\n" |
834 | +"X-Generator: Launchpad (build 17017)\n" |
835 | |
836 | #: ../data/clickscope.ini.in.in.h:1 |
837 | msgid "Apps" |
838 | @@ -65,12 +65,12 @@ |
839 | #. TRANSLATORS: Do NOT translate ${title} here. |
840 | #: ../scope/click/preview.cpp:602 |
841 | msgid "Uninstall ${title}?" |
842 | -msgstr "" |
843 | +msgstr "Vil du avinstallere ${title}?" |
844 | |
845 | #. TODO: see bug LP: #1289434 |
846 | #: ../scope/click/preview.cpp:611 |
847 | msgid "Cancel" |
848 | -msgstr "" |
849 | +msgstr "Avbryt" |
850 | |
851 | #: ../scope/click/preview.cpp:663 |
852 | msgid "Install" |
853 | |
854 | === modified file 'po/ru.po' |
855 | --- po/ru.po 2014-05-13 06:36:54 +0000 |
856 | +++ po/ru.po 2014-05-23 14:58:59 +0000 |
857 | @@ -8,78 +8,78 @@ |
858 | "Project-Id-Version: unity-scope-click\n" |
859 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" |
860 | "POT-Creation-Date: 2014-05-09 15:06-0400\n" |
861 | -"PO-Revision-Date: 2014-05-01 05:40+0000\n" |
862 | -"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
863 | +"PO-Revision-Date: 2014-05-16 16:25+0000\n" |
864 | +"Last-Translator: Zonov Roman <Unknown>\n" |
865 | "Language-Team: Russian <ru@li.org>\n" |
866 | "MIME-Version: 1.0\n" |
867 | "Content-Type: text/plain; charset=UTF-8\n" |
868 | "Content-Transfer-Encoding: 8bit\n" |
869 | -"X-Launchpad-Export-Date: 2014-05-13 06:36+0000\n" |
870 | -"X-Generator: Launchpad (build 17002)\n" |
871 | +"X-Launchpad-Export-Date: 2014-05-17 07:17+0000\n" |
872 | +"X-Generator: Launchpad (build 17007)\n" |
873 | |
874 | #: ../data/clickscope.ini.in.in.h:1 |
875 | msgid "Apps" |
876 | -msgstr "" |
877 | +msgstr "Приложения" |
878 | |
879 | #: ../data/clickscope.ini.in.in.h:2 |
880 | msgid "Scope for searching the click app store" |
881 | -msgstr "" |
882 | +msgstr "Критерии поиска в магазине приложений" |
883 | |
884 | #: ../scope/click/preview.cpp:272 |
885 | msgid "Download Error" |
886 | -msgstr "" |
887 | +msgstr "Ошибка загрузки" |
888 | |
889 | #: ../scope/click/preview.cpp:273 |
890 | msgid "Download or install failed. Please try again." |
891 | -msgstr "" |
892 | +msgstr "Загрузка или установка не удалась. Пожалуйста, попробуйте снова." |
893 | |
894 | #. TODO see bug LP: #1289434 |
895 | #: ../scope/click/preview.cpp:275 |
896 | msgid "Close" |
897 | -msgstr "" |
898 | +msgstr "Закрыть" |
899 | |
900 | #: ../scope/click/preview.cpp:280 |
901 | msgid "Login Error" |
902 | -msgstr "" |
903 | +msgstr "Ошибка входа" |
904 | |
905 | #: ../scope/click/preview.cpp:281 |
906 | msgid "Please log in to your Ubuntu One account." |
907 | -msgstr "" |
908 | +msgstr "Войдите в учётную запись Ubuntu One." |
909 | |
910 | #: ../scope/click/preview.cpp:283 |
911 | msgid "Go to Accounts" |
912 | -msgstr "" |
913 | +msgstr "Перейти к списку учётных записей" |
914 | |
915 | #: ../scope/click/preview.cpp:506 |
916 | msgid "Open" |
917 | -msgstr "" |
918 | +msgstr "Открыть" |
919 | |
920 | #: ../scope/click/preview.cpp:514 ../scope/click/preview.cpp:615 |
921 | msgid "Uninstall" |
922 | -msgstr "" |
923 | +msgstr "Удалить" |
924 | |
925 | #: ../scope/click/preview.cpp:599 |
926 | msgid "Confirmation" |
927 | -msgstr "" |
928 | +msgstr "Подтверждение" |
929 | |
930 | #. TRANSLATORS: Do NOT translate ${title} here. |
931 | #: ../scope/click/preview.cpp:602 |
932 | msgid "Uninstall ${title}?" |
933 | -msgstr "" |
934 | +msgstr "Удалить ${title}?" |
935 | |
936 | #. TODO: see bug LP: #1289434 |
937 | #: ../scope/click/preview.cpp:611 |
938 | msgid "Cancel" |
939 | -msgstr "" |
940 | +msgstr "Отмена" |
941 | |
942 | #: ../scope/click/preview.cpp:663 |
943 | msgid "Install" |
944 | -msgstr "" |
945 | +msgstr "Установить" |
946 | |
947 | #: ../scope/click/query.cpp:95 |
948 | msgid "My apps" |
949 | -msgstr "" |
950 | +msgstr "Мои приложения" |
951 | |
952 | #: ../scope/click/query.cpp:189 |
953 | msgid "Available" |
954 | -msgstr "" |
955 | +msgstr "Доступно" |
956 | |
957 | === modified file 'scope/click/CMakeLists.txt' |
958 | --- scope/click/CMakeLists.txt 2014-05-13 19:32:29 +0000 |
959 | +++ scope/click/CMakeLists.txt 2014-05-23 14:58:59 +0000 |
960 | @@ -9,16 +9,13 @@ |
961 | ) |
962 | |
963 | add_library(${SCOPE_LIB_UNVERSIONED} SHARED |
964 | - configuration.cpp |
965 | download-manager.cpp |
966 | index.cpp |
967 | interface.cpp |
968 | - network_access_manager.cpp |
969 | query.cpp |
970 | reviews.cpp |
971 | scope.cpp |
972 | scope_activation.cpp |
973 | - smartconnect.cpp |
974 | package.cpp |
975 | preview.cpp |
976 | ubuntuone_credentials.cpp |
977 | @@ -35,7 +32,6 @@ |
978 | qt5_use_modules (${SCOPE_LIB_UNVERSIONED} Network) |
979 | |
980 | target_link_libraries (${SCOPE_LIB_UNVERSIONED} |
981 | - -L${CMAKE_BINARY_DIR}/libclickscope |
982 | ${SCOPE_LIB_NAME} |
983 | ${JSON_CPP_LDFLAGS} |
984 | ${UNITY_SCOPES_LDFLAGS} |
985 | |
986 | === modified file 'scope/click/download-manager.h' |
987 | --- scope/click/download-manager.h 2014-03-22 00:08:31 +0000 |
988 | +++ scope/click/download-manager.h 2014-05-23 14:58:59 +0000 |
989 | @@ -30,7 +30,6 @@ |
990 | #ifndef CLICK_DOWNLOAD_MANAGER_H |
991 | #define CLICK_DOWNLOAD_MANAGER_H |
992 | |
993 | -#include "network_access_manager.h" |
994 | #include "ubuntuone_credentials.h" |
995 | |
996 | #include <QDebug> |
997 | @@ -38,6 +37,8 @@ |
998 | #include <QObject> |
999 | #include <QString> |
1000 | |
1001 | +#include <click/network_access_manager.h> |
1002 | + |
1003 | #include <ubuntu/download_manager/manager.h> |
1004 | |
1005 | using Ubuntu::DownloadManager::Download; |
1006 | |
1007 | === modified file 'scope/click/index.cpp' |
1008 | --- scope/click/index.cpp 2014-04-16 21:13:28 +0000 |
1009 | +++ scope/click/index.cpp 2014-05-23 14:58:59 +0000 |
1010 | @@ -34,11 +34,12 @@ |
1011 | #include <cstdlib> |
1012 | #include <sstream> |
1013 | |
1014 | +#include <click/smartconnect.h> |
1015 | + |
1016 | #include "download-manager.h" |
1017 | #include "index.h" |
1018 | #include "interface.h" |
1019 | #include "application.h" |
1020 | -#include "smartconnect.h" |
1021 | |
1022 | namespace json = Json; |
1023 | |
1024 | @@ -87,30 +88,45 @@ |
1025 | |
1026 | } |
1027 | |
1028 | -std::string Index::build_index_query(std::string query) |
1029 | +std::string Index::build_index_query(const std::string& query) |
1030 | { |
1031 | std::stringstream result; |
1032 | |
1033 | result << query; |
1034 | + return result.str(); |
1035 | +} |
1036 | + |
1037 | +std::map<std::string, std::string> Index::build_headers() |
1038 | +{ |
1039 | + std::stringstream frameworks; |
1040 | for (auto f: configuration->get_available_frameworks()) { |
1041 | - result << ",framework:" << f; |
1042 | + frameworks << "," << f; |
1043 | } |
1044 | - result << ",architecture:" << configuration->get_architecture(); |
1045 | |
1046 | - return result.str(); |
1047 | + return std::map<std::string, std::string> { |
1048 | + {"Accept", "application/hal+json,application/json"}, |
1049 | + {"X-Ubuntu-Frameworks", frameworks.str()}, |
1050 | + {"X-Ubuntu-Architecture", configuration->get_architecture()} |
1051 | + }; |
1052 | } |
1053 | |
1054 | click::web::Cancellable Index::search (const std::string& query, std::function<void(click::PackageList)> callback) |
1055 | { |
1056 | click::web::CallParams params; |
1057 | - std::string built_query(build_index_query(query)); |
1058 | + const std::string built_query(build_index_query(query)); |
1059 | params.add(click::QUERY_ARGNAME, built_query.c_str()); |
1060 | QSharedPointer<click::web::Response> response(client->call( |
1061 | - get_base_url() + click::SEARCH_PATH, params)); |
1062 | + get_base_url() + click::SEARCH_PATH, "GET", false, build_headers(), "", params)); |
1063 | |
1064 | QObject::connect(response.data(), &click::web::Response::finished, [=](QString reply) { |
1065 | - click::PackageList pl = click::package_list_from_json(reply.toUtf8().constData()); |
1066 | - qDebug() << "found packages:" << pl.size(); |
1067 | + Json::Reader reader; |
1068 | + Json::Value root; |
1069 | + |
1070 | + click::PackageList pl; |
1071 | + if (reader.parse(reply.toUtf8().constData(), root)) { |
1072 | + pl = click::package_list_from_json_node(root); |
1073 | + qDebug() << "found packages:" << pl.size(); |
1074 | + } |
1075 | callback(pl); |
1076 | }); |
1077 | QObject::connect(response.data(), &click::web::Response::error, [=](QString /*description*/) { |
1078 | |
1079 | === modified file 'scope/click/index.h' |
1080 | --- scope/click/index.h 2014-04-16 21:13:28 +0000 |
1081 | +++ scope/click/index.h 2014-05-23 14:58:59 +0000 |
1082 | @@ -34,7 +34,8 @@ |
1083 | #include <string> |
1084 | #include <functional> |
1085 | |
1086 | -#include "configuration.h" |
1087 | +#include <click/configuration.h> |
1088 | + |
1089 | #include "package.h" |
1090 | #include "webclient.h" |
1091 | |
1092 | @@ -63,7 +64,9 @@ |
1093 | protected: |
1094 | QSharedPointer<web::Client> client; |
1095 | QSharedPointer<Configuration> configuration; |
1096 | - virtual std::string build_index_query(std::string query); |
1097 | + virtual std::string build_index_query(const std::string& query); |
1098 | + virtual std::map<std::string, std::string> build_headers(); |
1099 | + |
1100 | public: |
1101 | enum class Error {NoError, CredentialsError, NetworkError}; |
1102 | Index(const QSharedPointer<click::web::Client>& client, |
1103 | |
1104 | === modified file 'scope/click/package.cpp' |
1105 | --- scope/click/package.cpp 2014-04-09 20:25:13 +0000 |
1106 | +++ scope/click/package.cpp 2014-05-23 14:58:59 +0000 |
1107 | @@ -66,12 +66,58 @@ |
1108 | lhs.framework == rhs.framework; |
1109 | } |
1110 | |
1111 | +Package package_from_json_node(const Json::Value& item) |
1112 | +{ |
1113 | + Package p; |
1114 | + p.name = item[Package::JsonKeys::name].asString(); |
1115 | + p.title = item[Package::JsonKeys::title].asString(); |
1116 | + p.price = item[Package::JsonKeys::price].asDouble(); |
1117 | + p.icon_url = item[Package::JsonKeys::icon_url].asString(); |
1118 | + p.url = item[Package::JsonKeys::links][Package::JsonKeys::self][Package::JsonKeys::href].asString(); |
1119 | + if (p.url.empty()) { |
1120 | + p.url = item[Package::JsonKeys::resource_url].asString(); |
1121 | + } |
1122 | + return p; |
1123 | +} |
1124 | + |
1125 | +PackageList package_list_from_json_node(const Json::Value& root) |
1126 | +{ |
1127 | + PackageList pl; |
1128 | + if (root.isObject() && root.isMember(Package::JsonKeys::embedded)) |
1129 | + { |
1130 | + auto const emb = root[Package::JsonKeys::embedded]; |
1131 | + if (emb.isObject() && emb.isMember(Package::JsonKeys::ci_package)) |
1132 | + { |
1133 | + auto const pkg = emb[Package::JsonKeys::ci_package]; |
1134 | + for (uint i = 0; i < pkg.size(); i++) |
1135 | + { |
1136 | + Package p; |
1137 | + const json::Value item = pkg[i]; |
1138 | + p = package_from_json_node(item); |
1139 | + pl.push_back(p); |
1140 | + } |
1141 | + } |
1142 | + } |
1143 | + else if (root.isArray()) |
1144 | + { |
1145 | + qDebug() << "Fell back to old array mode."; |
1146 | + qDebug() << root.size() << "packages returned."; |
1147 | + for (uint i = 0; i < root.size(); i++) |
1148 | + { |
1149 | + |
1150 | + Package p; |
1151 | + const json::Value item = root[i]; |
1152 | + p = package_from_json_node(item); |
1153 | + pl.push_back(p); |
1154 | + } |
1155 | + } |
1156 | + return pl; |
1157 | +} |
1158 | + |
1159 | PackageList package_list_from_json(const std::string& json) |
1160 | { |
1161 | std::istringstream is(json); |
1162 | |
1163 | - PackageList pl; |
1164 | - |
1165 | json::Reader reader; |
1166 | json::Value root; |
1167 | |
1168 | @@ -79,18 +125,7 @@ |
1169 | throw std::runtime_error(reader.getFormattedErrorMessages()); |
1170 | } |
1171 | |
1172 | - for (uint i = 0; i < root.size(); i++) |
1173 | - { |
1174 | - Package p; |
1175 | - json::Value item = root[i]; |
1176 | - p.name = item[Package::JsonKeys::name].asString(); |
1177 | - p.title = item[Package::JsonKeys::title].asString(); |
1178 | - p.price = item[Package::JsonKeys::price].asDouble(); |
1179 | - p.icon_url = item[Package::JsonKeys::icon_url].asString(); |
1180 | - p.url = item[Package::JsonKeys::resource_url].asString(); |
1181 | - pl.push_back(p); |
1182 | - } |
1183 | - return pl; |
1184 | + return package_list_from_json_node(root); |
1185 | } |
1186 | |
1187 | PackageDetails PackageDetails::from_json(const std::string &json) |
1188 | |
1189 | === modified file 'scope/click/package.h' |
1190 | --- scope/click/package.h 2014-04-09 20:25:13 +0000 |
1191 | +++ scope/click/package.h 2014-05-23 14:58:59 +0000 |
1192 | @@ -46,6 +46,11 @@ |
1193 | { |
1194 | JsonKeys() = delete; |
1195 | |
1196 | + constexpr static const char* embedded {"_embedded"}; |
1197 | + constexpr static const char* links{"_links"}; |
1198 | + constexpr static const char* self{"self"}; |
1199 | + constexpr static const char* href{"href"}; |
1200 | + constexpr static const char* ci_package {"clickindex:package"}; |
1201 | constexpr static const char* name{"name"}; |
1202 | constexpr static const char* title{"title"}; |
1203 | constexpr static const char* price{"price"}; |
1204 | @@ -84,7 +89,9 @@ |
1205 | |
1206 | typedef std::list<Package> PackageList; |
1207 | |
1208 | +Package package_from_json_node(const Json::Value& item); |
1209 | PackageList package_list_from_json(const std::string& json); |
1210 | +PackageList package_list_from_json_node(const Json::Value& root); |
1211 | |
1212 | struct PackageDetails |
1213 | { |
1214 | |
1215 | === modified file 'scope/click/preview.h' |
1216 | --- scope/click/preview.h 2014-04-29 03:17:38 +0000 |
1217 | +++ scope/click/preview.h 2014-05-23 14:58:59 +0000 |
1218 | @@ -31,11 +31,12 @@ |
1219 | #define CLICKPREVIEW_H |
1220 | |
1221 | #include "index.h" |
1222 | -#include "network_access_manager.h" |
1223 | #include "download-manager.h" |
1224 | #include "qtbridge.h" |
1225 | #include "reviews.h" |
1226 | |
1227 | +#include <click/network_access_manager.h> |
1228 | + |
1229 | #include <unity/scopes/ActionMetadata.h> |
1230 | #include <unity/scopes/PreviewQueryBase.h> |
1231 | #include <unity/scopes/PreviewWidget.h> |
1232 | |
1233 | === modified file 'scope/click/query.cpp' |
1234 | --- scope/click/query.cpp 2014-05-13 19:32:29 +0000 |
1235 | +++ scope/click/query.cpp 2014-05-23 14:58:59 +0000 |
1236 | @@ -44,6 +44,7 @@ |
1237 | #include<vector> |
1238 | #include<set> |
1239 | #include<sstream> |
1240 | +#include <cassert> |
1241 | |
1242 | #include <click/click-i18n.h> |
1243 | |
1244 | @@ -116,19 +117,19 @@ |
1245 | |
1246 | struct click::Query::Private |
1247 | { |
1248 | - Private(const std::string& query, click::Index& index, const scopes::SearchMetadata& metadata) |
1249 | + Private(const unity::scopes::CannedQuery& query, click::Index& index, const scopes::SearchMetadata& metadata) |
1250 | : query(query), |
1251 | index(index), |
1252 | meta(metadata) |
1253 | { |
1254 | } |
1255 | - std::string query; |
1256 | + unity::scopes::CannedQuery query; |
1257 | click::Index& index; |
1258 | scopes::SearchMetadata meta; |
1259 | click::web::Cancellable search_operation; |
1260 | }; |
1261 | |
1262 | -click::Query::Query(std::string const& query, click::Index& index, scopes::SearchMetadata const& metadata) |
1263 | +click::Query::Query(unity::scopes::CannedQuery const& query, click::Index& index, scopes::SearchMetadata const& metadata) |
1264 | : impl(new Private(query, index, metadata)) |
1265 | { |
1266 | } |
1267 | @@ -140,7 +141,7 @@ |
1268 | |
1269 | void click::Query::cancelled() |
1270 | { |
1271 | - qDebug() << "cancelling search of" << QString::fromStdString(impl->query); |
1272 | + qDebug() << "cancelling search of" << QString::fromStdString(impl->query.query_string()); |
1273 | impl->search_operation.cancel(); |
1274 | } |
1275 | |
1276 | @@ -196,47 +197,49 @@ |
1277 | |
1278 | run_under_qt([=]() |
1279 | { |
1280 | - qDebug() << "starting search of" << QString::fromStdString(impl->query); |
1281 | - |
1282 | - impl->search_operation = impl->index.search(impl->query, [=](PackageList packages){ |
1283 | - qDebug("callback here"); |
1284 | - foreach (auto p, packages) { |
1285 | - qDebug() << "pushing result" << QString::fromStdString(p.name); |
1286 | - try { |
1287 | - scopes::CategorisedResult res(category); |
1288 | - if (locallyInstalledApps.count(p.name) > 0) { |
1289 | - qDebug() << "already installed" << QString::fromStdString(p.name); |
1290 | - continue; |
1291 | + auto search_cb = [this, searchReply, category, locallyInstalledApps](PackageList packages) { |
1292 | + qDebug("search callback"); |
1293 | + |
1294 | + // handle packages data |
1295 | + foreach (auto p, packages) { |
1296 | + qDebug() << "pushing result" << QString::fromStdString(p.name); |
1297 | + try { |
1298 | + scopes::CategorisedResult res(category); |
1299 | + if (locallyInstalledApps.count(p.name) > 0) { |
1300 | + qDebug() << "already installed" << QString::fromStdString(p.name); |
1301 | + continue; |
1302 | + } |
1303 | + res.set_title(p.title); |
1304 | + res.set_art(p.icon_url); |
1305 | + res.set_uri(p.url); |
1306 | + res[click::Query::ResultKeys::NAME] = p.name; |
1307 | + res[click::Query::ResultKeys::INSTALLED] = false; |
1308 | + |
1309 | + this->push_result(searchReply, res); |
1310 | + } catch(const std::exception& e){ |
1311 | + qDebug() << "PackageDetails::loadJson: Exception thrown while decoding JSON: " << e.what() ; |
1312 | + } catch(...){ |
1313 | + qDebug() << "no reason to catch"; |
1314 | } |
1315 | - res.set_title(p.title); |
1316 | - res.set_art(p.icon_url); |
1317 | - res.set_uri(p.url); |
1318 | - res[click::Query::ResultKeys::NAME] = p.name; |
1319 | - res[click::Query::ResultKeys::INSTALLED] = false; |
1320 | - |
1321 | - this->push_result(searchReply, res); |
1322 | - } catch(const std::exception& e){ |
1323 | - qDebug() << "PackageDetails::loadJson: Exception thrown while decoding JSON: " << e.what() ; |
1324 | - } catch(...){ |
1325 | - qDebug() << "no reason to catch"; |
1326 | } |
1327 | - } |
1328 | - qDebug() << "search completed"; |
1329 | - this->finished(searchReply); |
1330 | - }); |
1331 | + qDebug() << "search completed"; |
1332 | + this->finished(searchReply); |
1333 | + }; |
1334 | |
1335 | + qDebug() << "starting search of" << QString::fromStdString(impl->query.query_string()); |
1336 | + impl->search_operation = impl->index.search(impl->query.query_string(), search_cb); |
1337 | }); |
1338 | - |
1339 | } |
1340 | |
1341 | void click::Query::run(scopes::SearchReplyProxy const& searchReply) |
1342 | { |
1343 | + auto query = impl->query.query_string(); |
1344 | std::string categoryTemplate = CATEGORY_APPS_SEARCH; |
1345 | - if (impl->query.empty()) { |
1346 | + if (query.empty()) { |
1347 | categoryTemplate = CATEGORY_APPS_DISPLAY; |
1348 | } |
1349 | auto localResults = clickInterfaceInstance().find_installed_apps( |
1350 | - impl->query); |
1351 | + query); |
1352 | |
1353 | push_local_results( |
1354 | searchReply, |
1355 | |
1356 | === modified file 'scope/click/query.h' |
1357 | --- scope/click/query.h 2014-05-02 00:01:43 +0000 |
1358 | +++ scope/click/query.h 2014-05-23 14:58:59 +0000 |
1359 | @@ -38,6 +38,7 @@ |
1360 | #include <QSharedPointer> |
1361 | #include <set> |
1362 | |
1363 | + |
1364 | namespace click |
1365 | { |
1366 | |
1367 | @@ -69,7 +70,7 @@ |
1368 | constexpr static const char* VERSION{"version"}; |
1369 | }; |
1370 | |
1371 | - Query(std::string const& query, click::Index& index, scopes::SearchMetadata const& metadata); |
1372 | + Query(unity::scopes::CannedQuery const& query, click::Index& index, scopes::SearchMetadata const& metadata); |
1373 | virtual ~Query(); |
1374 | |
1375 | virtual void cancelled() override; |
1376 | |
1377 | === modified file 'scope/click/reviews.cpp' |
1378 | --- scope/click/reviews.cpp 2014-05-07 21:22:59 +0000 |
1379 | +++ scope/click/reviews.cpp 2014-05-23 14:58:59 +0000 |
1380 | @@ -139,8 +139,15 @@ |
1381 | root["review_text"] = review.review_text; |
1382 | |
1383 | root["arch_tag"] = click::Configuration().get_architecture(); |
1384 | - // NOTE: We only use the base language code for reviews. |
1385 | - root["language"] = click::Configuration().get_language_base(); |
1386 | + /* NOTE: We only use the base language code for reviews, except for |
1387 | + * codes in the click::Configuration::FULL_LANG_CODES vector. |
1388 | + */ |
1389 | + auto language = click::Configuration().get_language(); |
1390 | + if (click::Configuration::is_full_lang_code(language)) { |
1391 | + root["language"] = language; |
1392 | + } else { |
1393 | + root["language"] = click::Configuration().get_language_base(); |
1394 | + } |
1395 | |
1396 | // NOTE: "summary" is a required field, but we don't have one. Use "". |
1397 | root["summary"] = "Review"; |
1398 | |
1399 | === modified file 'scope/click/scope.cpp' |
1400 | --- scope/click/scope.cpp 2014-05-13 19:32:29 +0000 |
1401 | +++ scope/click/scope.cpp 2014-05-23 14:58:59 +0000 |
1402 | @@ -31,13 +31,13 @@ |
1403 | #include "scope.h" |
1404 | #include "query.h" |
1405 | #include "preview.h" |
1406 | -#include "network_access_manager.h" |
1407 | #include "interface.h" |
1408 | #include "scope_activation.h" |
1409 | |
1410 | #include <QSharedPointer> |
1411 | |
1412 | #include <click/key_file_locator.h> |
1413 | +#include <click/network_access_manager.h> |
1414 | #include <click/click-i18n.h> |
1415 | |
1416 | namespace |
1417 | @@ -88,7 +88,7 @@ |
1418 | |
1419 | scopes::SearchQueryBase::UPtr click::Scope::search(unity::scopes::CannedQuery const& q, scopes::SearchMetadata const& metadata) |
1420 | { |
1421 | - return scopes::SearchQueryBase::UPtr(new click::Query(q.query_string(), *index, metadata)); |
1422 | + return scopes::SearchQueryBase::UPtr(new click::Query(q, *index, metadata)); |
1423 | } |
1424 | |
1425 | |
1426 | |
1427 | === modified file 'scope/click/scope.h' |
1428 | --- scope/click/scope.h 2014-04-29 03:17:38 +0000 |
1429 | +++ scope/click/scope.h 2014-05-23 14:58:59 +0000 |
1430 | @@ -30,12 +30,13 @@ |
1431 | #ifndef CLICK_SCOPE_H |
1432 | #define CLICK_SCOPE_H |
1433 | |
1434 | +#include <click/network_access_manager.h> |
1435 | + |
1436 | #include <unity/scopes/ScopeBase.h> |
1437 | #include <unity/scopes/QueryBase.h> |
1438 | #include <unity/scopes/ActivationQueryBase.h> |
1439 | |
1440 | #include "index.h" |
1441 | -#include "network_access_manager.h" |
1442 | #include "webclient.h" |
1443 | |
1444 | namespace scopes = unity::scopes; |
1445 | |
1446 | === modified file 'scope/click/webclient.cpp' |
1447 | --- scope/click/webclient.cpp 2014-05-13 15:34:17 +0000 |
1448 | +++ scope/click/webclient.cpp 2014-05-23 14:58:59 +0000 |
1449 | @@ -30,11 +30,12 @@ |
1450 | #include <QBuffer> |
1451 | #include <QDebug> |
1452 | |
1453 | -#include "configuration.h" |
1454 | +#include <click/configuration.h> |
1455 | +#include <click/smartconnect.h> |
1456 | +#include <click/network_access_manager.h> |
1457 | + |
1458 | #include "webclient.h" |
1459 | -#include "smartconnect.h" |
1460 | |
1461 | -#include "network_access_manager.h" |
1462 | |
1463 | void click::web::CallParams::add(const std::string& key, const std::string& value) |
1464 | { |
1465 | |
1466 | === modified file 'scope/tests/CMakeLists.txt' |
1467 | --- scope/tests/CMakeLists.txt 2014-05-14 21:50:52 +0000 |
1468 | +++ scope/tests/CMakeLists.txt 2014-05-23 14:58:59 +0000 |
1469 | @@ -1,13 +1,6 @@ |
1470 | set (CLICKSCOPE_TESTS_TARGET click-scope-tests) |
1471 | find_package(Threads) |
1472 | |
1473 | -# Build with system gmock and embedded gtest |
1474 | -set (GMOCK_INCLUDE_DIR "/usr/include/gmock/include" CACHE PATH "gmock source include directory") |
1475 | -set (GMOCK_SOURCE_DIR "/usr/src/gmock" CACHE PATH "gmock source directory") |
1476 | -set (GTEST_INCLUDE_DIR "${GMOCK_SOURCE_DIR}/gtest/include" CACHE PATH "gtest source include directory") |
1477 | - |
1478 | -add_subdirectory(${GMOCK_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock") |
1479 | - |
1480 | # Qt5 bits |
1481 | SET (CMAKE_INCLUDE_CURRENT_DIR ON) |
1482 | SET (CMAKE_AUTOMOC ON) |
1483 | @@ -25,15 +18,12 @@ |
1484 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test_data.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/test_data.cpp) |
1485 | |
1486 | add_executable (${CLICKSCOPE_TESTS_TARGET} |
1487 | - mock_network_access_manager.h |
1488 | mock_webclient.h |
1489 | - test_configuration.cpp |
1490 | test_download_manager.cpp |
1491 | test_index.cpp |
1492 | test_interface.cpp |
1493 | test_query.cpp |
1494 | test_reviews.cpp |
1495 | - test_smartconnect.cpp |
1496 | test_webclient.cpp |
1497 | |
1498 | ${CMAKE_CURRENT_BINARY_DIR}/test_data.cpp |
1499 | @@ -43,6 +33,7 @@ |
1500 | |
1501 | target_link_libraries(${CLICKSCOPE_TESTS_TARGET} |
1502 | ${SCOPE_LIB_UNVERSIONED} |
1503 | + ${SCOPE_LIB_NAME} |
1504 | |
1505 | ${UNITY_SCOPES_LDFLAGS} |
1506 | ${UBUNTUONE_LDFLAGS} |
1507 | |
1508 | === modified file 'scope/tests/fake_json.h' |
1509 | --- scope/tests/fake_json.h 2014-04-23 20:38:12 +0000 |
1510 | +++ scope/tests/fake_json.h 2014-05-23 14:58:59 +0000 |
1511 | @@ -54,28 +54,40 @@ |
1512 | ] |
1513 | )foo"; |
1514 | |
1515 | -const std::string FAKE_JSON_SEARCH_RESULT_ONE = R"foo( |
1516 | - [ |
1517 | - { |
1518 | - "name": "org.example.awesomelauncher", |
1519 | - "title": "Awesome Launcher", |
1520 | - "description": "This is an awesome launcher.", |
1521 | - "price": 1.99, |
1522 | - "icon_url": "http://software-center.ubuntu.com/site_media/appmedia/2012/09/SPAZ.png", |
1523 | - "resource_url": "http://search.apps.ubuntu.com/api/v1/package/org.example.awesomelauncher" |
1524 | - } |
1525 | - ] |
1526 | +const std::string FAKE_JSON_SEARCH_RESULT_ONE = R"foo({ |
1527 | + "_embedded": { |
1528 | + "clickindex:package": [ |
1529 | + { |
1530 | + "name": "org.example.awesomelauncher", |
1531 | + "title": "Awesome Launcher", |
1532 | + "description": "This is an awesome launcher.", |
1533 | + "price": 1.99, |
1534 | + "icon_url": "http://software-center.ubuntu.com/site_media/appmedia/2012/09/SPAZ.png", |
1535 | + "_links": { |
1536 | + "self": { |
1537 | + "href": "http://search.apps.ubuntu.com/api/v1/package/org.example.awesomelauncher" |
1538 | + } |
1539 | + } |
1540 | + } |
1541 | + ] |
1542 | + } |
1543 | + } |
1544 | )foo"; |
1545 | |
1546 | -const std::string FAKE_JSON_SEARCH_RESULT_MANY = R"foo( |
1547 | - [ |
1548 | +const std::string FAKE_JSON_SEARCH_RESULT_MANY = R"foo({ |
1549 | + "_embedded": { |
1550 | + "clickindex:package": [ |
1551 | { |
1552 | "name": "org.example.awesomelauncher", |
1553 | "title": "Awesome Launcher", |
1554 | "description": "This is an awesome launcher.", |
1555 | "price": 1.99, |
1556 | "icon_url": "http://software-center.ubuntu.com/site_media/appmedia/2012/09/SPAZ.png", |
1557 | - "resource_url": "http://search.apps.ubuntu.com/api/v1/package/org.example.awesomelauncher" |
1558 | + "_links": { |
1559 | + "self": { |
1560 | + "href": "http://search.apps.ubuntu.com/api/v1/package/org.example.awesomelauncher" |
1561 | + } |
1562 | + } |
1563 | }, |
1564 | { |
1565 | "name": "org.example.fantastiqueapp", |
1566 | @@ -83,7 +95,11 @@ |
1567 | "description": "This is a fantasticc app.", |
1568 | "price": 0.0, |
1569 | "icon_url": "http://assets.ubuntu.com/sites/ubuntu/504/u/img/ubuntu/features/icon-find-more-apps-64x64.png", |
1570 | - "resource_url": "http://search.apps.ubuntu.com/api/v1/package/org.example.fantasticapp" |
1571 | + "_links": { |
1572 | + "self": { |
1573 | + "href": "http://search.apps.ubuntu.com/api/v1/package/org.example.fantasticapp" |
1574 | + } |
1575 | + } |
1576 | }, |
1577 | { |
1578 | "name": "org.example.awesomewidget", |
1579 | @@ -91,9 +107,15 @@ |
1580 | "description": "This is an awesome widget.", |
1581 | "price": 1.99, |
1582 | "icon_url": "http://assets.ubuntu.com/sites/ubuntu/504/u/img/ubuntu/features/icon-photos-and-videos-64x64.png", |
1583 | - "resource_url": "http://search.apps.ubuntu.com/api/v1/package/org.example.awesomewidget" |
1584 | + "_links": { |
1585 | + "self": { |
1586 | + "href": "http://search.apps.ubuntu.com/api/v1/package/org.example.awesomewidget" |
1587 | + } |
1588 | + } |
1589 | } |
1590 | ] |
1591 | + } |
1592 | + } |
1593 | )foo"; |
1594 | |
1595 | const std::string FAKE_JSON_PACKAGE_DETAILS = R"foo( |
1596 | |
1597 | === modified file 'scope/tests/test_download_manager.cpp' |
1598 | --- scope/tests/test_download_manager.cpp 2014-03-22 00:08:31 +0000 |
1599 | +++ scope/tests/test_download_manager.cpp 2014-05-23 14:58:59 +0000 |
1600 | @@ -42,8 +42,8 @@ |
1601 | #include <gtest/gtest.h> |
1602 | |
1603 | #include <click/download-manager.h> |
1604 | +#include <tests/mock_network_access_manager.h> |
1605 | |
1606 | -#include "mock_network_access_manager.h" |
1607 | #include "mock_ubuntuone_credentials.h" |
1608 | #include "mock_ubuntu_download_manager.h" |
1609 | |
1610 | |
1611 | === modified file 'scope/tests/test_index.cpp' |
1612 | --- scope/tests/test_index.cpp 2014-05-20 14:52:13 +0000 |
1613 | +++ scope/tests/test_index.cpp 2014-05-23 14:58:59 +0000 |
1614 | @@ -30,7 +30,8 @@ |
1615 | #include "click/index.h" |
1616 | #include "click/webclient.h" |
1617 | |
1618 | -#include "mock_network_access_manager.h" |
1619 | +#include <tests/mock_network_access_manager.h> |
1620 | + |
1621 | #include "mock_ubuntuone_credentials.h" |
1622 | #include "mock_webclient.h" |
1623 | #include "fake_json.h" |
1624 | @@ -51,7 +52,8 @@ |
1625 | click::Index(client, configuration) |
1626 | { |
1627 | } |
1628 | - MOCK_METHOD1(build_index_query, std::string(std::string)); |
1629 | + MOCK_METHOD1(build_index_query, std::string(const std::string&)); |
1630 | + MOCK_METHOD0(build_headers, std::map<std::string, std::string>()); |
1631 | }; |
1632 | |
1633 | class MockConfiguration : public click::Configuration { |
1634 | @@ -73,6 +75,8 @@ |
1635 | clientPtr.reset(new NiceMock<MockClient>(namPtr)); |
1636 | configPtr.reset(new MockConfiguration()); |
1637 | indexPtr.reset(new MockableIndex(clientPtr, configPtr)); |
1638 | + // register default value for build_headers() mock |
1639 | + DefaultValue<std::map<std::string, std::string>>::Set(std::map<std::string, std::string>()); |
1640 | } |
1641 | public: |
1642 | MOCK_METHOD1(search_callback, void(click::PackageList)); |
1643 | @@ -452,6 +456,7 @@ |
1644 | class ExhibitionistIndex : public click::Index { |
1645 | public: |
1646 | using click::Index::build_index_query; |
1647 | + using click::Index::build_headers; |
1648 | ExhibitionistIndex(const QSharedPointer<click::web::Client>& client, |
1649 | const QSharedPointer<click::Configuration> configuration) : |
1650 | click::Index(client, configuration) |
1651 | @@ -480,19 +485,19 @@ |
1652 | }; |
1653 | |
1654 | |
1655 | -TEST_F(QueryStringTest, testBuildQueryAddsArchitecture) |
1656 | +TEST_F(QueryStringTest, testBuildHeadersAddsArchitecture) |
1657 | { |
1658 | EXPECT_CALL(*configPtr, get_architecture()).Times(1).WillOnce(Return(fake_arch)); |
1659 | EXPECT_CALL(*configPtr, get_available_frameworks()).Times(1).WillOnce(Return(fake_frameworks)); |
1660 | - auto index_query = indexPtr->build_index_query("fake"); |
1661 | - EXPECT_NE(std::string::npos, index_query.find("architecture:" + fake_arch)); |
1662 | + auto hdrs = indexPtr->build_headers(); |
1663 | + EXPECT_EQ(fake_arch, hdrs["X-Ubuntu-Architecture"]); |
1664 | } |
1665 | |
1666 | -TEST_F(QueryStringTest, testBuildQueryAddsFramework) |
1667 | +TEST_F(QueryStringTest, testBuildHeadersAddsFramework) |
1668 | { |
1669 | EXPECT_CALL(*configPtr, get_architecture()).Times(1).WillOnce(Return(fake_arch)); |
1670 | EXPECT_CALL(*configPtr, get_available_frameworks()).Times(1).WillOnce(Return(fake_frameworks)); |
1671 | - auto index_query = indexPtr->build_index_query("fake"); |
1672 | - EXPECT_NE(std::string::npos, index_query.find("framework:" + fake_fwk_1)); |
1673 | - EXPECT_NE(std::string::npos, index_query.find("framework:" + fake_fwk_2)); |
1674 | + auto hdrs = indexPtr->build_headers(); |
1675 | + EXPECT_NE(std::string::npos, hdrs["X-Ubuntu-Frameworks"].find(fake_fwk_1)); |
1676 | + EXPECT_NE(std::string::npos, hdrs["X-Ubuntu-Frameworks"].find(fake_fwk_2)); |
1677 | } |
1678 | |
1679 | === modified file 'scope/tests/test_query.cpp' |
1680 | --- scope/tests/test_query.cpp 2014-05-20 14:52:13 +0000 |
1681 | +++ scope/tests/test_query.cpp 2014-05-23 14:58:59 +0000 |
1682 | @@ -38,7 +38,7 @@ |
1683 | #include "click/index.h" |
1684 | #include "click/application.h" |
1685 | |
1686 | -#include "mock_network_access_manager.h" |
1687 | +#include <tests/mock_network_access_manager.h> |
1688 | |
1689 | #include <unity/scopes/CategoryRenderer.h> |
1690 | #include <unity/scopes/CategorisedResult.h> |
1691 | @@ -78,7 +78,7 @@ |
1692 | |
1693 | class MockQueryBase : public click::Query { |
1694 | public: |
1695 | - MockQueryBase(const std::string query, click::Index& index, |
1696 | + MockQueryBase(const unity::scopes::CannedQuery& query, click::Index& index, |
1697 | scopes::SearchMetadata const& metadata) : click::Query(query, index, metadata) |
1698 | { |
1699 | |
1700 | @@ -92,7 +92,7 @@ |
1701 | |
1702 | class MockQuery : public MockQueryBase { |
1703 | public: |
1704 | - MockQuery(const std::string query, click::Index& index, |
1705 | + MockQuery(const unity::scopes::CannedQuery& query, click::Index& index, |
1706 | scopes::SearchMetadata const& metadata) : MockQueryBase(query, index, metadata) |
1707 | { |
1708 | |
1709 | @@ -114,7 +114,7 @@ |
1710 | |
1711 | class MockQueryRun : public MockQueryBase { |
1712 | public: |
1713 | - MockQueryRun(const std::string query, click::Index& index, |
1714 | + MockQueryRun(const unity::scopes::CannedQuery& query, click::Index& index, |
1715 | scopes::SearchMetadata const& metadata) : MockQueryBase(query, index, metadata) |
1716 | { |
1717 | |
1718 | @@ -145,7 +145,8 @@ |
1719 | MockIndex mock_index; |
1720 | scopes::SearchMetadata metadata("en_EN", "phone"); |
1721 | std::set<std::string> no_installed_packages; |
1722 | - MockQuery q(FAKE_QUERY, mock_index, metadata); |
1723 | + const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, ""); |
1724 | + MockQuery q(query, mock_index, metadata); |
1725 | EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _)).Times(1); |
1726 | scopes::SearchReplyProxy reply; |
1727 | |
1728 | @@ -163,7 +164,8 @@ |
1729 | MockIndex mock_index(packages); |
1730 | scopes::SearchMetadata metadata("en_EN", "phone"); |
1731 | std::set<std::string> no_installed_packages; |
1732 | - MockQuery q(FAKE_QUERY, mock_index, metadata); |
1733 | + const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, ""); |
1734 | + MockQuery q(query, mock_index, metadata); |
1735 | EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _)); |
1736 | |
1737 | scopes::CategoryRenderer renderer("{}"); |
1738 | @@ -184,7 +186,8 @@ |
1739 | MockIndex mock_index(packages); |
1740 | scopes::SearchMetadata metadata("en_EN", "phone"); |
1741 | std::set<std::string> no_installed_packages; |
1742 | - MockQuery q(FAKE_QUERY, mock_index, metadata); |
1743 | + const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, ""); |
1744 | + MockQuery q(query, mock_index, metadata); |
1745 | EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _)); |
1746 | |
1747 | scopes::CategoryRenderer renderer("{}"); |
1748 | @@ -204,7 +207,8 @@ |
1749 | MockIndex mock_index(packages); |
1750 | scopes::SearchMetadata metadata("en_EN", "phone"); |
1751 | std::set<std::string> no_installed_packages; |
1752 | - MockQuery q(FAKE_QUERY, mock_index, metadata); |
1753 | + const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, ""); |
1754 | + MockQuery q(query, mock_index, metadata); |
1755 | EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _)).Times(0); |
1756 | |
1757 | EXPECT_CALL(q, register_category(_, _, _, _, _)).WillOnce(Return(nullptr)); |
1758 | @@ -222,7 +226,8 @@ |
1759 | MockIndex mock_index(packages); |
1760 | scopes::SearchMetadata metadata("en_EN", "phone"); |
1761 | std::set<std::string> no_installed_packages; |
1762 | - MockQueryRun q(FAKE_QUERY, mock_index, metadata); |
1763 | + const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, ""); |
1764 | + MockQueryRun q(query, mock_index, metadata); |
1765 | auto reply = scopes::SearchReplyProxy(); |
1766 | EXPECT_CALL(q, push_local_results(_, _, _)); |
1767 | EXPECT_CALL(q, add_available_apps(reply, no_installed_packages, _)); |
1768 | @@ -243,7 +248,8 @@ |
1769 | std::set<std::string> one_installed_package { |
1770 | "org.example.app2" |
1771 | }; |
1772 | - MockQuery q(FAKE_QUERY, mock_index, metadata); |
1773 | + const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, ""); |
1774 | + MockQuery q(query, mock_index, metadata); |
1775 | EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _)); |
1776 | |
1777 | scopes::CategoryRenderer renderer("{}"); |
1778 | |
1779 | === modified file 'scope/tests/test_reviews.cpp' |
1780 | --- scope/tests/test_reviews.cpp 2014-04-29 03:17:38 +0000 |
1781 | +++ scope/tests/test_reviews.cpp 2014-05-23 14:58:59 +0000 |
1782 | @@ -30,8 +30,9 @@ |
1783 | #include <click/reviews.h> |
1784 | #include <click/webclient.h> |
1785 | |
1786 | +#include <tests/mock_network_access_manager.h> |
1787 | + |
1788 | #include "fake_json.h" |
1789 | -#include "mock_network_access_manager.h" |
1790 | #include "mock_ubuntuone_credentials.h" |
1791 | #include "mock_webclient.h" |
1792 | |
1793 | @@ -274,8 +275,8 @@ |
1794 | review.package_version = "0.1"; |
1795 | |
1796 | ASSERT_EQ(setenv(click::Configuration::LANGUAGE_ENVVAR, |
1797 | - "zh_TW.UTF-8", 1), 0); |
1798 | - std::string expected_language = "\"language\":\"zh\""; |
1799 | + "es_AR.UTF-8", 1), 0); |
1800 | + std::string expected_language = "\"language\":\"es\""; |
1801 | EXPECT_CALL(*clientPtr, callImpl(_, "POST", true, _, |
1802 | HasSubstr(expected_language), _)) |
1803 | .Times(1) |
1804 | @@ -286,6 +287,32 @@ |
1805 | ASSERT_EQ(unsetenv(click::Configuration::LANGUAGE_ENVVAR), 0); |
1806 | } |
1807 | |
1808 | +TEST_F(ReviewsTest, testSubmitReviewLanguageCorrectForFullLangCodes) |
1809 | +{ |
1810 | + LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
1811 | + auto response = responseForReply(reply.asSharedPtr()); |
1812 | + |
1813 | + click::Review review; |
1814 | + review.rating = 3; |
1815 | + review.review_text = "A review."; |
1816 | + review.package_name = "com.example.test"; |
1817 | + review.package_version = "0.1"; |
1818 | + |
1819 | + for (std::string lang: click::Configuration::FULL_LANG_CODES) { |
1820 | + ASSERT_EQ(setenv(click::Configuration::LANGUAGE_ENVVAR, |
1821 | + lang.c_str(), 1), 0); |
1822 | + std::string expected_language = "\"language\":\"" + lang + "\""; |
1823 | + EXPECT_CALL(*clientPtr, callImpl(_, "POST", true, _, |
1824 | + HasSubstr(expected_language), _)) |
1825 | + .Times(1) |
1826 | + .WillOnce(Return(response)); |
1827 | + |
1828 | + auto submit_op = reviewsPtr->submit_review(review, |
1829 | + [](click::Reviews::Error){}); |
1830 | + ASSERT_EQ(unsetenv(click::Configuration::LANGUAGE_ENVVAR), 0); |
1831 | + } |
1832 | +} |
1833 | + |
1834 | TEST_F(ReviewsTest, testGetBaseUrl) |
1835 | { |
1836 | const char *value = getenv(click::REVIEWS_BASE_URL_ENVVAR.c_str()); |
1837 | |
1838 | === modified file 'scope/tests/test_webclient.cpp' |
1839 | --- scope/tests/test_webclient.cpp 2014-05-13 14:11:42 +0000 |
1840 | +++ scope/tests/test_webclient.cpp 2014-05-23 14:58:59 +0000 |
1841 | @@ -28,10 +28,11 @@ |
1842 | */ |
1843 | #include <QDebug> |
1844 | |
1845 | -#include "click/configuration.h" |
1846 | -#include "click/webclient.h" |
1847 | - |
1848 | -#include "mock_network_access_manager.h" |
1849 | +#include <click/configuration.h> |
1850 | +#include <click/webclient.h> |
1851 | + |
1852 | +#include <tests/mock_network_access_manager.h> |
1853 | + |
1854 | #include "mock_ubuntuone_credentials.h" |
1855 | |
1856 | #include <gtest/gtest.h> |
PASSED: Continuous integration, rev:227 jenkins. qa.ubuntu. com/job/ unity-scope- click-ci/ 468/ jenkins. qa.ubuntu. com/job/ unity-scope- click-utopic- amd64-ci/ 8 jenkins. qa.ubuntu. com/job/ unity-scope- click-utopic- armhf-ci/ 8 jenkins. qa.ubuntu. com/job/ unity-scope- click-utopic- armhf-ci/ 8/artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- scope-click- ci/468/ rebuild
http://