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