Merge lp:~dobey/unity-scope-click/clicksnap into lp:unity-scope-click
- clicksnap
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~dobey/unity-scope-click/clicksnap |
Merge into: | lp:unity-scope-click |
Diff against target: |
4429 lines (+1203/-1758) 66 files modified
CMakeLists.txt (+7/-1) bin/install-helper (+7/-2) debian/control (+3/-2) libclickscope/click/CMakeLists.txt (+4/-1) libclickscope/click/configuration.cpp (+17/-3) libclickscope/click/configuration.h (+5/-4) libclickscope/click/download-manager.cpp (+43/-83) libclickscope/click/download-manager.h (+4/-8) libclickscope/click/index.cpp (+52/-2) libclickscope/click/index.h (+11/-2) libclickscope/click/interface.cpp (+167/-370) libclickscope/click/interface.h (+15/-29) libclickscope/click/key_file_locator.cpp (+0/-94) libclickscope/click/key_file_locator.h (+0/-70) libclickscope/click/package.cpp (+4/-0) libclickscope/click/package.h (+4/-0) libclickscope/click/preview.cpp (+23/-8) libclickscope/click/webclient.cpp (+26/-17) libclickscope/click/webclient.h (+2/-0) libclickscope/tests/CMakeLists.txt (+3/-3) libclickscope/tests/applications/system/address-book-app.desktop (+0/-15) libclickscope/tests/applications/system/messaging-app.desktop (+0/-14) libclickscope/tests/applications/system/translated.desktop (+0/-9) libclickscope/tests/applications/user/badd-appid.desktop (+0/-10) libclickscope/tests/applications/user/com.ubuntu.accented_accented_0.5.29.desktop (+0/-13) libclickscope/tests/applications/user/com.ubuntu.calculator_calculator_0.1.3.206.desktop (+0/-14) libclickscope/tests/applications/user/com.ubuntu.calendar_calendar_0.4.182.desktop (+0/-14) libclickscope/tests/applications/user/com.ubuntu.clock_clock_1.0.300.desktop (+0/-14) libclickscope/tests/applications/user/com.ubuntu.developer.webapps.webapp-amazon_webapp-amazon_1.0.6.desktop (+0/-10) libclickscope/tests/applications/user/com.ubuntu.developer.webapps.webapp-ebay_webapp-ebay_1.0.8.desktop (+0/-11) libclickscope/tests/applications/user/com.ubuntu.developer.webapps.webapp-facebook_webapp-facebook_1.0.5.desktop (+0/-12) libclickscope/tests/applications/user/com.ubuntu.developer.webapps.webapp-gmail_webapp-gmail_1.0.8.desktop (+0/-11) libclickscope/tests/applications/user/com.ubuntu.developer.webapps.webapp-twitter_webapp-twitter_1.0.5.desktop (+0/-12) libclickscope/tests/applications/user/com.ubuntu.dropping-letters_dropping-letters_0.1.2.2.43.desktop (+0/-13) libclickscope/tests/applications/user/com.ubuntu.filemanager_filemanager_0.1.1.97.desktop (+0/-13) libclickscope/tests/applications/user/com.ubuntu.music_music_1.1.329.desktop (+0/-15) libclickscope/tests/applications/user/com.ubuntu.notes_notes_1.4.242.desktop (+0/-14) libclickscope/tests/applications/user/com.ubuntu.shorts_shorts_0.2.162.desktop (+0/-14) libclickscope/tests/applications/user/com.ubuntu.stock-ticker-mobile_stock-ticker-mobile_0.3.7.66.desktop (+0/-16) libclickscope/tests/applications/user/com.ubuntu.sudoku_sudoku_1.0.142.desktop (+0/-15) libclickscope/tests/applications/user/com.ubuntu.terminal_terminal_0.5.29.desktop (+0/-13) libclickscope/tests/applications/user/com.ubuntu.weather_weather_1.0.168.desktop (+0/-15) libclickscope/tests/applications/user/non-click-app-nodisplay.desktop (+0/-9) libclickscope/tests/applications/user/non-click-app-onlyshowin-gnome-unity.desktop (+0/-10) libclickscope/tests/applications/user/non-click-app-onlyshowin-gnome.desktop (+0/-10) libclickscope/tests/applications/user/non-click-app-onlyshowin-unity.desktop (+0/-10) libclickscope/tests/applications/user/non-click-app-without-exception.desktop (+0/-9) libclickscope/tests/applications/user/pre-translated.desktop (+0/-14) libclickscope/tests/applications/user/semi-broken.desktop (+0/-1) libclickscope/tests/mock_ual.h (+156/-0) libclickscope/tests/mock_webclient.h (+9/-7) libclickscope/tests/test_bootstrap.cpp (+2/-2) libclickscope/tests/test_data.cpp.in (+0/-43) libclickscope/tests/test_data.h (+0/-3) libclickscope/tests/test_download_manager.cpp (+155/-127) libclickscope/tests/test_index.cpp (+225/-20) libclickscope/tests/test_interface.cpp (+162/-446) libclickscope/tests/test_pay.cpp (+13/-13) libclickscope/tests/test_preview.cpp (+2/-2) libclickscope/tests/test_reviews.cpp (+16/-16) scope/clickapps/apps-query.cpp (+8/-8) scope/clickapps/apps-scope.cpp (+0/-1) scope/clickstore/store-query.cpp (+47/-10) scope/clickstore/store-scope.cpp (+0/-1) scope/tests/test_apps_query.cpp (+6/-6) tools/init-departments/init-departments.cpp (+5/-4) |
To merge this branch: | bzr merge lp:~dobey/unity-scope-click/clicksnap |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
unity-api-1-bot | continuous-integration | Approve | |
Unity API Team | Pending | ||
Review via email: mp+303849@code.launchpad.net |
This proposal has been superseded by a proposal from 2016-08-25.
Commit message
Support for snaps.
Description of the change
unity-api-1-bot (unity-api-1-bot) wrote : | # |
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:497
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
- 498. By dobey
-
Update dependencies to allow either snaps or clicks to be supported.
- 499. By dobey
-
Merge up chagnes from ual-apps.
- 500. By dobey
-
Collapse snapd.socket check to simplify function.
- 501. By dobey
-
Remove the extra check for downloads.size > 1, as it shouldn't happen.
- 502. By dobey
-
Some cleanup in download-
manager. cpp per code review. - 503. By dobey
-
Fixes to index.cpp per code review.
- 504. By dobey
-
Break up mock responseForReply per code review.
- 505. By dobey
-
Refactor index tests perh code review.
- 506. By dobey
-
Use const auto in for loops.
- 507. By dobey
-
Want const references for the for loops here.
- 508. By dobey
-
New script to download snap assertions and perform install
- 509. By dobey
-
Fix the snap script to do the right thing.
Add necessary dependencies for the script. - 510. By dobey
-
Check that filename argument is non-empty before continuing.
- 511. By dobey
-
Check if name is alias instead of using snap_id to determine if snap.
- 512. By dobey
-
If frameworks list is empty send "none" instead of empty header.
- 513. By dobey
-
Use a bash function instead of variable for wget, to avoid weird escaping.
Unmerged revisions
- 513. By dobey
-
Use a bash function instead of variable for wget, to avoid weird escaping.
- 512. By dobey
-
If frameworks list is empty send "none" instead of empty header.
- 511. By dobey
-
Check if name is alias instead of using snap_id to determine if snap.
- 510. By dobey
-
Check that filename argument is non-empty before continuing.
- 509. By dobey
-
Fix the snap script to do the right thing.
Add necessary dependencies for the script. - 508. By dobey
-
New script to download snap assertions and perform install
- 507. By dobey
-
Want const references for the for loops here.
- 506. By dobey
-
Use const auto in for loops.
- 505. By dobey
-
Refactor index tests perh code review.
- 504. By dobey
-
Break up mock responseForReply per code review.
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2016-07-14 18:37:27 +0000 | |||
3 | +++ CMakeLists.txt 2016-08-24 21:39:08 +0000 | |||
4 | @@ -8,7 +8,7 @@ | |||
5 | 8 | 8 | ||
6 | 9 | # Some default CFLAGS | 9 | # Some default CFLAGS |
7 | 10 | SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g -Wall -Wextra -Werror -fPIC") | 10 | SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g -Wall -Wextra -Werror -fPIC") |
9 | 11 | SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -g -Wextra -Wall -Werror -Werror=conversion-null -fPIC") | 11 | SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -g -Wextra -Wall -Werror -Werror=conversion-null -Wno-ignored-qualifiers -fPIC") |
10 | 12 | 12 | ||
11 | 13 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) | 13 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) |
12 | 14 | 14 | ||
13 | @@ -24,6 +24,12 @@ | |||
14 | 24 | include(UseGSettings) | 24 | include(UseGSettings) |
15 | 25 | find_package (PkgConfig REQUIRED) | 25 | find_package (PkgConfig REQUIRED) |
16 | 26 | 26 | ||
17 | 27 | pkg_check_modules(UAL REQUIRED ubuntu-app-launch-2>=0.9) | ||
18 | 28 | add_definitions(${UAL_CFLAGS} ${UAL_CFLAGS_OTHER}) | ||
19 | 29 | |||
20 | 30 | pkg_check_modules(CLICK REQUIRED click-0.4) | ||
21 | 31 | add_definitions(${CLICK_CFLAGS} ${CLICK_CFLAGS_OTHER}) | ||
22 | 32 | |||
23 | 27 | pkg_check_modules(UNITY_SCOPES REQUIRED libunity-scopes>=0.6.7 libunity-api>=0.1.3) | 33 | pkg_check_modules(UNITY_SCOPES REQUIRED libunity-scopes>=0.6.7 libunity-api>=0.1.3) |
24 | 28 | add_definitions(${UNITY_SCOPES_CFLAGS} ${UNITY_SCOPES_CFLAGS_OTHER}) | 34 | add_definitions(${UNITY_SCOPES_CFLAGS} ${UNITY_SCOPES_CFLAGS_OTHER}) |
25 | 29 | 35 | ||
26 | 30 | 36 | ||
27 | === modified file 'bin/install-helper' | |||
28 | --- bin/install-helper 2014-06-20 05:09:01 +0000 | |||
29 | +++ bin/install-helper 2016-08-24 21:39:08 +0000 | |||
30 | @@ -1,6 +1,6 @@ | |||
31 | 1 | #!/bin/bash | 1 | #!/bin/bash |
32 | 2 | # | 2 | # |
34 | 3 | # Copyright (C) 2014 Canonical Ltd. | 3 | # Copyright (C) 2014-2016 Canonical Ltd. |
35 | 4 | # | 4 | # |
36 | 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 |
37 | 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 |
38 | @@ -47,7 +47,12 @@ | |||
39 | 47 | 47 | ||
40 | 48 | function install-package { | 48 | function install-package { |
41 | 49 | FILE_NAME="$1" | 49 | FILE_NAME="$1" |
43 | 50 | pkcon -p install-local "$FILE_NAME" | 50 | FILE_TYPE="${FILE_NAME##*.}" |
44 | 51 | if [ ${FILE_TYPE} = "click" ]; then | ||
45 | 52 | pkcon -p install-local "${FILE_NAME}" | ||
46 | 53 | else | ||
47 | 54 | pkexec snap install "${FILE_NAME}" | ||
48 | 55 | fi | ||
49 | 51 | } | 56 | } |
50 | 52 | 57 | ||
51 | 53 | function app_id-from-package_name { | 58 | function app_id-from-package_name { |
52 | 54 | 59 | ||
53 | === modified file 'debian/control' | |||
54 | --- debian/control 2016-05-25 16:17:00 +0000 | |||
55 | +++ debian/control 2016-08-24 21:39:08 +0000 | |||
56 | @@ -1,8 +1,7 @@ | |||
57 | 1 | Source: unity-scope-click | 1 | Source: unity-scope-click |
58 | 2 | Section: x11 | 2 | Section: x11 |
59 | 3 | Priority: optional | 3 | Priority: optional |
62 | 4 | Build-Depends: click, | 4 | Build-Depends: cmake (>= 2.8.10), |
61 | 5 | cmake (>= 2.8.10), | ||
63 | 6 | cmake-extras, | 5 | cmake-extras, |
64 | 7 | dbus-x11, | 6 | dbus-x11, |
65 | 8 | debhelper (>= 9), | 7 | debhelper (>= 9), |
66 | @@ -12,9 +11,11 @@ | |||
67 | 12 | intltool, | 11 | intltool, |
68 | 13 | lcov, | 12 | lcov, |
69 | 14 | libboost-locale-dev, | 13 | libboost-locale-dev, |
70 | 14 | libclick-0.4-dev, | ||
71 | 15 | libglib2.0-dev (>= 2.32), | 15 | libglib2.0-dev (>= 2.32), |
72 | 16 | libjsoncpp-dev, | 16 | libjsoncpp-dev, |
73 | 17 | libpay2-dev (>= 2.0.0+15.04.20150701), | 17 | libpay2-dev (>= 2.0.0+15.04.20150701), |
74 | 18 | libubuntu-app-launch2-dev (>= 0.9), | ||
75 | 18 | libubuntu-download-manager-client-dev (>= 0.3+14.10.20140430-0ubuntu1), | 19 | libubuntu-download-manager-client-dev (>= 0.3+14.10.20140430-0ubuntu1), |
76 | 19 | libubuntu-download-manager-common-dev (>= 0.3+14.10.20140430-0ubuntu1), | 20 | libubuntu-download-manager-common-dev (>= 0.3+14.10.20140430-0ubuntu1), |
77 | 20 | libubuntuoneauth-2.0-dev (>= 15.10), | 21 | libubuntuoneauth-2.0-dev (>= 15.10), |
78 | 21 | 22 | ||
79 | === modified file 'libclickscope/click/CMakeLists.txt' | |||
80 | --- libclickscope/click/CMakeLists.txt 2015-04-14 21:19:21 +0000 | |||
81 | +++ libclickscope/click/CMakeLists.txt 2016-08-24 21:39:08 +0000 | |||
82 | @@ -22,7 +22,6 @@ | |||
83 | 22 | highlights.cpp | 22 | highlights.cpp |
84 | 23 | index.cpp | 23 | index.cpp |
85 | 24 | interface.cpp | 24 | interface.cpp |
86 | 25 | key_file_locator.cpp | ||
87 | 26 | launcher.cpp | 25 | launcher.cpp |
88 | 27 | network_access_manager.cpp | 26 | network_access_manager.cpp |
89 | 28 | package.cpp | 27 | package.cpp |
90 | @@ -43,6 +42,8 @@ | |||
91 | 43 | ${JSON_CPP_INCLUDE_DIRS} | 42 | ${JSON_CPP_INCLUDE_DIRS} |
92 | 44 | ${LIBPAY_INCLUDE_DIRS} | 43 | ${LIBPAY_INCLUDE_DIRS} |
93 | 45 | ${GSETTINGS_QT_INCLUDE_DIRS} | 44 | ${GSETTINGS_QT_INCLUDE_DIRS} |
94 | 45 | ${UAL_INCLUDE_DIRS} | ||
95 | 46 | ${CLICK_INCLUDE_DIRS} | ||
96 | 46 | ${CMAKE_SOURCE_DIR}/libclickscope | 47 | ${CMAKE_SOURCE_DIR}/libclickscope |
97 | 47 | ) | 48 | ) |
98 | 48 | 49 | ||
99 | @@ -54,5 +55,7 @@ | |||
100 | 54 | ${UBUNTU_DOWNLOAD_MANAGER_CLIENT_LDFLAGS} | 55 | ${UBUNTU_DOWNLOAD_MANAGER_CLIENT_LDFLAGS} |
101 | 55 | ${UBUNTU_DOWNLOAD_MANAGER_COMMON_LDFLAGS} | 56 | ${UBUNTU_DOWNLOAD_MANAGER_COMMON_LDFLAGS} |
102 | 56 | ${GSETTINGS_QT_LIBRARIES} | 57 | ${GSETTINGS_QT_LIBRARIES} |
103 | 58 | ${UAL_LDFLAGS} | ||
104 | 59 | ${CLICK_LDFLAGS} | ||
105 | 57 | -lboost_locale | 60 | -lboost_locale |
106 | 58 | ) | 61 | ) |
107 | 59 | 62 | ||
108 | === modified file 'libclickscope/click/configuration.cpp' | |||
109 | --- libclickscope/click/configuration.cpp 2016-02-19 03:35:43 +0000 | |||
110 | +++ libclickscope/click/configuration.cpp 2016-08-24 21:39:08 +0000 | |||
111 | @@ -1,5 +1,5 @@ | |||
112 | 1 | /* | 1 | /* |
114 | 2 | * Copyright (C) 2014-2015 Canonical Ltd. | 2 | * Copyright (C) 2014-2016 Canonical Ltd. |
115 | 3 | * | 3 | * |
116 | 4 | * This program is free software: you can redistribute it and/or modify it | 4 | * This program is free software: you can redistribute it and/or modify it |
117 | 5 | * under the terms of the GNU General Public License version 3, as published | 5 | * under the terms of the GNU General Public License version 3, as published |
118 | @@ -27,6 +27,8 @@ | |||
119 | 27 | * files in the program, then also delete it here. | 27 | * files in the program, then also delete it here. |
120 | 28 | */ | 28 | */ |
121 | 29 | 29 | ||
122 | 30 | #include "configuration.h" | ||
123 | 31 | |||
124 | 30 | #include <string> | 32 | #include <string> |
125 | 31 | #include <vector> | 33 | #include <vector> |
126 | 32 | 34 | ||
127 | @@ -43,8 +45,9 @@ | |||
128 | 43 | 45 | ||
129 | 44 | #include <boost/algorithm/string.hpp> | 46 | #include <boost/algorithm/string.hpp> |
130 | 45 | #include <boost/algorithm/string/replace.hpp> | 47 | #include <boost/algorithm/string/replace.hpp> |
133 | 46 | 48 | #include <sys/stat.h> | |
134 | 47 | #include "configuration.h" | 49 | #include <sys/types.h> |
135 | 50 | #include <unistd.h> | ||
136 | 48 | 51 | ||
137 | 49 | namespace click { | 52 | namespace click { |
138 | 50 | 53 | ||
139 | @@ -121,6 +124,17 @@ | |||
140 | 121 | return arch; | 124 | return arch; |
141 | 122 | } | 125 | } |
142 | 123 | 126 | ||
143 | 127 | bool Configuration::is_snapd_running() const | ||
144 | 128 | { | ||
145 | 129 | struct stat sb; | ||
146 | 130 | int retval = stat("/run/snapd.socket", &sb); | ||
147 | 131 | if (retval == 0 && (sb.st_mode & S_IFMT) == S_IFSOCK) { | ||
148 | 132 | return true; | ||
149 | 133 | } | ||
150 | 134 | |||
151 | 135 | return false; | ||
152 | 136 | } | ||
153 | 137 | |||
154 | 124 | bool Configuration::get_purchases_enabled() | 138 | bool Configuration::get_purchases_enabled() |
155 | 125 | { | 139 | { |
156 | 126 | const char* env_value = std::getenv(PURCHASES_ENVVAR); | 140 | const char* env_value = std::getenv(PURCHASES_ENVVAR); |
157 | 127 | 141 | ||
158 | === modified file 'libclickscope/click/configuration.h' | |||
159 | --- libclickscope/click/configuration.h 2016-02-19 03:35:43 +0000 | |||
160 | +++ libclickscope/click/configuration.h 2016-08-24 21:39:08 +0000 | |||
161 | @@ -54,6 +54,7 @@ | |||
162 | 54 | 54 | ||
163 | 55 | virtual std::vector<std::string> get_available_frameworks(); | 55 | virtual std::vector<std::string> get_available_frameworks(); |
164 | 56 | virtual std::string get_architecture(); | 56 | virtual std::string get_architecture(); |
165 | 57 | virtual bool is_snapd_running() const; | ||
166 | 57 | static bool get_purchases_enabled(); | 58 | static bool get_purchases_enabled(); |
167 | 58 | static std::string get_currency(const std::string& fallback = CURRENCY_DEFAULT); | 59 | static std::string get_currency(const std::string& fallback = CURRENCY_DEFAULT); |
168 | 59 | 60 | ||
169 | @@ -78,11 +79,11 @@ | |||
170 | 78 | virtual const std::vector<std::string> get_dconf_strings(const std::string& schema, const std::string& key) const; | 79 | virtual const std::vector<std::string> get_dconf_strings(const std::string& schema, const std::string& key) const; |
171 | 79 | static const std::vector<std::string>& get_default_core_apps() { | 80 | static const std::vector<std::string>& get_default_core_apps() { |
172 | 80 | static std::vector<std::string> default_apps { | 81 | static std::vector<std::string> default_apps { |
176 | 81 | "dialer-app", | 82 | "dialer-app.desktop", |
177 | 82 | "messaging-app", | 83 | "messaging-app.desktop", |
178 | 83 | "address-book-app", | 84 | "address-book-app.desktop", |
179 | 84 | "com.ubuntu.camera_camera", | 85 | "com.ubuntu.camera_camera", |
181 | 85 | "webbrowser-app", | 86 | "webbrowser-app.desktop", |
182 | 86 | "com.ubuntu.clock_clock" | 87 | "com.ubuntu.clock_clock" |
183 | 87 | }; | 88 | }; |
184 | 88 | return default_apps; | 89 | return default_apps; |
185 | 89 | 90 | ||
186 | === modified file 'libclickscope/click/download-manager.cpp' | |||
187 | --- libclickscope/click/download-manager.cpp 2016-05-10 13:42:12 +0000 | |||
188 | +++ libclickscope/click/download-manager.cpp 2016-08-24 21:39:08 +0000 | |||
189 | @@ -57,12 +57,6 @@ | |||
190 | 57 | 57 | ||
191 | 58 | static const QString DOWNLOAD_MANAGER_SHA512 = "sha512"; | 58 | static const QString DOWNLOAD_MANAGER_SHA512 = "sha512"; |
192 | 59 | 59 | ||
193 | 60 | const QByteArray& CLICK_TOKEN_HEADER() | ||
194 | 61 | { | ||
195 | 62 | static const QByteArray result("X-Click-Token"); | ||
196 | 63 | return result; | ||
197 | 64 | } | ||
198 | 65 | |||
199 | 66 | DownloadManager::DownloadManager(const QSharedPointer<click::web::Client>& client, | 60 | DownloadManager::DownloadManager(const QSharedPointer<click::web::Client>& client, |
200 | 67 | const QSharedPointer<udm::Manager>& manager) : | 61 | const QSharedPointer<udm::Manager>& manager) : |
201 | 68 | client(client), | 62 | client(client), |
202 | @@ -86,11 +80,11 @@ | |||
203 | 86 | if (downloads.size() > 0) { | 80 | if (downloads.size() > 0) { |
204 | 87 | auto download = downloads.at(0); | 81 | auto download = downloads.at(0); |
205 | 88 | object_path = download->id().toStdString(); | 82 | object_path = download->id().toStdString(); |
211 | 89 | } | 83 | qDebug() << "Found object path" << QString::fromStdString(object_path) |
212 | 90 | qDebug() << "Found object path" << QString::fromStdString(object_path) | 84 | << "for package" << QString::fromStdString(package_name); |
213 | 91 | << "for package" << QString::fromStdString(package_name); | 85 | if (downloads.size() > 1) { |
214 | 92 | if (downloads.size() > 1) { | 86 | qWarning() << "More than one download with the same object path"; |
215 | 93 | qWarning() << "More than one download with the same object path"; | 87 | } |
216 | 94 | } | 88 | } |
217 | 95 | callback(object_path); | 89 | callback(object_path); |
218 | 96 | }, [callback, package_name](const QString& /*key*/, const QString& /*value*/, DownloadsList* /*downloads_list*/){ | 90 | }, [callback, package_name](const QString& /*key*/, const QString& /*value*/, DownloadsList* /*downloads_list*/){ |
219 | @@ -100,78 +94,44 @@ | |||
220 | 100 | }); | 94 | }); |
221 | 101 | } | 95 | } |
222 | 102 | 96 | ||
295 | 103 | click::web::Cancellable DownloadManager::start(const std::string& url, | 97 | void DownloadManager::start(const std::string& url, |
296 | 104 | const std::string& download_sha512, | 98 | const std::string& download_sha512, |
297 | 105 | const std::string& package_name, | 99 | const std::string& package_name, |
298 | 106 | const std::function<void (std::string, Error)>& callback) | 100 | const std::function<void (std::string, Error)>& callback) |
299 | 107 | { | 101 | { |
300 | 108 | QSharedPointer<click::web::Response> response = client->call | 102 | auto signature = client->signUrl(url, "GET"); |
301 | 109 | (url, "HEAD", true); | 103 | |
302 | 110 | 104 | QVariantMap metadata; | |
303 | 111 | QObject::connect(response.data(), &click::web::Response::finished, | 105 | |
304 | 112 | [this, callback, url, download_sha512, package_name, | 106 | QVariant commandline = QVariant(QStringList() << DOWNLOAD_COMMAND << "$file" << package_name.c_str()); |
305 | 113 | response](QString) { | 107 | metadata[DOWNLOAD_COMMAND_KEY] = commandline; |
306 | 114 | auto status = response->get_status_code(); | 108 | metadata[DOWNLOAD_APP_ID_KEY] = package_name.c_str(); |
307 | 115 | if (status == 200) { | 109 | metadata["package_name"] = package_name.c_str(); |
308 | 116 | auto clickToken = response->get_header(CLICK_TOKEN_HEADER().data()); | 110 | |
309 | 117 | qDebug() << "Received click token:" << clickToken.c_str(); | 111 | QMap<QString, QString> headers; |
310 | 118 | QVariantMap metadata; | 112 | headers[click::web::AUTHORIZATION_HEADER.c_str()] = signature.c_str(); |
311 | 119 | 113 | ||
312 | 120 | QVariant commandline = QVariant(QStringList() << DOWNLOAD_COMMAND << "$file" << package_name.c_str()); | 114 | udm::DownloadStruct downloadStruct(url.c_str(), |
313 | 121 | metadata[DOWNLOAD_COMMAND_KEY] = commandline; | 115 | download_sha512.c_str(), |
314 | 122 | metadata[DOWNLOAD_APP_ID_KEY] = package_name.c_str(); | 116 | DOWNLOAD_MANAGER_SHA512, |
315 | 123 | metadata["package_name"] = package_name.c_str(); | 117 | metadata, |
316 | 124 | 118 | headers); | |
317 | 125 | QMap<QString, QString> headers; | 119 | |
318 | 126 | headers[CLICK_TOKEN_HEADER()] = clickToken.c_str(); | 120 | dm->createDownload(downloadStruct, |
319 | 127 | 121 | [callback](Download* download) { | |
320 | 128 | udm::DownloadStruct downloadStruct(url.c_str(), | 122 | if (download->isError()) { |
321 | 129 | download_sha512.c_str(), | 123 | auto error = download->error()->errorString().toUtf8().data(); |
322 | 130 | DOWNLOAD_MANAGER_SHA512, | 124 | qDebug() << "Received error from ubuntu-download-manager:" << error; |
323 | 131 | metadata, | 125 | callback(error, Error::DownloadInstallError); |
324 | 132 | headers); | 126 | } else { |
325 | 133 | 127 | download->start(); | |
326 | 134 | dm->createDownload(downloadStruct, | 128 | callback(download->id().toUtf8().data(), Error::NoError); |
327 | 135 | [callback](Download* download) { | 129 | } |
328 | 136 | if (download->isError()) { | 130 | }, |
329 | 137 | auto error = download->error()->errorString().toUtf8().data(); | 131 | [callback](Download* download) { |
330 | 138 | qDebug() << "Received error from ubuntu-download-manager:" << error; | 132 | callback(download->error()->errorString().toUtf8().data(), |
331 | 139 | callback(error, Error::DownloadInstallError); | 133 | Error::DownloadInstallError); |
332 | 140 | } else { | 134 | }); |
261 | 141 | download->start(); | ||
262 | 142 | callback(download->id().toUtf8().data(), Error::NoError); | ||
263 | 143 | } | ||
264 | 144 | }, | ||
265 | 145 | [callback](Download* download) { | ||
266 | 146 | callback(download->error()->errorString().toUtf8().data(), | ||
267 | 147 | Error::DownloadInstallError); | ||
268 | 148 | }); | ||
269 | 149 | } else { | ||
270 | 150 | std::string error{"Unhandled HTTP response code: "}; | ||
271 | 151 | error += status; | ||
272 | 152 | callback(error, Error::DownloadInstallError); | ||
273 | 153 | } | ||
274 | 154 | }); | ||
275 | 155 | QObject::connect(response.data(), &click::web::Response::error, | ||
276 | 156 | [this, callback, package_name](QString error, int error_code) { | ||
277 | 157 | qWarning() << QStringLiteral("Network error (%1) fetching click token for:").arg(error_code) << package_name.c_str(); | ||
278 | 158 | switch(error_code) { | ||
279 | 159 | case 401: | ||
280 | 160 | case 403: | ||
281 | 161 | client->invalidateCredentials(); | ||
282 | 162 | callback(error.toUtf8().data(), Error::CredentialsError); | ||
283 | 163 | break; | ||
284 | 164 | default: | ||
285 | 165 | callback(error.toUtf8().data(), Error::DownloadInstallError); | ||
286 | 166 | } | ||
287 | 167 | }); | ||
288 | 168 | |||
289 | 169 | return click::web::Cancellable(response); | ||
290 | 170 | } | ||
291 | 171 | |||
292 | 172 | void DownloadManager::setCredentialsService(const QSharedPointer<click::CredentialsService>& credentialsService) | ||
293 | 173 | { | ||
294 | 174 | sso = credentialsService; | ||
333 | 175 | } | 135 | } |
334 | 176 | 136 | ||
335 | 177 | } // namespace click | 137 | } // namespace click |
336 | 178 | 138 | ||
337 | === modified file 'libclickscope/click/download-manager.h' | |||
338 | --- libclickscope/click/download-manager.h 2016-02-26 18:51:22 +0000 | |||
339 | +++ libclickscope/click/download-manager.h 2016-08-24 21:39:08 +0000 | |||
340 | @@ -68,18 +68,14 @@ | |||
341 | 68 | 68 | ||
342 | 69 | virtual void get_progress(const std::string& package_name, | 69 | virtual void get_progress(const std::string& package_name, |
343 | 70 | const std::function<void (std::string)>& callback); | 70 | const std::function<void (std::string)>& callback); |
351 | 71 | virtual click::web::Cancellable start(const std::string& url, | 71 | virtual void start(const std::string& url, |
352 | 72 | const std::string& download_sha512, | 72 | const std::string& download_sha512, |
353 | 73 | const std::string& package_name, | 73 | const std::string& package_name, |
354 | 74 | const std::function<void (std::string, | 74 | const std::function<void (std::string, Error)>& callback); |
348 | 75 | Error)>& callback); | ||
349 | 76 | |||
350 | 77 | virtual void setCredentialsService(const QSharedPointer<click::CredentialsService>& credentialsService); | ||
355 | 78 | 75 | ||
356 | 79 | protected: | 76 | protected: |
357 | 80 | QSharedPointer<click::web::Client> client; | 77 | QSharedPointer<click::web::Client> client; |
358 | 81 | QSharedPointer<Ubuntu::DownloadManager::Manager> dm; | 78 | QSharedPointer<Ubuntu::DownloadManager::Manager> dm; |
359 | 82 | QSharedPointer<click::CredentialsService> sso; | ||
360 | 83 | }; | 79 | }; |
361 | 84 | 80 | ||
362 | 85 | } | 81 | } |
363 | 86 | 82 | ||
364 | === modified file 'libclickscope/click/index.cpp' | |||
365 | --- libclickscope/click/index.cpp 2016-04-26 10:56:47 +0000 | |||
366 | +++ libclickscope/click/index.cpp 2016-08-24 21:39:08 +0000 | |||
367 | @@ -123,6 +123,15 @@ | |||
368 | 123 | }; | 123 | }; |
369 | 124 | } | 124 | } |
370 | 125 | 125 | ||
371 | 126 | std::map<std::string, std::string> Index::add_snap_headers(const std::map<std::string, std::string>& headers) const | ||
372 | 127 | { | ||
373 | 128 | std::map<std::string, std::string> new_headers{headers}; | ||
374 | 129 | new_headers["X-Ubuntu-Series"] = "16"; // Need to get from snapd | ||
375 | 130 | new_headers["X-Ubuntu-Slots"] = "unity8"; // Only want unity8-using snaps | ||
376 | 131 | |||
377 | 132 | return new_headers; | ||
378 | 133 | } | ||
379 | 134 | |||
380 | 126 | std::pair<Packages, Packages> Index::package_lists_from_json(const std::string& json) | 135 | std::pair<Packages, Packages> Index::package_lists_from_json(const std::string& json) |
381 | 127 | { | 136 | { |
382 | 128 | Json::Reader reader; | 137 | Json::Reader reader; |
383 | @@ -147,6 +156,36 @@ | |||
384 | 147 | return std::pair<Packages, Packages>(pl, recommends); | 156 | return std::pair<Packages, Packages>(pl, recommends); |
385 | 148 | } | 157 | } |
386 | 149 | 158 | ||
387 | 159 | click::web::Cancellable Index::search_snaps(const std::string& query, | ||
388 | 160 | std::function<void(click::Packages search_results, click::Packages recommendations)> callback, | ||
389 | 161 | bool force_cache) | ||
390 | 162 | { | ||
391 | 163 | click::web::CallParams params; | ||
392 | 164 | auto built_query = build_index_query(query, "" /* No dept for snaps */); | ||
393 | 165 | params.add(click::QUERY_ARGNAME, built_query.c_str()); | ||
394 | 166 | |||
395 | 167 | auto headers = add_snap_headers(build_headers()); | ||
396 | 168 | |||
397 | 169 | QSharedPointer<click::web::Response> response | ||
398 | 170 | (client->call(get_base_url() + click::SNAP_SEARCH_PATH, | ||
399 | 171 | "GET", true, headers, "", params, force_cache)); | ||
400 | 172 | |||
401 | 173 | QObject::connect(response.data(), &click::web::Response::finished, [=](QString reply) { | ||
402 | 174 | std::pair<Packages, Packages> package_lists; | ||
403 | 175 | package_lists = package_lists_from_json(reply.toUtf8().constData()); | ||
404 | 176 | callback(package_lists.first, package_lists.second); | ||
405 | 177 | }); | ||
406 | 178 | QObject::connect(response.data(), &click::web::Response::error, [=](QString /*description*/) { | ||
407 | 179 | qDebug() << "No packages found due to network error"; | ||
408 | 180 | click::Packages pl; | ||
409 | 181 | click::Packages recommends; | ||
410 | 182 | qDebug() << "calling callback"; | ||
411 | 183 | callback(pl, recommends); | ||
412 | 184 | qDebug() << " ...Done!"; | ||
413 | 185 | }); | ||
414 | 186 | return click::web::Cancellable(response); | ||
415 | 187 | } | ||
416 | 188 | |||
417 | 150 | click::web::Cancellable Index::search (const std::string& query, const std::string& department, | 189 | click::web::Cancellable Index::search (const std::string& query, const std::string& department, |
418 | 151 | std::function<void(click::Packages search_results, click::Packages recommendations)> callback, | 190 | std::function<void(click::Packages search_results, click::Packages recommendations)> callback, |
419 | 152 | bool force_cache) | 191 | bool force_cache) |
420 | @@ -215,10 +254,21 @@ | |||
421 | 215 | return click::web::Cancellable(response); | 254 | return click::web::Cancellable(response); |
422 | 216 | } | 255 | } |
423 | 217 | 256 | ||
425 | 218 | click::web::Cancellable Index::get_details (const std::string& package_name, std::function<void(PackageDetails, click::Index::Error)> callback, bool force_cache) | 257 | click::web::Cancellable Index::get_details (const std::string& package_name, |
426 | 258 | std::function<void(PackageDetails, | ||
427 | 259 | click::Index::Error)> callback, | ||
428 | 260 | bool is_snap, | ||
429 | 261 | bool force_cache) | ||
430 | 219 | { | 262 | { |
431 | 263 | std::string details_path{click::DETAILS_PATH}; | ||
432 | 264 | auto headers = build_headers(); | ||
433 | 265 | if (is_snap) { | ||
434 | 266 | details_path = click::SNAP_DETAILS_PATH; | ||
435 | 267 | headers = add_snap_headers(headers); | ||
436 | 268 | } | ||
437 | 220 | QSharedPointer<click::web::Response> response = client->call | 269 | QSharedPointer<click::web::Response> response = client->call |
439 | 221 | (get_base_url() + click::DETAILS_PATH + package_name, | 270 | (get_base_url() + details_path + package_name, |
440 | 271 | "GET", true, headers, "", | ||
441 | 222 | click::web::CallParams(), | 272 | click::web::CallParams(), |
442 | 223 | force_cache); | 273 | force_cache); |
443 | 224 | qDebug() << "getting details for" << package_name.c_str(); | 274 | qDebug() << "getting details for" << package_name.c_str(); |
444 | 225 | 275 | ||
445 | === modified file 'libclickscope/click/index.h' | |||
446 | --- libclickscope/click/index.h 2016-04-26 10:56:47 +0000 | |||
447 | +++ libclickscope/click/index.h 2016-08-24 21:39:08 +0000 | |||
448 | @@ -1,5 +1,5 @@ | |||
449 | 1 | /* | 1 | /* |
451 | 2 | * Copyright (C) 2014 Canonical Ltd. | 2 | * Copyright (C) 2014-2016 Canonical Ltd. |
452 | 3 | * | 3 | * |
453 | 4 | * This program is free software: you can redistribute it and/or modify it | 4 | * This program is free software: you can redistribute it and/or modify it |
454 | 5 | * under the terms of the GNU General Public License version 3, as published | 5 | * under the terms of the GNU General Public License version 3, as published |
455 | @@ -49,11 +49,13 @@ | |||
456 | 49 | const std::string SEARCH_BASE_URL_ENVVAR = "U1_SEARCH_BASE_URL"; | 49 | const std::string SEARCH_BASE_URL_ENVVAR = "U1_SEARCH_BASE_URL"; |
457 | 50 | const std::string SEARCH_BASE_URL = "https://search.apps.ubuntu.com/"; | 50 | const std::string SEARCH_BASE_URL = "https://search.apps.ubuntu.com/"; |
458 | 51 | const std::string SEARCH_PATH = "api/v1/search"; | 51 | const std::string SEARCH_PATH = "api/v1/search"; |
459 | 52 | const std::string SNAP_SEARCH_PATH = "api/v1/snaps/search"; | ||
460 | 52 | const std::string BOOTSTRAP_PATH = "api/v1"; | 53 | const std::string BOOTSTRAP_PATH = "api/v1"; |
461 | 53 | const std::string SUPPORTED_FRAMEWORKS = "framework:ubuntu-sdk-13.10"; | 54 | const std::string SUPPORTED_FRAMEWORKS = "framework:ubuntu-sdk-13.10"; |
462 | 54 | const std::string QUERY_ARGNAME = "q"; | 55 | const std::string QUERY_ARGNAME = "q"; |
463 | 55 | const std::string ARCHITECTURE = "architecture:"; | 56 | const std::string ARCHITECTURE = "architecture:"; |
464 | 56 | const std::string DETAILS_PATH = "api/v1/package/"; | 57 | const std::string DETAILS_PATH = "api/v1/package/"; |
465 | 58 | const std::string SNAP_DETAILS_PATH = "api/v1/snaps/details/"; | ||
466 | 57 | const std::string CURRENCY_HEADER = "X-Suggested-Currency"; | 59 | const std::string CURRENCY_HEADER = "X-Suggested-Currency"; |
467 | 58 | 60 | ||
468 | 59 | class PackageManager | 61 | class PackageManager |
469 | @@ -72,6 +74,7 @@ | |||
470 | 72 | std::string m_suggested_currency; | 74 | std::string m_suggested_currency; |
471 | 73 | virtual std::string build_index_query(const std::string& query, const std::string& department); | 75 | virtual std::string build_index_query(const std::string& query, const std::string& department); |
472 | 74 | virtual std::map<std::string, std::string> build_headers(); | 76 | virtual std::map<std::string, std::string> build_headers(); |
473 | 77 | virtual std::map<std::string, std::string> add_snap_headers(const std::map<std::string, std::string>& headers) const; | ||
474 | 75 | 78 | ||
475 | 76 | public: | 79 | public: |
476 | 77 | enum class Error {NoError, CredentialsError, NetworkError}; | 80 | enum class Error {NoError, CredentialsError, NetworkError}; |
477 | @@ -79,9 +82,15 @@ | |||
478 | 79 | Index(const QSharedPointer<click::web::Client>& client, | 82 | Index(const QSharedPointer<click::web::Client>& client, |
479 | 80 | const QSharedPointer<Configuration> configuration=QSharedPointer<Configuration>(new Configuration())); | 83 | const QSharedPointer<Configuration> configuration=QSharedPointer<Configuration>(new Configuration())); |
480 | 81 | virtual std::pair<Packages, Packages> package_lists_from_json(const std::string& json); | 84 | virtual std::pair<Packages, Packages> package_lists_from_json(const std::string& json); |
481 | 85 | virtual click::web::Cancellable search_snaps(const std::string& query, | ||
482 | 86 | std::function<void(click::Packages search_results, click::Packages recommendations)> callback, | ||
483 | 87 | bool force_cache = false); | ||
484 | 82 | virtual click::web::Cancellable search (const std::string& query, const std::string& department, std::function<void(Packages, Packages)> callback, bool | 88 | virtual click::web::Cancellable search (const std::string& query, const std::string& department, std::function<void(Packages, Packages)> callback, bool |
485 | 83 | force_cache = false); | 89 | force_cache = false); |
487 | 84 | virtual click::web::Cancellable get_details(const std::string& package_name, std::function<void(PackageDetails, Error)> callback, bool force_cache = false); | 90 | virtual click::web::Cancellable get_details(const std::string& package_name, |
488 | 91 | std::function<void(PackageDetails, Error)> callback, | ||
489 | 92 | bool is_snap = false, | ||
490 | 93 | bool force_cache = false); | ||
491 | 85 | virtual click::web::Cancellable bootstrap(std::function<void(const DepartmentList&, const HighlightList&, Error, int)> callback, bool force_cache = false); | 94 | virtual click::web::Cancellable bootstrap(std::function<void(const DepartmentList&, const HighlightList&, Error, int)> callback, bool force_cache = false); |
492 | 86 | virtual click::web::Cancellable departments(const std::string& department_href, std::function<void(const DepartmentList&, const HighlightList&, Error, int)> | 95 | virtual click::web::Cancellable departments(const std::string& department_href, std::function<void(const DepartmentList&, const HighlightList&, Error, int)> |
493 | 87 | callback, bool force_cache = false); | 96 | callback, bool force_cache = false); |
494 | 88 | 97 | ||
495 | === modified file 'libclickscope/click/interface.cpp' | |||
496 | --- libclickscope/click/interface.cpp 2016-07-14 18:37:27 +0000 | |||
497 | +++ libclickscope/click/interface.cpp 2016-08-24 21:39:08 +0000 | |||
498 | @@ -1,5 +1,5 @@ | |||
499 | 1 | /* | 1 | /* |
501 | 2 | * Copyright (C) 2014 Canonical Ltd. | 2 | * Copyright (C) 2014-2016 Canonical Ltd. |
502 | 3 | * | 3 | * |
503 | 4 | * This program is free software: you can redistribute it and/or modify it | 4 | * This program is free software: you can redistribute it and/or modify it |
504 | 5 | * under the terms of the GNU General Public License version 3, as published | 5 | * under the terms of the GNU General Public License version 3, as published |
505 | @@ -27,6 +27,10 @@ | |||
506 | 27 | * files in the program, then also delete it here. | 27 | * files in the program, then also delete it here. |
507 | 28 | */ | 28 | */ |
508 | 29 | 29 | ||
509 | 30 | #include <click.h> | ||
510 | 31 | |||
511 | 32 | #include "interface.h" | ||
512 | 33 | |||
513 | 30 | #include <QDebug> | 34 | #include <QDebug> |
514 | 31 | #include <QDir> | 35 | #include <QDir> |
515 | 32 | #include <QProcess> | 36 | #include <QProcess> |
516 | @@ -51,12 +55,15 @@ | |||
517 | 51 | #include <unity/UnityExceptions.h> | 55 | #include <unity/UnityExceptions.h> |
518 | 52 | #include <unity/util/IniParser.h> | 56 | #include <unity/util/IniParser.h> |
519 | 53 | 57 | ||
520 | 54 | #include "interface.h" | ||
521 | 55 | #include <click/key_file_locator.h> | ||
522 | 56 | #include <click/departments-db.h> | 58 | #include <click/departments-db.h> |
523 | 57 | 59 | ||
524 | 60 | #include <ubuntu-app-launch/registry.h> | ||
525 | 61 | |||
526 | 58 | #include <click/click-i18n.h> | 62 | #include <click/click-i18n.h> |
527 | 59 | 63 | ||
528 | 64 | using namespace ubuntu::app_launch; | ||
529 | 65 | namespace ual = ubuntu::app_launch; | ||
530 | 66 | |||
531 | 60 | namespace { | 67 | namespace { |
532 | 61 | 68 | ||
533 | 62 | /* Thanks to | 69 | /* Thanks to |
534 | @@ -122,114 +129,6 @@ | |||
535 | 122 | static const std::string DESKTOP_FILE_ONLYSHOWIN("OnlyShowIn"); | 129 | static const std::string DESKTOP_FILE_ONLYSHOWIN("OnlyShowIn"); |
536 | 123 | static const std::string ONLYSHOWIN_UNITY("Unity"); | 130 | static const std::string ONLYSHOWIN_UNITY("Unity"); |
537 | 124 | 131 | ||
538 | 125 | Interface::Interface(const QSharedPointer<click::KeyFileLocator>& keyFileLocator) | ||
539 | 126 | : keyFileLocator(keyFileLocator) | ||
540 | 127 | { | ||
541 | 128 | } | ||
542 | 129 | |||
543 | 130 | Interface::~Interface() | ||
544 | 131 | { | ||
545 | 132 | } | ||
546 | 133 | |||
547 | 134 | bool Interface::show_desktop_apps() | ||
548 | 135 | { | ||
549 | 136 | return getenv(ENV_SHOW_DESKTOP_APPS) != nullptr; | ||
550 | 137 | } | ||
551 | 138 | |||
552 | 139 | bool Interface::is_visible_app(const unity::util::IniParser &keyFile) | ||
553 | 140 | { | ||
554 | 141 | if (keyFile.has_key(DESKTOP_FILE_GROUP, DESKTOP_FILE_NODISPLAY)) { | ||
555 | 142 | auto val = keyFile.get_string(DESKTOP_FILE_GROUP, DESKTOP_FILE_NODISPLAY); | ||
556 | 143 | if (val == std::string("true")) { | ||
557 | 144 | return false; | ||
558 | 145 | } | ||
559 | 146 | } | ||
560 | 147 | |||
561 | 148 | if (keyFile.has_key(DESKTOP_FILE_GROUP, DESKTOP_FILE_ONLYSHOWIN)) { | ||
562 | 149 | auto value = keyFile.get_string(DESKTOP_FILE_GROUP, DESKTOP_FILE_ONLYSHOWIN); | ||
563 | 150 | std::stringstream ss(value); | ||
564 | 151 | std::string item; | ||
565 | 152 | |||
566 | 153 | while (std::getline(ss, item, ';')) { | ||
567 | 154 | if (item == ONLYSHOWIN_UNITY) { | ||
568 | 155 | return true; | ||
569 | 156 | } | ||
570 | 157 | } | ||
571 | 158 | return false; | ||
572 | 159 | } | ||
573 | 160 | |||
574 | 161 | return true; | ||
575 | 162 | } | ||
576 | 163 | |||
577 | 164 | std::string Interface::get_translated_string(const unity::util::IniParser& keyFile, | ||
578 | 165 | const std::string& group, | ||
579 | 166 | const std::string& key, | ||
580 | 167 | const std::string& domain) | ||
581 | 168 | { | ||
582 | 169 | std::string language = Configuration().get_language(); | ||
583 | 170 | if (!domain.empty()) { | ||
584 | 171 | return dgettext(domain.c_str(), | ||
585 | 172 | keyFile.get_string(group, key).c_str()); | ||
586 | 173 | } else { | ||
587 | 174 | return keyFile.get_locale_string(group, key, language); | ||
588 | 175 | } | ||
589 | 176 | } | ||
590 | 177 | |||
591 | 178 | click::Application Interface::load_app_from_desktop(const unity::util::IniParser& keyFile, | ||
592 | 179 | const std::string& filename) | ||
593 | 180 | { | ||
594 | 181 | Application app; | ||
595 | 182 | std::string domain; | ||
596 | 183 | if (keyFile.has_key(DESKTOP_FILE_GROUP, DESKTOP_FILE_KEY_DOMAIN)) { | ||
597 | 184 | domain = keyFile.get_string(DESKTOP_FILE_GROUP, | ||
598 | 185 | DESKTOP_FILE_KEY_DOMAIN); | ||
599 | 186 | } | ||
600 | 187 | app.title = get_translated_string(keyFile, | ||
601 | 188 | DESKTOP_FILE_GROUP, | ||
602 | 189 | DESKTOP_FILE_KEY_NAME, | ||
603 | 190 | domain); | ||
604 | 191 | |||
605 | 192 | app.url = "application:///" + filename; | ||
606 | 193 | if (keyFile.has_key(DESKTOP_FILE_GROUP, DESKTOP_FILE_KEY_ICON)) { | ||
607 | 194 | app.icon_url = add_theme_scheme(keyFile.get_string(DESKTOP_FILE_GROUP, | ||
608 | 195 | DESKTOP_FILE_KEY_ICON)); | ||
609 | 196 | } | ||
610 | 197 | |||
611 | 198 | if (keyFile.has_key(DESKTOP_FILE_GROUP, DESKTOP_FILE_KEY_KEYWORDS)) { | ||
612 | 199 | app.keywords = keyFile.get_string_array(DESKTOP_FILE_GROUP, | ||
613 | 200 | DESKTOP_FILE_KEY_KEYWORDS); | ||
614 | 201 | } | ||
615 | 202 | |||
616 | 203 | if (keyFile.has_key(DESKTOP_FILE_GROUP, DESKTOP_FILE_UBUNTU_DEFAULT_DEPARTMENT)) { | ||
617 | 204 | app.default_department = keyFile.get_string(DESKTOP_FILE_GROUP, DESKTOP_FILE_UBUNTU_DEFAULT_DEPARTMENT); | ||
618 | 205 | } | ||
619 | 206 | |||
620 | 207 | if (keyFile.has_key(DESKTOP_FILE_GROUP, DESKTOP_FILE_KEY_APP_ID)) { | ||
621 | 208 | QString app_id = QString::fromStdString(keyFile.get_string( | ||
622 | 209 | DESKTOP_FILE_GROUP, | ||
623 | 210 | DESKTOP_FILE_KEY_APP_ID)); | ||
624 | 211 | QStringList id = app_id.split("_", QString::SkipEmptyParts); | ||
625 | 212 | if (id.length() == 3) { | ||
626 | 213 | app.name = id[0].toUtf8().data(); | ||
627 | 214 | app.version = id[2].toUtf8().data(); | ||
628 | 215 | app.url = "appid://" + id[0].toStdString() + "/" + id[1].toStdString() + "/current-user-version"; | ||
629 | 216 | } else { | ||
630 | 217 | app.name = "unknown"; | ||
631 | 218 | app.version = "unknown"; | ||
632 | 219 | } | ||
633 | 220 | } | ||
634 | 221 | if (keyFile.has_key(DESKTOP_FILE_GROUP, DESKTOP_FILE_COMMENT)) { | ||
635 | 222 | app.description = get_translated_string(keyFile, | ||
636 | 223 | DESKTOP_FILE_GROUP, | ||
637 | 224 | DESKTOP_FILE_COMMENT, | ||
638 | 225 | domain); | ||
639 | 226 | } | ||
640 | 227 | if (keyFile.has_key(DESKTOP_FILE_GROUP, DESKTOP_FILE_SCREENSHOT)) { | ||
641 | 228 | app.main_screenshot = keyFile.get_string(DESKTOP_FILE_GROUP, | ||
642 | 229 | DESKTOP_FILE_SCREENSHOT); | ||
643 | 230 | } | ||
644 | 231 | return app; | ||
645 | 232 | } | ||
646 | 233 | 132 | ||
647 | 234 | std::vector<click::Application> Interface::sort_apps(const std::vector<click::Application>& apps) | 133 | std::vector<click::Application> Interface::sort_apps(const std::vector<click::Application>& apps) |
648 | 235 | { | 134 | { |
649 | @@ -264,11 +163,16 @@ | |||
650 | 264 | return result; | 163 | return result; |
651 | 265 | } | 164 | } |
652 | 266 | 165 | ||
654 | 267 | /* find_installed_apps() | 166 | std::list<std::shared_ptr<ual::Application>> Interface::installed_apps() |
655 | 167 | { | ||
656 | 168 | return ual::Registry::installedApps(); | ||
657 | 169 | } | ||
658 | 170 | |||
659 | 171 | /* search() | ||
660 | 268 | * | 172 | * |
662 | 269 | * Find all of the installed apps matching @search_query in a timeout. | 173 | * Find all of the installed apps matching @query in a timeout. |
663 | 270 | */ | 174 | */ |
665 | 271 | std::vector<click::Application> Interface::find_installed_apps(const std::string& search_query, | 175 | std::vector<click::Application> Interface::search(const std::string& query, |
666 | 272 | const std::vector<std::string>& ignored_apps, | 176 | const std::vector<std::string>& ignored_apps, |
667 | 273 | const std::string& current_department, | 177 | const std::string& current_department, |
668 | 274 | const std::shared_ptr<click::DepartmentsDb>& depts_db) | 178 | const std::shared_ptr<click::DepartmentsDb>& depts_db) |
669 | @@ -292,118 +196,109 @@ | |||
670 | 292 | } | 196 | } |
671 | 293 | } | 197 | } |
672 | 294 | 198 | ||
760 | 295 | std::vector<Application> result; | 199 | std::vector<click::Application> result; |
761 | 296 | 200 | ||
762 | 297 | bool include_desktop_results = show_desktop_apps(); | 201 | for (auto ualapp: installed_apps()) { |
763 | 298 | auto enumerator = [&result, this, search_query, ignored_apps, current_department, packages_in_department, apply_department_filter, include_desktop_results, depts_db] | 202 | click::Application app; |
764 | 299 | (const unity::util::IniParser& keyFile, const std::string& filename) | 203 | |
765 | 300 | { | 204 | // Get the package name and APP_ID info. |
766 | 301 | if (keyFile.has_group(DESKTOP_FILE_GROUP) == false) { | 205 | app.name = ualapp->appId().package.value(); |
767 | 302 | qWarning() << "Broken desktop file:" << QString::fromStdString(filename); | 206 | if (app.name.empty()) { |
768 | 303 | return; | 207 | app.name = std::string{ualapp->appId().appname.value()} + ".desktop"; |
769 | 304 | } | 208 | app.url = "application:///" + app.name; |
770 | 305 | if (is_visible_app(keyFile) == false) { | 209 | if (!is_non_click_app(app.name)) { |
771 | 306 | return; // from the enumerator lambda | 210 | qDebug() << "Skipping legacy app:" << QString::fromStdString(app.name); |
772 | 307 | } | 211 | continue; |
773 | 308 | 212 | } | |
774 | 309 | if (include_desktop_results || keyFile.has_key(DESKTOP_FILE_GROUP, DESKTOP_FILE_UBUNTU_TOUCH) | 213 | } else { |
775 | 310 | || keyFile.has_key(DESKTOP_FILE_GROUP, DESKTOP_FILE_KEY_APP_ID) | 214 | app.url = "appid://" + app.name + "/" + ualapp->appId().appname.value() + "/current-user-version"; |
776 | 311 | || Interface::is_non_click_app(QString::fromStdString(filename))) { | 215 | } |
777 | 312 | auto app = load_app_from_desktop(keyFile, filename); | 216 | |
778 | 313 | auto app_id = app.name.empty() ? filename : app.name; | 217 | if (!ignored_apps.empty() && |
779 | 314 | if (!ignored_apps.empty() && | 218 | std::find(ignored_apps.begin(), ignored_apps.end(), |
780 | 315 | std::find(ignored_apps.begin(), ignored_apps.end(), | 219 | app.name) != ignored_apps.end()) { |
781 | 316 | app_id) != ignored_apps.end()) | 220 | // The app is ignored. Get out of here. |
782 | 317 | { | 221 | qDebug() << "App is ignored, skipping:" << QString::fromStdString(app.name); |
783 | 318 | // The app is ignored. Get out of here. | 222 | continue; |
784 | 319 | return; | 223 | } |
785 | 320 | } | 224 | |
786 | 321 | 225 | // Get the .desktop file info from UAL, since we're not ignoring | |
787 | 322 | // app from click package has non-empty name; for non-click apps use desktop filename | 226 | auto appinfo = ualapp->info(); |
788 | 323 | const std::string department_key = app.name.empty() ? filename : app.name; | 227 | app.title = appinfo->name(); |
789 | 324 | 228 | app.description = appinfo->description(); | |
790 | 325 | // check if apps is present in current department | 229 | app.icon_url = appinfo->iconPath(); |
791 | 326 | if (apply_department_filter) | 230 | app.default_department = appinfo->defaultDepartment(); |
792 | 327 | { | 231 | app.main_screenshot = appinfo->screenshotPath(); |
793 | 328 | if (packages_in_department.find(department_key) == packages_in_department.end()) | 232 | app.keywords = appinfo->keywords(); |
794 | 329 | { | 233 | |
795 | 330 | if (app.default_department.empty()) | 234 | // app from click package has non-empty name; for non-click apps use desktop filename |
796 | 331 | { | 235 | auto department_key = app.name; |
797 | 332 | // default department not present in the keyfile, skip this app | 236 | qDebug() << "Using department key:" << QString::fromStdString(department_key); |
798 | 333 | return; | 237 | |
799 | 334 | } | 238 | // check if apps is present in current department |
800 | 335 | else | 239 | if (apply_department_filter) { |
801 | 336 | { | 240 | if (packages_in_department.find(department_key) == |
802 | 337 | // default department not empty: check if this app is in a different | 241 | packages_in_department.end()) { |
803 | 338 | // department in the db (i.e. got moved from the default department); | 242 | if (app.default_department.empty()) { |
804 | 339 | if (depts_db->has_package(department_key)) | 243 | // default department not present in the keyfile, skip this app |
805 | 340 | { | 244 | continue; |
806 | 341 | // app is now in a different department | 245 | } else { |
807 | 342 | return; | 246 | // default department not empty: check if this app is in a different |
808 | 343 | } | 247 | // department in the db (i.e. got moved from the default department); |
809 | 344 | 248 | if (depts_db->has_package(department_key)) { | |
810 | 345 | if (app.default_department != current_department) | 249 | // app is now in a different department |
811 | 346 | { | 250 | continue; |
812 | 347 | return; | 251 | } |
813 | 348 | } | 252 | |
814 | 349 | // else - this package is in current department | 253 | if (app.default_department != current_department) { |
815 | 350 | } | 254 | continue; |
816 | 351 | } | 255 | } |
817 | 352 | } | 256 | // else - this package is in current department |
818 | 353 | 257 | } | |
819 | 354 | // | 258 | } |
820 | 355 | // the packages_in_department set contains packages from | 259 | } |
821 | 356 | // all its subdepartments; we need to find actual department now | 260 | |
822 | 357 | // to update app.real_department. | 261 | // the packages_in_department set contains packages from |
823 | 358 | if (depts_db) | 262 | // all its subdepartments; we need to find actual department now |
824 | 359 | { | 263 | // to update app.real_department. |
825 | 360 | if (depts_db->has_package(department_key)) | 264 | if (depts_db) { |
826 | 361 | { | 265 | if (depts_db->has_package(department_key)) { |
827 | 362 | try | 266 | try { |
828 | 363 | { | 267 | app.real_department = depts_db->get_department_for_package(department_key); |
829 | 364 | app.real_department = depts_db->get_department_for_package(department_key); | 268 | } catch (const std::exception &e) { |
830 | 365 | } | 269 | qWarning() << "Failed to get department of package:" << QString::fromStdString(department_key); |
831 | 366 | catch (const std::exception &e) | 270 | } |
832 | 367 | { | 271 | } else { |
833 | 368 | qWarning() << "Failed to get department of package:" << QString::fromStdString(department_key); | 272 | app.real_department = app.default_department; |
834 | 369 | } | 273 | if (app.real_department.empty()) { |
835 | 370 | } | 274 | qWarning() << "No default department set in the .desktop file and no entry in the database for" << QString::fromStdString(department_key); |
836 | 371 | else | 275 | } |
837 | 372 | { | 276 | } |
838 | 373 | app.real_department = app.default_department; | 277 | } |
839 | 374 | if (app.real_department.empty()) | 278 | |
840 | 375 | { | 279 | if (query.empty()) { |
841 | 376 | qWarning() << "No default department set in the .desktop file and no entry in the database for" << QString::fromStdString(department_key); | 280 | result.push_back(app); |
842 | 377 | } | 281 | } else { |
843 | 378 | } | 282 | QString lquery = ::unaccent(QString::fromStdString(query)); |
844 | 379 | } | 283 | |
845 | 380 | 284 | // Check keywords for the search query as well. | |
846 | 381 | if (search_query.empty()) { | 285 | for (auto kwd: app.keywords) { |
847 | 286 | QString keyword = ::unaccent(QString::fromStdString(kwd)); | ||
848 | 287 | if (!keyword.isEmpty() | ||
849 | 288 | && keyword.contains(lquery, Qt::CaseInsensitive)) { | ||
850 | 289 | result.push_back(app); | ||
851 | 290 | } | ||
852 | 291 | } | ||
853 | 292 | |||
854 | 293 | QString search_title = ::unaccent(QString::fromStdString(app.title)); | ||
855 | 294 | // check the app title for the search query. | ||
856 | 295 | if (!search_title.isEmpty() | ||
857 | 296 | && search_title.contains(lquery, Qt::CaseInsensitive)) { | ||
858 | 382 | result.push_back(app); | 297 | result.push_back(app); |
859 | 383 | } else { | ||
860 | 384 | QString lquery = ::unaccent(QString::fromStdString(search_query)); | ||
861 | 385 | |||
862 | 386 | // Check keywords for the search query as well. | ||
863 | 387 | for (auto kwd: app.keywords) { | ||
864 | 388 | QString keyword = ::unaccent(QString::fromStdString(kwd)); | ||
865 | 389 | if (!keyword.isEmpty() | ||
866 | 390 | && keyword.contains(lquery, Qt::CaseInsensitive)) { | ||
867 | 391 | result.push_back(app); | ||
868 | 392 | return; | ||
869 | 393 | } | ||
870 | 394 | } | ||
871 | 395 | |||
872 | 396 | QString search_title = ::unaccent(QString::fromStdString(app.title)); | ||
873 | 397 | // check the app title for the search query. | ||
874 | 398 | if (!search_title.isEmpty() | ||
875 | 399 | && search_title.contains(lquery, Qt::CaseInsensitive)) { | ||
876 | 400 | result.push_back(app); | ||
877 | 401 | } | ||
878 | 402 | } | 298 | } |
879 | 403 | } | 299 | } |
881 | 404 | }; | 300 | } |
882 | 405 | 301 | ||
883 | 406 | keyFileLocator->enumerateKeyFilesForInstalledApplications(enumerator); | ||
884 | 407 | return sort_apps(result); | 302 | return sort_apps(result); |
885 | 408 | } | 303 | } |
886 | 409 | 304 | ||
887 | @@ -412,9 +307,9 @@ | |||
888 | 412 | * Tests that @filename is one of the special-cased filenames for apps | 307 | * Tests that @filename is one of the special-cased filenames for apps |
889 | 413 | * which are not packaged as clicks, but required on Ubuntu Touch. | 308 | * which are not packaged as clicks, but required on Ubuntu Touch. |
890 | 414 | */ | 309 | */ |
892 | 415 | bool Interface::is_non_click_app(const QString& filename) | 310 | bool Interface::is_non_click_app(const std::string& app_id) |
893 | 416 | { | 311 | { |
895 | 417 | return click::nonClickDesktopFiles().count(filename.toUtf8().data()) > 0; | 312 | return click::nonClickDesktopFiles().count(app_id) > 0; |
896 | 418 | } | 313 | } |
897 | 419 | 314 | ||
898 | 420 | /* | 315 | /* |
899 | @@ -440,42 +335,6 @@ | |||
900 | 440 | return icon_id; | 335 | return icon_id; |
901 | 441 | } | 336 | } |
902 | 442 | 337 | ||
903 | 443 | ManifestList manifest_list_from_json(const std::string& json) | ||
904 | 444 | { | ||
905 | 445 | using namespace boost::property_tree; | ||
906 | 446 | |||
907 | 447 | std::istringstream is(json); | ||
908 | 448 | |||
909 | 449 | ptree pt; | ||
910 | 450 | read_json(is, pt); | ||
911 | 451 | |||
912 | 452 | ManifestList manifests; | ||
913 | 453 | |||
914 | 454 | BOOST_FOREACH(ptree::value_type &v, pt) | ||
915 | 455 | { | ||
916 | 456 | assert(v.first.empty()); // array elements have no names | ||
917 | 457 | auto node = v.second; | ||
918 | 458 | Manifest manifest; | ||
919 | 459 | |||
920 | 460 | manifest.name = node.get<std::string>("name"); | ||
921 | 461 | manifest.version = node.get<std::string>("version"); | ||
922 | 462 | manifest.removable = node.get<bool>("_removable"); | ||
923 | 463 | |||
924 | 464 | BOOST_FOREACH(ptree::value_type &sv, node.get_child("hooks")) | ||
925 | 465 | { | ||
926 | 466 | // FIXME: "primary app" for a package is not defined, we just | ||
927 | 467 | // use first one here: | ||
928 | 468 | manifest.first_app_name = sv.first; | ||
929 | 469 | break; | ||
930 | 470 | } | ||
931 | 471 | qDebug() << "adding manifest: " << manifest.name.c_str() << manifest.version.c_str() << manifest.first_app_name.c_str(); | ||
932 | 472 | |||
933 | 473 | manifests.push_back(manifest); | ||
934 | 474 | } | ||
935 | 475 | |||
936 | 476 | return manifests; | ||
937 | 477 | } | ||
938 | 478 | |||
939 | 479 | Manifest manifest_from_json(const std::string& json) | 338 | Manifest manifest_from_json(const std::string& json) |
940 | 480 | { | 339 | { |
941 | 481 | using namespace boost::property_tree; | 340 | using namespace boost::property_tree; |
942 | @@ -509,124 +368,62 @@ | |||
943 | 509 | return manifest; | 368 | return manifest; |
944 | 510 | } | 369 | } |
945 | 511 | 370 | ||
946 | 512 | void Interface::get_manifests(std::function<void(ManifestList, InterfaceError)> callback) | ||
947 | 513 | { | ||
948 | 514 | std::string command = "click list --manifest"; | ||
949 | 515 | qDebug() << "Running command:" << command.c_str(); | ||
950 | 516 | run_process(command, [callback](int code, const std::string& stdout_data, const std::string& stderr_data) { | ||
951 | 517 | if (code == 0) { | ||
952 | 518 | try { | ||
953 | 519 | ManifestList manifests = manifest_list_from_json(stdout_data); | ||
954 | 520 | callback(manifests, InterfaceError::NoError); | ||
955 | 521 | } catch (...) { | ||
956 | 522 | qWarning() << "Can't parse 'click list --manifest' output: " << QString::fromStdString(stdout_data); | ||
957 | 523 | callback(ManifestList(), InterfaceError::ParseError); | ||
958 | 524 | } | ||
959 | 525 | } else { | ||
960 | 526 | qWarning() << "Error" << code << "running 'click list --manifest': " << QString::fromStdString(stderr_data); | ||
961 | 527 | callback(ManifestList(), InterfaceError::CallError); | ||
962 | 528 | } | ||
963 | 529 | }); | ||
964 | 530 | } | ||
965 | 531 | |||
966 | 532 | PackageSet package_names_from_stdout(const std::string& stdout_data) | ||
967 | 533 | { | ||
968 | 534 | const char TAB='\t', NEWLINE='\n'; | ||
969 | 535 | std::istringstream iss(stdout_data); | ||
970 | 536 | PackageSet installed_packages; | ||
971 | 537 | |||
972 | 538 | while (iss.peek() != EOF) { | ||
973 | 539 | std::string line; | ||
974 | 540 | std::getline(iss, line, NEWLINE); | ||
975 | 541 | |||
976 | 542 | if (!line.empty()) { | ||
977 | 543 | // Must initialize linestream after line is filled. | ||
978 | 544 | std::istringstream linestream(line); | ||
979 | 545 | |||
980 | 546 | Package p; | ||
981 | 547 | std::getline(linestream, p.name, TAB); | ||
982 | 548 | std::getline(linestream, p.version); | ||
983 | 549 | if (iss.eof() || p.name.empty() || p.version.empty()) { | ||
984 | 550 | qWarning() << "Error encountered parsing 'click list' output:" << QString::fromStdString(line); | ||
985 | 551 | } else { | ||
986 | 552 | installed_packages.insert(p); | ||
987 | 553 | } | ||
988 | 554 | } | ||
989 | 555 | } | ||
990 | 556 | |||
991 | 557 | return installed_packages; | ||
992 | 558 | } | ||
993 | 559 | |||
994 | 560 | void Interface::get_installed_packages(std::function<void(PackageSet, InterfaceError)> callback) | 371 | void Interface::get_installed_packages(std::function<void(PackageSet, InterfaceError)> callback) |
995 | 561 | { | 372 | { |
1010 | 562 | std::string command = "click list"; | 373 | PackageSet packages; |
1011 | 563 | qDebug() << "Running command:" << command.c_str(); | 374 | for (auto app: installed_apps()) { |
1012 | 564 | run_process(command, [callback](int code, const std::string& stdout_data, const std::string& stderr_data) { | 375 | Package p; |
1013 | 565 | if (code == 0) { | 376 | p.name = app->appId().package.value(); |
1014 | 566 | try { | 377 | p.version = app->appId().version.value(); |
1015 | 567 | PackageSet package_names = package_names_from_stdout(stdout_data); | 378 | if (!p.name.empty() && !p.version.empty()) { |
1016 | 568 | callback(package_names, InterfaceError::NoError); | 379 | packages.insert(p); |
1003 | 569 | } catch (...) { | ||
1004 | 570 | qWarning() << "Can't parse 'click list' output: " << QString::fromStdString(stdout_data); | ||
1005 | 571 | callback(PackageSet(), InterfaceError::ParseError); | ||
1006 | 572 | } | ||
1007 | 573 | } else { | ||
1008 | 574 | qWarning() << "Error" << code << "running 'click list': " << QString::fromStdString(stderr_data); | ||
1009 | 575 | callback(PackageSet(), InterfaceError::CallError); | ||
1017 | 576 | } | 380 | } |
1019 | 577 | }); | 381 | } |
1020 | 382 | callback(packages, InterfaceError::NoError); | ||
1021 | 383 | } | ||
1022 | 384 | |||
1023 | 385 | std::string Interface::get_manifest_json(const std::string &package) | ||
1024 | 386 | { | ||
1025 | 387 | GError* error = NULL; | ||
1026 | 388 | |||
1027 | 389 | auto clickdb = click_db_new(); | ||
1028 | 390 | click_db_read(clickdb, NULL, &error); | ||
1029 | 391 | if (error != NULL) { | ||
1030 | 392 | qCritical() << "Error reading click DB:" << error->message; | ||
1031 | 393 | g_error_free(error); | ||
1032 | 394 | return ""; | ||
1033 | 395 | } | ||
1034 | 396 | |||
1035 | 397 | auto clickuser = click_user_new_for_user(clickdb, NULL, &error); | ||
1036 | 398 | if (error != NULL) { | ||
1037 | 399 | qCritical() << "Error setting up click user:" << error->message; | ||
1038 | 400 | g_error_free(error); | ||
1039 | 401 | return ""; | ||
1040 | 402 | } | ||
1041 | 403 | |||
1042 | 404 | auto result = click_user_get_manifest_as_string(clickuser, package.c_str(), | ||
1043 | 405 | &error); | ||
1044 | 406 | if (error != NULL) { | ||
1045 | 407 | qCritical() << "Error getting manifest:" << error->message; | ||
1046 | 408 | g_error_free(error); | ||
1047 | 409 | return ""; | ||
1048 | 410 | } | ||
1049 | 411 | |||
1050 | 412 | std::string retval{result}; | ||
1051 | 413 | g_free(result); | ||
1052 | 414 | return retval; | ||
1053 | 578 | } | 415 | } |
1054 | 579 | 416 | ||
1055 | 580 | void Interface::get_manifest_for_app(const std::string &app_id, | 417 | void Interface::get_manifest_for_app(const std::string &app_id, |
1056 | 581 | std::function<void(Manifest, InterfaceError)> callback) | 418 | std::function<void(Manifest, InterfaceError)> callback) |
1057 | 582 | { | 419 | { |
1105 | 583 | std::string command = "click info " + app_id; | 420 | try { |
1106 | 584 | qDebug() << "Running command:" << command.c_str(); | 421 | Manifest manifest = manifest_from_json(get_manifest_json(app_id)); |
1107 | 585 | run_process(command, [callback, app_id](int code, const std::string& stdout_data, const std::string& stderr_data) { | 422 | callback(manifest, InterfaceError::NoError); |
1108 | 586 | if (code == 0) { | 423 | } catch (...) { |
1109 | 587 | try { | 424 | qWarning() << "Can't parse manifest for:" << QString::fromStdString(app_id); |
1110 | 588 | Manifest manifest = manifest_from_json(stdout_data); | 425 | callback(Manifest(), InterfaceError::ParseError); |
1111 | 589 | callback(manifest, InterfaceError::NoError); | 426 | } |
1065 | 590 | } catch (...) { | ||
1066 | 591 | qWarning() << "Can't parse 'click info" << QString::fromStdString(app_id) | ||
1067 | 592 | << "' output: " << QString::fromStdString(stdout_data); | ||
1068 | 593 | callback(Manifest(), InterfaceError::ParseError); | ||
1069 | 594 | } | ||
1070 | 595 | } else { | ||
1071 | 596 | qWarning() << "Error" << code << "running 'click info" << QString::fromStdString(app_id) | ||
1072 | 597 | << "': " << QString::fromStdString(stderr_data); | ||
1073 | 598 | callback(Manifest(), InterfaceError::CallError); | ||
1074 | 599 | } | ||
1075 | 600 | }); | ||
1076 | 601 | } | ||
1077 | 602 | |||
1078 | 603 | void Interface::run_process(const std::string& command, | ||
1079 | 604 | std::function<void(int code, | ||
1080 | 605 | const std::string& stdout_data, | ||
1081 | 606 | const std::string& stderr_data)> callback) | ||
1082 | 607 | { | ||
1083 | 608 | QSharedPointer<QProcess> process(new QProcess()); | ||
1084 | 609 | typedef void(QProcess::*QProcessFinished)(int, QProcess::ExitStatus); | ||
1085 | 610 | typedef void(QProcess::*QProcessError)(QProcess::ProcessError); | ||
1086 | 611 | QObject::connect(process.data(), | ||
1087 | 612 | static_cast<QProcessFinished>(&QProcess::finished), | ||
1088 | 613 | [callback, process](int code, QProcess::ExitStatus /*status*/) { | ||
1089 | 614 | qDebug() << "command finished with exit code:" << code; | ||
1090 | 615 | std::string data{process->readAllStandardOutput().data()}; | ||
1091 | 616 | std::string errors{process->readAllStandardError().data()}; | ||
1092 | 617 | callback(code, data, errors); | ||
1093 | 618 | } ); | ||
1094 | 619 | |||
1095 | 620 | QObject::connect(process.data(), | ||
1096 | 621 | static_cast<QProcessError>(&QProcess::error), | ||
1097 | 622 | [callback, process](QProcess::ProcessError error) { | ||
1098 | 623 | qCritical() << "error running command:" << error; | ||
1099 | 624 | std::string data{process->readAllStandardOutput().data()}; | ||
1100 | 625 | std::string errors{process->readAllStandardError().data()}; | ||
1101 | 626 | callback(process->exitCode(), data, errors); | ||
1102 | 627 | } ); | ||
1103 | 628 | |||
1104 | 629 | process->start(command.c_str()); | ||
1112 | 630 | } | 427 | } |
1113 | 631 | 428 | ||
1114 | 632 | } // namespace click | 429 | } // namespace click |
1115 | 633 | 430 | ||
1116 | === modified file 'libclickscope/click/interface.h' | |||
1117 | --- libclickscope/click/interface.h 2016-07-14 18:37:27 +0000 | |||
1118 | +++ libclickscope/click/interface.h 2016-08-24 21:39:08 +0000 | |||
1119 | @@ -1,5 +1,5 @@ | |||
1120 | 1 | /* | 1 | /* |
1122 | 2 | * Copyright (C) 2014 Canonical Ltd. | 2 | * Copyright (C) 2014-2016 Canonical Ltd. |
1123 | 3 | * | 3 | * |
1124 | 4 | * This program is free software: you can redistribute it and/or modify it | 4 | * This program is free software: you can redistribute it and/or modify it |
1125 | 5 | * under the terms of the GNU General Public License version 3, as published | 5 | * under the terms of the GNU General Public License version 3, as published |
1126 | @@ -30,15 +30,19 @@ | |||
1127 | 30 | #ifndef CLICK_INTERFACE_H | 30 | #ifndef CLICK_INTERFACE_H |
1128 | 31 | #define CLICK_INTERFACE_H | 31 | #define CLICK_INTERFACE_H |
1129 | 32 | 32 | ||
1132 | 33 | #include <QObject> | 33 | #include "application.h" |
1133 | 34 | #include <QStringList> | 34 | #include "package.h" |
1134 | 35 | |||
1135 | 36 | #include <ubuntu-app-launch/application.h> | ||
1136 | 37 | |||
1137 | 35 | #include <unity/util/IniParser.h> | 38 | #include <unity/util/IniParser.h> |
1138 | 36 | 39 | ||
1139 | 40 | #include <memory> | ||
1140 | 41 | #include <unordered_set> | ||
1141 | 37 | #include <vector> | 42 | #include <vector> |
1142 | 38 | #include <unordered_set> | ||
1143 | 39 | 43 | ||
1146 | 40 | #include "application.h" | 44 | using namespace ubuntu::app_launch; |
1147 | 41 | #include "package.h" | 45 | namespace ual = ubuntu::app_launch; |
1148 | 42 | 46 | ||
1149 | 43 | namespace click | 47 | namespace click |
1150 | 44 | { | 48 | { |
1151 | @@ -74,46 +78,28 @@ | |||
1152 | 74 | enum class InterfaceError {NoError, CallError, ParseError}; | 78 | enum class InterfaceError {NoError, CallError, ParseError}; |
1153 | 75 | typedef std::list<Manifest> ManifestList; | 79 | typedef std::list<Manifest> ManifestList; |
1154 | 76 | 80 | ||
1155 | 77 | ManifestList manifest_list_from_json(const std::string& json); | ||
1156 | 78 | Manifest manifest_from_json(const std::string& json); | 81 | Manifest manifest_from_json(const std::string& json); |
1157 | 79 | PackageSet package_names_from_stdout(const std::string& stdout_data); | ||
1158 | 80 | 82 | ||
1159 | 81 | class Interface | 83 | class Interface |
1160 | 82 | { | 84 | { |
1161 | 83 | public: | 85 | public: |
1162 | 84 | Interface(const QSharedPointer<KeyFileLocator>& keyFileLocator); | ||
1163 | 85 | Interface() = default; | 86 | Interface() = default; |
1165 | 86 | virtual ~Interface(); | 87 | virtual ~Interface() = default; |
1166 | 87 | 88 | ||
1167 | 88 | virtual std::string get_translated_string(const unity::util::IniParser& keyFile, | ||
1168 | 89 | const std::string& group, | ||
1169 | 90 | const std::string& key, | ||
1170 | 91 | const std::string& domain); | ||
1171 | 92 | virtual Application load_app_from_desktop(const unity::util::IniParser& keyFile, | ||
1172 | 93 | const std::string& filename); | ||
1173 | 94 | static std::vector<Application> sort_apps(const std::vector<Application>& apps); | 89 | static std::vector<Application> sort_apps(const std::vector<Application>& apps); |
1175 | 95 | virtual std::vector<Application> find_installed_apps(const std::string& search_query, | 90 | virtual std::list<std::shared_ptr<ual::Application>> installed_apps(); |
1176 | 91 | virtual std::vector<Application> search(const std::string& query, | ||
1177 | 96 | const std::vector<std::string>& ignored_apps = std::vector<std::string>{}, | 92 | const std::vector<std::string>& ignored_apps = std::vector<std::string>{}, |
1178 | 97 | const std::string& current_department = "", | 93 | const std::string& current_department = "", |
1179 | 98 | const std::shared_ptr<click::DepartmentsDb>& depts_db = nullptr); | 94 | const std::shared_ptr<click::DepartmentsDb>& depts_db = nullptr); |
1180 | 99 | 95 | ||
1182 | 100 | static bool is_non_click_app(const QString& filename); | 96 | static bool is_non_click_app(const std::string& app_id); |
1183 | 101 | 97 | ||
1184 | 102 | static bool is_icon_identifier(const std::string &icon_id); | 98 | static bool is_icon_identifier(const std::string &icon_id); |
1185 | 103 | static std::string add_theme_scheme(const std::string &filename); | 99 | static std::string add_theme_scheme(const std::string &filename); |
1186 | 104 | virtual void get_manifests(std::function<void(ManifestList, InterfaceError)> callback); | ||
1187 | 105 | virtual void get_installed_packages(std::function<void(PackageSet, InterfaceError)> callback); | 100 | virtual void get_installed_packages(std::function<void(PackageSet, InterfaceError)> callback); |
1188 | 101 | virtual std::string get_manifest_json(const std::string &package); | ||
1189 | 106 | virtual void get_manifest_for_app(const std::string &app_id, std::function<void(Manifest, InterfaceError)> callback); | 102 | virtual void get_manifest_for_app(const std::string &app_id, std::function<void(Manifest, InterfaceError)> callback); |
1190 | 107 | constexpr static const char* ENV_SHOW_DESKTOP_APPS {"CLICK_SCOPE_SHOW_DESKTOP_APPS"}; | ||
1191 | 108 | virtual bool is_visible_app(const unity::util::IniParser& keyFile); | ||
1192 | 109 | virtual bool show_desktop_apps(); | ||
1193 | 110 | |||
1194 | 111 | virtual void run_process(const std::string& command, | ||
1195 | 112 | std::function<void(int code, | ||
1196 | 113 | const std::string& stdout_data, | ||
1197 | 114 | const std::string& stderr_data)> callback); | ||
1198 | 115 | private: | ||
1199 | 116 | QSharedPointer<KeyFileLocator> keyFileLocator; | ||
1200 | 117 | }; | 103 | }; |
1201 | 118 | 104 | ||
1202 | 119 | } // namespace click | 105 | } // namespace click |
1203 | 120 | 106 | ||
1204 | === removed file 'libclickscope/click/key_file_locator.cpp' | |||
1205 | --- libclickscope/click/key_file_locator.cpp 2015-11-24 18:23:23 +0000 | |||
1206 | +++ libclickscope/click/key_file_locator.cpp 1970-01-01 00:00:00 +0000 | |||
1207 | @@ -1,94 +0,0 @@ | |||
1208 | 1 | /* | ||
1209 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
1210 | 3 | * | ||
1211 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1212 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
1213 | 6 | * by the Free Software Foundation. | ||
1214 | 7 | * | ||
1215 | 8 | * This program is distributed in the hope that it will be useful, but | ||
1216 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1217 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1218 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
1219 | 12 | * | ||
1220 | 13 | * You should have received a copy of the GNU General Public License along | ||
1221 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1222 | 15 | * | ||
1223 | 16 | * In addition, as a special exception, the copyright holders give | ||
1224 | 17 | * permission to link the code of portions of this program with the | ||
1225 | 18 | * OpenSSL library under certain conditions as described in each | ||
1226 | 19 | * individual source file, and distribute linked combinations | ||
1227 | 20 | * including the two. | ||
1228 | 21 | * You must obey the GNU General Public License in all respects | ||
1229 | 22 | * for all of the code used other than OpenSSL. If you modify | ||
1230 | 23 | * file(s) with this exception, you may extend this exception to your | ||
1231 | 24 | * version of the file(s), but you are not obligated to do so. If you | ||
1232 | 25 | * do not wish to do so, delete this exception statement from your | ||
1233 | 26 | * version. If you delete this exception statement from all source | ||
1234 | 27 | * files in the program, then also delete it here. | ||
1235 | 28 | */ | ||
1236 | 29 | |||
1237 | 30 | #include "key_file_locator.h" | ||
1238 | 31 | |||
1239 | 32 | #include <unity/Exception.h> | ||
1240 | 33 | #include <unity/UnityExceptions.h> | ||
1241 | 34 | #include <unity/util/IniParser.h> | ||
1242 | 35 | |||
1243 | 36 | #include <QDebug> | ||
1244 | 37 | #include <QDir> | ||
1245 | 38 | #include <QStandardPaths> | ||
1246 | 39 | #include <QString> | ||
1247 | 40 | |||
1248 | 41 | namespace | ||
1249 | 42 | { | ||
1250 | 43 | static const QString NON_CLICK_PATH("/usr/share/applications"); | ||
1251 | 44 | |||
1252 | 45 | void find_apps_in_dir(const QString& dir_path, | ||
1253 | 46 | const click::KeyFileLocator::Enumerator& enumerator) | ||
1254 | 47 | { | ||
1255 | 48 | QDir dir(dir_path, "*.desktop", | ||
1256 | 49 | QDir::Unsorted, QDir::Readable | QDir::Files); | ||
1257 | 50 | QStringList entries = dir.entryList(); | ||
1258 | 51 | for (int i = 0; i < entries.size(); ++i) { | ||
1259 | 52 | QString filename = entries.at(i); | ||
1260 | 53 | QString full_path = dir.absoluteFilePath(filename); | ||
1261 | 54 | try { | ||
1262 | 55 | enumerator(unity::util::IniParser(full_path.toUtf8().data()), | ||
1263 | 56 | filename.toUtf8().data()); | ||
1264 | 57 | } catch (const unity::FileException& file_exp) { | ||
1265 | 58 | qWarning() << "Error reading file:" << file_exp.to_string().c_str(); | ||
1266 | 59 | } catch (const unity::LogicException& logic_exp) { | ||
1267 | 60 | qCritical() << "Error reading file:" << logic_exp.to_string().c_str(); | ||
1268 | 61 | } | ||
1269 | 62 | } | ||
1270 | 63 | } | ||
1271 | 64 | } | ||
1272 | 65 | |||
1273 | 66 | const std::string& click::KeyFileLocator::systemApplicationsDirectory() | ||
1274 | 67 | { | ||
1275 | 68 | static const std::string s{"/usr/share/applications"}; | ||
1276 | 69 | return s; | ||
1277 | 70 | } | ||
1278 | 71 | |||
1279 | 72 | const std::string& click::KeyFileLocator::userApplicationsDirectory() | ||
1280 | 73 | { | ||
1281 | 74 | static const std::string s | ||
1282 | 75 | { | ||
1283 | 76 | qPrintable(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/applications") | ||
1284 | 77 | }; | ||
1285 | 78 | return s; | ||
1286 | 79 | } | ||
1287 | 80 | |||
1288 | 81 | click::KeyFileLocator::KeyFileLocator( | ||
1289 | 82 | const std::string& systemApplicationsDir, | ||
1290 | 83 | const std::string& userApplicationsDir) | ||
1291 | 84 | : systemApplicationsDir(systemApplicationsDir), | ||
1292 | 85 | userApplicationsDir(userApplicationsDir) | ||
1293 | 86 | { | ||
1294 | 87 | } | ||
1295 | 88 | |||
1296 | 89 | void click::KeyFileLocator::enumerateKeyFilesForInstalledApplications( | ||
1297 | 90 | const click::KeyFileLocator::Enumerator& enumerator) | ||
1298 | 91 | { | ||
1299 | 92 | find_apps_in_dir(QString::fromStdString(systemApplicationsDir), enumerator); | ||
1300 | 93 | find_apps_in_dir(QString::fromStdString(userApplicationsDir), enumerator); | ||
1301 | 94 | } | ||
1302 | 95 | 0 | ||
1303 | === removed file 'libclickscope/click/key_file_locator.h' | |||
1304 | --- libclickscope/click/key_file_locator.h 2014-05-13 19:32:29 +0000 | |||
1305 | +++ libclickscope/click/key_file_locator.h 1970-01-01 00:00:00 +0000 | |||
1306 | @@ -1,70 +0,0 @@ | |||
1307 | 1 | /* | ||
1308 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
1309 | 3 | * | ||
1310 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1311 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
1312 | 6 | * by the Free Software Foundation. | ||
1313 | 7 | * | ||
1314 | 8 | * This program is distributed in the hope that it will be useful, but | ||
1315 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1316 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1317 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
1318 | 12 | * | ||
1319 | 13 | * You should have received a copy of the GNU General Public License along | ||
1320 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1321 | 15 | * | ||
1322 | 16 | * In addition, as a special exception, the copyright holders give | ||
1323 | 17 | * permission to link the code of portions of this program with the | ||
1324 | 18 | * OpenSSL library under certain conditions as described in each | ||
1325 | 19 | * individual source file, and distribute linked combinations | ||
1326 | 20 | * including the two. | ||
1327 | 21 | * You must obey the GNU General Public License in all respects | ||
1328 | 22 | * for all of the code used other than OpenSSL. If you modify | ||
1329 | 23 | * file(s) with this exception, you may extend this exception to your | ||
1330 | 24 | * version of the file(s), but you are not obligated to do so. If you | ||
1331 | 25 | * do not wish to do so, delete this exception statement from your | ||
1332 | 26 | * version. If you delete this exception statement from all source | ||
1333 | 27 | * files in the program, then also delete it here. | ||
1334 | 28 | */ | ||
1335 | 29 | |||
1336 | 30 | #ifndef CLICK_KEY_FILE_LOCATOR_H | ||
1337 | 31 | #define CLICK_KEY_FILE_LOCATOR_H | ||
1338 | 32 | |||
1339 | 33 | #include <functional> | ||
1340 | 34 | #include <string> | ||
1341 | 35 | |||
1342 | 36 | namespace unity | ||
1343 | 37 | { | ||
1344 | 38 | namespace util | ||
1345 | 39 | { | ||
1346 | 40 | class IniParser; | ||
1347 | 41 | } | ||
1348 | 42 | } | ||
1349 | 43 | |||
1350 | 44 | namespace click | ||
1351 | 45 | { | ||
1352 | 46 | class KeyFileLocator | ||
1353 | 47 | { | ||
1354 | 48 | public: | ||
1355 | 49 | static const std::string& systemApplicationsDirectory(); | ||
1356 | 50 | static const std::string& userApplicationsDirectory(); | ||
1357 | 51 | |||
1358 | 52 | typedef std::function<void(const unity::util::IniParser&, const std::string&)> Enumerator; | ||
1359 | 53 | |||
1360 | 54 | KeyFileLocator(const std::string& systemApplicationsDir = systemApplicationsDirectory(), | ||
1361 | 55 | const std::string& userApplicationsDir = userApplicationsDirectory()); | ||
1362 | 56 | KeyFileLocator(const KeyFileLocator&) = delete; | ||
1363 | 57 | virtual ~KeyFileLocator() = default; | ||
1364 | 58 | |||
1365 | 59 | KeyFileLocator& operator=(const KeyFileLocator&) = delete; | ||
1366 | 60 | bool operator==(const KeyFileLocator&) const = delete; | ||
1367 | 61 | |||
1368 | 62 | virtual void enumerateKeyFilesForInstalledApplications(const Enumerator& enumerator); | ||
1369 | 63 | |||
1370 | 64 | private: | ||
1371 | 65 | std::string systemApplicationsDir; | ||
1372 | 66 | std::string userApplicationsDir; | ||
1373 | 67 | }; | ||
1374 | 68 | } | ||
1375 | 69 | |||
1376 | 70 | #endif // CLICK_KEY_FILE_LOCATOR_H | ||
1377 | 71 | 0 | ||
1378 | === modified file 'libclickscope/click/package.cpp' | |||
1379 | --- libclickscope/click/package.cpp 2015-11-24 18:23:23 +0000 | |||
1380 | +++ libclickscope/click/package.cpp 2016-08-24 21:39:08 +0000 | |||
1381 | @@ -95,6 +95,10 @@ | |||
1382 | 95 | p.publisher = item[Package::JsonKeys::publisher].asString(); | 95 | p.publisher = item[Package::JsonKeys::publisher].asString(); |
1383 | 96 | p.rating = item[Package::JsonKeys::rating].asDouble(); | 96 | p.rating = item[Package::JsonKeys::rating].asDouble(); |
1384 | 97 | p.version = item[Package::JsonKeys::version].asString(); | 97 | p.version = item[Package::JsonKeys::version].asString(); |
1385 | 98 | |||
1386 | 99 | p.snap_id = item[Package::JsonKeys::snap_id].asString(); | ||
1387 | 100 | p.alias = item[Package::JsonKeys::alias].asString(); | ||
1388 | 101 | |||
1389 | 98 | return p; | 102 | return p; |
1390 | 99 | } | 103 | } |
1391 | 100 | 104 | ||
1392 | 101 | 105 | ||
1393 | === modified file 'libclickscope/click/package.h' | |||
1394 | --- libclickscope/click/package.h 2015-11-24 18:23:23 +0000 | |||
1395 | +++ libclickscope/click/package.h 2016-08-24 21:39:08 +0000 | |||
1396 | @@ -64,6 +64,8 @@ | |||
1397 | 64 | constexpr static const char* publisher{"publisher"}; | 64 | constexpr static const char* publisher{"publisher"}; |
1398 | 65 | constexpr static const char* rating{"ratings_average"}; | 65 | constexpr static const char* rating{"ratings_average"}; |
1399 | 66 | constexpr static const char* version{"version"}; | 66 | constexpr static const char* version{"version"}; |
1400 | 67 | constexpr static const char* snap_id{"snap_id"}; | ||
1401 | 68 | constexpr static const char* alias{"alias"}; | ||
1402 | 67 | 69 | ||
1403 | 68 | // NOTE: The "price" field is deprecated in favor of "prices" | 70 | // NOTE: The "price" field is deprecated in favor of "prices" |
1404 | 69 | constexpr static const char* prices{"prices"}; | 71 | constexpr static const char* prices{"prices"}; |
1405 | @@ -107,6 +109,8 @@ | |||
1406 | 107 | void matches (std::string query, std::function<bool> callback); | 109 | void matches (std::string query, std::function<bool> callback); |
1407 | 108 | std::string content; | 110 | std::string content; |
1408 | 109 | std::map<std::string, double> prices; | 111 | std::map<std::string, double> prices; |
1409 | 112 | std::string snap_id; | ||
1410 | 113 | std::string alias; | ||
1411 | 110 | 114 | ||
1412 | 111 | struct hash_name { | 115 | struct hash_name { |
1413 | 112 | public : | 116 | public : |
1414 | 113 | 117 | ||
1415 | === modified file 'libclickscope/click/preview.cpp' | |||
1416 | --- libclickscope/click/preview.cpp 2016-07-18 15:38:22 +0000 | |||
1417 | +++ libclickscope/click/preview.cpp 2016-08-24 21:39:08 +0000 | |||
1418 | @@ -413,6 +413,9 @@ | |||
1419 | 413 | } | 413 | } |
1420 | 414 | } | 414 | } |
1421 | 415 | 415 | ||
1422 | 416 | // Need to use this in a couple places, so it's a static const. | ||
1423 | 417 | static const std::regex desktop_match("^(.*)\\.desktop$"); | ||
1424 | 418 | |||
1425 | 416 | // TODO: error handling - once get_details provides errors, we can | 419 | // TODO: error handling - once get_details provides errors, we can |
1426 | 417 | // return them from populateDetails and check them in the calling code | 420 | // return them from populateDetails and check them in the calling code |
1427 | 418 | // to decide whether to show error widgets. see bug LP: #1289541 | 421 | // to decide whether to show error widgets. see bug LP: #1289541 |
1428 | @@ -422,8 +425,9 @@ | |||
1429 | 422 | { | 425 | { |
1430 | 423 | 426 | ||
1431 | 424 | std::string app_name = get_string_maybe_null(result["name"]); | 427 | std::string app_name = get_string_maybe_null(result["name"]); |
1432 | 428 | std::string snap_id = get_string_maybe_null(result["snap_id"]); | ||
1433 | 425 | 429 | ||
1435 | 426 | if (app_name.empty()) { | 430 | if (app_name.empty() || std::regex_match(app_name, desktop_match)) { |
1436 | 427 | click::PackageDetails details; | 431 | click::PackageDetails details; |
1437 | 428 | qDebug() << "in populateDetails(), app_name is empty"; | 432 | qDebug() << "in populateDetails(), app_name is empty"; |
1438 | 429 | details.package.title = result.title(); | 433 | details.package.title = result.title(); |
1439 | @@ -437,9 +441,13 @@ | |||
1440 | 437 | // I think this should not be required when we switch the click::Index over | 441 | // I think this should not be required when we switch the click::Index over |
1441 | 438 | // to using the Qt bridge. With that, the qt dependency becomes an implementation detail | 442 | // to using the Qt bridge. With that, the qt dependency becomes an implementation detail |
1442 | 439 | // and code using it does not need to worry about threading/event loop topics. | 443 | // and code using it does not need to worry about threading/event loop topics. |
1444 | 440 | run_under_qt([this, details_callback, reviews_callback, app_name, force_cache]() | 444 | run_under_qt([this, details_callback, reviews_callback, app_name, snap_id, force_cache]() |
1445 | 441 | { | 445 | { |
1447 | 442 | index_operation = index->get_details(app_name, [this, app_name, details_callback, reviews_callback, force_cache](PackageDetails details, click::Index::Error error){ | 446 | index_operation = index->get_details(app_name, |
1448 | 447 | [this, app_name, snap_id, | ||
1449 | 448 | details_callback, | ||
1450 | 449 | reviews_callback, | ||
1451 | 450 | force_cache](PackageDetails details, click::Index::Error error){ | ||
1452 | 443 | if(error == click::Index::Error::NoError) { | 451 | if(error == click::Index::Error::NoError) { |
1453 | 444 | qDebug() << "Got details:" << app_name.c_str(); | 452 | qDebug() << "Got details:" << app_name.c_str(); |
1454 | 445 | details_callback(details); | 453 | details_callback(details); |
1455 | @@ -452,10 +460,17 @@ | |||
1456 | 452 | details.main_screenshot_url = get_string_maybe_null(result["main_screenshot"]); | 460 | details.main_screenshot_url = get_string_maybe_null(result["main_screenshot"]); |
1457 | 453 | details_callback(details); | 461 | details_callback(details); |
1458 | 454 | } | 462 | } |
1463 | 455 | reviews_operation = reviews->fetch_reviews(app_name, | 463 | // FIXME: No RNR support for v2 snaps yet, so avoid the |
1464 | 456 | reviews_callback, | 464 | // network hit if we're showing a snap preview |
1465 | 457 | force_cache); | 465 | if (snap_id.empty()) { |
1466 | 458 | }, force_cache); | 466 | reviews_operation = reviews->fetch_reviews(app_name, |
1467 | 467 | reviews_callback, | ||
1468 | 468 | force_cache); | ||
1469 | 469 | } else { | ||
1470 | 470 | reviews_callback(click::ReviewList{}, | ||
1471 | 471 | click::Reviews::Error::NoError); | ||
1472 | 472 | } | ||
1473 | 473 | }, !snap_id.empty(), force_cache); | ||
1474 | 459 | }); | 474 | }); |
1475 | 460 | } | 475 | } |
1476 | 461 | } | 476 | } |
1477 | @@ -900,7 +915,7 @@ | |||
1478 | 900 | std::promise<Manifest> manifest_promise; | 915 | std::promise<Manifest> manifest_promise; |
1479 | 901 | std::future<Manifest> manifest_future = manifest_promise.get_future(); | 916 | std::future<Manifest> manifest_future = manifest_promise.get_future(); |
1480 | 902 | std::string app_name = result["name"].get_string(); | 917 | std::string app_name = result["name"].get_string(); |
1482 | 903 | if (!app_name.empty()) { | 918 | if (!app_name.empty() && !std::regex_match(app_name, desktop_match)) { |
1483 | 904 | qt::core::world::enter_with_task([&]() { | 919 | qt::core::world::enter_with_task([&]() { |
1484 | 905 | click::Interface().get_manifest_for_app(app_name, | 920 | click::Interface().get_manifest_for_app(app_name, |
1485 | 906 | [&](Manifest found_manifest, InterfaceError error) { | 921 | [&](Manifest found_manifest, InterfaceError error) { |
1486 | 907 | 922 | ||
1487 | === modified file 'libclickscope/click/webclient.cpp' | |||
1488 | --- libclickscope/click/webclient.cpp 2016-05-25 16:19:51 +0000 | |||
1489 | +++ libclickscope/click/webclient.cpp 2016-08-24 21:39:08 +0000 | |||
1490 | @@ -78,6 +78,26 @@ | |||
1491 | 78 | { | 78 | { |
1492 | 79 | } | 79 | } |
1493 | 80 | 80 | ||
1494 | 81 | std::string click::web::Client::signUrl(const std::string& url, | ||
1495 | 82 | const std::string& method) | ||
1496 | 83 | { | ||
1497 | 84 | QString signature; | ||
1498 | 85 | |||
1499 | 86 | if (impl->sso.isNull()) { | ||
1500 | 87 | qCritical() << "Unable to sign request without SSO object."; | ||
1501 | 88 | } else { | ||
1502 | 89 | auto token = impl->sso->getToken(); | ||
1503 | 90 | if (token.isValid()) { | ||
1504 | 91 | signature = token.signUrl(QString::fromStdString(url), | ||
1505 | 92 | QString::fromStdString(method)); | ||
1506 | 93 | qDebug() << "Signed URL:" << QString::fromStdString(url); | ||
1507 | 94 | } else { | ||
1508 | 95 | qWarning() << "Signing requested but returned token is invalid."; | ||
1509 | 96 | } | ||
1510 | 97 | } | ||
1511 | 98 | return signature.toStdString(); | ||
1512 | 99 | } | ||
1513 | 100 | |||
1514 | 81 | QSharedPointer<click::web::Response> click::web::Client::call( | 101 | QSharedPointer<click::web::Response> click::web::Client::call( |
1515 | 82 | const std::string& iri, | 102 | const std::string& iri, |
1516 | 83 | const click::web::CallParams& params, | 103 | const click::web::CallParams& params, |
1517 | @@ -137,25 +157,14 @@ | |||
1518 | 137 | auto deviceId = Configuration().get_device_id(); | 157 | auto deviceId = Configuration().get_device_id(); |
1519 | 138 | request->setRawHeader(DEVICE_ID_HEADER.c_str(), deviceId.data()); | 158 | request->setRawHeader(DEVICE_ID_HEADER.c_str(), deviceId.data()); |
1520 | 139 | 159 | ||
1538 | 140 | if (sign && !impl->sso.isNull()) { | 160 | if (sign) { |
1539 | 141 | auto token = impl->sso->getToken(); | 161 | auto auth_header = signUrl(url.toString().toStdString(), method); |
1540 | 142 | if (token.isValid()) { | 162 | if (!auth_header.empty()) |
1541 | 143 | QString auth_header = token.signUrl(url.toString(), | 163 | request->setRawHeader(AUTHORIZATION_HEADER.c_str(), |
1542 | 144 | method.c_str()); | 164 | auth_header.c_str()); |
1526 | 145 | qDebug() << "Signed URL:" << request->url().toString(); | ||
1527 | 146 | request->setRawHeader(AUTHORIZATION_HEADER.c_str(), auth_header.toUtf8()); | ||
1528 | 147 | } else { | ||
1529 | 148 | qWarning() << "Signing reuested but returned token is invalid."; | ||
1530 | 149 | } | ||
1531 | 150 | |||
1532 | 151 | doConnect(); | ||
1533 | 152 | } else { | ||
1534 | 153 | if (sign && impl->sso.isNull()) { | ||
1535 | 154 | qCritical() << "Unable to sign request without SSO object."; | ||
1536 | 155 | } | ||
1537 | 156 | doConnect(); | ||
1543 | 157 | } | 165 | } |
1544 | 158 | 166 | ||
1545 | 167 | doConnect(); | ||
1546 | 159 | 168 | ||
1547 | 160 | return responsePtr; | 169 | return responsePtr; |
1548 | 161 | } | 170 | } |
1549 | 162 | 171 | ||
1550 | === modified file 'libclickscope/click/webclient.h' | |||
1551 | --- libclickscope/click/webclient.h 2016-05-25 16:19:51 +0000 | |||
1552 | +++ libclickscope/click/webclient.h 2016-08-24 21:39:08 +0000 | |||
1553 | @@ -115,6 +115,8 @@ | |||
1554 | 115 | Client(const QSharedPointer<click::network::AccessManager>& networkAccessManager); | 115 | Client(const QSharedPointer<click::network::AccessManager>& networkAccessManager); |
1555 | 116 | virtual ~Client(); | 116 | virtual ~Client(); |
1556 | 117 | 117 | ||
1557 | 118 | virtual std::string signUrl(const std::string& url, | ||
1558 | 119 | const std::string& method); | ||
1559 | 118 | virtual QSharedPointer<Response> call( | 120 | virtual QSharedPointer<Response> call( |
1560 | 119 | const std::string& iri, | 121 | const std::string& iri, |
1561 | 120 | const CallParams& params = CallParams(), bool force_cache = false); | 122 | const CallParams& params = CallParams(), bool force_cache = false); |
1562 | 121 | 123 | ||
1563 | === modified file 'libclickscope/tests/CMakeLists.txt' | |||
1564 | --- libclickscope/tests/CMakeLists.txt 2015-07-02 21:56:45 +0000 | |||
1565 | +++ libclickscope/tests/CMakeLists.txt 2016-08-24 21:39:08 +0000 | |||
1566 | @@ -15,11 +15,13 @@ | |||
1567 | 15 | ${GMOCK_INCLUDE_DIR} | 15 | ${GMOCK_INCLUDE_DIR} |
1568 | 16 | ) | 16 | ) |
1569 | 17 | 17 | ||
1570 | 18 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test_data.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/test_data.cpp) | ||
1571 | 19 | add_definitions(-DTEST_DIR="${CMAKE_CURRENT_BINARY_DIR}") | 18 | add_definitions(-DTEST_DIR="${CMAKE_CURRENT_BINARY_DIR}") |
1572 | 20 | 19 | ||
1573 | 21 | add_executable (${LIBCLICKSCOPE_TESTS_TARGET} | 20 | add_executable (${LIBCLICKSCOPE_TESTS_TARGET} |
1574 | 22 | mock_network_access_manager.h | 21 | mock_network_access_manager.h |
1575 | 22 | mock_pay.h | ||
1576 | 23 | mock_ual.h | ||
1577 | 24 | mock_ubuntu_download_manager.h | ||
1578 | 23 | mock_ubuntuone_credentials.h | 25 | mock_ubuntuone_credentials.h |
1579 | 24 | mock_webclient.h | 26 | mock_webclient.h |
1580 | 25 | fake_json.cpp | 27 | fake_json.cpp |
1581 | @@ -37,8 +39,6 @@ | |||
1582 | 37 | test_smartconnect.cpp | 39 | test_smartconnect.cpp |
1583 | 38 | test_utils.cpp | 40 | test_utils.cpp |
1584 | 39 | test_webclient.cpp | 41 | test_webclient.cpp |
1585 | 40 | |||
1586 | 41 | ${CMAKE_CURRENT_BINARY_DIR}/test_data.cpp | ||
1587 | 42 | ) | 42 | ) |
1588 | 43 | 43 | ||
1589 | 44 | qt5_use_modules(${LIBCLICKSCOPE_TESTS_TARGET} Core Sql) | 44 | qt5_use_modules(${LIBCLICKSCOPE_TESTS_TARGET} Core Sql) |
1590 | 45 | 45 | ||
1591 | === removed directory 'libclickscope/tests/applications' | |||
1592 | === removed directory 'libclickscope/tests/applications/system' | |||
1593 | === removed file 'libclickscope/tests/applications/system/address-book-app.desktop' | |||
1594 | --- libclickscope/tests/applications/system/address-book-app.desktop 2014-07-21 12:41:31 +0000 | |||
1595 | +++ libclickscope/tests/applications/system/address-book-app.desktop 1970-01-01 00:00:00 +0000 | |||
1596 | @@ -1,15 +0,0 @@ | |||
1597 | 1 | [Desktop Entry] | ||
1598 | 2 | Encoding=UTF-8 | ||
1599 | 3 | Version=1.0 | ||
1600 | 4 | Terminal=false | ||
1601 | 5 | Type=Application | ||
1602 | 6 | Name=Contacts | ||
1603 | 7 | GenericName=Contacts | ||
1604 | 8 | Exec=/usr/bin/address-book-app %u | ||
1605 | 9 | Icon=contacts-app | ||
1606 | 10 | X-Ubuntu-Touch=true | ||
1607 | 11 | X-Ubuntu-StageHint=SideStage | ||
1608 | 12 | X-Ubuntu-Gettext-Domain=address-book-app | ||
1609 | 13 | X-Ubuntu-Single-Instance=true | ||
1610 | 14 | X-Ubuntu-Default-Department-ID=accessories | ||
1611 | 15 | # this one has no screenshot nor comment, to test how it breaks | ||
1612 | 16 | 0 | ||
1613 | === removed file 'libclickscope/tests/applications/system/messaging-app.desktop' | |||
1614 | --- libclickscope/tests/applications/system/messaging-app.desktop 2014-04-02 11:56:49 +0000 | |||
1615 | +++ libclickscope/tests/applications/system/messaging-app.desktop 1970-01-01 00:00:00 +0000 | |||
1616 | @@ -1,14 +0,0 @@ | |||
1617 | 1 | [Desktop Entry] | ||
1618 | 2 | Type=Application | ||
1619 | 3 | Name=Messaging | ||
1620 | 4 | GenericName=Messaging | ||
1621 | 5 | Comment=Messaging application | ||
1622 | 6 | Exec=messaging-app %u | ||
1623 | 7 | Terminal=false | ||
1624 | 8 | Icon=messages-app | ||
1625 | 9 | MimeType=x-scheme-handler/contact;x-scheme-handler/call | ||
1626 | 10 | X-Ubuntu-Touch=true | ||
1627 | 11 | X-Ubuntu-StageHint=SideStage | ||
1628 | 12 | X-Ubuntu-Gettext-Domain=messaging-app | ||
1629 | 13 | X-Ubuntu-Single-Instance=true | ||
1630 | 14 | X-Screenshot=/usr/share/messaging-app/assets/messaging-app-screenshot.png | ||
1631 | 15 | 0 | ||
1632 | === removed file 'libclickscope/tests/applications/system/translated.desktop' | |||
1633 | --- libclickscope/tests/applications/system/translated.desktop 2014-05-05 20:21:53 +0000 | |||
1634 | +++ libclickscope/tests/applications/system/translated.desktop 1970-01-01 00:00:00 +0000 | |||
1635 | @@ -1,9 +0,0 @@ | |||
1636 | 1 | [Desktop Entry] | ||
1637 | 2 | Type=Application | ||
1638 | 3 | Name=Translated App | ||
1639 | 4 | Name[en]=Translated App | ||
1640 | 5 | Name[es]=Translated App in Spanish | ||
1641 | 6 | Comment=Translated application | ||
1642 | 7 | Comment[en]=Translated application | ||
1643 | 8 | Comment[es]=Translated application in Spanish | ||
1644 | 9 | X-Ubuntu-Touch=true | ||
1645 | 10 | 0 | ||
1646 | === removed directory 'libclickscope/tests/applications/user' | |||
1647 | === removed file 'libclickscope/tests/applications/user/badd-appid.desktop' | |||
1648 | --- libclickscope/tests/applications/user/badd-appid.desktop 2016-01-04 20:50:16 +0000 | |||
1649 | +++ libclickscope/tests/applications/user/badd-appid.desktop 1970-01-01 00:00:00 +0000 | |||
1650 | @@ -1,10 +0,0 @@ | |||
1651 | 1 | [Desktop Entry] | ||
1652 | 2 | Version=1.0 | ||
1653 | 3 | Type=Application | ||
1654 | 4 | Terminal=false | ||
1655 | 5 | Exec=processTest | ||
1656 | 6 | Icon=/home/phablet/animatedDemos/football-ball.png | ||
1657 | 7 | Path=/home/phablet/processTest | ||
1658 | 8 | Name=Football | ||
1659 | 9 | X-Ubuntu-Touch=true | ||
1660 | 10 | X-Ubuntu-Application-ID=football | ||
1661 | 11 | 0 | ||
1662 | === removed file 'libclickscope/tests/applications/user/broken.desktop' | |||
1663 | 12 | Binary files libclickscope/tests/applications/user/broken.desktop 2014-04-28 22:10:15 +0000 and libclickscope/tests/applications/user/broken.desktop 1970-01-01 00:00:00 +0000 differ | 1 | Binary files libclickscope/tests/applications/user/broken.desktop 2014-04-28 22:10:15 +0000 and libclickscope/tests/applications/user/broken.desktop 1970-01-01 00:00:00 +0000 differ |
1664 | === removed file 'libclickscope/tests/applications/user/com.ubuntu.accented_accented_0.5.29.desktop' | |||
1665 | --- libclickscope/tests/applications/user/com.ubuntu.accented_accented_0.5.29.desktop 2016-03-03 14:19:50 +0000 | |||
1666 | +++ libclickscope/tests/applications/user/com.ubuntu.accented_accented_0.5.29.desktop 1970-01-01 00:00:00 +0000 | |||
1667 | @@ -1,13 +0,0 @@ | |||
1668 | 1 | [Desktop Entry] | ||
1669 | 2 | Version=1.0 | ||
1670 | 3 | Type=Application | ||
1671 | 4 | Terminal=false | ||
1672 | 5 | Exec=aa-exec-click -p com.ubuntu.accented_accented_0.5.29 -- qmlscene ./ubuntu-accented-app.qml -I ./plugins | ||
1673 | 6 | Icon=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.accented/./accented64.png | ||
1674 | 7 | Name=Cámara | ||
1675 | 8 | X-Ubuntu-Touch=true | ||
1676 | 9 | X-Ubuntu-StageHint=SideStage | ||
1677 | 10 | |||
1678 | 11 | Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.accented | ||
1679 | 12 | X-Ubuntu-Old-Icon=./accented64.png | ||
1680 | 13 | X-Ubuntu-Application-ID=com.ubuntu.accented_accented_0.5.29 | ||
1681 | 14 | 0 | ||
1682 | === removed file 'libclickscope/tests/applications/user/com.ubuntu.calculator_calculator_0.1.3.206.desktop' | |||
1683 | --- libclickscope/tests/applications/user/com.ubuntu.calculator_calculator_0.1.3.206.desktop 2014-02-10 12:23:35 +0000 | |||
1684 | +++ libclickscope/tests/applications/user/com.ubuntu.calculator_calculator_0.1.3.206.desktop 1970-01-01 00:00:00 +0000 | |||
1685 | @@ -1,14 +0,0 @@ | |||
1686 | 1 | [Desktop Entry] | ||
1687 | 2 | Version=1.0 | ||
1688 | 3 | Type=Application | ||
1689 | 4 | Terminal=false | ||
1690 | 5 | Exec=aa-exec-click -p com.ubuntu.calculator_calculator_0.1.3.206 -- qmlscene ./ubuntu-calculator-app.qml | ||
1691 | 6 | Icon=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calculator/./calculator64.png | ||
1692 | 7 | Name=Calculator | ||
1693 | 8 | X-Ubuntu-Touch=true | ||
1694 | 9 | X-Ubuntu-StageHint=SideStage | ||
1695 | 10 | X-Ubuntu-Gettext-Domain=com.ubuntu.calculator | ||
1696 | 11 | |||
1697 | 12 | Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calculator | ||
1698 | 13 | X-Ubuntu-Old-Icon=./calculator64.png | ||
1699 | 14 | X-Ubuntu-Application-ID=com.ubuntu.calculator_calculator_0.1.3.206 | ||
1700 | 15 | 0 | ||
1701 | === removed file 'libclickscope/tests/applications/user/com.ubuntu.calendar_calendar_0.4.182.desktop' | |||
1702 | --- libclickscope/tests/applications/user/com.ubuntu.calendar_calendar_0.4.182.desktop 2014-02-10 12:23:35 +0000 | |||
1703 | +++ libclickscope/tests/applications/user/com.ubuntu.calendar_calendar_0.4.182.desktop 1970-01-01 00:00:00 +0000 | |||
1704 | @@ -1,14 +0,0 @@ | |||
1705 | 1 | [Desktop Entry] | ||
1706 | 2 | Version=1.0 | ||
1707 | 3 | Type=Application | ||
1708 | 4 | Terminal=false | ||
1709 | 5 | Exec=aa-exec-click -p com.ubuntu.calendar_calendar_0.4.182 -- qmlscene %u ./calendar.qml | ||
1710 | 6 | Icon=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calendar/./calendar64.png | ||
1711 | 7 | Name=Calendar | ||
1712 | 8 | X-Ubuntu-Touch=true | ||
1713 | 9 | X-Ubuntu-StageHint=SideStage | ||
1714 | 10 | X-Ubuntu-Gettext-Domain=com.ubuntu.calendar | ||
1715 | 11 | |||
1716 | 12 | Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calendar | ||
1717 | 13 | X-Ubuntu-Old-Icon=./calendar64.png | ||
1718 | 14 | X-Ubuntu-Application-ID=com.ubuntu.calendar_calendar_0.4.182 | ||
1719 | 15 | 0 | ||
1720 | === removed file 'libclickscope/tests/applications/user/com.ubuntu.clock_clock_1.0.300.desktop' | |||
1721 | --- libclickscope/tests/applications/user/com.ubuntu.clock_clock_1.0.300.desktop 2014-02-10 12:23:35 +0000 | |||
1722 | +++ libclickscope/tests/applications/user/com.ubuntu.clock_clock_1.0.300.desktop 1970-01-01 00:00:00 +0000 | |||
1723 | @@ -1,14 +0,0 @@ | |||
1724 | 1 | [Desktop Entry] | ||
1725 | 2 | Version=1.0 | ||
1726 | 3 | Type=Application | ||
1727 | 4 | Terminal=false | ||
1728 | 5 | Exec=aa-exec-click -p com.ubuntu.clock_clock_1.0.300 -- qmlscene ./ubuntu-clock-app.qml | ||
1729 | 6 | Icon=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.clock/./clock64.png | ||
1730 | 7 | Name=Clock | ||
1731 | 8 | X-Ubuntu-Touch=true | ||
1732 | 9 | X-Ubuntu-StageHint=SideStage | ||
1733 | 10 | X-Ubuntu-Gettext-Domain=com.ubuntu.clock | ||
1734 | 11 | |||
1735 | 12 | Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.clock | ||
1736 | 13 | X-Ubuntu-Old-Icon=./clock64.png | ||
1737 | 14 | X-Ubuntu-Application-ID=com.ubuntu.clock_clock_1.0.300 | ||
1738 | 15 | 0 | ||
1739 | === removed file 'libclickscope/tests/applications/user/com.ubuntu.developer.webapps.webapp-amazon_webapp-amazon_1.0.6.desktop' | |||
1740 | --- libclickscope/tests/applications/user/com.ubuntu.developer.webapps.webapp-amazon_webapp-amazon_1.0.6.desktop 2014-02-10 12:23:35 +0000 | |||
1741 | +++ libclickscope/tests/applications/user/com.ubuntu.developer.webapps.webapp-amazon_webapp-amazon_1.0.6.desktop 1970-01-01 00:00:00 +0000 | |||
1742 | @@ -1,10 +0,0 @@ | |||
1743 | 1 | [Desktop Entry] | ||
1744 | 2 | Type=Application | ||
1745 | 3 | Terminal=false | ||
1746 | 4 | Exec=aa-exec-click -p com.ubuntu.developer.webapps.webapp-amazon_webapp-amazon_1.0.6 -- webbrowser-app --enable-back-forward --webapp --webappUrlPatterns=https?://www.amazon.com/*,https?://s.amazon-adsystem.com/* http://www.amazon.com/gp/aw | ||
1747 | 5 | Name=Amazon | ||
1748 | 6 | Icon=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.developer.webapps.webapp-amazon/./amazon.png | ||
1749 | 7 | X-Ubuntu-Touch=true | ||
1750 | 8 | Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.developer.webapps.webapp-amazon | ||
1751 | 9 | X-Ubuntu-Old-Icon=./amazon.png | ||
1752 | 10 | X-Ubuntu-Application-ID=com.ubuntu.developer.webapps.webapp-amazon_webapp-amazon_1.0.6 | ||
1753 | 11 | 0 | ||
1754 | === removed file 'libclickscope/tests/applications/user/com.ubuntu.developer.webapps.webapp-ebay_webapp-ebay_1.0.8.desktop' | |||
1755 | --- libclickscope/tests/applications/user/com.ubuntu.developer.webapps.webapp-ebay_webapp-ebay_1.0.8.desktop 2014-02-10 12:23:35 +0000 | |||
1756 | +++ libclickscope/tests/applications/user/com.ubuntu.developer.webapps.webapp-ebay_webapp-ebay_1.0.8.desktop 1970-01-01 00:00:00 +0000 | |||
1757 | @@ -1,11 +0,0 @@ | |||
1758 | 1 | [Desktop Entry] | ||
1759 | 2 | Type=Application | ||
1760 | 3 | Terminal=false | ||
1761 | 4 | Exec=aa-exec-click -p com.ubuntu.developer.webapps.webapp-ebay_webapp-ebay_1.0.8 -- webbrowser-app --enable-back-forward --webappUrlPatterns=https?://*.ebay.com/* --webapp http://m.ebay.com/ | ||
1762 | 5 | Name=eBay | ||
1763 | 6 | Icon=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.developer.webapps.webapp-ebay/./ebay.png | ||
1764 | 7 | X-Ubuntu-Touch=true | ||
1765 | 8 | X-Ubuntu-Single-Instance=true | ||
1766 | 9 | Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.developer.webapps.webapp-ebay | ||
1767 | 10 | X-Ubuntu-Old-Icon=./ebay.png | ||
1768 | 11 | X-Ubuntu-Application-ID=com.ubuntu.developer.webapps.webapp-ebay_webapp-ebay_1.0.8 | ||
1769 | 12 | 0 | ||
1770 | === removed file 'libclickscope/tests/applications/user/com.ubuntu.developer.webapps.webapp-facebook_webapp-facebook_1.0.5.desktop' | |||
1771 | --- libclickscope/tests/applications/user/com.ubuntu.developer.webapps.webapp-facebook_webapp-facebook_1.0.5.desktop 2014-02-10 12:23:35 +0000 | |||
1772 | +++ libclickscope/tests/applications/user/com.ubuntu.developer.webapps.webapp-facebook_webapp-facebook_1.0.5.desktop 1970-01-01 00:00:00 +0000 | |||
1773 | @@ -1,12 +0,0 @@ | |||
1774 | 1 | [Desktop Entry] | ||
1775 | 2 | Type=Application | ||
1776 | 3 | Terminal=false | ||
1777 | 4 | Exec=aa-exec-click -p com.ubuntu.developer.webapps.webapp-facebook_webapp-facebook_1.0.5 -- webbrowser-app --enable-back-forward --webapp --webappUrlPatterns=https?://m.facebook.com/* https://m.facebook.com/ | ||
1778 | 5 | Name=Facebook | ||
1779 | 6 | Icon=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.developer.webapps.webapp-facebook/./facebook.png | ||
1780 | 7 | X-Ubuntu-Touch=true | ||
1781 | 8 | X-Ubuntu-StageHint=SideStage | ||
1782 | 9 | X-Ubuntu-Single-Instance=true | ||
1783 | 10 | Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.developer.webapps.webapp-facebook | ||
1784 | 11 | X-Ubuntu-Old-Icon=./facebook.png | ||
1785 | 12 | X-Ubuntu-Application-ID=com.ubuntu.developer.webapps.webapp-facebook_webapp-facebook_1.0.5 | ||
1786 | 13 | 0 | ||
1787 | === removed file 'libclickscope/tests/applications/user/com.ubuntu.developer.webapps.webapp-gmail_webapp-gmail_1.0.8.desktop' | |||
1788 | --- libclickscope/tests/applications/user/com.ubuntu.developer.webapps.webapp-gmail_webapp-gmail_1.0.8.desktop 2014-02-10 12:23:35 +0000 | |||
1789 | +++ libclickscope/tests/applications/user/com.ubuntu.developer.webapps.webapp-gmail_webapp-gmail_1.0.8.desktop 1970-01-01 00:00:00 +0000 | |||
1790 | @@ -1,11 +0,0 @@ | |||
1791 | 1 | [Desktop Entry] | ||
1792 | 2 | Type=Application | ||
1793 | 3 | Terminal=false | ||
1794 | 4 | Exec=aa-exec-click -p com.ubuntu.developer.webapps.webapp-gmail_webapp-gmail_1.0.8 -- webbrowser-app --enable-back-forward --webappModelSearchPath=. --webapp='R01haWwNCg==' https://mail.google.com/ | ||
1795 | 5 | Name=Gmail | ||
1796 | 6 | Icon=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.developer.webapps.webapp-gmail/./gmail.png | ||
1797 | 7 | X-Ubuntu-Touch=true | ||
1798 | 8 | X-Ubuntu-Single-Instance=true | ||
1799 | 9 | Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.developer.webapps.webapp-gmail | ||
1800 | 10 | X-Ubuntu-Old-Icon=./gmail.png | ||
1801 | 11 | X-Ubuntu-Application-ID=com.ubuntu.developer.webapps.webapp-gmail_webapp-gmail_1.0.8 | ||
1802 | 12 | 0 | ||
1803 | === removed file 'libclickscope/tests/applications/user/com.ubuntu.developer.webapps.webapp-twitter_webapp-twitter_1.0.5.desktop' | |||
1804 | --- libclickscope/tests/applications/user/com.ubuntu.developer.webapps.webapp-twitter_webapp-twitter_1.0.5.desktop 2014-02-10 12:23:35 +0000 | |||
1805 | +++ libclickscope/tests/applications/user/com.ubuntu.developer.webapps.webapp-twitter_webapp-twitter_1.0.5.desktop 1970-01-01 00:00:00 +0000 | |||
1806 | @@ -1,12 +0,0 @@ | |||
1807 | 1 | [Desktop Entry] | ||
1808 | 2 | Type=Application | ||
1809 | 3 | Terminal=false | ||
1810 | 4 | Exec=aa-exec-click -p com.ubuntu.developer.webapps.webapp-twitter_webapp-twitter_1.0.5 -- webbrowser-app --enable-back-forward --webapp --webappUrlPatterns=https?://mobile.twitter.com/* https://mobile.twitter.com/session/new?bypass_interstitial=true | ||
1811 | 5 | Name=Twitter | ||
1812 | 6 | Icon=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.developer.webapps.webapp-twitter/./twitter.png | ||
1813 | 7 | X-Ubuntu-Touch=true | ||
1814 | 8 | X-Ubuntu-StageHint=SideStage | ||
1815 | 9 | X-Ubuntu-Single-Instance=true | ||
1816 | 10 | Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.developer.webapps.webapp-twitter | ||
1817 | 11 | X-Ubuntu-Old-Icon=./twitter.png | ||
1818 | 12 | X-Ubuntu-Application-ID=com.ubuntu.developer.webapps.webapp-twitter_webapp-twitter_1.0.5 | ||
1819 | 13 | 0 | ||
1820 | === removed file 'libclickscope/tests/applications/user/com.ubuntu.dropping-letters_dropping-letters_0.1.2.2.43.desktop' | |||
1821 | --- libclickscope/tests/applications/user/com.ubuntu.dropping-letters_dropping-letters_0.1.2.2.43.desktop 2014-02-10 12:23:35 +0000 | |||
1822 | +++ libclickscope/tests/applications/user/com.ubuntu.dropping-letters_dropping-letters_0.1.2.2.43.desktop 1970-01-01 00:00:00 +0000 | |||
1823 | @@ -1,13 +0,0 @@ | |||
1824 | 1 | [Desktop Entry] | ||
1825 | 2 | Version=1.0 | ||
1826 | 3 | Type=Application | ||
1827 | 4 | Icon=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.dropping-letters/dropping-letters.png | ||
1828 | 5 | Terminal=false | ||
1829 | 6 | Name=Dropping Letters | ||
1830 | 7 | Exec=aa-exec-click -p com.ubuntu.dropping-letters_dropping-letters_0.1.2.2.43 -- qmlscene dropping-letters.qml | ||
1831 | 8 | X-Ubuntu-Touch=true | ||
1832 | 9 | X-Ubuntu-StageHint=SideStage | ||
1833 | 10 | |||
1834 | 11 | Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.dropping-letters | ||
1835 | 12 | X-Ubuntu-Old-Icon=dropping-letters.png | ||
1836 | 13 | X-Ubuntu-Application-ID=com.ubuntu.dropping-letters_dropping-letters_0.1.2.2.43 | ||
1837 | 14 | 0 | ||
1838 | === removed file 'libclickscope/tests/applications/user/com.ubuntu.filemanager_filemanager_0.1.1.97.desktop' | |||
1839 | --- libclickscope/tests/applications/user/com.ubuntu.filemanager_filemanager_0.1.1.97.desktop 2014-02-10 12:23:35 +0000 | |||
1840 | +++ libclickscope/tests/applications/user/com.ubuntu.filemanager_filemanager_0.1.1.97.desktop 1970-01-01 00:00:00 +0000 | |||
1841 | @@ -1,13 +0,0 @@ | |||
1842 | 1 | [Desktop Entry] | ||
1843 | 2 | Version=1.0 | ||
1844 | 3 | Type=Application | ||
1845 | 4 | Terminal=false | ||
1846 | 5 | Exec=aa-exec-click -p com.ubuntu.filemanager_filemanager_0.1.1.97 -- qmlscene ./ubuntu-filemanager-app.qml -I ./plugins | ||
1847 | 6 | Icon=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.filemanager/./filemanager64.png | ||
1848 | 7 | Name=File Manager | ||
1849 | 8 | X-Ubuntu-Touch=true | ||
1850 | 9 | X-Ubuntu-StageHint=SideStage | ||
1851 | 10 | |||
1852 | 11 | Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.filemanager | ||
1853 | 12 | X-Ubuntu-Old-Icon=./filemanager64.png | ||
1854 | 13 | X-Ubuntu-Application-ID=com.ubuntu.filemanager_filemanager_0.1.1.97 | ||
1855 | 14 | 0 | ||
1856 | === removed file 'libclickscope/tests/applications/user/com.ubuntu.music_music_1.1.329.desktop' | |||
1857 | --- libclickscope/tests/applications/user/com.ubuntu.music_music_1.1.329.desktop 2014-02-10 12:23:35 +0000 | |||
1858 | +++ libclickscope/tests/applications/user/com.ubuntu.music_music_1.1.329.desktop 1970-01-01 00:00:00 +0000 | |||
1859 | @@ -1,15 +0,0 @@ | |||
1860 | 1 | [Desktop Entry] | ||
1861 | 2 | Version=1.0 | ||
1862 | 3 | Name=Music | ||
1863 | 4 | Comment=Ubuntu Touch Music Player | ||
1864 | 5 | Exec=aa-exec-click -p com.ubuntu.music_music_1.1.329 -- qmlscene ./music-app.qml --file=%f -I ./plugins | ||
1865 | 6 | Icon=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.music/images/music.png | ||
1866 | 7 | Terminal=false | ||
1867 | 8 | Type=Application | ||
1868 | 9 | StartupNotify=true | ||
1869 | 10 | X-Ubuntu-Single-Instance=true | ||
1870 | 11 | X-Ubuntu-Touch=true | ||
1871 | 12 | |||
1872 | 13 | Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.music | ||
1873 | 14 | X-Ubuntu-Old-Icon=images/music.png | ||
1874 | 15 | X-Ubuntu-Application-ID=com.ubuntu.music_music_1.1.329 | ||
1875 | 16 | 0 | ||
1876 | === removed file 'libclickscope/tests/applications/user/com.ubuntu.notes_notes_1.4.242.desktop' | |||
1877 | --- libclickscope/tests/applications/user/com.ubuntu.notes_notes_1.4.242.desktop 2014-02-10 12:23:35 +0000 | |||
1878 | +++ libclickscope/tests/applications/user/com.ubuntu.notes_notes_1.4.242.desktop 1970-01-01 00:00:00 +0000 | |||
1879 | @@ -1,14 +0,0 @@ | |||
1880 | 1 | [Desktop Entry] | ||
1881 | 2 | Type=Application | ||
1882 | 3 | Exec=aa-exec-click -p com.ubuntu.notes_notes_1.4.242 -- qmlscene $@ -I ./usr/lib/arm-linux-gnueabihf/qt5/qml NotesApp.qml | ||
1883 | 4 | Name=Notes | ||
1884 | 5 | GenericName=Notes application for Ubuntu | ||
1885 | 6 | Icon=notepad | ||
1886 | 7 | Terminal=false | ||
1887 | 8 | |||
1888 | 9 | X-Ubuntu-Touch=true | ||
1889 | 10 | X-Ubuntu-StageHint=SideStage | ||
1890 | 11 | X-Ubuntu-Gettext-Domain=com.ubuntu.notes | ||
1891 | 12 | X-Ubuntu-Single-Instance=true | ||
1892 | 13 | Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.notes | ||
1893 | 14 | X-Ubuntu-Application-ID=com.ubuntu.notes_notes_1.4.242 | ||
1894 | 15 | 0 | ||
1895 | === removed file 'libclickscope/tests/applications/user/com.ubuntu.shorts_shorts_0.2.162.desktop' | |||
1896 | --- libclickscope/tests/applications/user/com.ubuntu.shorts_shorts_0.2.162.desktop 2014-02-10 12:23:35 +0000 | |||
1897 | +++ libclickscope/tests/applications/user/com.ubuntu.shorts_shorts_0.2.162.desktop 1970-01-01 00:00:00 +0000 | |||
1898 | @@ -1,14 +0,0 @@ | |||
1899 | 1 | [Desktop Entry] | ||
1900 | 2 | Version=1.0 | ||
1901 | 3 | Type=Application | ||
1902 | 4 | Terminal=false | ||
1903 | 5 | Exec=aa-exec-click -p com.ubuntu.shorts_shorts_0.2.162 -- qmlscene ./rssreader-app.qml | ||
1904 | 6 | Icon=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.shorts/./rssreader64.png | ||
1905 | 7 | Name=Shorts | ||
1906 | 8 | Keywords=shorts;rss;reader | ||
1907 | 9 | X-Ubuntu-Touch=true | ||
1908 | 10 | X-Ubuntu-StageHint=SideStage | ||
1909 | 11 | |||
1910 | 12 | Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.shorts | ||
1911 | 13 | X-Ubuntu-Old-Icon=./rssreader64.png | ||
1912 | 14 | X-Ubuntu-Application-ID=com.ubuntu.shorts_shorts_0.2.162 | ||
1913 | 15 | 0 | ||
1914 | === removed file 'libclickscope/tests/applications/user/com.ubuntu.stock-ticker-mobile_stock-ticker-mobile_0.3.7.66.desktop' | |||
1915 | --- libclickscope/tests/applications/user/com.ubuntu.stock-ticker-mobile_stock-ticker-mobile_0.3.7.66.desktop 2014-02-10 12:23:35 +0000 | |||
1916 | +++ libclickscope/tests/applications/user/com.ubuntu.stock-ticker-mobile_stock-ticker-mobile_0.3.7.66.desktop 1970-01-01 00:00:00 +0000 | |||
1917 | @@ -1,16 +0,0 @@ | |||
1918 | 1 | [Desktop Entry] | ||
1919 | 2 | Version=1.0 | ||
1920 | 3 | Name=Stock Ticker | ||
1921 | 4 | GenericName=Stock Ticker | ||
1922 | 5 | Comment=An awesome Stock Ticker application with all the features you could imagine | ||
1923 | 6 | Exec=aa-exec-click -p com.ubuntu.stock-ticker-mobile_stock-ticker-mobile_0.3.7.66 -- qmlscene Stock_Ticker.qml | ||
1924 | 7 | Icon=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.stock-ticker-mobile/icons/stock_icon_48.png | ||
1925 | 8 | Terminal=false | ||
1926 | 9 | Type=Application | ||
1927 | 10 | X-Ubuntu-Touch=true | ||
1928 | 11 | X-Ubuntu-StageHint=SideStage | ||
1929 | 12 | Categories=Utility; | ||
1930 | 13 | |||
1931 | 14 | Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.stock-ticker-mobile | ||
1932 | 15 | X-Ubuntu-Old-Icon=icons/stock_icon_48.png | ||
1933 | 16 | X-Ubuntu-Application-ID=com.ubuntu.stock-ticker-mobile_stock-ticker-mobile_0.3.7.66 | ||
1934 | 17 | 0 | ||
1935 | === removed file 'libclickscope/tests/applications/user/com.ubuntu.sudoku_sudoku_1.0.142.desktop' | |||
1936 | --- libclickscope/tests/applications/user/com.ubuntu.sudoku_sudoku_1.0.142.desktop 2014-02-10 12:23:35 +0000 | |||
1937 | +++ libclickscope/tests/applications/user/com.ubuntu.sudoku_sudoku_1.0.142.desktop 1970-01-01 00:00:00 +0000 | |||
1938 | @@ -1,15 +0,0 @@ | |||
1939 | 1 | [Desktop Entry] | ||
1940 | 2 | Name=Sudoku | ||
1941 | 3 | Version=1.0 | ||
1942 | 4 | Comment=Sudoku Game for Ubuntu Touch | ||
1943 | 5 | Exec=aa-exec-click -p com.ubuntu.sudoku_sudoku_1.0.142 -- qmlscene sudoku-app.qml | ||
1944 | 6 | Icon=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.sudoku/SudokuGameIcon.png | ||
1945 | 7 | Terminal=false | ||
1946 | 8 | Type=Application | ||
1947 | 9 | X-Ubuntu-Touch=true | ||
1948 | 10 | X-Ubuntu-StageHint=SideStage | ||
1949 | 11 | X-Ubuntu-Gettext-Domain=com.ubuntu.sudoku | ||
1950 | 12 | |||
1951 | 13 | Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.sudoku | ||
1952 | 14 | X-Ubuntu-Old-Icon=SudokuGameIcon.png | ||
1953 | 15 | X-Ubuntu-Application-ID=com.ubuntu.sudoku_sudoku_1.0.142 | ||
1954 | 16 | 0 | ||
1955 | === removed file 'libclickscope/tests/applications/user/com.ubuntu.terminal_terminal_0.5.29.desktop' | |||
1956 | --- libclickscope/tests/applications/user/com.ubuntu.terminal_terminal_0.5.29.desktop 2014-02-10 12:23:35 +0000 | |||
1957 | +++ libclickscope/tests/applications/user/com.ubuntu.terminal_terminal_0.5.29.desktop 1970-01-01 00:00:00 +0000 | |||
1958 | @@ -1,13 +0,0 @@ | |||
1959 | 1 | [Desktop Entry] | ||
1960 | 2 | Version=1.0 | ||
1961 | 3 | Type=Application | ||
1962 | 4 | Terminal=false | ||
1963 | 5 | Exec=aa-exec-click -p com.ubuntu.terminal_terminal_0.5.29 -- qmlscene ./ubuntu-terminal-app.qml -I ./plugins | ||
1964 | 6 | Icon=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.terminal/./terminal64.png | ||
1965 | 7 | Name=Terminal | ||
1966 | 8 | X-Ubuntu-Touch=true | ||
1967 | 9 | X-Ubuntu-StageHint=SideStage | ||
1968 | 10 | |||
1969 | 11 | Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.terminal | ||
1970 | 12 | X-Ubuntu-Old-Icon=./terminal64.png | ||
1971 | 13 | X-Ubuntu-Application-ID=com.ubuntu.terminal_terminal_0.5.29 | ||
1972 | 14 | 0 | ||
1973 | === removed file 'libclickscope/tests/applications/user/com.ubuntu.weather_weather_1.0.168.desktop' | |||
1974 | --- libclickscope/tests/applications/user/com.ubuntu.weather_weather_1.0.168.desktop 2014-04-10 17:29:49 +0000 | |||
1975 | +++ libclickscope/tests/applications/user/com.ubuntu.weather_weather_1.0.168.desktop 1970-01-01 00:00:00 +0000 | |||
1976 | @@ -1,15 +0,0 @@ | |||
1977 | 1 | [Desktop Entry] | ||
1978 | 2 | Version=1.0 | ||
1979 | 3 | Type=Application | ||
1980 | 4 | Terminal=false | ||
1981 | 5 | Exec=aa-exec-click -p com.ubuntu.weather_weather_1.0.168 -- qmlscene ./ubuntu-weather-app.qml | ||
1982 | 6 | Icon=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.weather/./weather64.png | ||
1983 | 7 | Name=Weather | ||
1984 | 8 | X-Ubuntu-Touch=true | ||
1985 | 9 | X-Ubuntu-StageHint=SideStage | ||
1986 | 10 | X-Ubuntu-Gettext-Domain=com.ubuntu.weather | ||
1987 | 11 | |||
1988 | 12 | # Fake an app installed from a .deb | ||
1989 | 13 | #Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.weather | ||
1990 | 14 | #X-Ubuntu-Old-Icon=./weather64.png | ||
1991 | 15 | #X-Ubuntu-Application-ID=com.ubuntu.weather_weather_1.0.168 | ||
1992 | 16 | 0 | ||
1993 | === removed file 'libclickscope/tests/applications/user/non-click-app-nodisplay.desktop' | |||
1994 | --- libclickscope/tests/applications/user/non-click-app-nodisplay.desktop 2014-04-08 20:04:45 +0000 | |||
1995 | +++ libclickscope/tests/applications/user/non-click-app-nodisplay.desktop 1970-01-01 00:00:00 +0000 | |||
1996 | @@ -1,9 +0,0 @@ | |||
1997 | 1 | [Desktop Entry] | ||
1998 | 2 | Type=Application | ||
1999 | 3 | Name=Sample Desktop-only non-click app | ||
2000 | 4 | GenericName=NonClickAppWithoutException | ||
2001 | 5 | Comment=multiline description goes here | ||
2002 | 6 | Exec=messaging-app %u | ||
2003 | 7 | Terminal=false | ||
2004 | 8 | MimeType=x-scheme-handler/contact;x-scheme-handler/call | ||
2005 | 9 | NoDisplay=true | ||
2006 | 10 | 0 | ||
2007 | === removed file 'libclickscope/tests/applications/user/non-click-app-onlyshowin-gnome-unity.desktop' | |||
2008 | --- libclickscope/tests/applications/user/non-click-app-onlyshowin-gnome-unity.desktop 2014-04-08 20:04:45 +0000 | |||
2009 | +++ libclickscope/tests/applications/user/non-click-app-onlyshowin-gnome-unity.desktop 1970-01-01 00:00:00 +0000 | |||
2010 | @@ -1,10 +0,0 @@ | |||
2011 | 1 | [Desktop Entry] | ||
2012 | 2 | Type=Application | ||
2013 | 3 | Name=Sample Desktop-only non-click app | ||
2014 | 4 | GenericName=NonClickAppWithoutException | ||
2015 | 5 | Comment=multiline description goes here | ||
2016 | 6 | Exec=messaging-app %u | ||
2017 | 7 | Terminal=false | ||
2018 | 8 | MimeType=x-scheme-handler/contact;x-scheme-handler/call | ||
2019 | 9 | OnlyShowIn=GNOME;Unity; | ||
2020 | 10 | Name[en_US]=non-click-app-onlyshowin-gnome-unity.desktop | ||
2021 | 11 | 0 | ||
2022 | === removed file 'libclickscope/tests/applications/user/non-click-app-onlyshowin-gnome.desktop' | |||
2023 | --- libclickscope/tests/applications/user/non-click-app-onlyshowin-gnome.desktop 2014-04-08 20:04:45 +0000 | |||
2024 | +++ libclickscope/tests/applications/user/non-click-app-onlyshowin-gnome.desktop 1970-01-01 00:00:00 +0000 | |||
2025 | @@ -1,10 +0,0 @@ | |||
2026 | 1 | [Desktop Entry] | ||
2027 | 2 | Type=Application | ||
2028 | 3 | Name=Sample Desktop-only non-click app | ||
2029 | 4 | GenericName=NonClickAppWithoutException | ||
2030 | 5 | Comment=multiline description goes here | ||
2031 | 6 | Exec=messaging-app %u | ||
2032 | 7 | Terminal=false | ||
2033 | 8 | MimeType=x-scheme-handler/contact;x-scheme-handler/call | ||
2034 | 9 | OnlyShowIn=GNOME; | ||
2035 | 10 | Name[en_US]=non-click-app-onlyshowin-gnome.desktop | ||
2036 | 11 | 0 | ||
2037 | === removed file 'libclickscope/tests/applications/user/non-click-app-onlyshowin-unity.desktop' | |||
2038 | --- libclickscope/tests/applications/user/non-click-app-onlyshowin-unity.desktop 2014-04-08 20:04:45 +0000 | |||
2039 | +++ libclickscope/tests/applications/user/non-click-app-onlyshowin-unity.desktop 1970-01-01 00:00:00 +0000 | |||
2040 | @@ -1,10 +0,0 @@ | |||
2041 | 1 | [Desktop Entry] | ||
2042 | 2 | Type=Application | ||
2043 | 3 | Name=Sample Desktop-only non-click app | ||
2044 | 4 | GenericName=NonClickAppWithoutException | ||
2045 | 5 | Comment=multiline description goes here | ||
2046 | 6 | Exec=messaging-app %u | ||
2047 | 7 | Terminal=false | ||
2048 | 8 | MimeType=x-scheme-handler/contact;x-scheme-handler/call | ||
2049 | 9 | OnlyShowIn=Unity; | ||
2050 | 10 | Name[en_US]=non-click-app-onlyshowin-unity.desktop | ||
2051 | 11 | 0 | ||
2052 | === removed file 'libclickscope/tests/applications/user/non-click-app-without-exception.desktop' | |||
2053 | --- libclickscope/tests/applications/user/non-click-app-without-exception.desktop 2014-04-08 21:16:25 +0000 | |||
2054 | +++ libclickscope/tests/applications/user/non-click-app-without-exception.desktop 1970-01-01 00:00:00 +0000 | |||
2055 | @@ -1,9 +0,0 @@ | |||
2056 | 1 | [Desktop Entry] | ||
2057 | 2 | Type=Application | ||
2058 | 3 | Name=Sample Desktop-only non-click app | ||
2059 | 4 | GenericName=NonClickAppWithoutException | ||
2060 | 5 | Comment=multiline description goes here | ||
2061 | 6 | Exec=messaging-app %u | ||
2062 | 7 | Terminal=false | ||
2063 | 8 | Icon=sample-desktop-app | ||
2064 | 9 | MimeType=x-scheme-handler/contact;x-scheme-handler/call | ||
2065 | 10 | 0 | ||
2066 | === removed file 'libclickscope/tests/applications/user/pre-translated.desktop' | |||
2067 | --- libclickscope/tests/applications/user/pre-translated.desktop 2015-11-24 18:23:23 +0000 | |||
2068 | +++ libclickscope/tests/applications/user/pre-translated.desktop 1970-01-01 00:00:00 +0000 | |||
2069 | @@ -1,14 +0,0 @@ | |||
2070 | 1 | [Desktop Entry] | ||
2071 | 2 | Version=1.0 | ||
2072 | 3 | Type=Application | ||
2073 | 4 | Terminal=false | ||
2074 | 5 | Exec=aa-exec-click -p com.ubuntu.clock_clock_1.0.300 -- qmlscene ./ubuntu-clock-app.qml | ||
2075 | 6 | Icon=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.clock/./clock64.png | ||
2076 | 7 | _Name=Untranslated Clock | ||
2077 | 8 | X-Ubuntu-Touch=true | ||
2078 | 9 | X-Ubuntu-StageHint=SideStage | ||
2079 | 10 | X-Ubuntu-Gettext-Domain=com.ubuntu.clock | ||
2080 | 11 | |||
2081 | 12 | Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.clock | ||
2082 | 13 | X-Ubuntu-Old-Icon=./clock64.png | ||
2083 | 14 | X-Ubuntu-Application-ID=com.ubuntu.clock_clock_1.0.300 | ||
2084 | 15 | 0 | ||
2085 | === removed file 'libclickscope/tests/applications/user/semi-broken.desktop' | |||
2086 | --- libclickscope/tests/applications/user/semi-broken.desktop 2014-04-28 22:10:15 +0000 | |||
2087 | +++ libclickscope/tests/applications/user/semi-broken.desktop 1970-01-01 00:00:00 +0000 | |||
2088 | @@ -1,1 +0,0 @@ | |||
2089 | 1 | semi broken file | ||
2090 | 2 | 0 | ||
2091 | === added file 'libclickscope/tests/mock_ual.h' | |||
2092 | --- libclickscope/tests/mock_ual.h 1970-01-01 00:00:00 +0000 | |||
2093 | +++ libclickscope/tests/mock_ual.h 2016-08-24 21:39:08 +0000 | |||
2094 | @@ -0,0 +1,156 @@ | |||
2095 | 1 | /* | ||
2096 | 2 | * Copyright (C) 2016 Canonical Ltd. | ||
2097 | 3 | * | ||
2098 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
2099 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
2100 | 6 | * by the Free Software Foundation. | ||
2101 | 7 | * | ||
2102 | 8 | * This program is distributed in the hope that it will be useful, but | ||
2103 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2104 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
2105 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
2106 | 12 | * | ||
2107 | 13 | * You should have received a copy of the GNU General Public License along | ||
2108 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2109 | 15 | * | ||
2110 | 16 | * In addition, as a special exception, the copyright holders give | ||
2111 | 17 | * permission to link the code of portions of this program with the | ||
2112 | 18 | * OpenSSL library under certain conditions as described in each | ||
2113 | 19 | * individual source file, and distribute linked combinations | ||
2114 | 20 | * including the two. | ||
2115 | 21 | * You must obey the GNU General Public License in all respects | ||
2116 | 22 | * for all of the code used other than OpenSSL. If you modify | ||
2117 | 23 | * file(s) with this exception, you may extend this exception to your | ||
2118 | 24 | * version of the file(s), but you are not obligated to do so. If you | ||
2119 | 25 | * do not wish to do so, delete this exception statement from your | ||
2120 | 26 | * version. If you delete this exception statement from all source | ||
2121 | 27 | * files in the program, then also delete it here. | ||
2122 | 28 | */ | ||
2123 | 29 | |||
2124 | 30 | #include <ubuntu-app-launch/registry.h> | ||
2125 | 31 | |||
2126 | 32 | using namespace ubuntu::app_launch; | ||
2127 | 33 | namespace ual = ubuntu::app_launch; | ||
2128 | 34 | |||
2129 | 35 | #include <gtest/gtest.h> | ||
2130 | 36 | #include <gmock/gmock.h> | ||
2131 | 37 | |||
2132 | 38 | using namespace ::testing; | ||
2133 | 39 | |||
2134 | 40 | namespace | ||
2135 | 41 | { | ||
2136 | 42 | |||
2137 | 43 | class MockUALRegistry : public ual::Registry { | ||
2138 | 44 | public: | ||
2139 | 45 | MockUALRegistry() | ||
2140 | 46 | { | ||
2141 | 47 | } | ||
2142 | 48 | |||
2143 | 49 | MOCK_METHOD1(installedApps, std::list<std::shared_ptr<ual::Application>>(std::shared_ptr<ual::Registry>)); | ||
2144 | 50 | }; | ||
2145 | 51 | |||
2146 | 52 | class MockUALApplication : public ual::Application { | ||
2147 | 53 | public: | ||
2148 | 54 | class MockInfo; | ||
2149 | 55 | class MockInstance; | ||
2150 | 56 | |||
2151 | 57 | MockUALApplication(const ual::AppID& app_id, | ||
2152 | 58 | const std::shared_ptr<MockInfo>& info = {}) | ||
2153 | 59 | : _app_id(app_id), | ||
2154 | 60 | _info(info) | ||
2155 | 61 | { | ||
2156 | 62 | } | ||
2157 | 63 | |||
2158 | 64 | ual::AppID appId() | ||
2159 | 65 | { | ||
2160 | 66 | return _app_id; | ||
2161 | 67 | } | ||
2162 | 68 | |||
2163 | 69 | std::shared_ptr<ual::Application::Info> info() | ||
2164 | 70 | { | ||
2165 | 71 | return _info; | ||
2166 | 72 | } | ||
2167 | 73 | |||
2168 | 74 | static std::shared_ptr<MockUALApplication> create(ual::AppID app_id, | ||
2169 | 75 | std::shared_ptr<MockInfo> info = {}) | ||
2170 | 76 | { | ||
2171 | 77 | std::shared_ptr<MockUALApplication> result{new MockUALApplication(app_id, info)}; | ||
2172 | 78 | return result; | ||
2173 | 79 | } | ||
2174 | 80 | |||
2175 | 81 | class MockInfo : public ual::Application::Info | ||
2176 | 82 | { | ||
2177 | 83 | public: | ||
2178 | 84 | MockInfo(const std::string& title, | ||
2179 | 85 | const std::string& description, | ||
2180 | 86 | const std::string& iconPath) | ||
2181 | 87 | : _name(ual::Application::Info::Name::from_raw(title)), | ||
2182 | 88 | _description(ual::Application::Info::Description::from_raw(description)), | ||
2183 | 89 | _iconPath(ual::Application::Info::IconPath::from_raw(iconPath)), | ||
2184 | 90 | _defaultDept(ual::Application::Info::DefaultDepartment::from_raw("")), | ||
2185 | 91 | _ssPath(ual::Application::Info::IconPath::from_raw("")), | ||
2186 | 92 | _keywords(ual::Application::Info::Keywords::from_raw(std::vector<std::string>{})) | ||
2187 | 93 | { | ||
2188 | 94 | DefaultValue<const ual::Application::Info::DefaultDepartment&>::Set(_defaultDept); | ||
2189 | 95 | DefaultValue<const ual::Application::Info::IconPath&>::Set(_ssPath); | ||
2190 | 96 | DefaultValue<const ual::Application::Info::Keywords&>::Set(_keywords); | ||
2191 | 97 | } | ||
2192 | 98 | |||
2193 | 99 | const ual::Application::Info::Name& name() | ||
2194 | 100 | { | ||
2195 | 101 | return _name; | ||
2196 | 102 | } | ||
2197 | 103 | |||
2198 | 104 | const ual::Application::Info::Description& description() | ||
2199 | 105 | { | ||
2200 | 106 | return _description; | ||
2201 | 107 | } | ||
2202 | 108 | |||
2203 | 109 | const ual::Application::Info::IconPath& iconPath() | ||
2204 | 110 | { | ||
2205 | 111 | return _iconPath; | ||
2206 | 112 | } | ||
2207 | 113 | |||
2208 | 114 | MOCK_METHOD0(defaultDepartment, const ual::Application::Info::DefaultDepartment&()); | ||
2209 | 115 | MOCK_METHOD0(screenshotPath, const ual::Application::Info::IconPath&()); | ||
2210 | 116 | MOCK_METHOD0(keywords, const ual::Application::Info::Keywords&()); | ||
2211 | 117 | |||
2212 | 118 | MOCK_METHOD0(splash, ual::Application::Info::Splash()); | ||
2213 | 119 | MOCK_METHOD0(supportedOrientations, ual::Application::Info::Orientations()); | ||
2214 | 120 | MOCK_METHOD0(rotatesWindowContents, ual::Application::Info::RotatesWindow()); | ||
2215 | 121 | MOCK_METHOD0(supportsUbuntuLifecycle, ual::Application::Info::UbuntuLifecycle()); | ||
2216 | 122 | |||
2217 | 123 | private: | ||
2218 | 124 | ual::Application::Info::Name _name; | ||
2219 | 125 | ual::Application::Info::Description _description; | ||
2220 | 126 | ual::Application::Info::IconPath _iconPath; | ||
2221 | 127 | ual::Application::Info::DefaultDepartment _defaultDept; | ||
2222 | 128 | ual::Application::Info::IconPath _ssPath; | ||
2223 | 129 | ual::Application::Info::Keywords _keywords; | ||
2224 | 130 | }; | ||
2225 | 131 | |||
2226 | 132 | class MockInstance : public ual::Application::Instance | ||
2227 | 133 | { | ||
2228 | 134 | public: | ||
2229 | 135 | MOCK_METHOD0(isRunning, bool()); | ||
2230 | 136 | MOCK_METHOD0(logPath, std::string()); | ||
2231 | 137 | MOCK_METHOD0(primaryPid, pid_t()); | ||
2232 | 138 | MOCK_METHOD1(hasPid, bool(pid_t)); | ||
2233 | 139 | MOCK_METHOD0(pids, std::vector<pid_t>()); | ||
2234 | 140 | MOCK_METHOD0(pause, void()); | ||
2235 | 141 | MOCK_METHOD0(resume, void()); | ||
2236 | 142 | MOCK_METHOD0(stop, void()); | ||
2237 | 143 | }; | ||
2238 | 144 | |||
2239 | 145 | MOCK_METHOD0(hasInstances, bool()); | ||
2240 | 146 | MOCK_METHOD0(instances, std::vector<std::shared_ptr<ual::Application::Instance>>()); | ||
2241 | 147 | MOCK_METHOD1(launch, std::shared_ptr<ual::Application::Instance>(const std::vector<ual::Application::URL>&)); | ||
2242 | 148 | MOCK_METHOD1(launchTest, std::shared_ptr<ual::Application::Instance>(const std::vector<ual::Application::URL>&)); | ||
2243 | 149 | |||
2244 | 150 | private: | ||
2245 | 151 | ual::AppID _app_id; | ||
2246 | 152 | std::shared_ptr<MockInfo> _info; | ||
2247 | 153 | }; | ||
2248 | 154 | |||
2249 | 155 | } // namespace | ||
2250 | 156 | |||
2251 | 0 | 157 | ||
2252 | === modified file 'libclickscope/tests/mock_webclient.h' | |||
2253 | --- libclickscope/tests/mock_webclient.h 2016-05-25 16:19:51 +0000 | |||
2254 | +++ libclickscope/tests/mock_webclient.h 2016-08-24 21:39:08 +0000 | |||
2255 | @@ -61,13 +61,6 @@ | |||
2256 | 61 | Mock instance; | 61 | Mock instance; |
2257 | 62 | }; | 62 | }; |
2258 | 63 | 63 | ||
2259 | 64 | QSharedPointer<click::web::Response> responseForReply(const QSharedPointer<click::network::Reply>& reply) | ||
2260 | 65 | { | ||
2261 | 66 | auto response = QSharedPointer<click::web::Response>(new click::web::Response(QSharedPointer<QNetworkRequest>(new QNetworkRequest()), QSharedPointer<QBuffer>(new QBuffer()))); | ||
2262 | 67 | response->setReply(reply); | ||
2263 | 68 | return response; | ||
2264 | 69 | } | ||
2265 | 70 | |||
2266 | 71 | class MockClient : public click::web::Client | 64 | class MockClient : public click::web::Client |
2267 | 72 | { | 65 | { |
2268 | 73 | public: | 66 | public: |
2269 | @@ -76,6 +69,7 @@ | |||
2270 | 76 | { | 69 | { |
2271 | 77 | } | 70 | } |
2272 | 78 | 71 | ||
2273 | 72 | MOCK_METHOD2(signUrl, std::string(const std::string&, const std::string&)); | ||
2274 | 79 | // Mocking default arguments: https://groups.google.com/forum/#!topic/googlemock/XrabW20vV7o | 73 | // Mocking default arguments: https://groups.google.com/forum/#!topic/googlemock/XrabW20vV7o |
2275 | 80 | MOCK_METHOD6(callImpl, QSharedPointer<click::web::Response>( | 74 | MOCK_METHOD6(callImpl, QSharedPointer<click::web::Response>( |
2276 | 81 | const std::string& iri, | 75 | const std::string& iri, |
2277 | @@ -102,6 +96,14 @@ | |||
2278 | 102 | 96 | ||
2279 | 103 | MOCK_METHOD1(has_header, bool(const std::string& header)); | 97 | MOCK_METHOD1(has_header, bool(const std::string& header)); |
2280 | 104 | MOCK_METHOD1(get_header, std::string(const std::string&header)); | 98 | MOCK_METHOD1(get_header, std::string(const std::string&header)); |
2281 | 99 | |||
2282 | 100 | static QSharedPointer<click::web::Response> responseForReply(const QSharedPointer<click::network::Reply>& reply) | ||
2283 | 101 | { | ||
2284 | 102 | auto response = QSharedPointer<click::web::Response>(new click::web::Response(QSharedPointer<QNetworkRequest>(new QNetworkRequest()), QSharedPointer<QBuffer>(new QBuffer()))); | ||
2285 | 103 | response->setReply(reply); | ||
2286 | 104 | return response; | ||
2287 | 105 | } | ||
2288 | 106 | |||
2289 | 105 | }; | 107 | }; |
2290 | 106 | 108 | ||
2291 | 107 | } | 109 | } |
2292 | 108 | 110 | ||
2293 | === modified file 'libclickscope/tests/test_bootstrap.cpp' | |||
2294 | --- libclickscope/tests/test_bootstrap.cpp 2016-06-30 20:42:56 +0000 | |||
2295 | +++ libclickscope/tests/test_bootstrap.cpp 2016-08-24 21:39:08 +0000 | |||
2296 | @@ -70,7 +70,7 @@ | |||
2297 | 70 | TEST_F(BootstrapTest, testBootstrapCallsWebservice) | 70 | TEST_F(BootstrapTest, testBootstrapCallsWebservice) |
2298 | 71 | { | 71 | { |
2299 | 72 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 72 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2301 | 73 | auto response = responseForReply(reply.asSharedPtr()); | 73 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
2302 | 74 | 74 | ||
2303 | 75 | EXPECT_CALL(*clientPtr, callImpl(EndsWith(click::BOOTSTRAP_PATH), "GET", _, _, _, _)) | 75 | EXPECT_CALL(*clientPtr, callImpl(EndsWith(click::BOOTSTRAP_PATH), "GET", _, _, _, _)) |
2304 | 76 | .Times(1) | 76 | .Times(1) |
2305 | @@ -81,7 +81,7 @@ | |||
2306 | 81 | TEST_F(BootstrapTest, testBootstrapJsonIsParsed) | 81 | TEST_F(BootstrapTest, testBootstrapJsonIsParsed) |
2307 | 82 | { | 82 | { |
2308 | 83 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 83 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2310 | 84 | auto response = responseForReply(reply.asSharedPtr()); | 84 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
2311 | 85 | 85 | ||
2312 | 86 | QByteArray fake_json(FAKE_JSON_BOOTSTRAP.c_str()); | 86 | QByteArray fake_json(FAKE_JSON_BOOTSTRAP.c_str()); |
2313 | 87 | EXPECT_CALL(reply.instance, readAll()) | 87 | EXPECT_CALL(reply.instance, readAll()) |
2314 | 88 | 88 | ||
2315 | === removed file 'libclickscope/tests/test_data.cpp.in' | |||
2316 | --- libclickscope/tests/test_data.cpp.in 2014-05-26 14:27:31 +0000 | |||
2317 | +++ libclickscope/tests/test_data.cpp.in 1970-01-01 00:00:00 +0000 | |||
2318 | @@ -1,43 +0,0 @@ | |||
2319 | 1 | /* | ||
2320 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
2321 | 3 | * | ||
2322 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
2323 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
2324 | 6 | * by the Free Software Foundation. | ||
2325 | 7 | * | ||
2326 | 8 | * This program is distributed in the hope that it will be useful, but | ||
2327 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2328 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
2329 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
2330 | 12 | * | ||
2331 | 13 | * You should have received a copy of the GNU General Public License along | ||
2332 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2333 | 15 | * | ||
2334 | 16 | * In addition, as a special exception, the copyright holders give | ||
2335 | 17 | * permission to link the code of portions of this program with the | ||
2336 | 18 | * OpenSSL library under certain conditions as described in each | ||
2337 | 19 | * individual source file, and distribute linked combinations | ||
2338 | 20 | * including the two. | ||
2339 | 21 | * You must obey the GNU General Public License in all respects | ||
2340 | 22 | * for all of the code used other than OpenSSL. If you modify | ||
2341 | 23 | * file(s) with this exception, you may extend this exception to your | ||
2342 | 24 | * version of the file(s), but you are not obligated to do so. If you | ||
2343 | 25 | * do not wish to do so, delete this exception statement from your | ||
2344 | 26 | * version. If you delete this exception statement from all source | ||
2345 | 27 | * files in the program, then also delete it here. | ||
2346 | 28 | */ | ||
2347 | 29 | |||
2348 | 30 | |||
2349 | 31 | #include "test_data.h" | ||
2350 | 32 | |||
2351 | 33 | const std::string& testing::systemApplicationsDirectoryForTesting() | ||
2352 | 34 | { | ||
2353 | 35 | static const std::string s{"@CMAKE_CURRENT_SOURCE_DIR@/applications/system"}; | ||
2354 | 36 | return s; | ||
2355 | 37 | } | ||
2356 | 38 | |||
2357 | 39 | const std::string& testing::userApplicationsDirectoryForTesting() | ||
2358 | 40 | { | ||
2359 | 41 | static const std::string s{"@CMAKE_CURRENT_SOURCE_DIR@/applications/user"}; | ||
2360 | 42 | return s; | ||
2361 | 43 | } | ||
2362 | 44 | 0 | ||
2363 | === modified file 'libclickscope/tests/test_data.h' | |||
2364 | --- libclickscope/tests/test_data.h 2014-05-26 14:27:31 +0000 | |||
2365 | +++ libclickscope/tests/test_data.h 2016-08-24 21:39:08 +0000 | |||
2366 | @@ -38,9 +38,6 @@ | |||
2367 | 38 | const std::string FAKE_PATH = "fake/api/path"; | 38 | const std::string FAKE_PATH = "fake/api/path"; |
2368 | 39 | const std::string FAKE_QUERY = "FAKE_QUERY"; | 39 | const std::string FAKE_QUERY = "FAKE_QUERY"; |
2369 | 40 | const std::string FAKE_PACKAGENAME = "com.example.fakepackage"; | 40 | const std::string FAKE_PACKAGENAME = "com.example.fakepackage"; |
2370 | 41 | |||
2371 | 42 | const std::string& systemApplicationsDirectoryForTesting(); | ||
2372 | 43 | const std::string& userApplicationsDirectoryForTesting(); | ||
2373 | 44 | } | 41 | } |
2374 | 45 | 42 | ||
2375 | 46 | #endif // TEST_DATA_H | 43 | #endif // TEST_DATA_H |
2376 | 47 | 44 | ||
2377 | === modified file 'libclickscope/tests/test_download_manager.cpp' | |||
2378 | --- libclickscope/tests/test_download_manager.cpp 2016-05-10 13:42:12 +0000 | |||
2379 | +++ libclickscope/tests/test_download_manager.cpp 2016-08-24 21:39:08 +0000 | |||
2380 | @@ -63,6 +63,7 @@ | |||
2381 | 63 | 63 | ||
2382 | 64 | virtual void SetUp() | 64 | virtual void SetUp() |
2383 | 65 | { | 65 | { |
2384 | 66 | sdmPtr.reset(new MockSystemDownloadManager()); | ||
2385 | 66 | ssoPtr.reset(new MockCredentialsService()); | 67 | ssoPtr.reset(new MockCredentialsService()); |
2386 | 67 | namPtr.reset(new MockNetworkAccessManager()); | 68 | namPtr.reset(new MockNetworkAccessManager()); |
2387 | 68 | clientPtr.reset(new NiceMock<MockClient>(namPtr)); | 69 | clientPtr.reset(new NiceMock<MockClient>(namPtr)); |
2388 | @@ -76,138 +77,165 @@ | |||
2389 | 76 | 77 | ||
2390 | 77 | } | 78 | } |
2391 | 78 | 79 | ||
2393 | 79 | TEST_F(DownloadManagerTest, testStartCallsWebservice) | 80 | TEST_F(DownloadManagerTest, testStartCallsSignUrl) |
2394 | 80 | { | 81 | { |
2402 | 81 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 82 | EXPECT_CALL(*clientPtr, signUrl(_, "GET")).Times(1); |
2403 | 82 | auto response = responseForReply(reply.asSharedPtr()); | 83 | EXPECT_CALL(*sdmPtr, createDownload(_, _, _)).Times(1); |
2397 | 83 | |||
2398 | 84 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) | ||
2399 | 85 | .Times(1) | ||
2400 | 86 | .WillOnce(Return(response)); | ||
2401 | 87 | |||
2404 | 88 | dmPtr->start("", "", "", | 84 | dmPtr->start("", "", "", |
2405 | 89 | [](std::string, click::DownloadManager::Error) {}); | 85 | [](std::string, click::DownloadManager::Error) {}); |
2406 | 90 | } | 86 | } |
2407 | 91 | 87 | ||
2527 | 92 | TEST_F(DownloadManagerTest, testStartCallbackCalled) | 88 | TEST_F(DownloadManagerTest, testStartDownloadSuccssIsError) |
2528 | 93 | { | 89 | { |
2529 | 94 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 90 | auto mockDownload = new MockDownload(); |
2530 | 95 | auto response = responseForReply(reply.asSharedPtr()); | 91 | auto mockError = new MockError(); |
2531 | 96 | 92 | EXPECT_CALL(*mockDownload, isError()) | |
2532 | 97 | EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(0))); | 93 | .Times(1) |
2533 | 98 | EXPECT_CALL(reply.instance, readAll()) | 94 | .WillOnce(Return(true)); |
2534 | 99 | .Times(1) | 95 | EXPECT_CALL(*mockDownload, error()) |
2535 | 100 | .WillOnce(Return("")); | 96 | .Times(1) |
2536 | 101 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) | 97 | .WillOnce(Return(mockError)); |
2537 | 102 | .Times(1) | 98 | EXPECT_CALL(*mockError, errorString()) |
2538 | 103 | .WillOnce(Return(response)); | 99 | .Times(1) |
2539 | 104 | EXPECT_CALL(*this, start_callback(_, _)).Times(1); | 100 | .WillOnce(Return(QStringLiteral(""))); |
2540 | 105 | 101 | ||
2541 | 106 | dmPtr->start("", "", "", | 102 | EXPECT_CALL(*clientPtr, signUrl(_, "GET")).Times(1); |
2542 | 107 | [this](std::string msg, click::DownloadManager::Error err) { | 103 | EXPECT_CALL(*sdmPtr, createDownload(_, _, _)) |
2543 | 108 | start_callback(msg, err); | 104 | .Times(1) |
2544 | 109 | }); | 105 | .WillOnce(InvokeArgument<1>(mockDownload)); |
2545 | 110 | response->replyFinished(); | 106 | EXPECT_CALL(*this, start_callback(_, _)).Times(1); |
2546 | 111 | } | 107 | |
2547 | 112 | 108 | dmPtr->start("", "", "", | |
2548 | 113 | TEST_F(DownloadManagerTest, testStartHTTPForbidden) | 109 | [this](std::string msg, click::DownloadManager::Error err) { |
2549 | 114 | { | 110 | start_callback(msg, err); |
2550 | 115 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 111 | }); |
2551 | 116 | auto response = responseForReply(reply.asSharedPtr()); | 112 | |
2552 | 117 | 113 | delete mockError; | |
2553 | 118 | EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(403))); | 114 | delete mockDownload; |
2554 | 119 | EXPECT_CALL(reply.instance, readAll()) | 115 | } |
2555 | 120 | .Times(1) | 116 | |
2556 | 121 | .WillOnce(Return("")); | 117 | TEST_F(DownloadManagerTest, testStartDownloadSuccssCallsStart) |
2557 | 122 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) | 118 | { |
2558 | 123 | .Times(1) | 119 | auto mockDownload = new MockDownload(); |
2559 | 124 | .WillOnce(Return(response)); | 120 | EXPECT_CALL(*mockDownload, isError()) |
2560 | 125 | EXPECT_CALL(*this, start_callback(StartsWith("Unhandled HTTP response code:"), | 121 | .Times(1) |
2561 | 126 | click::DownloadManager::Error::DownloadInstallError)).Times(1); | 122 | .WillOnce(Return(false)); |
2562 | 127 | 123 | EXPECT_CALL(*mockDownload, start()).Times(1); | |
2563 | 128 | dmPtr->start("", "", "", | 124 | EXPECT_CALL(*mockDownload, id()) |
2564 | 129 | [this](std::string msg, click::DownloadManager::Error err) { | 125 | .Times(1) |
2565 | 130 | start_callback(msg, err); | 126 | .WillOnce(Return(QStringLiteral("download"))); |
2566 | 131 | }); | 127 | |
2567 | 132 | response->replyFinished(); | 128 | EXPECT_CALL(*clientPtr, signUrl(_, "GET")).Times(1); |
2568 | 133 | } | 129 | EXPECT_CALL(*sdmPtr, createDownload(_, _, _)) |
2569 | 134 | 130 | .Times(1) | |
2570 | 135 | TEST_F(DownloadManagerTest, testStartHTTPError) | 131 | .WillOnce(InvokeArgument<1>(mockDownload)); |
2571 | 136 | { | 132 | EXPECT_CALL(*this, start_callback(_, _)).Times(1); |
2572 | 137 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 133 | |
2573 | 138 | auto response = responseForReply(reply.asSharedPtr()); | 134 | dmPtr->start("", "", "", |
2574 | 139 | 135 | [this](std::string msg, click::DownloadManager::Error err) { | |
2575 | 140 | EXPECT_CALL(reply.instance, errorString()) | 136 | start_callback(msg, err); |
2576 | 141 | .WillOnce(Return(QString("ERROR"))); | 137 | }); |
2577 | 142 | EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(404))); | 138 | |
2578 | 143 | EXPECT_CALL(reply.instance, readAll()) | 139 | delete mockDownload; |
2579 | 144 | .Times(1) | 140 | } |
2580 | 145 | .WillOnce(Return("")); | 141 | |
2581 | 146 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) | 142 | TEST_F(DownloadManagerTest, testStartErrorCallback) |
2582 | 147 | .Times(1) | 143 | { |
2583 | 148 | .WillOnce(Return(response)); | 144 | auto mockDownload = new MockDownload(); |
2584 | 149 | EXPECT_CALL(*this, start_callback("ERROR (203)", | 145 | auto mockError = new MockError(); |
2585 | 150 | click::DownloadManager::Error::DownloadInstallError)).Times(1); | 146 | EXPECT_CALL(*mockDownload, error()) |
2586 | 151 | 147 | .Times(1) | |
2587 | 152 | dmPtr->start("", "", "", | 148 | .WillOnce(Return(mockError)); |
2588 | 153 | [this](std::string msg, click::DownloadManager::Error err) { | 149 | EXPECT_CALL(*mockError, errorString()) |
2589 | 154 | start_callback(msg, err); | 150 | .Times(1) |
2590 | 155 | }); | 151 | .WillOnce(Return(QStringLiteral(""))); |
2591 | 156 | response->errorHandler(QNetworkReply::ContentNotFoundError); | 152 | |
2592 | 157 | } | 153 | EXPECT_CALL(*clientPtr, signUrl(_, "GET")).Times(1); |
2593 | 158 | 154 | EXPECT_CALL(*sdmPtr, createDownload(_, _, _)) | |
2594 | 159 | TEST_F(DownloadManagerTest, testStartCredentialsError) | 155 | .Times(1) |
2595 | 160 | { | 156 | .WillOnce(InvokeArgument<2>(mockDownload)); |
2596 | 161 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 157 | EXPECT_CALL(*this, start_callback(_, _)).Times(1); |
2597 | 162 | auto response = responseForReply(reply.asSharedPtr()); | 158 | |
2598 | 163 | 159 | dmPtr->start("", "", "", | |
2599 | 164 | EXPECT_CALL(reply.instance, errorString()) | 160 | [this](std::string msg, click::DownloadManager::Error err) { |
2600 | 165 | .WillOnce(Return(QString("ERROR"))); | 161 | start_callback(msg, err); |
2601 | 166 | EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(401))); | 162 | }); |
2602 | 167 | EXPECT_CALL(reply.instance, readAll()) | 163 | |
2603 | 168 | .Times(1) | 164 | delete mockError; |
2604 | 169 | .WillOnce(Return("")); | 165 | delete mockDownload; |
2605 | 170 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) | 166 | } |
2606 | 171 | .Times(1) | 167 | |
2607 | 172 | .WillOnce(Return(response)); | 168 | TEST_F(DownloadManagerTest, testGetProgressDownloadFound) |
2608 | 173 | EXPECT_CALL(*ssoPtr, invalidateCredentials()); | 169 | { |
2609 | 174 | EXPECT_CALL(*this, start_callback("ERROR (201)", | 170 | auto mockDownloadsList = new MockDownloadsList(); |
2610 | 175 | click::DownloadManager::Error::CredentialsError)).Times(1); | 171 | auto mockDownload = QSharedPointer<MockDownload>(new MockDownload()); |
2611 | 176 | 172 | ||
2612 | 177 | dmPtr->start("", "", "test.package", | 173 | QList<QSharedPointer<Ubuntu::DownloadManager::Download>> downloads{mockDownload}; |
2613 | 178 | [this](std::string msg, click::DownloadManager::Error err) { | 174 | |
2614 | 179 | start_callback(msg, err); | 175 | EXPECT_CALL(*mockDownload, id()) |
2615 | 180 | }); | 176 | .Times(1) |
2616 | 181 | response->errorHandler(QNetworkReply::ContentAccessDenied); | 177 | .WillOnce(Return("download")); |
2617 | 182 | } | 178 | EXPECT_CALL(*mockDownloadsList, downloads()) |
2618 | 183 | 179 | .Times(1) | |
2619 | 184 | // FIXME: createDownload() SEGV under tests | 180 | .WillOnce(Return(downloads)); |
2620 | 185 | TEST_F(DownloadManagerTest, DISABLED_testStartDownloadCreated) | 181 | EXPECT_CALL(*sdmPtr, getAllDownloadsWithMetadata(_, _, _, _)) |
2621 | 186 | { | 182 | .Times(1) |
2622 | 187 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 183 | .WillOnce(InvokeArgument<2>(QStringLiteral(""), QStringLiteral(""), |
2623 | 188 | auto response = responseForReply(reply.asSharedPtr()); | 184 | mockDownloadsList)); |
2624 | 189 | 185 | dmPtr->get_progress("com.example.test", | |
2625 | 190 | EXPECT_CALL(reply.instance, rawHeader(QByteArray("X-Click-Token"))) | 186 | [this](std::string object_path) { |
2626 | 191 | .Times(1) | 187 | progress_callback(object_path); |
2627 | 192 | .WillOnce(Return(QString("clicktoken"))); | 188 | }); |
2628 | 193 | EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(200))); | 189 | |
2629 | 194 | EXPECT_CALL(reply.instance, readAll()) | 190 | delete mockDownloadsList; |
2630 | 195 | .Times(1) | 191 | } |
2631 | 196 | .WillOnce(Return("")); | 192 | |
2632 | 197 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) | 193 | TEST_F(DownloadManagerTest, testGetProgressMultipleDownloadsFound) |
2633 | 198 | .Times(1) | 194 | { |
2634 | 199 | .WillOnce(Return(response)); | 195 | auto mockDownloadsList = new MockDownloadsList(); |
2635 | 200 | 196 | auto mockDownload = QSharedPointer<MockDownload>(new MockDownload()); | |
2636 | 201 | EXPECT_CALL(*sdmPtr, createDownload(_, _, _)); | 197 | auto mockDownload2 = QSharedPointer<MockDownload>(new MockDownload()); |
2637 | 202 | dmPtr->start("", "", "test.package", | 198 | |
2638 | 203 | [this](std::string msg, click::DownloadManager::Error err) { | 199 | QList<QSharedPointer<Ubuntu::DownloadManager::Download>> downloads{mockDownload, mockDownload2}; |
2639 | 204 | start_callback(msg, err); | 200 | |
2640 | 205 | }); | 201 | EXPECT_CALL(*mockDownload, id()) |
2641 | 206 | response->replyFinished(); | 202 | .Times(1) |
2642 | 207 | } | 203 | .WillOnce(Return("download")); |
2643 | 208 | 204 | EXPECT_CALL(*mockDownloadsList, downloads()) | |
2644 | 209 | // FIXME: getAllDownloadsWithMetadata() SEGV under tests | 205 | .Times(1) |
2645 | 210 | TEST_F(DownloadManagerTest, DISABLED_testGetProgressNoDownloads) | 206 | .WillOnce(Return(downloads)); |
2646 | 207 | EXPECT_CALL(*sdmPtr, getAllDownloadsWithMetadata(_, _, _, _)) | ||
2647 | 208 | .Times(1) | ||
2648 | 209 | .WillOnce(InvokeArgument<2>(QStringLiteral(""), QStringLiteral(""), | ||
2649 | 210 | mockDownloadsList)); | ||
2650 | 211 | dmPtr->get_progress("com.example.test", | ||
2651 | 212 | [this](std::string object_path) { | ||
2652 | 213 | progress_callback(object_path); | ||
2653 | 214 | }); | ||
2654 | 215 | |||
2655 | 216 | delete mockDownloadsList; | ||
2656 | 217 | } | ||
2657 | 218 | |||
2658 | 219 | TEST_F(DownloadManagerTest, testGetProgressNoDownloadsFound) | ||
2659 | 220 | { | ||
2660 | 221 | auto mockDownloadsList = new MockDownloadsList(); | ||
2661 | 222 | QList<QSharedPointer<Ubuntu::DownloadManager::Download>> emptyDownloads{}; | ||
2662 | 223 | EXPECT_CALL(*mockDownloadsList, downloads()) | ||
2663 | 224 | .Times(1) | ||
2664 | 225 | .WillOnce(Return(emptyDownloads)); | ||
2665 | 226 | EXPECT_CALL(*sdmPtr, getAllDownloadsWithMetadata(_, _, _, _)) | ||
2666 | 227 | .Times(1) | ||
2667 | 228 | .WillOnce(InvokeArgument<2>(QStringLiteral(""), QStringLiteral(""), | ||
2668 | 229 | mockDownloadsList)); | ||
2669 | 230 | dmPtr->get_progress("com.example.test", | ||
2670 | 231 | [this](std::string object_path) { | ||
2671 | 232 | progress_callback(object_path); | ||
2672 | 233 | }); | ||
2673 | 234 | |||
2674 | 235 | delete mockDownloadsList; | ||
2675 | 236 | } | ||
2676 | 237 | |||
2677 | 238 | TEST_F(DownloadManagerTest, testGetProgressErrorCallback) | ||
2678 | 211 | { | 239 | { |
2679 | 212 | EXPECT_CALL(*sdmPtr, getAllDownloadsWithMetadata(_, _, _, _)) | 240 | EXPECT_CALL(*sdmPtr, getAllDownloadsWithMetadata(_, _, _, _)) |
2680 | 213 | .Times(1) | 241 | .Times(1) |
2681 | 214 | 242 | ||
2682 | === modified file 'libclickscope/tests/test_index.cpp' | |||
2683 | --- libclickscope/tests/test_index.cpp 2016-05-10 13:42:12 +0000 | |||
2684 | +++ libclickscope/tests/test_index.cpp 2016-08-24 21:39:08 +0000 | |||
2685 | @@ -97,7 +97,7 @@ | |||
2686 | 97 | TEST_F(IndexTest, testSearchCallsWebservice) | 97 | TEST_F(IndexTest, testSearchCallsWebservice) |
2687 | 98 | { | 98 | { |
2688 | 99 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 99 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2690 | 100 | auto response = responseForReply(reply.asSharedPtr()); | 100 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
2691 | 101 | 101 | ||
2692 | 102 | EXPECT_CALL(*configPtr, get_architecture()) | 102 | EXPECT_CALL(*configPtr, get_architecture()) |
2693 | 103 | .Times(1) | 103 | .Times(1) |
2694 | @@ -120,7 +120,7 @@ | |||
2695 | 120 | TEST_F(IndexTest, testSearchQueryIsLowercase) | 120 | TEST_F(IndexTest, testSearchQueryIsLowercase) |
2696 | 121 | { | 121 | { |
2697 | 122 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 122 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2699 | 123 | auto response = responseForReply(reply.asSharedPtr()); | 123 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
2700 | 124 | 124 | ||
2701 | 125 | EXPECT_CALL(*configPtr, get_architecture()) | 125 | EXPECT_CALL(*configPtr, get_architecture()) |
2702 | 126 | .Times(1) | 126 | .Times(1) |
2703 | @@ -139,7 +139,7 @@ | |||
2704 | 139 | TEST_F(IndexTest, testSearchSignsCall) | 139 | TEST_F(IndexTest, testSearchSignsCall) |
2705 | 140 | { | 140 | { |
2706 | 141 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 141 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2708 | 142 | auto response = responseForReply(reply.asSharedPtr()); | 142 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
2709 | 143 | 143 | ||
2710 | 144 | EXPECT_CALL(*configPtr, get_architecture()) | 144 | EXPECT_CALL(*configPtr, get_architecture()) |
2711 | 145 | .Times(1) | 145 | .Times(1) |
2712 | @@ -154,10 +154,160 @@ | |||
2713 | 154 | indexPtr->search("", "", [](click::Packages, click::Packages) {}); | 154 | indexPtr->search("", "", [](click::Packages, click::Packages) {}); |
2714 | 155 | } | 155 | } |
2715 | 156 | 156 | ||
2716 | 157 | TEST_F(IndexTest, testSearchSnapsCallsWebservice) | ||
2717 | 158 | { | ||
2718 | 159 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | ||
2719 | 160 | auto response = MockClient::responseForReply(reply.asSharedPtr()); | ||
2720 | 161 | |||
2721 | 162 | EXPECT_CALL(*configPtr, get_architecture()) | ||
2722 | 163 | .Times(1) | ||
2723 | 164 | .WillOnce(Return(fake_arch)); | ||
2724 | 165 | EXPECT_CALL(*configPtr, get_available_frameworks()) | ||
2725 | 166 | .Times(1) | ||
2726 | 167 | .WillOnce(Return(fake_frameworks)); | ||
2727 | 168 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) | ||
2728 | 169 | .Times(1) | ||
2729 | 170 | .WillOnce(Return(response)); | ||
2730 | 171 | |||
2731 | 172 | indexPtr->search_snaps("", [](click::Packages, click::Packages) {}); | ||
2732 | 173 | } | ||
2733 | 174 | |||
2734 | 175 | TEST_F(IndexTest, testSearchSnapsSendsRightPath) | ||
2735 | 176 | { | ||
2736 | 177 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | ||
2737 | 178 | auto response = MockClient::responseForReply(reply.asSharedPtr()); | ||
2738 | 179 | |||
2739 | 180 | EXPECT_CALL(*configPtr, get_architecture()) | ||
2740 | 181 | .Times(1) | ||
2741 | 182 | .WillOnce(Return(fake_arch)); | ||
2742 | 183 | EXPECT_CALL(*configPtr, get_available_frameworks()) | ||
2743 | 184 | .Times(1) | ||
2744 | 185 | .WillOnce(Return(fake_frameworks)); | ||
2745 | 186 | EXPECT_CALL(*clientPtr, callImpl(EndsWith(click::SNAP_SEARCH_PATH), | ||
2746 | 187 | _, _, _, _, _)) | ||
2747 | 188 | .Times(1) | ||
2748 | 189 | .WillOnce(Return(response)); | ||
2749 | 190 | |||
2750 | 191 | indexPtr->search_snaps("", [](click::Packages, click::Packages) {}); | ||
2751 | 192 | } | ||
2752 | 193 | |||
2753 | 194 | TEST_F(IndexTest, testSearchSnapsQueryIsLowercase) | ||
2754 | 195 | { | ||
2755 | 196 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | ||
2756 | 197 | auto response = MockClient::responseForReply(reply.asSharedPtr()); | ||
2757 | 198 | |||
2758 | 199 | EXPECT_CALL(*configPtr, get_architecture()) | ||
2759 | 200 | .Times(1) | ||
2760 | 201 | .WillOnce(Return(fake_arch)); | ||
2761 | 202 | EXPECT_CALL(*configPtr, get_available_frameworks()) | ||
2762 | 203 | .Times(1) | ||
2763 | 204 | .WillOnce(Return(fake_frameworks)); | ||
2764 | 205 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, QueryContains("foobar"))) | ||
2765 | 206 | .Times(1) | ||
2766 | 207 | .WillOnce(Return(response)); | ||
2767 | 208 | |||
2768 | 209 | indexPtr->search_snaps("FooBar", [](click::Packages, click::Packages) {}); | ||
2769 | 210 | } | ||
2770 | 211 | |||
2771 | 212 | |||
2772 | 213 | TEST_F(IndexTest, testSearcSnapshSignsCall) | ||
2773 | 214 | { | ||
2774 | 215 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | ||
2775 | 216 | auto response = MockClient::responseForReply(reply.asSharedPtr()); | ||
2776 | 217 | |||
2777 | 218 | EXPECT_CALL(*configPtr, get_architecture()) | ||
2778 | 219 | .Times(1) | ||
2779 | 220 | .WillOnce(Return(fake_arch)); | ||
2780 | 221 | EXPECT_CALL(*configPtr, get_available_frameworks()) | ||
2781 | 222 | .Times(1) | ||
2782 | 223 | .WillOnce(Return(fake_frameworks)); | ||
2783 | 224 | EXPECT_CALL(*clientPtr, callImpl(_, _, true, _, _, _)) | ||
2784 | 225 | .Times(1) | ||
2785 | 226 | .WillOnce(Return(response)); | ||
2786 | 227 | |||
2787 | 228 | indexPtr->search_snaps("", [](click::Packages, click::Packages) {}); | ||
2788 | 229 | } | ||
2789 | 230 | |||
2790 | 231 | TEST_F(IndexTest, testSearchSnapsIsCancellable) | ||
2791 | 232 | { | ||
2792 | 233 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | ||
2793 | 234 | auto response = MockClient::responseForReply(reply.asSharedPtr()); | ||
2794 | 235 | |||
2795 | 236 | EXPECT_CALL(*configPtr, get_architecture()) | ||
2796 | 237 | .Times(1) | ||
2797 | 238 | .WillOnce(Return(fake_arch)); | ||
2798 | 239 | EXPECT_CALL(*configPtr, get_available_frameworks()) | ||
2799 | 240 | .Times(1) | ||
2800 | 241 | .WillOnce(Return(fake_frameworks)); | ||
2801 | 242 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) | ||
2802 | 243 | .Times(1) | ||
2803 | 244 | .WillOnce(Return(response)); | ||
2804 | 245 | |||
2805 | 246 | auto search_operation = indexPtr->search_snaps("", [](click::Packages, | ||
2806 | 247 | click::Packages) {}); | ||
2807 | 248 | EXPECT_CALL(reply.instance, abort()).Times(1); | ||
2808 | 249 | search_operation.cancel(); | ||
2809 | 250 | } | ||
2810 | 251 | |||
2811 | 252 | TEST_F(IndexTest, testSearchSnapsEmptyJsonIsParsed) | ||
2812 | 253 | { | ||
2813 | 254 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | ||
2814 | 255 | auto response = MockClient::responseForReply(reply.asSharedPtr()); | ||
2815 | 256 | |||
2816 | 257 | QByteArray fake_json("[]"); | ||
2817 | 258 | EXPECT_CALL(reply.instance, readAll()) | ||
2818 | 259 | .Times(1) | ||
2819 | 260 | .WillOnce(Return(fake_json)); | ||
2820 | 261 | EXPECT_CALL(*configPtr, get_architecture()) | ||
2821 | 262 | .Times(1) | ||
2822 | 263 | .WillOnce(Return(fake_arch)); | ||
2823 | 264 | EXPECT_CALL(*configPtr, get_available_frameworks()) | ||
2824 | 265 | .Times(1) | ||
2825 | 266 | .WillOnce(Return(fake_frameworks)); | ||
2826 | 267 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) | ||
2827 | 268 | .Times(1) | ||
2828 | 269 | .WillOnce(Return(response)); | ||
2829 | 270 | click::Packages empty_package_list; | ||
2830 | 271 | EXPECT_CALL(*this, search_callback(empty_package_list, _)).Times(1); | ||
2831 | 272 | |||
2832 | 273 | indexPtr->search_snaps("", [this](click::Packages packages, | ||
2833 | 274 | click::Packages recommends){ | ||
2834 | 275 | search_callback(packages, recommends); | ||
2835 | 276 | }); | ||
2836 | 277 | response->replyFinished(); | ||
2837 | 278 | } | ||
2838 | 279 | |||
2839 | 280 | TEST_F(IndexTest, testSearchSnapsNetworkErrorIgnored) | ||
2840 | 281 | { | ||
2841 | 282 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | ||
2842 | 283 | auto response = MockClient::responseForReply(reply.asSharedPtr()); | ||
2843 | 284 | |||
2844 | 285 | EXPECT_CALL(*configPtr, get_architecture()) | ||
2845 | 286 | .Times(1) | ||
2846 | 287 | .WillOnce(Return(fake_arch)); | ||
2847 | 288 | EXPECT_CALL(*configPtr, get_available_frameworks()) | ||
2848 | 289 | .Times(1) | ||
2849 | 290 | .WillOnce(Return(fake_frameworks)); | ||
2850 | 291 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) | ||
2851 | 292 | .Times(1) | ||
2852 | 293 | .WillOnce(Return(response)); | ||
2853 | 294 | EXPECT_CALL(reply.instance, errorString()).Times(1) | ||
2854 | 295 | .WillOnce(Return("fake error")); | ||
2855 | 296 | indexPtr->search_snaps("", [this](click::Packages packages, | ||
2856 | 297 | click::Packages recommends){ | ||
2857 | 298 | search_callback(packages, recommends); | ||
2858 | 299 | }); | ||
2859 | 300 | |||
2860 | 301 | click::Packages empty_package_list; | ||
2861 | 302 | EXPECT_CALL(*this, search_callback(empty_package_list, _)).Times(1); | ||
2862 | 303 | |||
2863 | 304 | emit reply.instance.error(QNetworkReply::UnknownNetworkError); | ||
2864 | 305 | } | ||
2865 | 306 | |||
2866 | 157 | TEST_F(IndexTest, testBootstrapSignsCall) | 307 | TEST_F(IndexTest, testBootstrapSignsCall) |
2867 | 158 | { | 308 | { |
2868 | 159 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 309 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2870 | 160 | auto response = responseForReply(reply.asSharedPtr()); | 310 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
2871 | 161 | 311 | ||
2872 | 162 | EXPECT_CALL(*configPtr, get_architecture()) | 312 | EXPECT_CALL(*configPtr, get_architecture()) |
2873 | 163 | .Times(1) | 313 | .Times(1) |
2874 | @@ -175,7 +325,7 @@ | |||
2875 | 175 | TEST_F(IndexTest, testDepartmentsSignsCall) | 325 | TEST_F(IndexTest, testDepartmentsSignsCall) |
2876 | 176 | { | 326 | { |
2877 | 177 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 327 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2879 | 178 | auto response = responseForReply(reply.asSharedPtr()); | 328 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
2880 | 179 | 329 | ||
2881 | 180 | EXPECT_CALL(*configPtr, get_architecture()) | 330 | EXPECT_CALL(*configPtr, get_architecture()) |
2882 | 181 | .Times(1) | 331 | .Times(1) |
2883 | @@ -193,8 +343,14 @@ | |||
2884 | 193 | TEST_F(IndexTest, testDetailsSignsCall) | 343 | TEST_F(IndexTest, testDetailsSignsCall) |
2885 | 194 | { | 344 | { |
2886 | 195 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 345 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2888 | 196 | auto response = responseForReply(reply.asSharedPtr()); | 346 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
2889 | 197 | 347 | ||
2890 | 348 | EXPECT_CALL(*configPtr, get_architecture()) | ||
2891 | 349 | .Times(1) | ||
2892 | 350 | .WillOnce(Return(fake_arch)); | ||
2893 | 351 | EXPECT_CALL(*configPtr, get_available_frameworks()) | ||
2894 | 352 | .Times(1) | ||
2895 | 353 | .WillOnce(Return(fake_frameworks)); | ||
2896 | 198 | EXPECT_CALL(*clientPtr, callImpl(_, _, true, _, _, _)) | 354 | EXPECT_CALL(*clientPtr, callImpl(_, _, true, _, _, _)) |
2897 | 199 | .Times(1) | 355 | .Times(1) |
2898 | 200 | .WillOnce(Return(response)); | 356 | .WillOnce(Return(response)); |
2899 | @@ -205,7 +361,7 @@ | |||
2900 | 205 | TEST_F(IndexTest, testSearchSendsRightPath) | 361 | TEST_F(IndexTest, testSearchSendsRightPath) |
2901 | 206 | { | 362 | { |
2902 | 207 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 363 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2904 | 208 | auto response = responseForReply(reply.asSharedPtr()); | 364 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
2905 | 209 | 365 | ||
2906 | 210 | EXPECT_CALL(*configPtr, get_architecture()) | 366 | EXPECT_CALL(*configPtr, get_architecture()) |
2907 | 211 | .Times(1) | 367 | .Times(1) |
2908 | @@ -224,7 +380,7 @@ | |||
2909 | 224 | TEST_F(IndexTest, testSearchCallbackIsCalled) | 380 | TEST_F(IndexTest, testSearchCallbackIsCalled) |
2910 | 225 | { | 381 | { |
2911 | 226 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 382 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2913 | 227 | auto response = responseForReply(reply.asSharedPtr()); | 383 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
2914 | 228 | 384 | ||
2915 | 229 | QByteArray fake_json("[]"); | 385 | QByteArray fake_json("[]"); |
2916 | 230 | EXPECT_CALL(reply.instance, readAll()) | 386 | EXPECT_CALL(reply.instance, readAll()) |
2917 | @@ -251,7 +407,7 @@ | |||
2918 | 251 | TEST_F(IndexTest, testSearchEmptyJsonIsParsed) | 407 | TEST_F(IndexTest, testSearchEmptyJsonIsParsed) |
2919 | 252 | { | 408 | { |
2920 | 253 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 409 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2922 | 254 | auto response = responseForReply(reply.asSharedPtr()); | 410 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
2923 | 255 | 411 | ||
2924 | 256 | QByteArray fake_json("[]"); | 412 | QByteArray fake_json("[]"); |
2925 | 257 | EXPECT_CALL(reply.instance, readAll()) | 413 | EXPECT_CALL(reply.instance, readAll()) |
2926 | @@ -279,7 +435,7 @@ | |||
2927 | 279 | TEST_F(IndexTest, testSearchSingleJsonIsParsed) | 435 | TEST_F(IndexTest, testSearchSingleJsonIsParsed) |
2928 | 280 | { | 436 | { |
2929 | 281 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 437 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2931 | 282 | auto response = responseForReply(reply.asSharedPtr()); | 438 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
2932 | 283 | 439 | ||
2933 | 284 | QByteArray fake_json(FAKE_JSON_SEARCH_RESULT_ONE.c_str()); | 440 | QByteArray fake_json(FAKE_JSON_SEARCH_RESULT_ONE.c_str()); |
2934 | 285 | EXPECT_CALL(reply.instance, readAll()) | 441 | EXPECT_CALL(reply.instance, readAll()) |
2935 | @@ -315,7 +471,7 @@ | |||
2936 | 315 | TEST_F(IndexTest, testSearchIsCancellable) | 471 | TEST_F(IndexTest, testSearchIsCancellable) |
2937 | 316 | { | 472 | { |
2938 | 317 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 473 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2940 | 318 | auto response = responseForReply(reply.asSharedPtr()); | 474 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
2941 | 319 | 475 | ||
2942 | 320 | EXPECT_CALL(*configPtr, get_architecture()) | 476 | EXPECT_CALL(*configPtr, get_architecture()) |
2943 | 321 | .Times(1) | 477 | .Times(1) |
2944 | @@ -341,7 +497,7 @@ | |||
2945 | 341 | TEST_F(IndexTest, testSearchNetworkErrorIgnored) | 497 | TEST_F(IndexTest, testSearchNetworkErrorIgnored) |
2946 | 342 | { | 498 | { |
2947 | 343 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 499 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2949 | 344 | auto response = responseForReply(reply.asSharedPtr()); | 500 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
2950 | 345 | 501 | ||
2951 | 346 | EXPECT_CALL(*configPtr, get_architecture()) | 502 | EXPECT_CALL(*configPtr, get_architecture()) |
2952 | 347 | .Times(1) | 503 | .Times(1) |
2953 | @@ -367,8 +523,14 @@ | |||
2954 | 367 | TEST_F(IndexTest, testGetDetailsCallsWebservice) | 523 | TEST_F(IndexTest, testGetDetailsCallsWebservice) |
2955 | 368 | { | 524 | { |
2956 | 369 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 525 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2958 | 370 | auto response = responseForReply(reply.asSharedPtr()); | 526 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
2959 | 371 | 527 | ||
2960 | 528 | EXPECT_CALL(*configPtr, get_architecture()) | ||
2961 | 529 | .Times(1) | ||
2962 | 530 | .WillOnce(Return(fake_arch)); | ||
2963 | 531 | EXPECT_CALL(*configPtr, get_available_frameworks()) | ||
2964 | 532 | .Times(1) | ||
2965 | 533 | .WillOnce(Return(fake_frameworks)); | ||
2966 | 372 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) | 534 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
2967 | 373 | .Times(1) | 535 | .Times(1) |
2968 | 374 | .WillOnce(Return(response)); | 536 | .WillOnce(Return(response)); |
2969 | @@ -379,8 +541,14 @@ | |||
2970 | 379 | TEST_F(IndexTest, testGetDetailsSendsPackagename) | 541 | TEST_F(IndexTest, testGetDetailsSendsPackagename) |
2971 | 380 | { | 542 | { |
2972 | 381 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 543 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2974 | 382 | auto response = responseForReply(reply.asSharedPtr()); | 544 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
2975 | 383 | 545 | ||
2976 | 546 | EXPECT_CALL(*configPtr, get_architecture()) | ||
2977 | 547 | .Times(1) | ||
2978 | 548 | .WillOnce(Return(fake_arch)); | ||
2979 | 549 | EXPECT_CALL(*configPtr, get_available_frameworks()) | ||
2980 | 550 | .Times(1) | ||
2981 | 551 | .WillOnce(Return(fake_frameworks)); | ||
2982 | 384 | EXPECT_CALL(*clientPtr, callImpl(EndsWith(FAKE_PACKAGENAME), | 552 | EXPECT_CALL(*clientPtr, callImpl(EndsWith(FAKE_PACKAGENAME), |
2983 | 385 | _, _, _, _, _)) | 553 | _, _, _, _, _)) |
2984 | 386 | .Times(1) | 554 | .Times(1) |
2985 | @@ -392,8 +560,14 @@ | |||
2986 | 392 | TEST_F(IndexTest, testGetDetailsSendsRightPath) | 560 | TEST_F(IndexTest, testGetDetailsSendsRightPath) |
2987 | 393 | { | 561 | { |
2988 | 394 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 562 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2990 | 395 | auto response = responseForReply(reply.asSharedPtr()); | 563 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
2991 | 396 | 564 | ||
2992 | 565 | EXPECT_CALL(*configPtr, get_architecture()) | ||
2993 | 566 | .Times(1) | ||
2994 | 567 | .WillOnce(Return(fake_arch)); | ||
2995 | 568 | EXPECT_CALL(*configPtr, get_available_frameworks()) | ||
2996 | 569 | .Times(1) | ||
2997 | 570 | .WillOnce(Return(fake_frameworks)); | ||
2998 | 397 | EXPECT_CALL(*clientPtr, callImpl(StartsWith(click::SEARCH_BASE_URL + | 571 | EXPECT_CALL(*clientPtr, callImpl(StartsWith(click::SEARCH_BASE_URL + |
2999 | 398 | click::DETAILS_PATH), | 572 | click::DETAILS_PATH), |
3000 | 399 | _, _, _, _, _)) | 573 | _, _, _, _, _)) |
3001 | @@ -406,8 +580,14 @@ | |||
3002 | 406 | TEST_F(IndexTest, testGetDetailsCallbackIsCalled) | 580 | TEST_F(IndexTest, testGetDetailsCallbackIsCalled) |
3003 | 407 | { | 581 | { |
3004 | 408 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 582 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3006 | 409 | auto response = responseForReply(reply.asSharedPtr()); | 583 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
3007 | 410 | 584 | ||
3008 | 585 | EXPECT_CALL(*configPtr, get_architecture()) | ||
3009 | 586 | .Times(1) | ||
3010 | 587 | .WillOnce(Return(fake_arch)); | ||
3011 | 588 | EXPECT_CALL(*configPtr, get_available_frameworks()) | ||
3012 | 589 | .Times(1) | ||
3013 | 590 | .WillOnce(Return(fake_frameworks)); | ||
3014 | 411 | QByteArray fake_json(FAKE_JSON_PACKAGE_DETAILS.c_str()); | 591 | QByteArray fake_json(FAKE_JSON_PACKAGE_DETAILS.c_str()); |
3015 | 412 | EXPECT_CALL(reply.instance, readAll()) | 592 | EXPECT_CALL(reply.instance, readAll()) |
3016 | 413 | .Times(1) | 593 | .Times(1) |
3017 | @@ -425,8 +605,14 @@ | |||
3018 | 425 | TEST_F(IndexTest, testGetDetailsJsonIsParsed) | 605 | TEST_F(IndexTest, testGetDetailsJsonIsParsed) |
3019 | 426 | { | 606 | { |
3020 | 427 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 607 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3022 | 428 | auto response = responseForReply(reply.asSharedPtr()); | 608 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
3023 | 429 | 609 | ||
3024 | 610 | EXPECT_CALL(*configPtr, get_architecture()) | ||
3025 | 611 | .Times(1) | ||
3026 | 612 | .WillOnce(Return(fake_arch)); | ||
3027 | 613 | EXPECT_CALL(*configPtr, get_available_frameworks()) | ||
3028 | 614 | .Times(1) | ||
3029 | 615 | .WillOnce(Return(fake_frameworks)); | ||
3030 | 430 | QByteArray fake_json(FAKE_JSON_PACKAGE_DETAILS.c_str()); | 616 | QByteArray fake_json(FAKE_JSON_PACKAGE_DETAILS.c_str()); |
3031 | 431 | EXPECT_CALL(reply.instance, readAll()) | 617 | EXPECT_CALL(reply.instance, readAll()) |
3032 | 432 | .Times(1) | 618 | .Times(1) |
3033 | @@ -486,7 +672,14 @@ | |||
3034 | 486 | TEST_F(IndexTest, testGetDetailsJsonUtf8) | 672 | TEST_F(IndexTest, testGetDetailsJsonUtf8) |
3035 | 487 | { | 673 | { |
3036 | 488 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 674 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3038 | 489 | auto response = responseForReply(reply.asSharedPtr()); | 675 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
3039 | 676 | |||
3040 | 677 | EXPECT_CALL(*configPtr, get_architecture()) | ||
3041 | 678 | .Times(1) | ||
3042 | 679 | .WillOnce(Return(fake_arch)); | ||
3043 | 680 | EXPECT_CALL(*configPtr, get_available_frameworks()) | ||
3044 | 681 | .Times(1) | ||
3045 | 682 | .WillOnce(Return(fake_frameworks)); | ||
3046 | 490 | 683 | ||
3047 | 491 | QByteArray appname_utf8("\xe5\xb0\x8f\xe6\xb5\xb7"); | 684 | QByteArray appname_utf8("\xe5\xb0\x8f\xe6\xb5\xb7"); |
3048 | 492 | QByteArray appname_json("\\u5c0f\\u6d77"); | 685 | QByteArray appname_json("\\u5c0f\\u6d77"); |
3049 | @@ -554,8 +747,14 @@ | |||
3050 | 554 | TEST_F(IndexTest, testGetDetailsNetworkErrorReported) | 747 | TEST_F(IndexTest, testGetDetailsNetworkErrorReported) |
3051 | 555 | { | 748 | { |
3052 | 556 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 749 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3054 | 557 | auto response = responseForReply(reply.asSharedPtr()); | 750 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
3055 | 558 | 751 | ||
3056 | 752 | EXPECT_CALL(*configPtr, get_architecture()) | ||
3057 | 753 | .Times(1) | ||
3058 | 754 | .WillOnce(Return(fake_arch)); | ||
3059 | 755 | EXPECT_CALL(*configPtr, get_available_frameworks()) | ||
3060 | 756 | .Times(1) | ||
3061 | 757 | .WillOnce(Return(fake_frameworks)); | ||
3062 | 559 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) | 758 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
3063 | 560 | .Times(1) | 759 | .Times(1) |
3064 | 561 | .WillOnce(Return(response)); | 760 | .WillOnce(Return(response)); |
3065 | @@ -571,8 +770,14 @@ | |||
3066 | 571 | TEST_F(IndexTest, testGetDetailsIsCancellable) | 770 | TEST_F(IndexTest, testGetDetailsIsCancellable) |
3067 | 572 | { | 771 | { |
3068 | 573 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 772 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3070 | 574 | auto response = responseForReply(reply.asSharedPtr()); | 773 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
3071 | 575 | 774 | ||
3072 | 775 | EXPECT_CALL(*configPtr, get_architecture()) | ||
3073 | 776 | .Times(1) | ||
3074 | 777 | .WillOnce(Return(fake_arch)); | ||
3075 | 778 | EXPECT_CALL(*configPtr, get_available_frameworks()) | ||
3076 | 779 | .Times(1) | ||
3077 | 780 | .WillOnce(Return(fake_frameworks)); | ||
3078 | 576 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) | 781 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
3079 | 577 | .Times(1) | 782 | .Times(1) |
3080 | 578 | .WillOnce(Return(response)); | 783 | .WillOnce(Return(response)); |
3081 | 579 | 784 | ||
3082 | === modified file 'libclickscope/tests/test_interface.cpp' | |||
3083 | --- libclickscope/tests/test_interface.cpp 2016-07-11 19:12:17 +0000 | |||
3084 | +++ libclickscope/tests/test_interface.cpp 2016-08-24 21:39:08 +0000 | |||
3085 | @@ -28,6 +28,7 @@ | |||
3086 | 28 | */ | 28 | */ |
3087 | 29 | 29 | ||
3088 | 30 | #include "fake_json.h" | 30 | #include "fake_json.h" |
3089 | 31 | #include "mock_ual.h" | ||
3090 | 31 | #include "test_data.h" | 32 | #include "test_data.h" |
3091 | 32 | 33 | ||
3092 | 33 | #include <QCoreApplication> | 34 | #include <QCoreApplication> |
3093 | @@ -41,7 +42,6 @@ | |||
3094 | 41 | #include <gtest/gtest.h> | 42 | #include <gtest/gtest.h> |
3095 | 42 | 43 | ||
3096 | 43 | #include <click/interface.h> | 44 | #include <click/interface.h> |
3097 | 44 | #include <click/key_file_locator.h> | ||
3098 | 45 | #include <click/departments-db.h> | 45 | #include <click/departments-db.h> |
3099 | 46 | 46 | ||
3100 | 47 | using namespace click; | 47 | using namespace click; |
3101 | @@ -99,30 +99,6 @@ | |||
3102 | 99 | { | 99 | { |
3103 | 100 | const std::string emptyQuery{}; | 100 | const std::string emptyQuery{}; |
3104 | 101 | 101 | ||
3105 | 102 | struct MockKeyFileLocator : public click::KeyFileLocator | ||
3106 | 103 | { | ||
3107 | 104 | typedef click::KeyFileLocator Super; | ||
3108 | 105 | |||
3109 | 106 | MockKeyFileLocator() | ||
3110 | 107 | { | ||
3111 | 108 | using namespace ::testing; | ||
3112 | 109 | |||
3113 | 110 | ON_CALL(*this, enumerateKeyFilesForInstalledApplications(_)) | ||
3114 | 111 | .WillByDefault( | ||
3115 | 112 | Invoke( | ||
3116 | 113 | this, | ||
3117 | 114 | &MockKeyFileLocator::doEnumerateKeyFilesForInstalledApplications)); | ||
3118 | 115 | } | ||
3119 | 116 | |||
3120 | 117 | MOCK_METHOD1(enumerateKeyFilesForInstalledApplications, | ||
3121 | 118 | void(const Super::Enumerator&)); | ||
3122 | 119 | |||
3123 | 120 | void doEnumerateKeyFilesForInstalledApplications(const Super::Enumerator& enumerator) | ||
3124 | 121 | { | ||
3125 | 122 | Super::enumerateKeyFilesForInstalledApplications(enumerator); | ||
3126 | 123 | } | ||
3127 | 124 | }; | ||
3128 | 125 | |||
3129 | 126 | class ClickInterfaceTest : public ::testing::Test { | 102 | class ClickInterfaceTest : public ::testing::Test { |
3130 | 127 | public: | 103 | public: |
3131 | 128 | MOCK_METHOD2(manifest_callback, void(Manifest, InterfaceError)); | 104 | MOCK_METHOD2(manifest_callback, void(Manifest, InterfaceError)); |
3132 | @@ -136,11 +112,10 @@ | |||
3133 | 136 | 112 | ||
3134 | 137 | class FakeClickInterface : public click::Interface { | 113 | class FakeClickInterface : public click::Interface { |
3135 | 138 | public: | 114 | public: |
3136 | 139 | FakeClickInterface(const QSharedPointer<KeyFileLocator>& keyFileLocator) : Interface(keyFileLocator) {} | ||
3137 | 140 | FakeClickInterface() {} | 115 | FakeClickInterface() {} |
3138 | 141 | 116 | ||
3141 | 142 | MOCK_METHOD0(show_desktop_apps, bool()); | 117 | MOCK_METHOD1(get_manifest_json, std::string(const std::string&)); |
3142 | 143 | MOCK_METHOD2(run_process, void(const std::string&, std::function<void(int, const std::string&, const std::string&)>)); | 118 | MOCK_METHOD0(installed_apps, std::list<std::shared_ptr<ual::Application>>()); |
3143 | 144 | }; | 119 | }; |
3144 | 145 | 120 | ||
3145 | 146 | TEST(ClickInterface, testIsNonClickAppFalse) | 121 | TEST(ClickInterface, testIsNonClickAppFalse) |
3146 | @@ -154,114 +129,104 @@ | |||
3147 | 154 | // If this ever breaks, something is very very wrong. | 129 | // If this ever breaks, something is very very wrong. |
3148 | 155 | for (const auto& element : nonClickDesktopFiles()) | 130 | for (const auto& element : nonClickDesktopFiles()) |
3149 | 156 | { | 131 | { |
3152 | 157 | QString filename = element.c_str(); | 132 | EXPECT_TRUE(Interface::is_non_click_app(element)); |
3151 | 158 | EXPECT_TRUE(Interface::is_non_click_app(filename)); | ||
3153 | 159 | } | 133 | } |
3154 | 160 | } | 134 | } |
3155 | 161 | 135 | ||
3156 | 162 | TEST(ClickInterface, testCallsIntoKeyFileLocatorForFindingInstalledApps) | ||
3157 | 163 | { | ||
3158 | 164 | using namespace ::testing; | ||
3159 | 165 | MockKeyFileLocator mockKeyFileLocator; | ||
3160 | 166 | QSharedPointer<click::KeyFileLocator> keyFileLocator( | ||
3161 | 167 | &mockKeyFileLocator, | ||
3162 | 168 | [](click::KeyFileLocator*){}); | ||
3163 | 169 | |||
3164 | 170 | |||
3165 | 171 | FakeClickInterface iface(keyFileLocator); | ||
3166 | 172 | EXPECT_CALL(iface, show_desktop_apps()) | ||
3167 | 173 | .Times(1) | ||
3168 | 174 | .WillOnce(Return(false)); | ||
3169 | 175 | |||
3170 | 176 | EXPECT_CALL(mockKeyFileLocator, enumerateKeyFilesForInstalledApplications(_)).Times(1); | ||
3171 | 177 | |||
3172 | 178 | iface.find_installed_apps(emptyQuery); | ||
3173 | 179 | } | ||
3174 | 180 | |||
3175 | 181 | TEST(ClickInterface, testFindAppsInDirEmpty) | 136 | TEST(ClickInterface, testFindAppsInDirEmpty) |
3176 | 182 | { | 137 | { |
3185 | 183 | QSharedPointer<click::KeyFileLocator> keyFileLocator( | 138 | FakeClickInterface iface; |
3186 | 184 | new click::KeyFileLocator( | 139 | |
3187 | 185 | testing::systemApplicationsDirectoryForTesting(), | 140 | EXPECT_CALL(iface, installed_apps()).Times(1). |
3188 | 186 | testing::userApplicationsDirectoryForTesting())); | 141 | WillOnce(Return(std::list<std::shared_ptr<ual::Application>>{})); |
3189 | 187 | 142 | auto results = iface.search("xyzzygy"); | |
3182 | 188 | click::Interface iface(keyFileLocator); | ||
3183 | 189 | |||
3184 | 190 | auto results = iface.find_installed_apps("xyzzygy"); | ||
3190 | 191 | 143 | ||
3191 | 192 | EXPECT_TRUE(results.empty()); | 144 | EXPECT_TRUE(results.empty()); |
3192 | 193 | } | 145 | } |
3193 | 194 | 146 | ||
3194 | 195 | TEST_F(ClickInterfaceTest, testFindAppsInDirIgnoredApps) | 147 | TEST_F(ClickInterfaceTest, testFindAppsInDirIgnoredApps) |
3195 | 196 | { | 148 | { |
3200 | 197 | QSharedPointer<click::KeyFileLocator> keyFileLocator( | 149 | FakeClickInterface iface; |
3201 | 198 | new click::KeyFileLocator( | 150 | std::list<std::shared_ptr<ual::Application>> applist{ |
3202 | 199 | testing::systemApplicationsDirectoryForTesting(), | 151 | MockUALApplication::create(ual::AppID::parse("com.ubuntu.calculator_calculator_0.1"), |
3203 | 200 | testing::userApplicationsDirectoryForTesting())); | 152 | std::shared_ptr<MockUALApplication::MockInfo>{new MockUALApplication::MockInfo("Calculator", "The calculator", "/opt/click.ubuntu.com/foo/bar/calculator.png")}), |
3204 | 153 | MockUALApplication::create(ual::AppID::find("webbrowser-app"), | ||
3205 | 154 | std::shared_ptr<MockUALApplication::MockInfo>{new MockUALApplication::MockInfo("Browser", "The browser", "webbrowser-app")}), | ||
3206 | 155 | MockUALApplication::create(ual::AppID::find("messaging-app"), | ||
3207 | 156 | std::shared_ptr<MockUALApplication::MockInfo>{new MockUALApplication::MockInfo("Messaging", "Your messages", "messaging-app")}), | ||
3208 | 157 | }; | ||
3209 | 201 | 158 | ||
3210 | 202 | click::Interface iface(keyFileLocator); | ||
3211 | 203 | ignoredApps.push_back("messaging-app.desktop"); | 159 | ignoredApps.push_back("messaging-app.desktop"); |
3212 | 204 | ignoredApps.push_back("com.ubuntu.calculator"); | 160 | ignoredApps.push_back("com.ubuntu.calculator"); |
3213 | 205 | 161 | ||
3216 | 206 | auto results = iface.find_installed_apps("", ignoredApps); | 162 | EXPECT_CALL(iface, installed_apps()).Times(1). |
3217 | 207 | EXPECT_EQ(20, results.size()); | 163 | WillOnce(Return(applist)); |
3218 | 164 | auto results = iface.search("", ignoredApps); | ||
3219 | 165 | ASSERT_EQ(1, results.size()); | ||
3220 | 208 | } | 166 | } |
3221 | 209 | 167 | ||
3222 | 210 | TEST_F(ClickInterfaceTest, testFindClockUsesShortAppid) | 168 | TEST_F(ClickInterfaceTest, testFindClockUsesShortAppid) |
3223 | 211 | { | 169 | { |
3233 | 212 | QSharedPointer<click::KeyFileLocator> keyFileLocator( | 170 | FakeClickInterface iface; |
3234 | 213 | new click::KeyFileLocator( | 171 | |
3235 | 214 | testing::systemApplicationsDirectoryForTesting(), | 172 | EXPECT_CALL(iface, installed_apps()).Times(1). |
3236 | 215 | testing::userApplicationsDirectoryForTesting())); | 173 | WillOnce(Return(std::list<std::shared_ptr<ual::Application>>{ |
3237 | 216 | 174 | MockUALApplication::create(ual::AppID::parse("com.ubuntu.clock_clock_0.1"), | |
3238 | 217 | click::Interface iface(keyFileLocator); | 175 | std::shared_ptr<MockUALApplication::MockInfo>{new MockUALApplication::MockInfo("Clock", "The clock", "/opt/click.ubuntu.com/foo/bar/clock.png")}), |
3239 | 218 | 176 | })); | |
3240 | 219 | auto results = iface.find_installed_apps("Clock"); | 177 | auto results = iface.search("Clock"); |
3241 | 220 | EXPECT_EQ(1u, results.size()); | 178 | ASSERT_EQ(1u, results.size()); |
3242 | 221 | EXPECT_EQ("appid://com.ubuntu.clock/clock/current-user-version", results.begin()->url); | 179 | EXPECT_EQ("appid://com.ubuntu.clock/clock/current-user-version", results.begin()->url); |
3243 | 222 | } | 180 | } |
3244 | 223 | 181 | ||
3245 | 224 | TEST_F(ClickInterfaceTest, testFindLegacyAppUsesDeskopId) | 182 | TEST_F(ClickInterfaceTest, testFindLegacyAppUsesDeskopId) |
3246 | 225 | { | 183 | { |
3256 | 226 | QSharedPointer<click::KeyFileLocator> keyFileLocator( | 184 | FakeClickInterface iface; |
3257 | 227 | new click::KeyFileLocator( | 185 | |
3258 | 228 | testing::systemApplicationsDirectoryForTesting(), | 186 | EXPECT_CALL(iface, installed_apps()).Times(1). |
3259 | 229 | testing::userApplicationsDirectoryForTesting())); | 187 | WillOnce(Return(std::list<std::shared_ptr<ual::Application>>{ |
3260 | 230 | 188 | MockUALApplication::create(ual::AppID::find("messaging-app"), | |
3261 | 231 | click::Interface iface(keyFileLocator); | 189 | std::shared_ptr<MockUALApplication::MockInfo>{new MockUALApplication::MockInfo("Messaging", "Your messages", "messaging-app")}) |
3262 | 232 | 190 | })); | |
3263 | 233 | auto results = iface.find_installed_apps("Messaging"); | 191 | auto results = iface.search("Messaging"); |
3264 | 234 | EXPECT_EQ(1u, results.size()); | 192 | ASSERT_EQ(1u, results.size()); |
3265 | 235 | EXPECT_EQ("application:///messaging-app.desktop", results.begin()->url); | 193 | EXPECT_EQ("application:///messaging-app.desktop", results.begin()->url); |
3266 | 236 | } | 194 | } |
3267 | 237 | 195 | ||
3268 | 238 | // | ||
3269 | 239 | // test that application with a default department id key in the desktop | 196 | // test that application with a default department id key in the desktop |
3270 | 240 | // file is returned when department matches | 197 | // file is returned when department matches |
3271 | 241 | TEST_F(ClickInterfaceTest, testFindAppsWithAppWithDefaultDepartmentId) | 198 | TEST_F(ClickInterfaceTest, testFindAppsWithAppWithDefaultDepartmentId) |
3272 | 242 | { | 199 | { |
3279 | 243 | QSharedPointer<click::KeyFileLocator> keyFileLocator( | 200 | FakeClickInterface iface; |
3280 | 244 | new click::KeyFileLocator( | 201 | |
3281 | 245 | testing::systemApplicationsDirectoryForTesting(), | 202 | auto mockapp = MockUALApplication::create(ual::AppID::find("address-book-app"), |
3282 | 246 | testing::userApplicationsDirectoryForTesting())); | 203 | std::shared_ptr<MockUALApplication::MockInfo>{new MockUALApplication::MockInfo("Contacts", "Address book", "address-book-app")}); |
3283 | 247 | 204 | ||
3284 | 248 | click::Interface iface(keyFileLocator); | 205 | auto dept = ual::Application::Info::DefaultDepartment::from_raw("accessories"); |
3285 | 206 | DefaultValue<const ual::Application::Info::DefaultDepartment&>::Set(dept); | ||
3286 | 207 | |||
3287 | 208 | EXPECT_CALL(iface, installed_apps()).Times(1). | ||
3288 | 209 | WillOnce(Return(std::list<std::shared_ptr<ual::Application>>{mockapp})); | ||
3289 | 249 | 210 | ||
3290 | 250 | auto depts_db = std::make_shared<click::DepartmentsDb>(":memory:"); | 211 | auto depts_db = std::make_shared<click::DepartmentsDb>(":memory:"); |
3292 | 251 | auto results = iface.find_installed_apps("", ignoredApps, "accessories", depts_db); | 212 | auto results = iface.search("", ignoredApps, "accessories", depts_db); |
3293 | 252 | 213 | ||
3295 | 253 | EXPECT_EQ(1u, results.size()); | 214 | ASSERT_EQ(1u, results.size()); |
3296 | 254 | EXPECT_EQ("Contacts", results.begin()->title); | 215 | EXPECT_EQ("Contacts", results.begin()->title); |
3297 | 255 | } | 216 | } |
3298 | 256 | 217 | ||
3299 | 257 | TEST_F(ClickInterfaceTest, testFindAppsWithAppWithDefaultDepartmentIdOverriden) | 218 | TEST_F(ClickInterfaceTest, testFindAppsWithAppWithDefaultDepartmentIdOverriden) |
3300 | 258 | { | 219 | { |
3307 | 259 | QSharedPointer<click::KeyFileLocator> keyFileLocator( | 220 | FakeClickInterface iface; |
3308 | 260 | new click::KeyFileLocator( | 221 | |
3309 | 261 | testing::systemApplicationsDirectoryForTesting(), | 222 | auto mockapp = MockUALApplication::create(ual::AppID::find("address-book-app"), |
3310 | 262 | testing::userApplicationsDirectoryForTesting())); | 223 | std::shared_ptr<MockUALApplication::MockInfo>{new MockUALApplication::MockInfo("Contacts", "Address book", "address-book-app")}); |
3311 | 263 | 224 | ||
3312 | 264 | click::Interface iface(keyFileLocator); | 225 | auto dept = ual::Application::Info::DefaultDepartment::from_raw("accessories"); |
3313 | 226 | DefaultValue<const ual::Application::Info::DefaultDepartment&>::Set(dept); | ||
3314 | 227 | |||
3315 | 228 | EXPECT_CALL(iface, installed_apps()). | ||
3316 | 229 | WillRepeatedly(Return(std::list<std::shared_ptr<ual::Application>>{mockapp})); | ||
3317 | 265 | 230 | ||
3318 | 266 | auto depts_db = std::make_shared<click::DepartmentsDb>(":memory:"); | 231 | auto depts_db = std::make_shared<click::DepartmentsDb>(":memory:"); |
3319 | 267 | 232 | ||
3320 | @@ -270,32 +235,42 @@ | |||
3321 | 270 | depts_db->store_department_mapping("utilities", ""); | 235 | depts_db->store_department_mapping("utilities", ""); |
3322 | 271 | depts_db->store_department_mapping("accessories", ""); | 236 | depts_db->store_department_mapping("accessories", ""); |
3323 | 272 | 237 | ||
3326 | 273 | auto results = iface.find_installed_apps("", ignoredApps, "utilies", depts_db); | 238 | auto results = iface.search("", ignoredApps, "utilies", depts_db); |
3327 | 274 | EXPECT_EQ(0, results.size()); | 239 | ASSERT_EQ(0, results.size()); |
3328 | 275 | 240 | ||
3329 | 276 | // address book applicaton moved to utilities | 241 | // address book applicaton moved to utilities |
3330 | 277 | depts_db->store_package_mapping("address-book-app.desktop", "utilities"); | 242 | depts_db->store_package_mapping("address-book-app.desktop", "utilities"); |
3332 | 278 | results = iface.find_installed_apps("", ignoredApps, "utilities", depts_db); | 243 | results = iface.search("", ignoredApps, "utilities", depts_db); |
3333 | 279 | 244 | ||
3335 | 280 | EXPECT_EQ(1u, results.size()); | 245 | ASSERT_EQ(1u, results.size()); |
3336 | 281 | EXPECT_EQ("Contacts", results.begin()->title); | 246 | EXPECT_EQ("Contacts", results.begin()->title); |
3337 | 282 | } | 247 | } |
3338 | 283 | 248 | ||
3339 | 284 | TEST(ClickInterface, testFindAppsInDirSorted) | 249 | TEST(ClickInterface, testFindAppsInDirSorted) |
3340 | 285 | { | 250 | { |
3349 | 286 | QSharedPointer<click::KeyFileLocator> keyFileLocator( | 251 | FakeClickInterface iface; |
3350 | 287 | new click::KeyFileLocator( | 252 | |
3351 | 288 | testing::systemApplicationsDirectoryForTesting(), | 253 | EXPECT_CALL(iface, installed_apps()).Times(1). |
3352 | 289 | testing::userApplicationsDirectoryForTesting())); | 254 | WillOnce(Return(std::list<std::shared_ptr<ual::Application>>{ |
3353 | 290 | 255 | MockUALApplication::create(ual::AppID::parse("com.ubuntu.clock_clock_0.1"), | |
3354 | 291 | click::Interface iface(keyFileLocator); | 256 | std::shared_ptr<MockUALApplication::MockInfo>{new MockUALApplication::MockInfo("Clock", "The clock", "/opt/click.ubuntu.com/foo/bar/clock.png")}), |
3355 | 292 | 257 | MockUALApplication::create(ual::AppID::find("address-book-app"), | |
3356 | 293 | auto results = iface.find_installed_apps("ock"); | 258 | std::shared_ptr<MockUALApplication::MockInfo>{new MockUALApplication::MockInfo("Contacts", "Address book", "address-book-app")}), |
3357 | 259 | MockUALApplication::create(ual::AppID::parse("com.ubuntu.stock-ticker-mobile_stockticker_0.1"), | ||
3358 | 260 | std::shared_ptr<MockUALApplication::MockInfo>{new MockUALApplication::MockInfo("Stock Ticker", "A stock ticker.", "/opt/click.ubuntu.com/foo/bar/stock_icon_48.png")}), | ||
3359 | 261 | })); | ||
3360 | 262 | |||
3361 | 263 | auto results = iface.search("ock"); | ||
3362 | 294 | 264 | ||
3363 | 295 | const std::vector<click::Application> expected_results = { | 265 | const std::vector<click::Application> expected_results = { |
3365 | 296 | {"com.ubuntu.clock", "Clock", 0.0, "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.clock/./clock64.png", "application:///com.ubuntu.clock_clock_1.0.300.desktop", "", "", ""}, | 266 | {"com.ubuntu.clock", "Clock", 0.0, |
3366 | 267 | "/opt/click.ubuntu.com/foo/bar/clock.png", | ||
3367 | 268 | "appid://com.ubuntu.clock/clock/current-user-version", | ||
3368 | 269 | "The clock", "", ""}, | ||
3369 | 297 | {"com.ubuntu.stock-ticker-mobile", "Stock Ticker", 0.0, | 270 | {"com.ubuntu.stock-ticker-mobile", "Stock Ticker", 0.0, |
3371 | 298 | "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.stock-ticker-mobile/icons/stock_icon_48.png", "application:///com.ubuntu.stock-ticker-mobile_stock-ticker-mobile_0.3.7.66.desktop", "An awesome Stock Ticker application with all the features you could imagine", "", ""}, | 271 | "/opt/click.ubuntu.com/foo/bar/stock_icon_48.png", |
3372 | 272 | "appid://com.ubuntu.stock-ticker-mobile/stockticker/current-user-version", | ||
3373 | 273 | "A stock ticker.", "", ""}, | ||
3374 | 299 | }; | 274 | }; |
3375 | 300 | EXPECT_EQ(expected_results, results); | 275 | EXPECT_EQ(expected_results, results); |
3376 | 301 | } | 276 | } |
3377 | @@ -382,58 +357,70 @@ | |||
3378 | 382 | ASSERT_EQ(unsetenv(Configuration::LANGUAGE_ENVVAR), 0); | 357 | ASSERT_EQ(unsetenv(Configuration::LANGUAGE_ENVVAR), 0); |
3379 | 383 | } | 358 | } |
3380 | 384 | 359 | ||
3433 | 385 | TEST(ClickInterface, testFindAppByKeyword) | 360 | TEST_F(ClickInterfaceTest, testFindAppByKeyword) |
3434 | 386 | { | 361 | { |
3435 | 387 | QSharedPointer<click::KeyFileLocator> keyFileLocator( | 362 | FakeClickInterface iface; |
3436 | 388 | new click::KeyFileLocator( | 363 | |
3437 | 389 | testing::systemApplicationsDirectoryForTesting(), | 364 | auto mockapp = MockUALApplication::create(ual::AppID::parse("com.ubuntu.camera_camera_5"), |
3438 | 390 | testing::userApplicationsDirectoryForTesting())); | 365 | std::shared_ptr<MockUALApplication::MockInfo>{new MockUALApplication::MockInfo("Cámara", "La cámara", "/opt/click.ubuntu.com/foo/bar/camera.png")}); |
3439 | 391 | 366 | ||
3440 | 392 | click::Interface iface(keyFileLocator); | 367 | std::vector<std::string>keys{"foo", "bar", "rss", "baz"}; |
3441 | 393 | 368 | auto mockkw = ual::Application::Info::Keywords::from_raw(keys); | |
3442 | 394 | auto results = iface.find_installed_apps("rss"); | 369 | DefaultValue<const ual::Application::Info::Keywords&>::Set(mockkw); |
3443 | 395 | 370 | ||
3444 | 396 | EXPECT_EQ(1, results.size()); | 371 | EXPECT_CALL(iface, installed_apps()).Times(1). |
3445 | 397 | } | 372 | WillOnce(Return(std::list<std::shared_ptr<ual::Application>>{mockapp})); |
3446 | 398 | 373 | ||
3447 | 399 | TEST(ClickInterface, testFindAppByKeywordCaseInsensitive) | 374 | auto results = iface.search("rss"); |
3448 | 400 | { | 375 | |
3449 | 401 | QSharedPointer<click::KeyFileLocator> keyFileLocator( | 376 | EXPECT_EQ(1, results.size()); |
3450 | 402 | new click::KeyFileLocator( | 377 | } |
3451 | 403 | testing::systemApplicationsDirectoryForTesting(), | 378 | |
3452 | 404 | testing::userApplicationsDirectoryForTesting())); | 379 | TEST_F(ClickInterfaceTest, testFindAppByKeywordCaseInsensitive) |
3453 | 405 | 380 | { | |
3454 | 406 | click::Interface iface(keyFileLocator); | 381 | FakeClickInterface iface; |
3455 | 407 | 382 | ||
3456 | 408 | auto results = iface.find_installed_apps("RsS"); | 383 | auto mockapp = MockUALApplication::create(ual::AppID::parse("com.ubuntu.camera_camera_5"), |
3457 | 409 | 384 | std::shared_ptr<MockUALApplication::MockInfo>{new MockUALApplication::MockInfo("Cámara", "La cámara", "/opt/click.ubuntu.com/foo/bar/camera.png")}); | |
3458 | 410 | EXPECT_EQ(1, results.size()); | 385 | |
3459 | 411 | } | 386 | std::vector<std::string>keys{"foo", "bar", "rss", "baz"}; |
3460 | 412 | 387 | auto mockkw = ual::Application::Info::Keywords::from_raw(keys); | |
3461 | 413 | TEST(ClickInterface, testFindAppAccented) | 388 | DefaultValue<const ual::Application::Info::Keywords&>::Set(mockkw); |
3462 | 414 | { | 389 | |
3463 | 415 | QSharedPointer<click::KeyFileLocator> keyFileLocator( | 390 | EXPECT_CALL(iface, installed_apps()).Times(1). |
3464 | 416 | new click::KeyFileLocator( | 391 | WillOnce(Return(std::list<std::shared_ptr<ual::Application>>{mockapp})); |
3465 | 417 | testing::systemApplicationsDirectoryForTesting(), | 392 | |
3466 | 418 | testing::userApplicationsDirectoryForTesting())); | 393 | auto results = iface.search("RsS"); |
3467 | 419 | 394 | ||
3468 | 420 | click::Interface iface(keyFileLocator); | 395 | EXPECT_EQ(1, results.size()); |
3469 | 421 | 396 | } | |
3470 | 422 | auto results = iface.find_installed_apps("Cámara"); | 397 | |
3471 | 423 | 398 | TEST_F(ClickInterfaceTest, testFindAppAccented) | |
3472 | 424 | EXPECT_EQ(1, results.size()); | 399 | { |
3473 | 425 | } | 400 | FakeClickInterface iface; |
3474 | 426 | 401 | ||
3475 | 427 | TEST(ClickInterface, testFindAppAccented2) | 402 | EXPECT_CALL(iface, installed_apps()).Times(1). |
3476 | 428 | { | 403 | WillOnce(Return(std::list<std::shared_ptr<ual::Application>>{ |
3477 | 429 | QSharedPointer<click::KeyFileLocator> keyFileLocator( | 404 | MockUALApplication::create(ual::AppID::parse("com.ubuntu.camera_camera_5"), |
3478 | 430 | new click::KeyFileLocator( | 405 | std::shared_ptr<MockUALApplication::MockInfo>{new MockUALApplication::MockInfo("Cámara", "La cámara", "/opt/click.ubuntu.com/foo/bar/camera.png")}), |
3479 | 431 | testing::systemApplicationsDirectoryForTesting(), | 406 | })); |
3480 | 432 | testing::userApplicationsDirectoryForTesting())); | 407 | |
3481 | 433 | 408 | auto results = iface.search("Cámara"); | |
3482 | 434 | click::Interface iface(keyFileLocator); | 409 | |
3483 | 435 | 410 | EXPECT_EQ(1, results.size()); | |
3484 | 436 | auto results = iface.find_installed_apps("Camara"); | 411 | } |
3485 | 412 | |||
3486 | 413 | TEST_F(ClickInterfaceTest, testFindAppAccented2) | ||
3487 | 414 | { | ||
3488 | 415 | FakeClickInterface iface; | ||
3489 | 416 | |||
3490 | 417 | EXPECT_CALL(iface, installed_apps()).Times(1). | ||
3491 | 418 | WillOnce(Return(std::list<std::shared_ptr<ual::Application>>{ | ||
3492 | 419 | MockUALApplication::create(ual::AppID::parse("com.ubuntu.camera_camera_5"), | ||
3493 | 420 | std::shared_ptr<MockUALApplication::MockInfo>{new MockUALApplication::MockInfo("Cámara", "La cámara", "/opt/click.ubuntu.com/foo/bar/camera.png")}), | ||
3494 | 421 | })); | ||
3495 | 422 | |||
3496 | 423 | auto results = iface.search("Camara"); | ||
3497 | 437 | 424 | ||
3498 | 438 | EXPECT_EQ(1, results.size()); | 425 | EXPECT_EQ(1, results.size()); |
3499 | 439 | } | 426 | } |
3500 | @@ -453,130 +440,6 @@ | |||
3501 | 453 | Interface::add_theme_scheme("/usr/share/unity8/graphics/applicationIcons/contacts-app@18.png")); | 440 | Interface::add_theme_scheme("/usr/share/unity8/graphics/applicationIcons/contacts-app@18.png")); |
3502 | 454 | } | 441 | } |
3503 | 455 | 442 | ||
3504 | 456 | std::vector<click::Application> find_installed_apps(const std::string& query, bool include_desktop_results) | ||
3505 | 457 | { | ||
3506 | 458 | using namespace ::testing; | ||
3507 | 459 | QSharedPointer<click::KeyFileLocator> keyFileLocator( | ||
3508 | 460 | new click::KeyFileLocator( | ||
3509 | 461 | testing::systemApplicationsDirectoryForTesting(), | ||
3510 | 462 | testing::userApplicationsDirectoryForTesting())); | ||
3511 | 463 | |||
3512 | 464 | FakeClickInterface iface(keyFileLocator); | ||
3513 | 465 | EXPECT_CALL(iface, show_desktop_apps()) | ||
3514 | 466 | .Times(1) | ||
3515 | 467 | .WillOnce(Return(include_desktop_results)); | ||
3516 | 468 | |||
3517 | 469 | return iface.find_installed_apps(query); | ||
3518 | 470 | } | ||
3519 | 471 | |||
3520 | 472 | TEST(ClickInterface, testFindInstalledAppsOnPhone) | ||
3521 | 473 | { | ||
3522 | 474 | auto result = find_installed_apps(emptyQuery, false); | ||
3523 | 475 | |||
3524 | 476 | EXPECT_TRUE(result.size() > 0); | ||
3525 | 477 | |||
3526 | 478 | for (const auto& app : non_desktop_applications) | ||
3527 | 479 | { | ||
3528 | 480 | qDebug() << "comparing" << QString::fromStdString(app.title); | ||
3529 | 481 | EXPECT_NE(result.end(), std::find(result.begin(), result.end(), app)); | ||
3530 | 482 | } | ||
3531 | 483 | |||
3532 | 484 | EXPECT_EQ(result.end(), std::find(result.begin(), result.end(), desktop_application)); | ||
3533 | 485 | } | ||
3534 | 486 | |||
3535 | 487 | TEST(ClickInterface, testFindInstalledAppsOnDesktop) | ||
3536 | 488 | { | ||
3537 | 489 | auto result = find_installed_apps(emptyQuery, true); | ||
3538 | 490 | |||
3539 | 491 | std::vector<click::Application> expected_apps(non_desktop_applications); | ||
3540 | 492 | expected_apps.push_back(desktop_application); | ||
3541 | 493 | |||
3542 | 494 | EXPECT_TRUE(result.size() > 0); | ||
3543 | 495 | |||
3544 | 496 | for (const auto& app : expected_apps) | ||
3545 | 497 | { | ||
3546 | 498 | qDebug() << "comparing" << QString::fromStdString(app.title); | ||
3547 | 499 | EXPECT_NE(result.end(), std::find(result.begin(), result.end(), app)); | ||
3548 | 500 | } | ||
3549 | 501 | } | ||
3550 | 502 | |||
3551 | 503 | TEST(ClickInterface, testInlineTranslationsLoaded) | ||
3552 | 504 | { | ||
3553 | 505 | QSharedPointer<click::KeyFileLocator> keyFileLocator(new click::KeyFileLocator()); | ||
3554 | 506 | click::Interface iface(keyFileLocator); | ||
3555 | 507 | |||
3556 | 508 | auto nodisplay = testing::systemApplicationsDirectoryForTesting() + "/translated.desktop"; | ||
3557 | 509 | unity::util::IniParser parser(nodisplay.data()); | ||
3558 | 510 | |||
3559 | 511 | ASSERT_EQ(setenv(Configuration::LANGUAGE_ENVVAR, "es_ES.UTF-8", 1), 0); | ||
3560 | 512 | auto app = iface.load_app_from_desktop(parser, nodisplay); | ||
3561 | 513 | EXPECT_EQ("Translated App in Spanish", app.title); | ||
3562 | 514 | EXPECT_EQ("Translated application in Spanish", app.description); | ||
3563 | 515 | ASSERT_EQ(unsetenv(Configuration::LANGUAGE_ENVVAR), 0); | ||
3564 | 516 | } | ||
3565 | 517 | |||
3566 | 518 | TEST(ClickInterface, testIncludeInResultsNoDisplayTrue) | ||
3567 | 519 | { | ||
3568 | 520 | QSharedPointer<click::KeyFileLocator> keyFileLocator(new click::KeyFileLocator()); | ||
3569 | 521 | click::Interface iface(keyFileLocator); | ||
3570 | 522 | |||
3571 | 523 | auto nodisplay = testing::userApplicationsDirectoryForTesting() + "/non-click-app-nodisplay.desktop"; | ||
3572 | 524 | unity::util::IniParser parser(nodisplay.data()); | ||
3573 | 525 | |||
3574 | 526 | EXPECT_FALSE(iface.is_visible_app(parser)); | ||
3575 | 527 | } | ||
3576 | 528 | |||
3577 | 529 | TEST(ClickInterface, testIncludeInResultsOnlyShowInGnome) | ||
3578 | 530 | { | ||
3579 | 531 | QSharedPointer<click::KeyFileLocator> keyFileLocator(new click::KeyFileLocator()); | ||
3580 | 532 | click::Interface iface(keyFileLocator); | ||
3581 | 533 | |||
3582 | 534 | auto nodisplay = testing::userApplicationsDirectoryForTesting() + "/non-click-app-onlyshowin-gnome.desktop"; | ||
3583 | 535 | unity::util::IniParser parser(nodisplay.data()); | ||
3584 | 536 | |||
3585 | 537 | EXPECT_FALSE(iface.is_visible_app(parser)); | ||
3586 | 538 | } | ||
3587 | 539 | |||
3588 | 540 | TEST(ClickInterface, testIncludeInResultsOnlyShowInGnomeUnity) | ||
3589 | 541 | { | ||
3590 | 542 | QSharedPointer<click::KeyFileLocator> keyFileLocator(new click::KeyFileLocator()); | ||
3591 | 543 | click::Interface iface(keyFileLocator); | ||
3592 | 544 | |||
3593 | 545 | auto nodisplay = testing::userApplicationsDirectoryForTesting() + "/non-click-app-onlyshowin-gnome-unity.desktop"; | ||
3594 | 546 | unity::util::IniParser parser(nodisplay.data()); | ||
3595 | 547 | |||
3596 | 548 | EXPECT_TRUE(iface.is_visible_app(parser)); | ||
3597 | 549 | } | ||
3598 | 550 | |||
3599 | 551 | TEST(ClickInterface, testIncludeInResultsOnlyShowInUnity) | ||
3600 | 552 | { | ||
3601 | 553 | QSharedPointer<click::KeyFileLocator> keyFileLocator(new click::KeyFileLocator()); | ||
3602 | 554 | click::Interface iface(keyFileLocator); | ||
3603 | 555 | |||
3604 | 556 | auto nodisplay = testing::userApplicationsDirectoryForTesting() + "/non-click-app-onlyshowin-unity.desktop"; | ||
3605 | 557 | unity::util::IniParser parser(nodisplay.data()); | ||
3606 | 558 | |||
3607 | 559 | EXPECT_TRUE(iface.is_visible_app(parser)); | ||
3608 | 560 | } | ||
3609 | 561 | |||
3610 | 562 | TEST(ClickInterface, testEnableDesktopApps) | ||
3611 | 563 | { | ||
3612 | 564 | QSharedPointer<click::KeyFileLocator> keyFileLocator(new click::KeyFileLocator()); | ||
3613 | 565 | click::Interface iface(keyFileLocator); | ||
3614 | 566 | |||
3615 | 567 | setenv(Interface::ENV_SHOW_DESKTOP_APPS, "YesPlease", true); | ||
3616 | 568 | EXPECT_TRUE(iface.show_desktop_apps()); | ||
3617 | 569 | } | ||
3618 | 570 | |||
3619 | 571 | TEST(ClickInterface, testDisableDesktopApps) | ||
3620 | 572 | { | ||
3621 | 573 | QSharedPointer<click::KeyFileLocator> keyFileLocator(new click::KeyFileLocator()); | ||
3622 | 574 | click::Interface iface(keyFileLocator); | ||
3623 | 575 | |||
3624 | 576 | unsetenv(Interface::ENV_SHOW_DESKTOP_APPS); | ||
3625 | 577 | EXPECT_FALSE(iface.show_desktop_apps()); | ||
3626 | 578 | } | ||
3627 | 579 | |||
3628 | 580 | TEST(ClickInterface, testManifestFromJsonOneApp) | 443 | TEST(ClickInterface, testManifestFromJsonOneApp) |
3629 | 581 | { | 444 | { |
3630 | 582 | Manifest m = manifest_from_json(FAKE_JSON_MANIFEST_ONE_APP); | 445 | Manifest m = manifest_from_json(FAKE_JSON_MANIFEST_ONE_APP); |
3631 | @@ -611,25 +474,12 @@ | |||
3632 | 611 | ASSERT_TRUE(m.has_any_scopes()); | 474 | ASSERT_TRUE(m.has_any_scopes()); |
3633 | 612 | } | 475 | } |
3634 | 613 | 476 | ||
3635 | 614 | TEST(ClickInterface, testGetManifestForAppCorrectCommand) | ||
3636 | 615 | { | ||
3637 | 616 | FakeClickInterface iface; | ||
3638 | 617 | std::string command = "click info " + FAKE_PACKAGENAME; | ||
3639 | 618 | EXPECT_CALL(iface, run_process(command, _)). | ||
3640 | 619 | Times(1); | ||
3641 | 620 | iface.get_manifest_for_app(FAKE_PACKAGENAME, [](Manifest, InterfaceError){}); | ||
3642 | 621 | } | ||
3643 | 622 | |||
3644 | 623 | TEST_F(ClickInterfaceTest, testGetManifestForAppParseError) | 477 | TEST_F(ClickInterfaceTest, testGetManifestForAppParseError) |
3645 | 624 | { | 478 | { |
3646 | 625 | FakeClickInterface iface; | 479 | FakeClickInterface iface; |
3648 | 626 | EXPECT_CALL(iface, run_process(_, _)). | 480 | EXPECT_CALL(iface, get_manifest_json(_)). |
3649 | 627 | Times(1). | 481 | Times(1). |
3655 | 628 | WillOnce(Invoke([&](const std::string&, | 482 | WillOnce(Return("INVALID JSON")); |
3651 | 629 | std::function<void(int, const std::string&, | ||
3652 | 630 | const std::string&)> callback){ | ||
3653 | 631 | callback(0, "INVALID JSON", ""); | ||
3654 | 632 | })); | ||
3656 | 633 | EXPECT_CALL(*this, manifest_callback(_, InterfaceError::ParseError)); | 483 | EXPECT_CALL(*this, manifest_callback(_, InterfaceError::ParseError)); |
3657 | 634 | iface.get_manifest_for_app(FAKE_PACKAGENAME, [this](Manifest manifest, | 484 | iface.get_manifest_for_app(FAKE_PACKAGENAME, [this](Manifest manifest, |
3658 | 635 | InterfaceError error){ | 485 | InterfaceError error){ |
3659 | @@ -637,33 +487,12 @@ | |||
3660 | 637 | }); | 487 | }); |
3661 | 638 | } | 488 | } |
3662 | 639 | 489 | ||
3663 | 640 | TEST_F(ClickInterfaceTest, testGetManifestForAppCommandFailed) | ||
3664 | 641 | { | ||
3665 | 642 | FakeClickInterface iface; | ||
3666 | 643 | EXPECT_CALL(iface, run_process(_, _)). | ||
3667 | 644 | Times(1). | ||
3668 | 645 | WillOnce(Invoke([&](const std::string&, | ||
3669 | 646 | std::function<void(int, const std::string&, | ||
3670 | 647 | const std::string&)> callback){ | ||
3671 | 648 | callback(-1, "", "CRITICAL: FAIL"); | ||
3672 | 649 | })); | ||
3673 | 650 | EXPECT_CALL(*this, manifest_callback(_, InterfaceError::CallError)); | ||
3674 | 651 | iface.get_manifest_for_app(FAKE_PACKAGENAME, [this](Manifest manifest, | ||
3675 | 652 | InterfaceError error){ | ||
3676 | 653 | manifest_callback(manifest, error); | ||
3677 | 654 | }); | ||
3678 | 655 | } | ||
3679 | 656 | |||
3680 | 657 | TEST_F(ClickInterfaceTest, testGetManifestForAppIsRemovable) | 490 | TEST_F(ClickInterfaceTest, testGetManifestForAppIsRemovable) |
3681 | 658 | { | 491 | { |
3682 | 659 | FakeClickInterface iface; | 492 | FakeClickInterface iface; |
3684 | 660 | EXPECT_CALL(iface, run_process(_, _)). | 493 | EXPECT_CALL(iface, get_manifest_json(_)). |
3685 | 661 | Times(1). | 494 | Times(1). |
3691 | 662 | WillOnce(Invoke([&](const std::string&, | 495 | WillOnce(Return(FAKE_JSON_MANIFEST_REMOVABLE)); |
3687 | 663 | std::function<void(int, const std::string&, | ||
3688 | 664 | const std::string&)> callback){ | ||
3689 | 665 | callback(0, FAKE_JSON_MANIFEST_REMOVABLE, ""); | ||
3690 | 666 | })); | ||
3692 | 667 | iface.get_manifest_for_app(FAKE_PACKAGENAME, [](Manifest manifest, | 496 | iface.get_manifest_for_app(FAKE_PACKAGENAME, [](Manifest manifest, |
3693 | 668 | InterfaceError error){ | 497 | InterfaceError error){ |
3694 | 669 | ASSERT_TRUE(error == InterfaceError::NoError); | 498 | ASSERT_TRUE(error == InterfaceError::NoError); |
3695 | @@ -674,13 +503,9 @@ | |||
3696 | 674 | TEST_F(ClickInterfaceTest, testGetManifestForAppIsNotRemovable) | 503 | TEST_F(ClickInterfaceTest, testGetManifestForAppIsNotRemovable) |
3697 | 675 | { | 504 | { |
3698 | 676 | FakeClickInterface iface; | 505 | FakeClickInterface iface; |
3700 | 677 | EXPECT_CALL(iface, run_process(_, _)). | 506 | EXPECT_CALL(iface, get_manifest_json(_)). |
3701 | 678 | Times(1). | 507 | Times(1). |
3707 | 679 | WillOnce(Invoke([&](const std::string&, | 508 | WillOnce(Return(FAKE_JSON_MANIFEST_NONREMOVABLE)); |
3703 | 680 | std::function<void(int, const std::string&, | ||
3704 | 681 | const std::string&)> callback){ | ||
3705 | 682 | callback(0, FAKE_JSON_MANIFEST_NONREMOVABLE, ""); | ||
3706 | 683 | })); | ||
3708 | 684 | iface.get_manifest_for_app(FAKE_PACKAGENAME, [](Manifest manifest, | 509 | iface.get_manifest_for_app(FAKE_PACKAGENAME, [](Manifest manifest, |
3709 | 685 | InterfaceError error){ | 510 | InterfaceError error){ |
3710 | 686 | ASSERT_TRUE(error == InterfaceError::NoError); | 511 | ASSERT_TRUE(error == InterfaceError::NoError); |
3711 | @@ -688,125 +513,16 @@ | |||
3712 | 688 | }); | 513 | }); |
3713 | 689 | } | 514 | } |
3714 | 690 | 515 | ||
3715 | 691 | TEST(ClickInterface, testGetManifestsCorrectCommand) | ||
3716 | 692 | { | ||
3717 | 693 | FakeClickInterface iface; | ||
3718 | 694 | std::string command = "click list --manifest"; | ||
3719 | 695 | EXPECT_CALL(iface, run_process(command, _)). | ||
3720 | 696 | Times(1); | ||
3721 | 697 | iface.get_manifests([](ManifestList, InterfaceError){}); | ||
3722 | 698 | } | ||
3723 | 699 | |||
3724 | 700 | TEST_F(ClickInterfaceTest, testGetManifestsParseError) | ||
3725 | 701 | { | ||
3726 | 702 | FakeClickInterface iface; | ||
3727 | 703 | EXPECT_CALL(iface, run_process(_, _)). | ||
3728 | 704 | Times(1). | ||
3729 | 705 | WillOnce(Invoke([&](const std::string&, | ||
3730 | 706 | std::function<void(int, const std::string&, | ||
3731 | 707 | const std::string&)> callback){ | ||
3732 | 708 | callback(0, "INVALID JSON", ""); | ||
3733 | 709 | })); | ||
3734 | 710 | EXPECT_CALL(*this, manifests_callback(_, InterfaceError::ParseError)); | ||
3735 | 711 | iface.get_manifests([this](ManifestList manifests, InterfaceError error){ | ||
3736 | 712 | manifests_callback(manifests, error); | ||
3737 | 713 | }); | ||
3738 | 714 | } | ||
3739 | 715 | |||
3740 | 716 | TEST_F(ClickInterfaceTest, testGetManifestsCommandFailed) | ||
3741 | 717 | { | ||
3742 | 718 | FakeClickInterface iface; | ||
3743 | 719 | EXPECT_CALL(iface, run_process(_, _)). | ||
3744 | 720 | Times(1). | ||
3745 | 721 | WillOnce(Invoke([&](const std::string&, | ||
3746 | 722 | std::function<void(int, const std::string&, | ||
3747 | 723 | const std::string&)> callback){ | ||
3748 | 724 | callback(-1, "", "CRITICAL: FAIL"); | ||
3749 | 725 | })); | ||
3750 | 726 | EXPECT_CALL(*this, manifests_callback(_, InterfaceError::CallError)); | ||
3751 | 727 | iface.get_manifests([this](ManifestList manifests, InterfaceError error){ | ||
3752 | 728 | manifests_callback(manifests, error); | ||
3753 | 729 | }); | ||
3754 | 730 | } | ||
3755 | 731 | |||
3756 | 732 | TEST_F(ClickInterfaceTest, testGetManifestsParsed) | ||
3757 | 733 | { | ||
3758 | 734 | FakeClickInterface iface; | ||
3759 | 735 | std::string expected_str = "[" + FAKE_JSON_MANIFEST_NONREMOVABLE + "," + | ||
3760 | 736 | FAKE_JSON_MANIFEST_REMOVABLE + "]"; | ||
3761 | 737 | ManifestList expected = manifest_list_from_json(expected_str); | ||
3762 | 738 | |||
3763 | 739 | EXPECT_CALL(iface, run_process(_, _)). | ||
3764 | 740 | Times(1). | ||
3765 | 741 | WillOnce(Invoke([&](const std::string&, | ||
3766 | 742 | std::function<void(int, const std::string&, | ||
3767 | 743 | const std::string&)> callback){ | ||
3768 | 744 | callback(0, expected_str, ""); | ||
3769 | 745 | })); | ||
3770 | 746 | iface.get_manifests([expected](ManifestList manifests, InterfaceError error){ | ||
3771 | 747 | ASSERT_TRUE(error == InterfaceError::NoError); | ||
3772 | 748 | ASSERT_TRUE(manifests.size() == expected.size()); | ||
3773 | 749 | }); | ||
3774 | 750 | } | ||
3775 | 751 | |||
3776 | 752 | TEST(ClickInterface, testGetInstalledPackagesCorrectCommand) | ||
3777 | 753 | { | ||
3778 | 754 | FakeClickInterface iface; | ||
3779 | 755 | std::string command = "click list"; | ||
3780 | 756 | EXPECT_CALL(iface, run_process(command, _)). | ||
3781 | 757 | Times(1); | ||
3782 | 758 | iface.get_installed_packages([](PackageSet, InterfaceError){}); | ||
3783 | 759 | } | ||
3784 | 760 | |||
3785 | 761 | TEST_F(ClickInterfaceTest, testGetInstalledPackagesParseError) | ||
3786 | 762 | { | ||
3787 | 763 | FakeClickInterface iface; | ||
3788 | 764 | std::string bad_stdout = "INVALID: err\nvalid.package\t1.0\n"; | ||
3789 | 765 | PackageSet expected{{"valid.package", "1.0"}}; | ||
3790 | 766 | |||
3791 | 767 | EXPECT_CALL(iface, run_process(_, _)). | ||
3792 | 768 | Times(1). | ||
3793 | 769 | WillOnce(Invoke([&](const std::string&, | ||
3794 | 770 | std::function<void(int, const std::string&, | ||
3795 | 771 | const std::string&)> callback){ | ||
3796 | 772 | callback(0, bad_stdout, ""); | ||
3797 | 773 | })); | ||
3798 | 774 | EXPECT_CALL(*this, installed_callback(_, InterfaceError::NoError)); | ||
3799 | 775 | iface.get_installed_packages([this, expected](PackageSet package_names, InterfaceError error){ | ||
3800 | 776 | installed_callback(package_names, error); | ||
3801 | 777 | ASSERT_EQ(package_names, expected); | ||
3802 | 778 | }); | ||
3803 | 779 | } | ||
3804 | 780 | |||
3805 | 781 | TEST_F(ClickInterfaceTest, testGetInstalledPackagesCommandFailed) | ||
3806 | 782 | { | ||
3807 | 783 | FakeClickInterface iface; | ||
3808 | 784 | EXPECT_CALL(iface, run_process(_, _)). | ||
3809 | 785 | Times(1). | ||
3810 | 786 | WillOnce(Invoke([&](const std::string&, | ||
3811 | 787 | std::function<void(int, const std::string&, | ||
3812 | 788 | const std::string&)> callback){ | ||
3813 | 789 | callback(-1, "", "CRITICAL: FAIL"); | ||
3814 | 790 | })); | ||
3815 | 791 | EXPECT_CALL(*this, installed_callback(_, InterfaceError::CallError)); | ||
3816 | 792 | iface.get_installed_packages([this](PackageSet package_names, InterfaceError error){ | ||
3817 | 793 | installed_callback(package_names, error); | ||
3818 | 794 | }); | ||
3819 | 795 | } | ||
3820 | 796 | |||
3821 | 797 | TEST_F(ClickInterfaceTest, testGetInstalledPackagesParsed) | 516 | TEST_F(ClickInterfaceTest, testGetInstalledPackagesParsed) |
3822 | 798 | { | 517 | { |
3823 | 799 | FakeClickInterface iface; | 518 | FakeClickInterface iface; |
3826 | 800 | std::string sample_stdout = "ABC\t0.1\nDEF\t0.2\n"; | 519 | PackageSet expected{{"foo.bar", "0.1"}, {"baz.foo", "0.2"}}; |
3825 | 801 | PackageSet expected{{"ABC", "0.1"}, {"DEF", "0.2"}}; | ||
3827 | 802 | 520 | ||
3835 | 803 | EXPECT_CALL(iface, run_process(_, _)). | 521 | EXPECT_CALL(iface, installed_apps()).Times(1). |
3836 | 804 | Times(1). | 522 | WillOnce(Return(std::list<std::shared_ptr<ual::Application>>{ |
3837 | 805 | WillOnce(Invoke([&](const std::string&, | 523 | MockUALApplication::create(ual::AppID::parse("foo.bar_foo_0.1")), |
3838 | 806 | std::function<void(int, const std::string&, | 524 | MockUALApplication::create(ual::AppID::parse("baz.foo_foo_0.2")) |
3839 | 807 | const std::string&)> callback){ | 525 | })); |
3833 | 808 | callback(0, sample_stdout, ""); | ||
3834 | 809 | })); | ||
3840 | 810 | iface.get_installed_packages([expected](PackageSet package_names, InterfaceError error){ | 526 | iface.get_installed_packages([expected](PackageSet package_names, InterfaceError error){ |
3841 | 811 | ASSERT_EQ(error, InterfaceError::NoError); | 527 | ASSERT_EQ(error, InterfaceError::NoError); |
3842 | 812 | ASSERT_EQ(package_names, expected); | 528 | ASSERT_EQ(package_names, expected); |
3843 | 813 | 529 | ||
3844 | === modified file 'libclickscope/tests/test_pay.cpp' | |||
3845 | --- libclickscope/tests/test_pay.cpp 2016-06-30 20:42:56 +0000 | |||
3846 | +++ libclickscope/tests/test_pay.cpp 2016-08-24 21:39:08 +0000 | |||
3847 | @@ -68,7 +68,7 @@ | |||
3848 | 68 | TEST_F(PayTest, testPayPackageRefundCalled) | 68 | TEST_F(PayTest, testPayPackageRefundCalled) |
3849 | 69 | { | 69 | { |
3850 | 70 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 70 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3852 | 71 | auto response = responseForReply(reply.asSharedPtr()); | 71 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
3853 | 72 | 72 | ||
3854 | 73 | EXPECT_CALL(*package, do_pay_package_refund("foo")).Times(1); | 73 | EXPECT_CALL(*package, do_pay_package_refund("foo")).Times(1); |
3855 | 74 | EXPECT_FALSE(package->refund("foo")); | 74 | EXPECT_FALSE(package->refund("foo")); |
3856 | @@ -77,7 +77,7 @@ | |||
3857 | 77 | TEST_F(PayTest, testPayPackageRefundNotCalledIfCallbackExists) | 77 | TEST_F(PayTest, testPayPackageRefundNotCalledIfCallbackExists) |
3858 | 78 | { | 78 | { |
3859 | 79 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 79 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3861 | 80 | auto response = responseForReply(reply.asSharedPtr()); | 80 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
3862 | 81 | 81 | ||
3863 | 82 | std::string callback_id = std::string{"foo"} + pay::APPENDAGE_REFUND; | 82 | std::string callback_id = std::string{"foo"} + pay::APPENDAGE_REFUND; |
3864 | 83 | package->callbacks[callback_id] = [](const std::string&, bool) {}; | 83 | package->callbacks[callback_id] = [](const std::string&, bool) {}; |
3865 | @@ -88,7 +88,7 @@ | |||
3866 | 88 | TEST_F(PayTest, testRefundReturnsTrueForPurchasedItem) | 88 | TEST_F(PayTest, testRefundReturnsTrueForPurchasedItem) |
3867 | 89 | { | 89 | { |
3868 | 90 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 90 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3870 | 91 | auto response = responseForReply(reply.asSharedPtr()); | 91 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
3871 | 92 | 92 | ||
3872 | 93 | package->success = true; | 93 | package->success = true; |
3873 | 94 | EXPECT_CALL(*package, do_pay_package_refund("foo")).Times(1); | 94 | EXPECT_CALL(*package, do_pay_package_refund("foo")).Times(1); |
3874 | @@ -98,7 +98,7 @@ | |||
3875 | 98 | TEST_F(PayTest, testPayPackageVerifyCalled) | 98 | TEST_F(PayTest, testPayPackageVerifyCalled) |
3876 | 99 | { | 99 | { |
3877 | 100 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 100 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3879 | 101 | auto response = responseForReply(reply.asSharedPtr()); | 101 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
3880 | 102 | 102 | ||
3881 | 103 | EXPECT_CALL(*package, do_pay_package_verify("foo")).Times(1); | 103 | EXPECT_CALL(*package, do_pay_package_verify("foo")).Times(1); |
3882 | 104 | EXPECT_FALSE(package->verify("foo")); | 104 | EXPECT_FALSE(package->verify("foo")); |
3883 | @@ -107,7 +107,7 @@ | |||
3884 | 107 | TEST_F(PayTest, testPayPackageVerifyNotCalledIfCallbackExists) | 107 | TEST_F(PayTest, testPayPackageVerifyNotCalledIfCallbackExists) |
3885 | 108 | { | 108 | { |
3886 | 109 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 109 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3888 | 110 | auto response = responseForReply(reply.asSharedPtr()); | 110 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
3889 | 111 | 111 | ||
3890 | 112 | std::string callback_id = std::string{"foo"} + pay::APPENDAGE_VERIFY; | 112 | std::string callback_id = std::string{"foo"} + pay::APPENDAGE_VERIFY; |
3891 | 113 | package->callbacks[callback_id] = [](const std::string&, bool) {}; | 113 | package->callbacks[callback_id] = [](const std::string&, bool) {}; |
3892 | @@ -118,7 +118,7 @@ | |||
3893 | 118 | TEST_F(PayTest, testVerifyReturnsTrueForPurchasedItem) | 118 | TEST_F(PayTest, testVerifyReturnsTrueForPurchasedItem) |
3894 | 119 | { | 119 | { |
3895 | 120 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 120 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3897 | 121 | auto response = responseForReply(reply.asSharedPtr()); | 121 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
3898 | 122 | 122 | ||
3899 | 123 | package->success = true; | 123 | package->success = true; |
3900 | 124 | EXPECT_CALL(*package, do_pay_package_verify("foo")).Times(1); | 124 | EXPECT_CALL(*package, do_pay_package_verify("foo")).Times(1); |
3901 | @@ -128,7 +128,7 @@ | |||
3902 | 128 | TEST_F(PayTest, testGetPurchasesCallsWebservice) | 128 | TEST_F(PayTest, testGetPurchasesCallsWebservice) |
3903 | 129 | { | 129 | { |
3904 | 130 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 130 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3906 | 131 | auto response = responseForReply(reply.asSharedPtr()); | 131 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
3907 | 132 | 132 | ||
3908 | 133 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) | 133 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
3909 | 134 | .Times(1) | 134 | .Times(1) |
3910 | @@ -140,7 +140,7 @@ | |||
3911 | 140 | TEST_F(PayTest, testGetPurchasesSendsCorrectPath) | 140 | TEST_F(PayTest, testGetPurchasesSendsCorrectPath) |
3912 | 141 | { | 141 | { |
3913 | 142 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 142 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3915 | 143 | auto response = responseForReply(reply.asSharedPtr()); | 143 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
3916 | 144 | 144 | ||
3917 | 145 | EXPECT_CALL(*clientPtr, callImpl(EndsWith(pay::PURCHASES_API_PATH), | 145 | EXPECT_CALL(*clientPtr, callImpl(EndsWith(pay::PURCHASES_API_PATH), |
3918 | 146 | _, _, _, _, _)) | 146 | _, _, _, _, _)) |
3919 | @@ -153,7 +153,7 @@ | |||
3920 | 153 | TEST_F(PayTest, testGetPurchasesCallbackCalled) | 153 | TEST_F(PayTest, testGetPurchasesCallbackCalled) |
3921 | 154 | { | 154 | { |
3922 | 155 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 155 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3924 | 156 | auto response = responseForReply(reply.asSharedPtr()); | 156 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
3925 | 157 | 157 | ||
3926 | 158 | QByteArray fake_json("[]"); | 158 | QByteArray fake_json("[]"); |
3927 | 159 | EXPECT_CALL(reply.instance, readAll()) | 159 | EXPECT_CALL(reply.instance, readAll()) |
3928 | @@ -173,7 +173,7 @@ | |||
3929 | 173 | TEST_F(PayTest, testGetPurchasesEmptyJsonIsParsed) | 173 | TEST_F(PayTest, testGetPurchasesEmptyJsonIsParsed) |
3930 | 174 | { | 174 | { |
3931 | 175 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 175 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3933 | 176 | auto response = responseForReply(reply.asSharedPtr()); | 176 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
3934 | 177 | 177 | ||
3935 | 178 | QByteArray fake_json("[]"); | 178 | QByteArray fake_json("[]"); |
3936 | 179 | EXPECT_CALL(reply.instance, readAll()) | 179 | EXPECT_CALL(reply.instance, readAll()) |
3937 | @@ -194,7 +194,7 @@ | |||
3938 | 194 | TEST_F(PayTest, testGetPurchasesSingleJsonIsParsedNullTimestamp) | 194 | TEST_F(PayTest, testGetPurchasesSingleJsonIsParsedNullTimestamp) |
3939 | 195 | { | 195 | { |
3940 | 196 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 196 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3942 | 197 | auto response = responseForReply(reply.asSharedPtr()); | 197 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
3943 | 198 | 198 | ||
3944 | 199 | QByteArray fake_json(FAKE_PURCHASES_LIST_JSON_NULL_TIMESTAMP); | 199 | QByteArray fake_json(FAKE_PURCHASES_LIST_JSON_NULL_TIMESTAMP); |
3945 | 200 | EXPECT_CALL(reply.instance, readAll()) | 200 | EXPECT_CALL(reply.instance, readAll()) |
3946 | @@ -215,7 +215,7 @@ | |||
3947 | 215 | TEST_F(PayTest, testGetPurchasesTimestampIsParsed) | 215 | TEST_F(PayTest, testGetPurchasesTimestampIsParsed) |
3948 | 216 | { | 216 | { |
3949 | 217 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 217 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3951 | 218 | auto response = responseForReply(reply.asSharedPtr()); | 218 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
3952 | 219 | 219 | ||
3953 | 220 | QByteArray fake_json(FAKE_PURCHASES_LIST_JSON); | 220 | QByteArray fake_json(FAKE_PURCHASES_LIST_JSON); |
3954 | 221 | EXPECT_CALL(reply.instance, readAll()) | 221 | EXPECT_CALL(reply.instance, readAll()) |
3955 | @@ -237,7 +237,7 @@ | |||
3956 | 237 | TEST_F(PayTest, testGetPurchasesIsCancellable) | 237 | TEST_F(PayTest, testGetPurchasesIsCancellable) |
3957 | 238 | { | 238 | { |
3958 | 239 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 239 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3960 | 240 | auto response = responseForReply(reply.asSharedPtr()); | 240 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
3961 | 241 | 241 | ||
3962 | 242 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) | 242 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
3963 | 243 | .Times(1) | 243 | .Times(1) |
3964 | 244 | 244 | ||
3965 | === modified file 'libclickscope/tests/test_preview.cpp' | |||
3966 | --- libclickscope/tests/test_preview.cpp 2016-07-13 20:30:09 +0000 | |||
3967 | +++ libclickscope/tests/test_preview.cpp 2016-08-24 21:39:08 +0000 | |||
3968 | @@ -1,5 +1,5 @@ | |||
3969 | 1 | /* | 1 | /* |
3971 | 2 | * Copyright (C) 2014 Canonical Ltd. | 2 | * Copyright (C) 2014-2016 Canonical Ltd. |
3972 | 3 | * | 3 | * |
3973 | 4 | * This program is free software: you can redistribute it and/or modify it | 4 | * This program is free software: you can redistribute it and/or modify it |
3974 | 5 | * under the terms of the GNU General Public License version 3, as published | 5 | * under the terms of the GNU General Public License version 3, as published |
3975 | @@ -64,7 +64,7 @@ | |||
3976 | 64 | FakeIndex() { | 64 | FakeIndex() { |
3977 | 65 | 65 | ||
3978 | 66 | } | 66 | } |
3980 | 67 | click::web::Cancellable get_details(const std::string& /*package_name*/, std::function<void(click::PackageDetails, Error)> callback, bool) override { | 67 | click::web::Cancellable get_details(const std::string& /*package_name*/, std::function<void(click::PackageDetails, Error)> callback, bool, bool) override { |
3981 | 68 | callback(click::PackageDetails(), Error::NetworkError); | 68 | callback(click::PackageDetails(), Error::NetworkError); |
3982 | 69 | return click::web::Cancellable(); | 69 | return click::web::Cancellable(); |
3983 | 70 | } | 70 | } |
3984 | 71 | 71 | ||
3985 | === modified file 'libclickscope/tests/test_reviews.cpp' | |||
3986 | --- libclickscope/tests/test_reviews.cpp 2016-05-10 13:42:12 +0000 | |||
3987 | +++ libclickscope/tests/test_reviews.cpp 2016-08-24 21:39:08 +0000 | |||
3988 | @@ -140,7 +140,7 @@ | |||
3989 | 140 | TEST_F(ReviewsTest, testFetchReviewsCallsWebservice) | 140 | TEST_F(ReviewsTest, testFetchReviewsCallsWebservice) |
3990 | 141 | { | 141 | { |
3991 | 142 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 142 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3993 | 143 | auto response = responseForReply(reply.asSharedPtr()); | 143 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
3994 | 144 | 144 | ||
3995 | 145 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) | 145 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
3996 | 146 | .Times(1) | 146 | .Times(1) |
3997 | @@ -153,7 +153,7 @@ | |||
3998 | 153 | TEST_F(ReviewsTest, testFetchReviewsDoesNotSignCall) | 153 | TEST_F(ReviewsTest, testFetchReviewsDoesNotSignCall) |
3999 | 154 | { | 154 | { |
4000 | 155 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 155 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
4002 | 156 | auto response = responseForReply(reply.asSharedPtr()); | 156 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
4003 | 157 | 157 | ||
4004 | 158 | EXPECT_CALL(*clientPtr, callImpl(_, _, false, _, _, _)) | 158 | EXPECT_CALL(*clientPtr, callImpl(_, _, false, _, _, _)) |
4005 | 159 | .Times(1) | 159 | .Times(1) |
4006 | @@ -166,7 +166,7 @@ | |||
4007 | 166 | TEST_F(ReviewsTest, testFetchReviewsSendsQueryAsParam) | 166 | TEST_F(ReviewsTest, testFetchReviewsSendsQueryAsParam) |
4008 | 167 | { | 167 | { |
4009 | 168 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 168 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
4011 | 169 | auto response = responseForReply(reply.asSharedPtr()); | 169 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
4012 | 170 | 170 | ||
4013 | 171 | click::web::CallParams params; | 171 | click::web::CallParams params; |
4014 | 172 | params.add(click::REVIEWS_QUERY_ARGNAME, FAKE_PACKAGENAME); | 172 | params.add(click::REVIEWS_QUERY_ARGNAME, FAKE_PACKAGENAME); |
4015 | @@ -181,7 +181,7 @@ | |||
4016 | 181 | TEST_F(ReviewsTest, testFetchReviewsSendsCorrectPath) | 181 | TEST_F(ReviewsTest, testFetchReviewsSendsCorrectPath) |
4017 | 182 | { | 182 | { |
4018 | 183 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 183 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
4020 | 184 | auto response = responseForReply(reply.asSharedPtr()); | 184 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
4021 | 185 | 185 | ||
4022 | 186 | EXPECT_CALL(*clientPtr, callImpl(EndsWith(click::REVIEWS_API_PATH), | 186 | EXPECT_CALL(*clientPtr, callImpl(EndsWith(click::REVIEWS_API_PATH), |
4023 | 187 | _, _, _, _, _)) | 187 | _, _, _, _, _)) |
4024 | @@ -195,7 +195,7 @@ | |||
4025 | 195 | TEST_F(ReviewsTest, testFetchReviewsCallbackCalled) | 195 | TEST_F(ReviewsTest, testFetchReviewsCallbackCalled) |
4026 | 196 | { | 196 | { |
4027 | 197 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 197 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
4029 | 198 | auto response = responseForReply(reply.asSharedPtr()); | 198 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
4030 | 199 | 199 | ||
4031 | 200 | QByteArray fake_json("[]"); | 200 | QByteArray fake_json("[]"); |
4032 | 201 | EXPECT_CALL(reply.instance, readAll()) | 201 | EXPECT_CALL(reply.instance, readAll()) |
4033 | @@ -216,7 +216,7 @@ | |||
4034 | 216 | TEST_F(ReviewsTest, testFetchReviewsNot200) | 216 | TEST_F(ReviewsTest, testFetchReviewsNot200) |
4035 | 217 | { | 217 | { |
4036 | 218 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 218 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
4038 | 219 | auto response = responseForReply(reply.asSharedPtr()); | 219 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
4039 | 220 | 220 | ||
4040 | 221 | EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(301))); | 221 | EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(301))); |
4041 | 222 | EXPECT_CALL(reply.instance, readAll()) | 222 | EXPECT_CALL(reply.instance, readAll()) |
4042 | @@ -238,7 +238,7 @@ | |||
4043 | 238 | TEST_F(ReviewsTest, testFetchReviewsEmptyJsonIsParsed) | 238 | TEST_F(ReviewsTest, testFetchReviewsEmptyJsonIsParsed) |
4044 | 239 | { | 239 | { |
4045 | 240 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 240 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
4047 | 241 | auto response = responseForReply(reply.asSharedPtr()); | 241 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
4048 | 242 | 242 | ||
4049 | 243 | QByteArray fake_json("[]"); | 243 | QByteArray fake_json("[]"); |
4050 | 244 | EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(200))); | 244 | EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(200))); |
4051 | @@ -261,7 +261,7 @@ | |||
4052 | 261 | TEST_F(ReviewsTest, testFetchReviewsSingleJsonIsParsed) | 261 | TEST_F(ReviewsTest, testFetchReviewsSingleJsonIsParsed) |
4053 | 262 | { | 262 | { |
4054 | 263 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 263 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
4056 | 264 | auto response = responseForReply(reply.asSharedPtr()); | 264 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
4057 | 265 | 265 | ||
4058 | 266 | QByteArray fake_json(FAKE_JSON_REVIEWS_RESULT_ONE.c_str()); | 266 | QByteArray fake_json(FAKE_JSON_REVIEWS_RESULT_ONE.c_str()); |
4059 | 267 | EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(200))); | 267 | EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(200))); |
4060 | @@ -295,7 +295,7 @@ | |||
4061 | 295 | TEST_F(ReviewsTest, testFetchReviewsNetworkErrorReported) | 295 | TEST_F(ReviewsTest, testFetchReviewsNetworkErrorReported) |
4062 | 296 | { | 296 | { |
4063 | 297 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 297 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
4065 | 298 | auto response = responseForReply(reply.asSharedPtr()); | 298 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
4066 | 299 | 299 | ||
4067 | 300 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) | 300 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
4068 | 301 | .Times(1) | 301 | .Times(1) |
4069 | @@ -318,7 +318,7 @@ | |||
4070 | 318 | TEST_F(ReviewsTest, testFetchReviewsIsCancellable) | 318 | TEST_F(ReviewsTest, testFetchReviewsIsCancellable) |
4071 | 319 | { | 319 | { |
4072 | 320 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 320 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
4074 | 321 | auto response = responseForReply(reply.asSharedPtr()); | 321 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
4075 | 322 | 322 | ||
4076 | 323 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) | 323 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
4077 | 324 | .Times(1) | 324 | .Times(1) |
4078 | @@ -333,7 +333,7 @@ | |||
4079 | 333 | TEST_F(ReviewsTest, testSubmitReviewIsCancellable) | 333 | TEST_F(ReviewsTest, testSubmitReviewIsCancellable) |
4080 | 334 | { | 334 | { |
4081 | 335 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 335 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
4083 | 336 | auto response = responseForReply(reply.asSharedPtr()); | 336 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
4084 | 337 | 337 | ||
4085 | 338 | click::Review review; | 338 | click::Review review; |
4086 | 339 | review.rating = 3; | 339 | review.rating = 3; |
4087 | @@ -354,7 +354,7 @@ | |||
4088 | 354 | TEST_F(ReviewsTest, testSubmitReviewUtf8) | 354 | TEST_F(ReviewsTest, testSubmitReviewUtf8) |
4089 | 355 | { | 355 | { |
4090 | 356 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 356 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
4092 | 357 | auto response = responseForReply(reply.asSharedPtr()); | 357 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
4093 | 358 | 358 | ||
4094 | 359 | click::Review review; | 359 | click::Review review; |
4095 | 360 | review.rating = 3; | 360 | review.rating = 3; |
4096 | @@ -378,7 +378,7 @@ | |||
4097 | 378 | TEST_F(ReviewsTest, testSubmitReviewLanguageCorrect) | 378 | TEST_F(ReviewsTest, testSubmitReviewLanguageCorrect) |
4098 | 379 | { | 379 | { |
4099 | 380 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 380 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
4101 | 381 | auto response = responseForReply(reply.asSharedPtr()); | 381 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
4102 | 382 | 382 | ||
4103 | 383 | click::Review review; | 383 | click::Review review; |
4104 | 384 | review.rating = 3; | 384 | review.rating = 3; |
4105 | @@ -402,7 +402,7 @@ | |||
4106 | 402 | TEST_F(ReviewsTest, testSubmitReviewLanguageCorrectForFullLangCodes) | 402 | TEST_F(ReviewsTest, testSubmitReviewLanguageCorrectForFullLangCodes) |
4107 | 403 | { | 403 | { |
4108 | 404 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 404 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
4110 | 405 | auto response = responseForReply(reply.asSharedPtr()); | 405 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
4111 | 406 | 406 | ||
4112 | 407 | click::Review review; | 407 | click::Review review; |
4113 | 408 | review.rating = 3; | 408 | review.rating = 3; |
4114 | @@ -428,7 +428,7 @@ | |||
4115 | 428 | TEST_F(ReviewsTest, testEditReviewUrlHasReviewId) | 428 | TEST_F(ReviewsTest, testEditReviewUrlHasReviewId) |
4116 | 429 | { | 429 | { |
4117 | 430 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 430 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
4119 | 431 | auto response = responseForReply(reply.asSharedPtr()); | 431 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
4120 | 432 | 432 | ||
4121 | 433 | click::Review review; | 433 | click::Review review; |
4122 | 434 | review.id = 1234; | 434 | review.id = 1234; |
4123 | @@ -448,7 +448,7 @@ | |||
4124 | 448 | TEST_F(ReviewsTest, testEditReviewIsCancellable) | 448 | TEST_F(ReviewsTest, testEditReviewIsCancellable) |
4125 | 449 | { | 449 | { |
4126 | 450 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 450 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
4128 | 451 | auto response = responseForReply(reply.asSharedPtr()); | 451 | auto response = MockClient::responseForReply(reply.asSharedPtr()); |
4129 | 452 | 452 | ||
4130 | 453 | click::Review review; | 453 | click::Review review; |
4131 | 454 | review.id = 1234; | 454 | review.id = 1234; |
4132 | 455 | 455 | ||
4133 | === modified file 'scope/clickapps/apps-query.cpp' | |||
4134 | --- scope/clickapps/apps-query.cpp 2016-06-22 20:46:28 +0000 | |||
4135 | +++ scope/clickapps/apps-query.cpp 2016-08-24 21:39:08 +0000 | |||
4136 | @@ -1,5 +1,5 @@ | |||
4137 | 1 | /* | 1 | /* |
4139 | 2 | * Copyright (C) 2014-2015 Canonical Ltd. | 2 | * Copyright (C) 2014-2016 Canonical Ltd. |
4140 | 3 | * | 3 | * |
4141 | 4 | * This program is free software: you can redistribute it and/or modify it | 4 | * This program is free software: you can redistribute it and/or modify it |
4142 | 5 | * under the terms of the GNU General Public License version 3, as published | 5 | * under the terms of the GNU General Public License version 3, as published |
4143 | @@ -27,10 +27,12 @@ | |||
4144 | 27 | * files in the program, then also delete it here. | 27 | * files in the program, then also delete it here. |
4145 | 28 | */ | 28 | */ |
4146 | 29 | 29 | ||
4147 | 30 | #include "apps-query.h" | ||
4148 | 31 | |||
4149 | 30 | #include <click/application.h> | 32 | #include <click/application.h> |
4150 | 31 | #include <click/departments-db.h> | 33 | #include <click/departments-db.h> |
4151 | 32 | 34 | ||
4153 | 33 | #include <click/key_file_locator.h> | 35 | #include <QDebug> |
4154 | 34 | 36 | ||
4155 | 35 | #include <unity/scopes/CategoryRenderer.h> | 37 | #include <unity/scopes/CategoryRenderer.h> |
4156 | 36 | #include <unity/scopes/CategorisedResult.h> | 38 | #include <unity/scopes/CategorisedResult.h> |
4157 | @@ -39,12 +41,11 @@ | |||
4158 | 39 | #include <unity/scopes/SearchMetadata.h> | 41 | #include <unity/scopes/SearchMetadata.h> |
4159 | 40 | #include <unity/scopes/Department.h> | 42 | #include <unity/scopes/Department.h> |
4160 | 41 | 43 | ||
4161 | 44 | #include <locale> | ||
4162 | 45 | #include <memory> | ||
4163 | 42 | #include <vector> | 46 | #include <vector> |
4164 | 43 | #include <locale> | ||
4165 | 44 | 47 | ||
4166 | 45 | #include <click/click-i18n.h> | 48 | #include <click/click-i18n.h> |
4167 | 46 | #include "apps-query.h" | ||
4168 | 47 | #include <QDebug> | ||
4169 | 48 | 49 | ||
4170 | 49 | namespace | 50 | namespace |
4171 | 50 | { | 51 | { |
4172 | @@ -259,8 +260,7 @@ | |||
4173 | 259 | 260 | ||
4174 | 260 | click::Interface& click::apps::Query::clickInterfaceInstance() | 261 | click::Interface& click::apps::Query::clickInterfaceInstance() |
4175 | 261 | { | 262 | { |
4178 | 262 | static QSharedPointer<click::KeyFileLocator> keyFileLocator(new click::KeyFileLocator()); | 263 | static click::Interface iface; |
4177 | 263 | static click::Interface iface(keyFileLocator); | ||
4179 | 264 | 264 | ||
4180 | 265 | return iface; | 265 | return iface; |
4181 | 266 | } | 266 | } |
4182 | @@ -420,7 +420,7 @@ | |||
4183 | 420 | const bool show_top_apps = querystr.empty() && current_dept.empty(); | 420 | const bool show_top_apps = querystr.empty() && current_dept.empty(); |
4184 | 421 | ResultPusher pusher(searchReply, show_top_apps ? impl->configuration.get_core_apps() : std::vector<std::string>()); | 421 | ResultPusher pusher(searchReply, show_top_apps ? impl->configuration.get_core_apps() : std::vector<std::string>()); |
4185 | 422 | auto const ignoredApps = impl->configuration.get_ignored_apps(); | 422 | auto const ignoredApps = impl->configuration.get_ignored_apps(); |
4187 | 423 | auto const localResults = clickInterfaceInstance().find_installed_apps(querystr, ignoredApps, current_dept, impl->depts_db); | 423 | auto const localResults = clickInterfaceInstance().search(querystr, ignoredApps, current_dept, impl->depts_db); |
4188 | 424 | 424 | ||
4189 | 425 | if (impl->depts_db) | 425 | if (impl->depts_db) |
4190 | 426 | { | 426 | { |
4191 | 427 | 427 | ||
4192 | === modified file 'scope/clickapps/apps-scope.cpp' | |||
4193 | --- scope/clickapps/apps-scope.cpp 2016-05-18 12:35:56 +0000 | |||
4194 | +++ scope/clickapps/apps-scope.cpp 2016-08-24 21:39:08 +0000 | |||
4195 | @@ -38,7 +38,6 @@ | |||
4196 | 38 | 38 | ||
4197 | 39 | #include <QSharedPointer> | 39 | #include <QSharedPointer> |
4198 | 40 | 40 | ||
4199 | 41 | #include <click/key_file_locator.h> | ||
4200 | 42 | #include <click/network_access_manager.h> | 41 | #include <click/network_access_manager.h> |
4201 | 43 | #include <click/click-i18n.h> | 42 | #include <click/click-i18n.h> |
4202 | 44 | #include <click/utils.h> | 43 | #include <click/utils.h> |
4203 | 45 | 44 | ||
4204 | === modified file 'scope/clickstore/store-query.cpp' | |||
4205 | --- scope/clickstore/store-query.cpp 2016-07-13 19:46:17 +0000 | |||
4206 | +++ scope/clickstore/store-query.cpp 2016-08-24 21:39:08 +0000 | |||
4207 | @@ -1,5 +1,5 @@ | |||
4208 | 1 | /* | 1 | /* |
4210 | 2 | * Copyright (C) 2014-2015 Canonical Ltd. | 2 | * Copyright (C) 2014-2016 Canonical Ltd. |
4211 | 3 | * | 3 | * |
4212 | 4 | * This program is free software: you can redistribute it and/or modify it | 4 | * This program is free software: you can redistribute it and/or modify it |
4213 | 5 | * under the terms of the GNU General Public License version 3, as published | 5 | * under the terms of the GNU General Public License version 3, as published |
4214 | @@ -32,7 +32,6 @@ | |||
4215 | 32 | 32 | ||
4216 | 33 | #include <click/application.h> | 33 | #include <click/application.h> |
4217 | 34 | #include <click/interface.h> | 34 | #include <click/interface.h> |
4218 | 35 | #include <click/key_file_locator.h> | ||
4219 | 36 | #include <click/qtbridge.h> | 35 | #include <click/qtbridge.h> |
4220 | 37 | #include <click/departments-db.h> | 36 | #include <click/departments-db.h> |
4221 | 38 | #include <click/utils.h> | 37 | #include <click/utils.h> |
4222 | @@ -47,12 +46,13 @@ | |||
4223 | 47 | #include <unity/scopes/Variant.h> | 46 | #include <unity/scopes/Variant.h> |
4224 | 48 | #include <unity/scopes/VariantBuilder.h> | 47 | #include <unity/scopes/VariantBuilder.h> |
4225 | 49 | 48 | ||
4226 | 49 | #include <cassert> | ||
4227 | 50 | #include <iomanip> | 50 | #include <iomanip> |
4228 | 51 | #include<vector> | ||
4229 | 52 | #include<set> | ||
4230 | 53 | #include<sstream> | ||
4231 | 54 | #include <cassert> | ||
4232 | 55 | #include <locale> | 51 | #include <locale> |
4233 | 52 | #include <memory> | ||
4234 | 53 | #include <set> | ||
4235 | 54 | #include <sstream> | ||
4236 | 55 | #include <vector> | ||
4237 | 56 | 56 | ||
4238 | 57 | #include <QLocale> | 57 | #include <QLocale> |
4239 | 58 | 58 | ||
4240 | @@ -169,6 +169,7 @@ | |||
4241 | 169 | click::HighlightList& highlights; | 169 | click::HighlightList& highlights; |
4242 | 170 | scopes::SearchMetadata meta; | 170 | scopes::SearchMetadata meta; |
4243 | 171 | click::web::Cancellable search_operation; | 171 | click::web::Cancellable search_operation; |
4244 | 172 | click::web::Cancellable search_snaps_operation; | ||
4245 | 172 | click::web::Cancellable purchases_operation; | 173 | click::web::Cancellable purchases_operation; |
4246 | 173 | pay::Package& pay_package; | 174 | pay::Package& pay_package; |
4247 | 174 | std::shared_future<void> qt_ready_; | 175 | std::shared_future<void> qt_ready_; |
4248 | @@ -196,12 +197,12 @@ | |||
4249 | 196 | { | 197 | { |
4250 | 197 | qDebug() << "cancelling search of" << QString::fromStdString(query().query_string()); | 198 | qDebug() << "cancelling search of" << QString::fromStdString(query().query_string()); |
4251 | 198 | impl->search_operation.cancel(); | 199 | impl->search_operation.cancel(); |
4252 | 200 | impl->search_snaps_operation.cancel(); | ||
4253 | 199 | } | 201 | } |
4254 | 200 | 202 | ||
4255 | 201 | click::Interface& click::Query::clickInterfaceInstance() | 203 | click::Interface& click::Query::clickInterfaceInstance() |
4256 | 202 | { | 204 | { |
4259 | 203 | static QSharedPointer<click::KeyFileLocator> keyFileLocator(new click::KeyFileLocator()); | 205 | static click::Interface iface; |
4258 | 204 | static click::Interface iface(keyFileLocator); | ||
4260 | 205 | 206 | ||
4261 | 206 | return iface; | 207 | return iface; |
4262 | 207 | } | 208 | } |
4263 | @@ -291,7 +292,12 @@ | |||
4264 | 291 | res.set_title(pkg.title); | 292 | res.set_title(pkg.title); |
4265 | 292 | res.set_art(pkg.icon_url); | 293 | res.set_art(pkg.icon_url); |
4266 | 293 | res.set_uri(pkg.url); | 294 | res.set_uri(pkg.url); |
4268 | 294 | res[click::Query::ResultKeys::NAME] = pkg.name; | 295 | res["snap_id"] = pkg.snap_id; |
4269 | 296 | if (pkg.snap_id.empty()) { | ||
4270 | 297 | res[click::Query::ResultKeys::NAME] = pkg.name; | ||
4271 | 298 | } else { | ||
4272 | 299 | res[click::Query::ResultKeys::NAME] = pkg.alias; | ||
4273 | 300 | } | ||
4274 | 295 | res["subtitle"] = pkg.publisher; | 301 | res["subtitle"] = pkg.publisher; |
4275 | 296 | auto installed = installedPackages.find(pkg); | 302 | auto installed = installedPackages.find(pkg); |
4276 | 297 | 303 | ||
4277 | @@ -534,6 +540,7 @@ | |||
4278 | 534 | push_package(searchReply, recommendsCategory, | 540 | push_package(searchReply, recommendsCategory, |
4279 | 535 | installedPackages, r); | 541 | installedPackages, r); |
4280 | 536 | } | 542 | } |
4281 | 543 | |||
4282 | 537 | qDebug() << "search completed"; | 544 | qDebug() << "search completed"; |
4283 | 538 | this->finished(searchReply); //FIXME: this shouldn't be needed | 545 | this->finished(searchReply); //FIXME: this shouldn't be needed |
4284 | 539 | }; | 546 | }; |
4285 | @@ -597,7 +604,37 @@ | |||
4286 | 597 | { | 604 | { |
4287 | 598 | qDebug() << "starting search of" << QString::fromStdString(query().query_string()); | 605 | qDebug() << "starting search of" << QString::fromStdString(query().query_string()); |
4288 | 599 | push_departments(searchReply); | 606 | push_departments(searchReply); |
4290 | 600 | impl->search_operation = impl->index.search(query().query_string(), query().department_id(), search_cb, force_cache); | 607 | impl->search_operation = impl->index.search |
4291 | 608 | (query().query_string(), query().department_id(), | ||
4292 | 609 | [this, search_cb, force_cache](Packages packages, | ||
4293 | 610 | Packages recommends) { | ||
4294 | 611 | if (Configuration().is_snapd_running()) { | ||
4295 | 612 | qDebug() << "Searching for snaps too."; | ||
4296 | 613 | impl->search_snaps_operation = impl->index.search_snaps | ||
4297 | 614 | (query().query_string(), | ||
4298 | 615 | [this, packages, recommends, search_cb](Packages snap_packages, | ||
4299 | 616 | Packages snap_recommends) { | ||
4300 | 617 | qDebug() << "In the callback."; | ||
4301 | 618 | Packages new_packages, new_recommends; | ||
4302 | 619 | for (auto p: packages) { | ||
4303 | 620 | new_packages.push_back(p); | ||
4304 | 621 | } | ||
4305 | 622 | for (auto p: snap_packages) { | ||
4306 | 623 | new_packages.push_back(p); | ||
4307 | 624 | } | ||
4308 | 625 | for (auto r: recommends) { | ||
4309 | 626 | new_recommends.push_back(r); | ||
4310 | 627 | } | ||
4311 | 628 | for (auto r: snap_recommends) { | ||
4312 | 629 | new_recommends.push_back(r); | ||
4313 | 630 | } | ||
4314 | 631 | qDebug() << "Snaps appended."; | ||
4315 | 632 | search_cb(new_packages, new_recommends); | ||
4316 | 633 | }, force_cache); | ||
4317 | 634 | } else { | ||
4318 | 635 | search_cb(packages, recommends); | ||
4319 | 636 | } | ||
4320 | 637 | }, force_cache); | ||
4321 | 601 | } | 638 | } |
4322 | 602 | } | 639 | } |
4323 | 603 | }); | 640 | }); |
4324 | 604 | 641 | ||
4325 | === modified file 'scope/clickstore/store-scope.cpp' | |||
4326 | --- scope/clickstore/store-scope.cpp 2016-05-25 16:19:58 +0000 | |||
4327 | +++ scope/clickstore/store-scope.cpp 2016-08-24 21:39:08 +0000 | |||
4328 | @@ -38,7 +38,6 @@ | |||
4329 | 38 | 38 | ||
4330 | 39 | #include <QSharedPointer> | 39 | #include <QSharedPointer> |
4331 | 40 | 40 | ||
4332 | 41 | #include <click/key_file_locator.h> | ||
4333 | 42 | #include <click/network_access_manager.h> | 41 | #include <click/network_access_manager.h> |
4334 | 43 | #include <click/click-i18n.h> | 42 | #include <click/click-i18n.h> |
4335 | 44 | 43 | ||
4336 | 45 | 44 | ||
4337 | === modified file 'scope/tests/test_apps_query.cpp' | |||
4338 | --- scope/tests/test_apps_query.cpp 2016-03-09 13:08:13 +0000 | |||
4339 | +++ scope/tests/test_apps_query.cpp 2016-08-24 21:39:08 +0000 | |||
4340 | @@ -1,5 +1,5 @@ | |||
4341 | 1 | /* | 1 | /* |
4343 | 2 | * Copyright (C) 2014 Canonical Ltd. | 2 | * Copyright (C) 2014-2016 Canonical Ltd. |
4344 | 3 | * | 3 | * |
4345 | 4 | * This program is free software: you can redistribute it and/or modify it | 4 | * This program is free software: you can redistribute it and/or modify it |
4346 | 5 | * under the terms of the GNU General Public License version 3, as published | 5 | * under the terms of the GNU General Public License version 3, as published |
4347 | @@ -61,7 +61,7 @@ | |||
4348 | 61 | { | 61 | { |
4349 | 62 | public: | 62 | public: |
4350 | 63 | MockClickInterface() = default; | 63 | MockClickInterface() = default; |
4352 | 64 | MOCK_METHOD4(find_installed_apps, std::vector<click::Application>(const std::string&, const std::vector<std::string>&, const std::string&, const std::shared_ptr<click::DepartmentsDb>&)); | 64 | MOCK_METHOD4(search, std::vector<click::Application>(const std::string&, const std::vector<std::string>&, const std::string&, const std::shared_ptr<click::DepartmentsDb>&)); |
4353 | 65 | }; | 65 | }; |
4354 | 66 | 66 | ||
4355 | 67 | class MockAppsQuery : public click::apps::Query | 67 | class MockAppsQuery : public click::apps::Query |
4356 | @@ -215,7 +215,7 @@ | |||
4357 | 215 | // no apps in 'books' department, thus excluded | 215 | // no apps in 'books' department, thus excluded |
4358 | 216 | std::list<std::string> expected_departments({{"", "games", "video"}}); | 216 | std::list<std::string> expected_departments({{"", "games", "video"}}); |
4359 | 217 | 217 | ||
4361 | 218 | EXPECT_CALL(*clickif, find_installed_apps(_, _, _, _)).WillOnce(Return(installed_apps)); | 218 | EXPECT_CALL(*clickif, search(_, _, _, _)).WillOnce(Return(installed_apps)); |
4362 | 219 | EXPECT_CALL(mock_reply, register_category("predefined", _, _, _)).WillOnce(Return(ptrCat)); | 219 | EXPECT_CALL(mock_reply, register_category("predefined", _, _, _)).WillOnce(Return(ptrCat)); |
4363 | 220 | EXPECT_CALL(mock_reply, register_category("local", StrNe(""), _, _)).WillOnce(Return(ptrCat)); | 220 | EXPECT_CALL(mock_reply, register_category("local", StrNe(""), _, _)).WillOnce(Return(ptrCat)); |
4364 | 221 | EXPECT_CALL(mock_reply, register_category("store", _, _, _)).WillOnce(Return(ptrCat)); | 221 | EXPECT_CALL(mock_reply, register_category("store", _, _, _)).WillOnce(Return(ptrCat)); |
4365 | @@ -264,7 +264,7 @@ | |||
4366 | 264 | 264 | ||
4367 | 265 | std::list<std::string> expected_departments({"", "games"}); | 265 | std::list<std::string> expected_departments({"", "games"}); |
4368 | 266 | 266 | ||
4370 | 267 | EXPECT_CALL(*clickif, find_installed_apps(_, _, _, _)).WillOnce(Return(installed_apps)); | 267 | EXPECT_CALL(*clickif, search(_, _, _, _)).WillOnce(Return(installed_apps)); |
4371 | 268 | EXPECT_CALL(mock_reply, register_category("local", StrEq(""), _, _)).WillOnce(Return(ptrCat)); | 268 | EXPECT_CALL(mock_reply, register_category("local", StrEq(""), _, _)).WillOnce(Return(ptrCat)); |
4372 | 269 | EXPECT_CALL(mock_reply, register_category("store", _, _, _)).WillOnce(Return(ptrCat)); | 269 | EXPECT_CALL(mock_reply, register_category("store", _, _, _)).WillOnce(Return(ptrCat)); |
4373 | 270 | EXPECT_CALL(mock_reply, register_departments(MatchesDepartments(expected_departments))); | 270 | EXPECT_CALL(mock_reply, register_departments(MatchesDepartments(expected_departments))); |
4374 | @@ -296,7 +296,7 @@ | |||
4375 | 296 | scopes::testing::MockSearchReply mock_reply; | 296 | scopes::testing::MockSearchReply mock_reply; |
4376 | 297 | scopes::SearchReplyProxy reply(&mock_reply, [](unity::scopes::SearchReply*){}); | 297 | scopes::SearchReplyProxy reply(&mock_reply, [](unity::scopes::SearchReply*){}); |
4377 | 298 | 298 | ||
4379 | 299 | EXPECT_CALL(*clickif, find_installed_apps(_, _, _, _)).WillOnce(Return(installed_apps)); | 299 | EXPECT_CALL(*clickif, search(_, _, _, _)).WillOnce(Return(installed_apps)); |
4380 | 300 | EXPECT_CALL(mock_reply, register_category("local", StrEq(""), _, _)).WillOnce(Return(ptrCat)); | 300 | EXPECT_CALL(mock_reply, register_category("local", StrEq(""), _, _)).WillOnce(Return(ptrCat)); |
4381 | 301 | EXPECT_CALL(mock_reply, register_category("store", _, _, _)).WillOnce(Return(ptrCat)); | 301 | EXPECT_CALL(mock_reply, register_category("store", _, _, _)).WillOnce(Return(ptrCat)); |
4382 | 302 | 302 | ||
4383 | @@ -323,7 +323,7 @@ | |||
4384 | 323 | 323 | ||
4385 | 324 | std::list<std::string> expected_departments({"", "games"}); | 324 | std::list<std::string> expected_departments({"", "games"}); |
4386 | 325 | 325 | ||
4388 | 326 | EXPECT_CALL(*clickif, find_installed_apps("Fooo", _, "games", _)).WillOnce(Return(installed_apps)); | 326 | EXPECT_CALL(*clickif, search("Fooo", _, "games", _)).WillOnce(Return(installed_apps)); |
4389 | 327 | EXPECT_CALL(mock_reply, register_category("local", StrEq(""), _, _)).WillOnce(Return(ptrCat)); | 327 | EXPECT_CALL(mock_reply, register_category("local", StrEq(""), _, _)).WillOnce(Return(ptrCat)); |
4390 | 328 | EXPECT_CALL(mock_reply, register_category("store", _, _, _)).WillOnce(Return(ptrCat)); | 328 | EXPECT_CALL(mock_reply, register_category("store", _, _, _)).WillOnce(Return(ptrCat)); |
4391 | 329 | EXPECT_CALL(*depts_db, get_department_name("games", expected_locales)).WillOnce(Return("Games")); | 329 | EXPECT_CALL(*depts_db, get_department_name("games", expected_locales)).WillOnce(Return("Games")); |
4392 | 330 | 330 | ||
4393 | === modified file 'tools/init-departments/init-departments.cpp' | |||
4394 | --- tools/init-departments/init-departments.cpp 2014-07-15 13:30:05 +0000 | |||
4395 | +++ tools/init-departments/init-departments.cpp 2016-08-24 21:39:08 +0000 | |||
4396 | @@ -1,5 +1,5 @@ | |||
4397 | 1 | /* | 1 | /* |
4399 | 2 | * Copyright (C) 2014 Canonical Ltd. | 2 | * Copyright (C) 2014-2016 Canonical Ltd. |
4400 | 3 | * | 3 | * |
4401 | 4 | * This program is free software: you can redistribute it and/or modify it | 4 | * This program is free software: you can redistribute it and/or modify it |
4402 | 5 | * under the terms of the GNU General Public License version 3, as published | 5 | * under the terms of the GNU General Public License version 3, as published |
4403 | @@ -28,14 +28,16 @@ | |||
4404 | 28 | */ | 28 | */ |
4405 | 29 | 29 | ||
4406 | 30 | #include <click/interface.h> | 30 | #include <click/interface.h> |
4407 | 31 | #include <click/key_file_locator.h> | ||
4408 | 32 | #include <click/index.h> | 31 | #include <click/index.h> |
4409 | 33 | #include <click/webclient.h> | 32 | #include <click/webclient.h> |
4410 | 34 | #include <click/network_access_manager.h> | 33 | #include <click/network_access_manager.h> |
4411 | 35 | #include <click/qtbridge.h> | 34 | #include <click/qtbridge.h> |
4412 | 36 | #include <click/departments-db.h> | 35 | #include <click/departments-db.h> |
4413 | 36 | |||
4414 | 37 | #include <future> | 37 | #include <future> |
4415 | 38 | #include <iostream> | 38 | #include <iostream> |
4416 | 39 | #include <memory> | ||
4417 | 40 | |||
4418 | 39 | #include <QDebug> | 41 | #include <QDebug> |
4419 | 40 | #include <QtGlobal> | 42 | #include <QtGlobal> |
4420 | 41 | 43 | ||
4421 | @@ -65,8 +67,7 @@ | |||
4422 | 65 | {"webbrowser-app.desktop", "web-browsers"} | 67 | {"webbrowser-app.desktop", "web-browsers"} |
4423 | 66 | }; | 68 | }; |
4424 | 67 | 69 | ||
4427 | 68 | QSharedPointer<click::KeyFileLocator> keyFileLocator(new click::KeyFileLocator()); | 70 | click::Interface iface; |
4426 | 69 | click::Interface iface(keyFileLocator); | ||
4428 | 70 | 71 | ||
4429 | 71 | void noDebug(QtMsgType, const QMessageLogContext&, const QString&) {} | 72 | void noDebug(QtMsgType, const QMessageLogContext&, const QString&) {} |
4430 | 72 | 73 |
PASSED: Continuous integration, rev:496 /jenkins. canonical. com/unity- api-1/job/ lp-unity- scope-click- ci/86/ /jenkins. canonical. com/unity- api-1/job/ build/470 /jenkins. canonical. com/unity- api-1/job/ build-0- fetch/476 /jenkins. canonical. com/unity- api-1/job/ build-1- sourcepkg/ release= vivid+overlay/ 381 /jenkins. canonical. com/unity- api-1/job/ build-1- sourcepkg/ release= xenial+ overlay/ 381 /jenkins. canonical. com/unity- api-1/job/ build-1- sourcepkg/ release= yakkety/ 381 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 311 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 311/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 311 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 311/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= yakkety/ 311 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= yakkety/ 311/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 311 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 311/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 311 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 311/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= yakkety/ 311 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= yakkety/ 311/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 311 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 311/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 311 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 311/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= yakkety/ 311 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= yakkety/ 311/artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/unity- api-1/job/ lp-unity- scope-click- ci/86/rebuild
https:/