Merge lp:~alecu/unity-scope-click/header-apps into lp:unity-scope-click/devel
- header-apps
- Merge into devel
Proposed by
Alejandro J. Cura
Status: | Merged |
---|---|
Merged at revision: | 317 |
Proposed branch: | lp:~alecu/unity-scope-click/header-apps |
Merge into: | lp:unity-scope-click/devel |
Diff against target: |
706 lines (+349/-54) (has conflicts) 12 files modified
CMakeLists.txt (+3/-3) libclickscope/click/CMakeLists.txt (+4/-0) libclickscope/click/configuration.cpp (+24/-0) libclickscope/click/configuration.h (+18/-0) libclickscope/tests/test_configuration.cpp (+27/-0) scope/clickapps/apps-query.cpp (+50/-31) scope/clickapps/apps-query.h (+34/-6) scope/clickapps/apps-scope.cpp (+2/-1) scope/tests/CMakeLists.txt (+44/-0) scope/tests/test_apps_query.cpp (+69/-0) scope/tests/test_helpers.h (+68/-0) scope/tests/test_query.cpp (+6/-13) Text conflict in scope/tests/test_query.cpp |
To merge this branch: | bzr merge lp:~alecu/unity-scope-click/header-apps |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity Team | Pending | ||
Review via email: mp+225468@code.launchpad.net |
Commit message
Description of the change
Initial version of the branch to show the 6 top apps
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2014-06-23 15:00:28 +0000 | |||
3 | +++ CMakeLists.txt 2014-07-03 13:14:19 +0000 | |||
4 | @@ -75,7 +75,7 @@ | |||
5 | 75 | 75 | ||
6 | 76 | # Custom targets for the tests | 76 | # Custom targets for the tests |
7 | 77 | add_custom_target (test | 77 | add_custom_target (test |
9 | 78 | DEPENDS test-click-scope test-libclickscope | 78 | DEPENDS test-click-scope test-apps-scope test-libclickscope |
10 | 79 | ) | 79 | ) |
11 | 80 | 80 | ||
12 | 81 | add_custom_target (test-disabled | 81 | add_custom_target (test-disabled |
13 | @@ -90,13 +90,13 @@ | |||
14 | 90 | 90 | ||
15 | 91 | # Add a custom target for running the tests under valgrind. | 91 | # Add a custom target for running the tests under valgrind. |
16 | 92 | add_custom_target (test-valgrind | 92 | add_custom_target (test-valgrind |
18 | 93 | DEPENDS test-click-scope-valgrind test-libclickscope-valgrind | 93 | DEPENDS test-click-scope-valgrind test-apps-scope-valgrind test-libclickscope-valgrind |
19 | 94 | ) | 94 | ) |
20 | 95 | 95 | ||
21 | 96 | # Add a custom target for running the tests under valgrind with the | 96 | # Add a custom target for running the tests under valgrind with the |
22 | 97 | # full leak checks enabled. | 97 | # full leak checks enabled. |
23 | 98 | add_custom_target (test-leaks | 98 | add_custom_target (test-leaks |
25 | 99 | DEPENDS test-click-scope-leaks test-libclickscope-leaks | 99 | DEPENDS test-click-scope-leaks test-apps-scope-leaks test-libclickscope-leaks |
26 | 100 | ) | 100 | ) |
27 | 101 | 101 | ||
28 | 102 | # Also let "make check" and partners work. | 102 | # Also let "make check" and partners work. |
29 | 103 | 103 | ||
30 | === modified file 'libclickscope/click/CMakeLists.txt' | |||
31 | --- libclickscope/click/CMakeLists.txt 2014-06-23 15:00:28 +0000 | |||
32 | +++ libclickscope/click/CMakeLists.txt 2014-07-03 13:14:19 +0000 | |||
33 | @@ -2,11 +2,13 @@ | |||
34 | 2 | SET (CMAKE_AUTOMOC ON) | 2 | SET (CMAKE_AUTOMOC ON) |
35 | 3 | find_package (Qt5Core REQUIRED) | 3 | find_package (Qt5Core REQUIRED) |
36 | 4 | pkg_check_modules(JSON_CPP REQUIRED jsoncpp) | 4 | pkg_check_modules(JSON_CPP REQUIRED jsoncpp) |
37 | 5 | pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt) | ||
38 | 5 | 6 | ||
39 | 6 | add_definitions( | 7 | add_definitions( |
40 | 7 | -DGETTEXT_PACKAGE=\"${PROJECT_NAME}\" | 8 | -DGETTEXT_PACKAGE=\"${PROJECT_NAME}\" |
41 | 8 | -DGETTEXT_LOCALEDIR=\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LOCALEDIR}\" | 9 | -DGETTEXT_LOCALEDIR=\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LOCALEDIR}\" |
42 | 9 | -DCLICK_INSTALL_HELPER=\"${CMAKE_INSTALL_PREFIX}/lib/unity-scope-click/install-helper\" | 10 | -DCLICK_INSTALL_HELPER=\"${CMAKE_INSTALL_PREFIX}/lib/unity-scope-click/install-helper\" |
43 | 11 | ${GSETTINGS_QT_CFLAGS} ${GSETTINGS_QT_OTHER} | ||
44 | 10 | ) | 12 | ) |
45 | 11 | 13 | ||
46 | 12 | add_library(${SCOPE_LIB_NAME} STATIC | 14 | add_library(${SCOPE_LIB_NAME} STATIC |
47 | @@ -32,6 +34,7 @@ | |||
48 | 32 | 34 | ||
49 | 33 | include_directories( | 35 | include_directories( |
50 | 34 | ${JSON_CPP_INCLUDE_DIRS} | 36 | ${JSON_CPP_INCLUDE_DIRS} |
51 | 37 | ${GSETTINGS_QT_INCLUDE_DIRS} | ||
52 | 35 | ${CMAKE_SOURCE_DIR}/libclickscope | 38 | ${CMAKE_SOURCE_DIR}/libclickscope |
53 | 36 | ) | 39 | ) |
54 | 37 | 40 | ||
55 | @@ -41,5 +44,6 @@ | |||
56 | 41 | ${UBUNTUONE_LDFLAGS} | 44 | ${UBUNTUONE_LDFLAGS} |
57 | 42 | ${UBUNTU_DOWNLOAD_MANAGER_CLIENT_LDFLAGS} | 45 | ${UBUNTU_DOWNLOAD_MANAGER_CLIENT_LDFLAGS} |
58 | 43 | ${UBUNTU_DOWNLOAD_MANAGER_COMMON_LDFLAGS} | 46 | ${UBUNTU_DOWNLOAD_MANAGER_COMMON_LDFLAGS} |
59 | 47 | ${GSETTINGS_QT_LIBRARIES} | ||
60 | 44 | -lboost_locale | 48 | -lboost_locale |
61 | 45 | ) | 49 | ) |
62 | 46 | 50 | ||
63 | === modified file 'libclickscope/click/configuration.cpp' | |||
64 | --- libclickscope/click/configuration.cpp 2014-06-25 21:33:59 +0000 | |||
65 | +++ libclickscope/click/configuration.cpp 2014-07-03 13:14:19 +0000 | |||
66 | @@ -32,6 +32,10 @@ | |||
67 | 32 | 32 | ||
68 | 33 | #include <QDir> | 33 | #include <QDir> |
69 | 34 | #include <QProcess> | 34 | #include <QProcess> |
70 | 35 | #include <QStringList> | ||
71 | 36 | #include <QVariant> | ||
72 | 37 | |||
73 | 38 | #include <qgsettings.h> | ||
74 | 35 | 39 | ||
75 | 36 | #include <boost/algorithm/string.hpp> | 40 | #include <boost/algorithm/string.hpp> |
76 | 37 | #include <boost/algorithm/string/replace.hpp> | 41 | #include <boost/algorithm/string/replace.hpp> |
77 | @@ -141,4 +145,24 @@ | |||
78 | 141 | != FULL_LANG_CODES.end(); | 145 | != FULL_LANG_CODES.end(); |
79 | 142 | } | 146 | } |
80 | 143 | 147 | ||
81 | 148 | const std::vector<std::string> Configuration::get_dconf_strings(const std::string& schema, const std::string& key) | ||
82 | 149 | { | ||
83 | 150 | QGSettings qgs(schema.c_str()); | ||
84 | 151 | auto locations = qgs.get(QString::fromStdString(key)).toStringList(); | ||
85 | 152 | std::vector<std::string> v; | ||
86 | 153 | for(const auto& l : locations) { | ||
87 | 154 | v.push_back(l.toStdString()); | ||
88 | 155 | } | ||
89 | 156 | return v; | ||
90 | 157 | } | ||
91 | 158 | |||
92 | 159 | const std::vector<std::string> Configuration::get_core_apps() | ||
93 | 160 | { | ||
94 | 161 | auto apps = get_dconf_strings(Configuration::COREAPPS_SCHEMA, Configuration::COREAPPS_KEY); | ||
95 | 162 | if (apps.empty()) { | ||
96 | 163 | apps = get_default_core_apps(); | ||
97 | 164 | } | ||
98 | 165 | return apps; | ||
99 | 166 | } | ||
100 | 167 | |||
101 | 144 | } // namespace click | 168 | } // namespace click |
102 | 145 | 169 | ||
103 | === modified file 'libclickscope/click/configuration.h' | |||
104 | --- libclickscope/click/configuration.h 2014-06-25 21:33:59 +0000 | |||
105 | +++ libclickscope/click/configuration.h 2014-07-03 13:14:19 +0000 | |||
106 | @@ -33,6 +33,8 @@ | |||
107 | 33 | #include <string> | 33 | #include <string> |
108 | 34 | #include <vector> | 34 | #include <vector> |
109 | 35 | 35 | ||
110 | 36 | #define _CURRENT_USER_VERSION "_current-user-version" | ||
111 | 37 | |||
112 | 36 | namespace click | 38 | namespace click |
113 | 37 | { | 39 | { |
114 | 38 | 40 | ||
115 | @@ -54,10 +56,26 @@ | |||
116 | 54 | virtual std::string get_accept_languages(); | 56 | virtual std::string get_accept_languages(); |
117 | 55 | static bool is_full_lang_code(const std::string& language); | 57 | static bool is_full_lang_code(const std::string& language); |
118 | 56 | 58 | ||
119 | 59 | constexpr static const char* COREAPPS_SCHEMA {""}; | ||
120 | 60 | constexpr static const char* COREAPPS_KEY {""}; | ||
121 | 61 | |||
122 | 62 | virtual const std::vector<std::string> get_core_apps(); | ||
123 | 57 | virtual ~Configuration() {} | 63 | virtual ~Configuration() {} |
124 | 58 | protected: | 64 | protected: |
125 | 59 | virtual std::vector<std::string> list_folder(const std::string &folder, const std::string &pattern); | 65 | virtual std::vector<std::string> list_folder(const std::string &folder, const std::string &pattern); |
126 | 60 | virtual std::string architectureFromDpkg(); | 66 | virtual std::string architectureFromDpkg(); |
127 | 67 | virtual const std::vector<std::string> get_dconf_strings(const std::string& schema, const std::string& key); | ||
128 | 68 | static const std::vector<std::string>& get_default_core_apps() { | ||
129 | 69 | static std::vector<std::string> default_apps { | ||
130 | 70 | "dialer-app.desktop", | ||
131 | 71 | "messaging-app.desktop", | ||
132 | 72 | "com.ubuntu.calculator_calculator" _CURRENT_USER_VERSION, | ||
133 | 73 | "com.ubuntu.clock_clock" _CURRENT_USER_VERSION, | ||
134 | 74 | "com.ubuntu.camera_camera" _CURRENT_USER_VERSION, | ||
135 | 75 | "com.ubuntu.calendar_calendar" _CURRENT_USER_VERSION | ||
136 | 76 | }; | ||
137 | 77 | return default_apps; | ||
138 | 78 | } | ||
139 | 61 | }; | 79 | }; |
140 | 62 | 80 | ||
141 | 63 | } // namespace click | 81 | } // namespace click |
142 | 64 | 82 | ||
143 | === modified file 'libclickscope/tests/test_configuration.cpp' | |||
144 | --- libclickscope/tests/test_configuration.cpp 2014-06-25 21:33:59 +0000 | |||
145 | +++ libclickscope/tests/test_configuration.cpp 2014-07-03 13:14:19 +0000 | |||
146 | @@ -27,6 +27,8 @@ | |||
147 | 27 | * files in the program, then also delete it here. | 27 | * files in the program, then also delete it here. |
148 | 28 | */ | 28 | */ |
149 | 29 | 29 | ||
150 | 30 | #include <QStringList> | ||
151 | 31 | |||
152 | 30 | #include <gmock/gmock.h> | 32 | #include <gmock/gmock.h> |
153 | 31 | #include <gtest/gtest.h> | 33 | #include <gtest/gtest.h> |
154 | 32 | 34 | ||
155 | @@ -42,10 +44,35 @@ | |||
156 | 42 | public: | 44 | public: |
157 | 43 | MOCK_METHOD2(list_folder, std::vector<std::string>( | 45 | MOCK_METHOD2(list_folder, std::vector<std::string>( |
158 | 44 | const std::string& folder, const std::string& pattern)); | 46 | const std::string& folder, const std::string& pattern)); |
159 | 47 | MOCK_METHOD2(get_dconf_strings, const std::vector<std::string>(const std::string& schema, const std::string& key)); | ||
160 | 48 | using Configuration::get_default_core_apps; | ||
161 | 45 | }; | 49 | }; |
162 | 46 | 50 | ||
163 | 47 | } | 51 | } |
164 | 48 | 52 | ||
165 | 53 | TEST(Configuration, getCoreAppsFound) | ||
166 | 54 | { | ||
167 | 55 | using namespace ::testing; | ||
168 | 56 | FakeConfiguration c; | ||
169 | 57 | EXPECT_CALL(c, get_dconf_strings(Configuration::COREAPPS_SCHEMA, | ||
170 | 58 | Configuration::COREAPPS_KEY)) | ||
171 | 59 | .WillOnce(Return(std::vector<std::string>{"package1", "package2"})); | ||
172 | 60 | auto found_apps = c.get_core_apps(); | ||
173 | 61 | auto expected_apps = std::vector<std::string>{"package1", "package2"}; | ||
174 | 62 | ASSERT_EQ(found_apps, expected_apps); | ||
175 | 63 | } | ||
176 | 64 | |||
177 | 65 | TEST(Configuration, getCoreAppsEmpty) | ||
178 | 66 | { | ||
179 | 67 | using namespace ::testing; | ||
180 | 68 | FakeConfiguration c; | ||
181 | 69 | EXPECT_CALL(c, get_dconf_strings(Configuration::COREAPPS_SCHEMA, | ||
182 | 70 | Configuration::COREAPPS_KEY)) | ||
183 | 71 | .WillOnce(Return(std::vector<std::string>{})); | ||
184 | 72 | auto found_apps = c.get_core_apps(); | ||
185 | 73 | auto expected_apps = c.get_default_core_apps(); | ||
186 | 74 | ASSERT_EQ(found_apps, expected_apps); | ||
187 | 75 | } | ||
188 | 49 | 76 | ||
189 | 50 | TEST(Configuration, getAvailableFrameworksUsesRightFolder) | 77 | TEST(Configuration, getAvailableFrameworksUsesRightFolder) |
190 | 51 | { | 78 | { |
191 | 52 | 79 | ||
192 | === modified file 'scope/clickapps/apps-query.cpp' | |||
193 | --- scope/clickapps/apps-query.cpp 2014-06-30 20:06:33 +0000 | |||
194 | +++ scope/clickapps/apps-query.cpp 2014-07-03 13:14:19 +0000 | |||
195 | @@ -104,7 +104,22 @@ | |||
196 | 104 | 104 | ||
197 | 105 | } | 105 | } |
198 | 106 | 106 | ||
200 | 107 | void click::Query::push_local_results(scopes::SearchReplyProxy const &replyProxy, | 107 | void click::apps::ResultPusher::push_result(scopes::Category::SCPtr& cat, const click::Application& a) |
201 | 108 | { | ||
202 | 109 | scopes::CategorisedResult res(cat); | ||
203 | 110 | res.set_title(a.title); | ||
204 | 111 | res.set_art(a.icon_url); | ||
205 | 112 | res.set_uri(a.url); | ||
206 | 113 | res[click::apps::Query::ResultKeys::NAME] = a.name; | ||
207 | 114 | res[click::apps::Query::ResultKeys::DESCRIPTION] = a.description; | ||
208 | 115 | res[click::apps::Query::ResultKeys::MAIN_SCREENSHOT] = a.main_screenshot; | ||
209 | 116 | res[click::apps::Query::ResultKeys::INSTALLED] = true; | ||
210 | 117 | res[click::apps::Query::ResultKeys::VERSION] = a.version; | ||
211 | 118 | replyProxy->push(res); | ||
212 | 119 | } | ||
213 | 120 | |||
214 | 121 | |||
215 | 122 | void click::apps::ResultPusher::push_local_results( | ||
216 | 108 | std::vector<click::Application> const &apps, | 123 | std::vector<click::Application> const &apps, |
217 | 109 | std::string &categoryTemplate) | 124 | std::string &categoryTemplate) |
218 | 110 | { | 125 | { |
219 | @@ -113,42 +128,32 @@ | |||
220 | 113 | 128 | ||
221 | 114 | for(const auto & a: apps) | 129 | for(const auto & a: apps) |
222 | 115 | { | 130 | { |
233 | 116 | scopes::CategorisedResult res(cat); | 131 | push_result(cat, a); |
224 | 117 | res.set_title(a.title); | ||
225 | 118 | res.set_art(a.icon_url); | ||
226 | 119 | res.set_uri(a.url); | ||
227 | 120 | res[click::Query::ResultKeys::NAME] = a.name; | ||
228 | 121 | res[click::Query::ResultKeys::DESCRIPTION] = a.description; | ||
229 | 122 | res[click::Query::ResultKeys::MAIN_SCREENSHOT] = a.main_screenshot; | ||
230 | 123 | res[click::Query::ResultKeys::INSTALLED] = true; | ||
231 | 124 | res[click::Query::ResultKeys::VERSION] = a.version; | ||
232 | 125 | replyProxy->push(res); | ||
234 | 126 | } | 132 | } |
235 | 127 | } | 133 | } |
236 | 128 | 134 | ||
238 | 129 | struct click::Query::Private | 135 | struct click::apps::Query::Private |
239 | 130 | { | 136 | { |
243 | 131 | Private(click::Index& index, const scopes::SearchMetadata& metadata) | 137 | Private(const scopes::SearchMetadata& metadata) |
244 | 132 | : index(index), | 138 | : meta(metadata) |
242 | 133 | meta(metadata) | ||
245 | 134 | { | 139 | { |
246 | 135 | } | 140 | } |
247 | 136 | click::Index& index; | ||
248 | 137 | scopes::SearchMetadata meta; | 141 | scopes::SearchMetadata meta; |
249 | 142 | click::Configuration configuration; | ||
250 | 138 | }; | 143 | }; |
251 | 139 | 144 | ||
253 | 140 | click::Query::Query(unity::scopes::CannedQuery const& query, click::Index& index, scopes::SearchMetadata const& metadata) | 145 | click::apps::Query::Query(unity::scopes::CannedQuery const& query, scopes::SearchMetadata const& metadata) |
254 | 141 | : unity::scopes::SearchQueryBase(query, metadata), | 146 | : unity::scopes::SearchQueryBase(query, metadata), |
256 | 142 | impl(new Private(index, metadata)) | 147 | impl(new Private(metadata)) |
257 | 143 | { | 148 | { |
258 | 144 | } | 149 | } |
259 | 145 | 150 | ||
261 | 146 | void click::Query::cancelled() | 151 | void click::apps::Query::cancelled() |
262 | 147 | { | 152 | { |
263 | 148 | qDebug() << "cancelling search of" << QString::fromStdString(query().query_string()); | 153 | qDebug() << "cancelling search of" << QString::fromStdString(query().query_string()); |
264 | 149 | } | 154 | } |
265 | 150 | 155 | ||
267 | 151 | click::Query::~Query() | 156 | click::apps::Query::~Query() |
268 | 152 | { | 157 | { |
269 | 153 | qDebug() << "destroying search"; | 158 | qDebug() << "destroying search"; |
270 | 154 | } | 159 | } |
271 | @@ -165,7 +170,7 @@ | |||
272 | 165 | 170 | ||
273 | 166 | } | 171 | } |
274 | 167 | 172 | ||
276 | 168 | void click::Query::add_fake_store_app(scopes::SearchReplyProxy const& searchReply) | 173 | void click::apps::Query::add_fake_store_app(scopes::SearchReplyProxy const& searchReply) |
277 | 169 | { | 174 | { |
278 | 170 | static const std::string title = _("Ubuntu Store"); | 175 | static const std::string title = _("Ubuntu Store"); |
279 | 171 | static const std::string cat_title = _("Get more apps from the store"); | 176 | static const std::string cat_title = _("Get more apps from the store"); |
280 | @@ -185,27 +190,41 @@ | |||
281 | 185 | res.set_title(title); | 190 | res.set_title(title); |
282 | 186 | res.set_art(STORE_DATA_DIR "/store-scope-icon.svg"); | 191 | res.set_art(STORE_DATA_DIR "/store-scope-icon.svg"); |
283 | 187 | res.set_uri(store_scope.to_uri()); | 192 | res.set_uri(store_scope.to_uri()); |
289 | 188 | res[click::Query::ResultKeys::NAME] = title; | 193 | res[click::apps::Query::ResultKeys::NAME] = title; |
290 | 189 | res[click::Query::ResultKeys::DESCRIPTION] = ""; | 194 | res[click::apps::Query::ResultKeys::DESCRIPTION] = ""; |
291 | 190 | res[click::Query::ResultKeys::MAIN_SCREENSHOT] = ""; | 195 | res[click::apps::Query::ResultKeys::MAIN_SCREENSHOT] = ""; |
292 | 191 | res[click::Query::ResultKeys::INSTALLED] = true; | 196 | res[click::apps::Query::ResultKeys::INSTALLED] = true; |
293 | 192 | res[click::Query::ResultKeys::VERSION] = ""; | 197 | res[click::apps::Query::ResultKeys::VERSION] = ""; |
294 | 193 | searchReply->push(res); | 198 | searchReply->push(res); |
295 | 194 | } | 199 | } |
296 | 195 | } | 200 | } |
297 | 196 | 201 | ||
299 | 197 | void click::Query::run(scopes::SearchReplyProxy const& searchReply) | 202 | std::vector<click::Application> click::apps::ResultPusher::push_top_results( |
300 | 203 | scopes::SearchReplyProxy replyProxy, | ||
301 | 204 | std::vector<click::Application> apps, | ||
302 | 205 | std::string& categoryTemplate) | ||
303 | 206 | { | ||
304 | 207 | Q_UNUSED(replyProxy) | ||
305 | 208 | Q_UNUSED(categoryTemplate) | ||
306 | 209 | return apps; | ||
307 | 210 | } | ||
308 | 211 | |||
309 | 212 | void click::apps::Query::run(scopes::SearchReplyProxy const& searchReply) | ||
310 | 198 | { | 213 | { |
311 | 199 | auto querystr = query().query_string(); | 214 | auto querystr = query().query_string(); |
312 | 215 | ResultPusher pusher(searchReply, impl->configuration); | ||
313 | 200 | std::string categoryTemplate = CATEGORY_APPS_SEARCH; | 216 | std::string categoryTemplate = CATEGORY_APPS_SEARCH; |
314 | 217 | auto localResults = clickInterfaceInstance().find_installed_apps( | ||
315 | 218 | querystr); | ||
316 | 219 | |||
317 | 201 | if (querystr.empty()) { | 220 | if (querystr.empty()) { |
318 | 202 | categoryTemplate = CATEGORY_APPS_DISPLAY; | 221 | categoryTemplate = CATEGORY_APPS_DISPLAY; |
319 | 222 | // localResults = pusher.push_top_results( | ||
320 | 223 | // searchReply, localResults, | ||
321 | 224 | // categoryTemplate); | ||
322 | 203 | } | 225 | } |
323 | 204 | auto localResults = clickInterfaceInstance().find_installed_apps( | ||
324 | 205 | querystr); | ||
325 | 206 | 226 | ||
328 | 207 | push_local_results( | 227 | pusher.push_local_results( |
327 | 208 | searchReply, | ||
329 | 209 | localResults, | 228 | localResults, |
330 | 210 | categoryTemplate); | 229 | categoryTemplate); |
331 | 211 | 230 | ||
332 | 212 | 231 | ||
333 | === modified file 'scope/clickapps/apps-query.h' | |||
334 | --- scope/clickapps/apps-query.h 2014-05-28 14:27:28 +0000 | |||
335 | +++ scope/clickapps/apps-query.h 2014-07-03 13:14:19 +0000 | |||
336 | @@ -43,8 +43,12 @@ | |||
337 | 43 | { | 43 | { |
338 | 44 | 44 | ||
339 | 45 | class Application; | 45 | class Application; |
340 | 46 | class Configuration; | ||
341 | 46 | class Index; | 47 | class Index; |
342 | 47 | 48 | ||
343 | 49 | namespace apps | ||
344 | 50 | { | ||
345 | 51 | |||
346 | 48 | class Query : public scopes::SearchQueryBase | 52 | class Query : public scopes::SearchQueryBase |
347 | 49 | { | 53 | { |
348 | 50 | public: | 54 | public: |
349 | @@ -60,7 +64,7 @@ | |||
350 | 60 | constexpr static const char* VERSION{"version"}; | 64 | constexpr static const char* VERSION{"version"}; |
351 | 61 | }; | 65 | }; |
352 | 62 | 66 | ||
354 | 63 | Query(unity::scopes::CannedQuery const& query, click::Index& index, scopes::SearchMetadata const& metadata); | 67 | Query(unity::scopes::CannedQuery const& query, scopes::SearchMetadata const& metadata); |
355 | 64 | virtual ~Query(); | 68 | virtual ~Query(); |
356 | 65 | 69 | ||
357 | 66 | virtual void cancelled() override; | 70 | virtual void cancelled() override; |
358 | @@ -69,14 +73,38 @@ | |||
359 | 69 | 73 | ||
360 | 70 | protected: | 74 | protected: |
361 | 71 | virtual void add_fake_store_app(scopes::SearchReplyProxy const &replyProxy); | 75 | virtual void add_fake_store_app(scopes::SearchReplyProxy const &replyProxy); |
362 | 72 | virtual void push_local_results(scopes::SearchReplyProxy const &replyProxy, | ||
363 | 73 | std::vector<click::Application> const &apps, | ||
364 | 74 | std::string& categoryTemplate); | ||
365 | 75 | |||
366 | 76 | private: | 76 | private: |
367 | 77 | struct Private; | 77 | struct Private; |
368 | 78 | QSharedPointer<Private> impl; | 78 | QSharedPointer<Private> impl; |
369 | 79 | }; | 79 | }; |
371 | 80 | } | 80 | |
372 | 81 | class ResultPusher | ||
373 | 82 | { | ||
374 | 83 | const click::Configuration& configuration; | ||
375 | 84 | const scopes::SearchReplyProxy &replyProxy; | ||
376 | 85 | public: | ||
377 | 86 | ResultPusher(const scopes::SearchReplyProxy &replyProxy, const click::Configuration& configuration) | ||
378 | 87 | : configuration(configuration), replyProxy(replyProxy) | ||
379 | 88 | { | ||
380 | 89 | |||
381 | 90 | } | ||
382 | 91 | |||
383 | 92 | virtual ~ResultPusher() | ||
384 | 93 | { | ||
385 | 94 | |||
386 | 95 | } | ||
387 | 96 | |||
388 | 97 | virtual void push_local_results(std::vector<click::Application> const &apps, | ||
389 | 98 | std::string& categoryTemplate); | ||
390 | 99 | |||
391 | 100 | virtual std::vector<click::Application> push_top_results( | ||
392 | 101 | scopes::SearchReplyProxy replyProxy, | ||
393 | 102 | std::vector<click::Application> apps, | ||
394 | 103 | std::string& categoryTemplate); | ||
395 | 104 | protected: | ||
396 | 105 | virtual void push_result(scopes::Category::SCPtr& cat, const click::Application& a); | ||
397 | 106 | }; | ||
398 | 107 | } // namespace apps | ||
399 | 108 | } // namespace query | ||
400 | 81 | 109 | ||
401 | 82 | #endif // CLICK_QUERY_H | 110 | #endif // CLICK_QUERY_H |
402 | 83 | 111 | ||
403 | === modified file 'scope/clickapps/apps-scope.cpp' | |||
404 | --- scope/clickapps/apps-scope.cpp 2014-06-18 16:23:50 +0000 | |||
405 | +++ scope/clickapps/apps-scope.cpp 2014-07-03 13:14:19 +0000 | |||
406 | @@ -42,6 +42,7 @@ | |||
407 | 42 | #include "apps-scope.h" | 42 | #include "apps-scope.h" |
408 | 43 | #include "apps-query.h" | 43 | #include "apps-query.h" |
409 | 44 | 44 | ||
410 | 45 | using namespace click; | ||
411 | 45 | 46 | ||
412 | 46 | click::Scope::Scope() | 47 | click::Scope::Scope() |
413 | 47 | { | 48 | { |
414 | @@ -78,7 +79,7 @@ | |||
415 | 78 | 79 | ||
416 | 79 | scopes::SearchQueryBase::UPtr click::Scope::search(unity::scopes::CannedQuery const& q, scopes::SearchMetadata const& metadata) | 80 | scopes::SearchQueryBase::UPtr click::Scope::search(unity::scopes::CannedQuery const& q, scopes::SearchMetadata const& metadata) |
417 | 80 | { | 81 | { |
419 | 81 | return scopes::SearchQueryBase::UPtr(new click::Query(q, *index, metadata)); | 82 | return scopes::SearchQueryBase::UPtr(new click::apps::Query(q, metadata)); |
420 | 82 | } | 83 | } |
421 | 83 | 84 | ||
422 | 84 | 85 | ||
423 | 85 | 86 | ||
424 | === modified file 'scope/tests/CMakeLists.txt' | |||
425 | --- scope/tests/CMakeLists.txt 2014-06-23 15:00:28 +0000 | |||
426 | +++ scope/tests/CMakeLists.txt 2014-07-03 13:14:19 +0000 | |||
427 | @@ -1,4 +1,5 @@ | |||
428 | 1 | set (CLICKSCOPE_TESTS_TARGET click-scope-tests) | 1 | set (CLICKSCOPE_TESTS_TARGET click-scope-tests) |
429 | 2 | set (APPS_SCOPE_TESTS_TARGET apps-scope-tests) | ||
430 | 2 | find_package(Threads) | 3 | find_package(Threads) |
431 | 3 | 4 | ||
432 | 4 | # Qt5 bits | 5 | # Qt5 bits |
433 | @@ -19,7 +20,12 @@ | |||
434 | 19 | test_query.cpp | 20 | test_query.cpp |
435 | 20 | ) | 21 | ) |
436 | 21 | 22 | ||
437 | 23 | add_executable (${APPS_SCOPE_TESTS_TARGET} | ||
438 | 24 | test_apps_query.cpp | ||
439 | 25 | ) | ||
440 | 26 | |||
441 | 22 | qt5_use_modules(${CLICKSCOPE_TESTS_TARGET} Core DBus Network Test) | 27 | qt5_use_modules(${CLICKSCOPE_TESTS_TARGET} Core DBus Network Test) |
442 | 28 | qt5_use_modules(${APPS_SCOPE_TESTS_TARGET} Core DBus Network Test) | ||
443 | 23 | 29 | ||
444 | 24 | target_link_libraries(${CLICKSCOPE_TESTS_TARGET} | 30 | target_link_libraries(${CLICKSCOPE_TESTS_TARGET} |
445 | 25 | ${STORE_LIB_UNVERSIONED} | 31 | ${STORE_LIB_UNVERSIONED} |
446 | @@ -37,6 +43,22 @@ | |||
447 | 37 | ${CMAKE_THREAD_LIBS_INIT} | 43 | ${CMAKE_THREAD_LIBS_INIT} |
448 | 38 | ) | 44 | ) |
449 | 39 | 45 | ||
450 | 46 | target_link_libraries(${APPS_SCOPE_TESTS_TARGET} | ||
451 | 47 | ${APPS_LIB_UNVERSIONED} | ||
452 | 48 | ${SCOPE_LIB_NAME} | ||
453 | 49 | |||
454 | 50 | ${UNITY_SCOPES_LDFLAGS} | ||
455 | 51 | ${UBUNTUONE_LDFLAGS} | ||
456 | 52 | ${UBUNTU_DOWNLOAD_MANAGER_CLIENT_LDFLAGS} | ||
457 | 53 | ${UBUNTU_DOWNLOAD_MANAGER_COMMON_LDFLAGS} | ||
458 | 54 | ${JSON_CPP_LDFLAGS} | ||
459 | 55 | |||
460 | 56 | gmock | ||
461 | 57 | gmock_main | ||
462 | 58 | |||
463 | 59 | ${CMAKE_THREAD_LIBS_INIT} | ||
464 | 60 | ) | ||
465 | 61 | |||
466 | 40 | add_custom_target (test-click-scope | 62 | add_custom_target (test-click-scope |
467 | 41 | COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${CLICKSCOPE_TESTS_TARGET} | 63 | COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${CLICKSCOPE_TESTS_TARGET} |
468 | 42 | DEPENDS ${CLICKSCOPE_TESTS_TARGET} | 64 | DEPENDS ${CLICKSCOPE_TESTS_TARGET} |
469 | @@ -56,6 +78,28 @@ | |||
470 | 56 | DEPENDS ${CLICKSCOPE_TESTS_TARGET} | 78 | DEPENDS ${CLICKSCOPE_TESTS_TARGET} |
471 | 57 | ) | 79 | ) |
472 | 58 | 80 | ||
473 | 81 | # --- | ||
474 | 82 | |||
475 | 83 | add_custom_target (test-apps-scope | ||
476 | 84 | COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${APPS_SCOPE_TESTS_TARGET} | ||
477 | 85 | DEPENDS ${APPS_SCOPE_TESTS_TARGET} | ||
478 | 86 | ) | ||
479 | 87 | |||
480 | 88 | add_custom_target(test-apps-scope-valgrind | ||
481 | 89 | COMMAND valgrind --tool=memcheck ${CMAKE_CURRENT_BINARY_DIR}/${APPS_SCOPE_TESTS_TARGET} | ||
482 | 90 | DEPENDS ${APPS_SCOPE_TESTS_TARGET} | ||
483 | 91 | ) | ||
484 | 92 | |||
485 | 93 | add_custom_target(test-apps-scope-leaks | ||
486 | 94 | COMMAND valgrind --tool=memcheck --track-origins=yes --num-callers=40 --leak-resolution=high --leak-check=full ${CMAKE_CURRENT_BINARY_DIR}/${APPS_SCOPE_TESTS_TARGET} | ||
487 | 95 | DEPENDS ${APPS_SCOPE_TESTS_TARGET} | ||
488 | 96 | ) | ||
489 | 97 | add_custom_target (test-apps-scope-disabled | ||
490 | 98 | COMMAND GTEST_ALSO_RUN_DISABLED_TESTS=1 ${CMAKE_CURRENT_BINARY_DIR}/${APPS_SCOPE_TESTS_TARGET} | ||
491 | 99 | DEPENDS ${APPS_SCOPE_TESTS_TARGET} | ||
492 | 100 | ) | ||
493 | 101 | |||
494 | 102 | |||
495 | 59 | add_subdirectory(integration) | 103 | add_subdirectory(integration) |
496 | 60 | add_subdirectory(download_manager_tool) | 104 | add_subdirectory(download_manager_tool) |
497 | 61 | add_subdirectory(click_interface_tool) | 105 | add_subdirectory(click_interface_tool) |
498 | 62 | 106 | ||
499 | === added file 'scope/tests/test_apps_query.cpp' | |||
500 | --- scope/tests/test_apps_query.cpp 1970-01-01 00:00:00 +0000 | |||
501 | +++ scope/tests/test_apps_query.cpp 2014-07-03 13:14:19 +0000 | |||
502 | @@ -0,0 +1,69 @@ | |||
503 | 1 | /* | ||
504 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
505 | 3 | * | ||
506 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
507 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
508 | 6 | * by the Free Software Foundation. | ||
509 | 7 | * | ||
510 | 8 | * This program is distributed in the hope that it will be useful, but | ||
511 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
512 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
513 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
514 | 12 | * | ||
515 | 13 | * You should have received a copy of the GNU General Public License along | ||
516 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
517 | 15 | * | ||
518 | 16 | * In addition, as a special exception, the copyright holders give | ||
519 | 17 | * permission to link the code of portions of this program with the | ||
520 | 18 | * OpenSSL library under certain conditions as described in each | ||
521 | 19 | * individual source file, and distribute linked combinations | ||
522 | 20 | * including the two. | ||
523 | 21 | * You must obey the GNU General Public License in all respects | ||
524 | 22 | * for all of the code used other than OpenSSL. If you modify | ||
525 | 23 | * file(s) with this exception, you may extend this exception to your | ||
526 | 24 | * version of the file(s), but you are not obligated to do so. If you | ||
527 | 25 | * do not wish to do so, delete this exception statement from your | ||
528 | 26 | * version. If you delete this exception statement from all source | ||
529 | 27 | * files in the program, then also delete it here. | ||
530 | 28 | */ | ||
531 | 29 | |||
532 | 30 | #include <string> | ||
533 | 31 | #include <memory> | ||
534 | 32 | |||
535 | 33 | #include <gtest/gtest.h> | ||
536 | 34 | #include <gmock/gmock.h> | ||
537 | 35 | |||
538 | 36 | #include <clickapps/apps-query.h> | ||
539 | 37 | |||
540 | 38 | #include <unity/scopes/SearchReply.h> | ||
541 | 39 | #include <unity/scopes/testing/MockSearchReply.h> | ||
542 | 40 | |||
543 | 41 | #include "test_helpers.h" | ||
544 | 42 | |||
545 | 43 | using namespace click::test::helpers; | ||
546 | 44 | |||
547 | 45 | class ResultPusherTest : public ::testing::Test | ||
548 | 46 | { | ||
549 | 47 | protected: | ||
550 | 48 | click::Configuration fake_configuration; | ||
551 | 49 | click::apps::ResultPusher pusher; | ||
552 | 50 | scopes::SearchReplyProxy reply; | ||
553 | 51 | public: | ||
554 | 52 | ResultPusherTest() : pusher(reply, fake_configuration) | ||
555 | 53 | { | ||
556 | 54 | reply.reset(new scopes::testing::MockSearchReply()); | ||
557 | 55 | } | ||
558 | 56 | }; | ||
559 | 57 | |||
560 | 58 | TEST_F(ResultPusherTest, testPushLocalResults) | ||
561 | 59 | { | ||
562 | 60 | std::string categoryTemplate; | ||
563 | 61 | std::vector<click::Application> apps{}; | ||
564 | 62 | auto apps2 = pusher.push_top_results(reply, apps, categoryTemplate); | ||
565 | 63 | } | ||
566 | 64 | |||
567 | 65 | TEST_F(ResultPusherTest, testPushOneResult) | ||
568 | 66 | { | ||
569 | 67 | |||
570 | 68 | // pusher.push_one_result(); | ||
571 | 69 | } | ||
572 | 0 | 70 | ||
573 | === added file 'scope/tests/test_helpers.h' | |||
574 | --- scope/tests/test_helpers.h 1970-01-01 00:00:00 +0000 | |||
575 | +++ scope/tests/test_helpers.h 2014-07-03 13:14:19 +0000 | |||
576 | @@ -0,0 +1,68 @@ | |||
577 | 1 | #ifndef TEST_HELPERS_H | ||
578 | 2 | #define TEST_HELPERS_H | ||
579 | 3 | |||
580 | 4 | #include <click/department-lookup.h> | ||
581 | 5 | #include <click/highlights.h> | ||
582 | 6 | #include "click/index.h" | ||
583 | 7 | #include <click/interface.h> | ||
584 | 8 | #include <click/package.h> | ||
585 | 9 | |||
586 | 10 | namespace click | ||
587 | 11 | { | ||
588 | 12 | namespace test | ||
589 | 13 | { | ||
590 | 14 | namespace helpers | ||
591 | 15 | { | ||
592 | 16 | static const std::string FAKE_QUERY {"FAKE_QUERY"}; | ||
593 | 17 | static const std::string FAKE_CATEGORY_TEMPLATE {"{}"}; | ||
594 | 18 | |||
595 | 19 | |||
596 | 20 | class MockIndex : public click::Index { | ||
597 | 21 | click::Packages packages; | ||
598 | 22 | click::DepartmentList departments; | ||
599 | 23 | click::DepartmentList bootstrap_departments; | ||
600 | 24 | click::HighlightList bootstrap_highlights; | ||
601 | 25 | public: | ||
602 | 26 | MockIndex(click::Packages packages = click::Packages(), | ||
603 | 27 | click::DepartmentList departments = click::DepartmentList(), | ||
604 | 28 | click::DepartmentList boot_departments = click::DepartmentList()) | ||
605 | 29 | : Index(QSharedPointer<click::web::Client>()), | ||
606 | 30 | packages(packages), | ||
607 | 31 | departments(departments), | ||
608 | 32 | bootstrap_departments(boot_departments) | ||
609 | 33 | { | ||
610 | 34 | |||
611 | 35 | } | ||
612 | 36 | |||
613 | 37 | click::web::Cancellable search(const std::string &query, std::function<void (click::Packages)> callback) override | ||
614 | 38 | { | ||
615 | 39 | do_search(query, callback); | ||
616 | 40 | callback(packages); | ||
617 | 41 | return click::web::Cancellable(); | ||
618 | 42 | } | ||
619 | 43 | |||
620 | 44 | click::web::Cancellable bootstrap(std::function<void(const click::DepartmentList&, const click::HighlightList&, Error, int)> callback) override | ||
621 | 45 | { | ||
622 | 46 | callback(bootstrap_departments, bootstrap_highlights, click::Index::Error::NoError, 0); | ||
623 | 47 | return click::web::Cancellable(); | ||
624 | 48 | } | ||
625 | 49 | |||
626 | 50 | MOCK_METHOD2(do_search, void(const std::string&, std::function<void(click::Packages)>)); | ||
627 | 51 | }; | ||
628 | 52 | |||
629 | 53 | |||
630 | 54 | class FakeCategory : public scopes::Category | ||
631 | 55 | { | ||
632 | 56 | public: | ||
633 | 57 | FakeCategory(std::string const& id, std::string const& title, | ||
634 | 58 | std::string const& icon, scopes::CategoryRenderer const& renderer) : | ||
635 | 59 | scopes::Category(id, title, icon, renderer) | ||
636 | 60 | { | ||
637 | 61 | } | ||
638 | 62 | |||
639 | 63 | }; | ||
640 | 64 | } // namespace helpers | ||
641 | 65 | } // namespace test | ||
642 | 66 | } // namespace click | ||
643 | 67 | |||
644 | 68 | #endif // TEST_HELPERS_H | ||
645 | 0 | 69 | ||
646 | === modified file 'scope/tests/test_query.cpp' | |||
647 | --- scope/tests/test_query.cpp 2014-06-24 17:18:53 +0000 | |||
648 | +++ scope/tests/test_query.cpp 2014-07-03 13:14:19 +0000 | |||
649 | @@ -35,8 +35,8 @@ | |||
650 | 35 | 35 | ||
651 | 36 | #include "click/qtbridge.h" | 36 | #include "click/qtbridge.h" |
652 | 37 | #include "clickstore/store-query.h" | 37 | #include "clickstore/store-query.h" |
653 | 38 | #include "click/index.h" | ||
654 | 39 | #include "click/application.h" | 38 | #include "click/application.h" |
655 | 39 | #include "test_helpers.h" | ||
656 | 40 | 40 | ||
657 | 41 | #include <tests/mock_network_access_manager.h> | 41 | #include <tests/mock_network_access_manager.h> |
658 | 42 | 42 | ||
659 | @@ -49,9 +49,11 @@ | |||
660 | 49 | 49 | ||
661 | 50 | using namespace ::testing; | 50 | using namespace ::testing; |
662 | 51 | using namespace click; | 51 | using namespace click; |
663 | 52 | using namespace click::test::helpers; | ||
664 | 52 | 53 | ||
665 | 53 | namespace | 54 | namespace |
666 | 54 | { | 55 | { |
667 | 56 | <<<<<<< TREE | ||
668 | 55 | static const std::string FAKE_QUERY {"FAKE_QUERY"}; | 57 | static const std::string FAKE_QUERY {"FAKE_QUERY"}; |
669 | 56 | static const std::string FAKE_CATEGORY_TEMPLATE {"{}"}; | 58 | static const std::string FAKE_CATEGORY_TEMPLATE {"{}"}; |
670 | 57 | 59 | ||
671 | @@ -94,6 +96,8 @@ | |||
672 | 94 | std::function<void(click::Packages, click::Packages)>)); | 96 | std::function<void(click::Packages, click::Packages)>)); |
673 | 95 | }; | 97 | }; |
674 | 96 | 98 | ||
675 | 99 | ======= | ||
676 | 100 | >>>>>>> MERGE-SOURCE | ||
677 | 97 | class MockQueryBase : public click::Query { | 101 | class MockQueryBase : public click::Query { |
678 | 98 | public: | 102 | public: |
679 | 99 | MockQueryBase(const unity::scopes::CannedQuery& query, click::Index& index, | 103 | MockQueryBase(const unity::scopes::CannedQuery& query, click::Index& index, |
680 | @@ -140,7 +144,7 @@ | |||
681 | 140 | public: | 144 | public: |
682 | 141 | MockQueryRun(const unity::scopes::CannedQuery& query, click::Index& index, | 145 | MockQueryRun(const unity::scopes::CannedQuery& query, click::Index& index, |
683 | 142 | click::DepartmentLookup& depts, | 146 | click::DepartmentLookup& depts, |
685 | 143 | click::HighlightList& highlights, | 147 | click::HighlightList& highlights, |
686 | 144 | scopes::SearchMetadata const& metadata) : MockQueryBase(query, index, depts, highlights, metadata) | 148 | scopes::SearchMetadata const& metadata) : MockQueryBase(query, index, depts, highlights, metadata) |
687 | 145 | { | 149 | { |
688 | 146 | 150 | ||
689 | @@ -154,17 +158,6 @@ | |||
690 | 154 | std::string& categoryTemplate)); | 158 | std::string& categoryTemplate)); |
691 | 155 | MOCK_METHOD0(get_installed_packages, PackageSet()); | 159 | MOCK_METHOD0(get_installed_packages, PackageSet()); |
692 | 156 | }; | 160 | }; |
693 | 157 | |||
694 | 158 | class FakeCategory : public scopes::Category | ||
695 | 159 | { | ||
696 | 160 | public: | ||
697 | 161 | FakeCategory(std::string const& id, std::string const& title, | ||
698 | 162 | std::string const& icon, scopes::CategoryRenderer const& renderer) : | ||
699 | 163 | scopes::Category(id, title, icon, renderer) | ||
700 | 164 | { | ||
701 | 165 | } | ||
702 | 166 | |||
703 | 167 | }; | ||
704 | 168 | } // namespace | 161 | } // namespace |
705 | 169 | 162 | ||
706 | 170 | TEST(QueryTest, testAddAvailableAppsCallsClickIndex) | 163 | TEST(QueryTest, testAddAvailableAppsCallsClickIndex) |