Merge lp:~alecu/unity-scope-click/header-apps into lp:unity-scope-click/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
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+225468@code.launchpad.net

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
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-06-23 15:00:28 +0000
+++ CMakeLists.txt 2014-07-03 13:14:19 +0000
@@ -75,7 +75,7 @@
7575
76# Custom targets for the tests76# Custom targets for the tests
77add_custom_target (test77add_custom_target (test
78 DEPENDS test-click-scope test-libclickscope78 DEPENDS test-click-scope test-apps-scope test-libclickscope
79)79)
8080
81add_custom_target (test-disabled81add_custom_target (test-disabled
@@ -90,13 +90,13 @@
9090
91# Add a custom target for running the tests under valgrind.91# Add a custom target for running the tests under valgrind.
92add_custom_target (test-valgrind92add_custom_target (test-valgrind
93 DEPENDS test-click-scope-valgrind test-libclickscope-valgrind93 DEPENDS test-click-scope-valgrind test-apps-scope-valgrind test-libclickscope-valgrind
94)94)
9595
96# Add a custom target for running the tests under valgrind with the96# Add a custom target for running the tests under valgrind with the
97# full leak checks enabled.97# full leak checks enabled.
98add_custom_target (test-leaks98add_custom_target (test-leaks
99 DEPENDS test-click-scope-leaks test-libclickscope-leaks99 DEPENDS test-click-scope-leaks test-apps-scope-leaks test-libclickscope-leaks
100)100)
101101
102# Also let "make check" and partners work.102# Also let "make check" and partners work.
103103
=== modified file 'libclickscope/click/CMakeLists.txt'
--- libclickscope/click/CMakeLists.txt 2014-06-23 15:00:28 +0000
+++ libclickscope/click/CMakeLists.txt 2014-07-03 13:14:19 +0000
@@ -2,11 +2,13 @@
2SET (CMAKE_AUTOMOC ON)2SET (CMAKE_AUTOMOC ON)
3find_package (Qt5Core REQUIRED)3find_package (Qt5Core REQUIRED)
4pkg_check_modules(JSON_CPP REQUIRED jsoncpp)4pkg_check_modules(JSON_CPP REQUIRED jsoncpp)
5pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
56
6add_definitions(7add_definitions(
7 -DGETTEXT_PACKAGE=\"${PROJECT_NAME}\"8 -DGETTEXT_PACKAGE=\"${PROJECT_NAME}\"
8 -DGETTEXT_LOCALEDIR=\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LOCALEDIR}\"9 -DGETTEXT_LOCALEDIR=\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LOCALEDIR}\"
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\"
11 ${GSETTINGS_QT_CFLAGS} ${GSETTINGS_QT_OTHER}
10)12)
1113
12add_library(${SCOPE_LIB_NAME} STATIC14add_library(${SCOPE_LIB_NAME} STATIC
@@ -32,6 +34,7 @@
3234
33include_directories(35include_directories(
34 ${JSON_CPP_INCLUDE_DIRS}36 ${JSON_CPP_INCLUDE_DIRS}
37 ${GSETTINGS_QT_INCLUDE_DIRS}
35 ${CMAKE_SOURCE_DIR}/libclickscope38 ${CMAKE_SOURCE_DIR}/libclickscope
36)39)
3740
@@ -41,5 +44,6 @@
41 ${UBUNTUONE_LDFLAGS}44 ${UBUNTUONE_LDFLAGS}
42 ${UBUNTU_DOWNLOAD_MANAGER_CLIENT_LDFLAGS}45 ${UBUNTU_DOWNLOAD_MANAGER_CLIENT_LDFLAGS}
43 ${UBUNTU_DOWNLOAD_MANAGER_COMMON_LDFLAGS}46 ${UBUNTU_DOWNLOAD_MANAGER_COMMON_LDFLAGS}
47 ${GSETTINGS_QT_LIBRARIES}
44 -lboost_locale48 -lboost_locale
45)49)
4650
=== modified file 'libclickscope/click/configuration.cpp'
--- libclickscope/click/configuration.cpp 2014-06-25 21:33:59 +0000
+++ libclickscope/click/configuration.cpp 2014-07-03 13:14:19 +0000
@@ -32,6 +32,10 @@
3232
33#include <QDir>33#include <QDir>
34#include <QProcess>34#include <QProcess>
35#include <QStringList>
36#include <QVariant>
37
38#include <qgsettings.h>
3539
36#include <boost/algorithm/string.hpp>40#include <boost/algorithm/string.hpp>
37#include <boost/algorithm/string/replace.hpp>41#include <boost/algorithm/string/replace.hpp>
@@ -141,4 +145,24 @@
141 != FULL_LANG_CODES.end();145 != FULL_LANG_CODES.end();
142}146}
143147
148const std::vector<std::string> Configuration::get_dconf_strings(const std::string& schema, const std::string& key)
149{
150 QGSettings qgs(schema.c_str());
151 auto locations = qgs.get(QString::fromStdString(key)).toStringList();
152 std::vector<std::string> v;
153 for(const auto& l : locations) {
154 v.push_back(l.toStdString());
155 }
156 return v;
157}
158
159const std::vector<std::string> Configuration::get_core_apps()
160{
161 auto apps = get_dconf_strings(Configuration::COREAPPS_SCHEMA, Configuration::COREAPPS_KEY);
162 if (apps.empty()) {
163 apps = get_default_core_apps();
164 }
165 return apps;
166}
167
144} // namespace click168} // namespace click
145169
=== modified file 'libclickscope/click/configuration.h'
--- libclickscope/click/configuration.h 2014-06-25 21:33:59 +0000
+++ libclickscope/click/configuration.h 2014-07-03 13:14:19 +0000
@@ -33,6 +33,8 @@
33#include <string>33#include <string>
34#include <vector>34#include <vector>
3535
36#define _CURRENT_USER_VERSION "_current-user-version"
37
36namespace click38namespace click
37{39{
3840
@@ -54,10 +56,26 @@
54 virtual std::string get_accept_languages();56 virtual std::string get_accept_languages();
55 static bool is_full_lang_code(const std::string& language);57 static bool is_full_lang_code(const std::string& language);
5658
59 constexpr static const char* COREAPPS_SCHEMA {""};
60 constexpr static const char* COREAPPS_KEY {""};
61
62 virtual const std::vector<std::string> get_core_apps();
57 virtual ~Configuration() {}63 virtual ~Configuration() {}
58protected:64protected:
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);
60 virtual std::string architectureFromDpkg();66 virtual std::string architectureFromDpkg();
67 virtual const std::vector<std::string> get_dconf_strings(const std::string& schema, const std::string& key);
68 static const std::vector<std::string>& get_default_core_apps() {
69 static std::vector<std::string> default_apps {
70 "dialer-app.desktop",
71 "messaging-app.desktop",
72 "com.ubuntu.calculator_calculator" _CURRENT_USER_VERSION,
73 "com.ubuntu.clock_clock" _CURRENT_USER_VERSION,
74 "com.ubuntu.camera_camera" _CURRENT_USER_VERSION,
75 "com.ubuntu.calendar_calendar" _CURRENT_USER_VERSION
76 };
77 return default_apps;
78 }
61};79};
6280
63} // namespace click81} // namespace click
6482
=== modified file 'libclickscope/tests/test_configuration.cpp'
--- libclickscope/tests/test_configuration.cpp 2014-06-25 21:33:59 +0000
+++ libclickscope/tests/test_configuration.cpp 2014-07-03 13:14:19 +0000
@@ -27,6 +27,8 @@
27 * files in the program, then also delete it here.27 * files in the program, then also delete it here.
28 */28 */
2929
30#include <QStringList>
31
30#include <gmock/gmock.h>32#include <gmock/gmock.h>
31#include <gtest/gtest.h>33#include <gtest/gtest.h>
3234
@@ -42,10 +44,35 @@
42public:44public:
43 MOCK_METHOD2(list_folder, std::vector<std::string>(45 MOCK_METHOD2(list_folder, std::vector<std::string>(
44 const std::string& folder, const std::string& pattern));46 const std::string& folder, const std::string& pattern));
47 MOCK_METHOD2(get_dconf_strings, const std::vector<std::string>(const std::string& schema, const std::string& key));
48 using Configuration::get_default_core_apps;
45};49};
4650
47}51}
4852
53TEST(Configuration, getCoreAppsFound)
54{
55 using namespace ::testing;
56 FakeConfiguration c;
57 EXPECT_CALL(c, get_dconf_strings(Configuration::COREAPPS_SCHEMA,
58 Configuration::COREAPPS_KEY))
59 .WillOnce(Return(std::vector<std::string>{"package1", "package2"}));
60 auto found_apps = c.get_core_apps();
61 auto expected_apps = std::vector<std::string>{"package1", "package2"};
62 ASSERT_EQ(found_apps, expected_apps);
63}
64
65TEST(Configuration, getCoreAppsEmpty)
66{
67 using namespace ::testing;
68 FakeConfiguration c;
69 EXPECT_CALL(c, get_dconf_strings(Configuration::COREAPPS_SCHEMA,
70 Configuration::COREAPPS_KEY))
71 .WillOnce(Return(std::vector<std::string>{}));
72 auto found_apps = c.get_core_apps();
73 auto expected_apps = c.get_default_core_apps();
74 ASSERT_EQ(found_apps, expected_apps);
75}
4976
50TEST(Configuration, getAvailableFrameworksUsesRightFolder)77TEST(Configuration, getAvailableFrameworksUsesRightFolder)
51{78{
5279
=== modified file 'scope/clickapps/apps-query.cpp'
--- scope/clickapps/apps-query.cpp 2014-06-30 20:06:33 +0000
+++ scope/clickapps/apps-query.cpp 2014-07-03 13:14:19 +0000
@@ -104,7 +104,22 @@
104104
105}105}
106106
107void click::Query::push_local_results(scopes::SearchReplyProxy const &replyProxy,107void click::apps::ResultPusher::push_result(scopes::Category::SCPtr& cat, const click::Application& a)
108{
109 scopes::CategorisedResult res(cat);
110 res.set_title(a.title);
111 res.set_art(a.icon_url);
112 res.set_uri(a.url);
113 res[click::apps::Query::ResultKeys::NAME] = a.name;
114 res[click::apps::Query::ResultKeys::DESCRIPTION] = a.description;
115 res[click::apps::Query::ResultKeys::MAIN_SCREENSHOT] = a.main_screenshot;
116 res[click::apps::Query::ResultKeys::INSTALLED] = true;
117 res[click::apps::Query::ResultKeys::VERSION] = a.version;
118 replyProxy->push(res);
119}
120
121
122void click::apps::ResultPusher::push_local_results(
108 std::vector<click::Application> const &apps,123 std::vector<click::Application> const &apps,
109 std::string &categoryTemplate)124 std::string &categoryTemplate)
110{125{
@@ -113,42 +128,32 @@
113128
114 for(const auto & a: apps)129 for(const auto & a: apps)
115 {130 {
116 scopes::CategorisedResult res(cat);131 push_result(cat, a);
117 res.set_title(a.title);
118 res.set_art(a.icon_url);
119 res.set_uri(a.url);
120 res[click::Query::ResultKeys::NAME] = a.name;
121 res[click::Query::ResultKeys::DESCRIPTION] = a.description;
122 res[click::Query::ResultKeys::MAIN_SCREENSHOT] = a.main_screenshot;
123 res[click::Query::ResultKeys::INSTALLED] = true;
124 res[click::Query::ResultKeys::VERSION] = a.version;
125 replyProxy->push(res);
126 }132 }
127}133}
128134
129struct click::Query::Private135struct click::apps::Query::Private
130{136{
131 Private(click::Index& index, const scopes::SearchMetadata& metadata)137 Private(const scopes::SearchMetadata& metadata)
132 : index(index),138 : meta(metadata)
133 meta(metadata)
134 {139 {
135 }140 }
136 click::Index& index;
137 scopes::SearchMetadata meta;141 scopes::SearchMetadata meta;
142 click::Configuration configuration;
138};143};
139144
140click::Query::Query(unity::scopes::CannedQuery const& query, click::Index& index, scopes::SearchMetadata const& metadata)145click::apps::Query::Query(unity::scopes::CannedQuery const& query, scopes::SearchMetadata const& metadata)
141 : unity::scopes::SearchQueryBase(query, metadata),146 : unity::scopes::SearchQueryBase(query, metadata),
142 impl(new Private(index, metadata))147 impl(new Private(metadata))
143{148{
144}149}
145150
146void click::Query::cancelled()151void click::apps::Query::cancelled()
147{152{
148 qDebug() << "cancelling search of" << QString::fromStdString(query().query_string());153 qDebug() << "cancelling search of" << QString::fromStdString(query().query_string());
149}154}
150155
151click::Query::~Query()156click::apps::Query::~Query()
152{157{
153 qDebug() << "destroying search";158 qDebug() << "destroying search";
154}159}
@@ -165,7 +170,7 @@
165170
166}171}
167172
168void click::Query::add_fake_store_app(scopes::SearchReplyProxy const& searchReply)173void click::apps::Query::add_fake_store_app(scopes::SearchReplyProxy const& searchReply)
169{174{
170 static const std::string title = _("Ubuntu Store");175 static const std::string title = _("Ubuntu Store");
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");
@@ -185,27 +190,41 @@
185 res.set_title(title);190 res.set_title(title);
186 res.set_art(STORE_DATA_DIR "/store-scope-icon.svg");191 res.set_art(STORE_DATA_DIR "/store-scope-icon.svg");
187 res.set_uri(store_scope.to_uri());192 res.set_uri(store_scope.to_uri());
188 res[click::Query::ResultKeys::NAME] = title;193 res[click::apps::Query::ResultKeys::NAME] = title;
189 res[click::Query::ResultKeys::DESCRIPTION] = "";194 res[click::apps::Query::ResultKeys::DESCRIPTION] = "";
190 res[click::Query::ResultKeys::MAIN_SCREENSHOT] = "";195 res[click::apps::Query::ResultKeys::MAIN_SCREENSHOT] = "";
191 res[click::Query::ResultKeys::INSTALLED] = true;196 res[click::apps::Query::ResultKeys::INSTALLED] = true;
192 res[click::Query::ResultKeys::VERSION] = "";197 res[click::apps::Query::ResultKeys::VERSION] = "";
193 searchReply->push(res);198 searchReply->push(res);
194 }199 }
195}200}
196201
197void click::Query::run(scopes::SearchReplyProxy const& searchReply)202std::vector<click::Application> click::apps::ResultPusher::push_top_results(
203 scopes::SearchReplyProxy replyProxy,
204 std::vector<click::Application> apps,
205 std::string& categoryTemplate)
206{
207 Q_UNUSED(replyProxy)
208 Q_UNUSED(categoryTemplate)
209 return apps;
210}
211
212void click::apps::Query::run(scopes::SearchReplyProxy const& searchReply)
198{213{
199 auto querystr = query().query_string();214 auto querystr = query().query_string();
215 ResultPusher pusher(searchReply, impl->configuration);
200 std::string categoryTemplate = CATEGORY_APPS_SEARCH;216 std::string categoryTemplate = CATEGORY_APPS_SEARCH;
217 auto localResults = clickInterfaceInstance().find_installed_apps(
218 querystr);
219
201 if (querystr.empty()) {220 if (querystr.empty()) {
202 categoryTemplate = CATEGORY_APPS_DISPLAY;221 categoryTemplate = CATEGORY_APPS_DISPLAY;
222// localResults = pusher.push_top_results(
223// searchReply, localResults,
224// categoryTemplate);
203 }225 }
204 auto localResults = clickInterfaceInstance().find_installed_apps(
205 querystr);
206226
207 push_local_results(227 pusher.push_local_results(
208 searchReply,
209 localResults,228 localResults,
210 categoryTemplate);229 categoryTemplate);
211230
212231
=== modified file 'scope/clickapps/apps-query.h'
--- scope/clickapps/apps-query.h 2014-05-28 14:27:28 +0000
+++ scope/clickapps/apps-query.h 2014-07-03 13:14:19 +0000
@@ -43,8 +43,12 @@
43{43{
4444
45class Application;45class Application;
46class Configuration;
46class Index;47class Index;
4748
49namespace apps
50{
51
48class Query : public scopes::SearchQueryBase52class Query : public scopes::SearchQueryBase
49{53{
50public:54public:
@@ -60,7 +64,7 @@
60 constexpr static const char* VERSION{"version"};64 constexpr static const char* VERSION{"version"};
61 };65 };
6266
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);
64 virtual ~Query();68 virtual ~Query();
6569
66 virtual void cancelled() override;70 virtual void cancelled() override;
@@ -69,14 +73,38 @@
6973
70protected:74protected:
71 virtual void add_fake_store_app(scopes::SearchReplyProxy const &replyProxy);75 virtual void add_fake_store_app(scopes::SearchReplyProxy const &replyProxy);
72 virtual void push_local_results(scopes::SearchReplyProxy const &replyProxy,
73 std::vector<click::Application> const &apps,
74 std::string& categoryTemplate);
75
76private:76private:
77 struct Private;77 struct Private;
78 QSharedPointer<Private> impl;78 QSharedPointer<Private> impl;
79};79};
80}80
81class ResultPusher
82{
83 const click::Configuration& configuration;
84 const scopes::SearchReplyProxy &replyProxy;
85public:
86 ResultPusher(const scopes::SearchReplyProxy &replyProxy, const click::Configuration& configuration)
87 : configuration(configuration), replyProxy(replyProxy)
88 {
89
90 }
91
92 virtual ~ResultPusher()
93 {
94
95 }
96
97 virtual void push_local_results(std::vector<click::Application> const &apps,
98 std::string& categoryTemplate);
99
100 virtual std::vector<click::Application> push_top_results(
101 scopes::SearchReplyProxy replyProxy,
102 std::vector<click::Application> apps,
103 std::string& categoryTemplate);
104protected:
105 virtual void push_result(scopes::Category::SCPtr& cat, const click::Application& a);
106};
107} // namespace apps
108} // namespace query
81109
82#endif // CLICK_QUERY_H110#endif // CLICK_QUERY_H
83111
=== modified file 'scope/clickapps/apps-scope.cpp'
--- scope/clickapps/apps-scope.cpp 2014-06-18 16:23:50 +0000
+++ scope/clickapps/apps-scope.cpp 2014-07-03 13:14:19 +0000
@@ -42,6 +42,7 @@
42#include "apps-scope.h"42#include "apps-scope.h"
43#include "apps-query.h"43#include "apps-query.h"
4444
45using namespace click;
4546
46click::Scope::Scope()47click::Scope::Scope()
47{48{
@@ -78,7 +79,7 @@
7879
79scopes::SearchQueryBase::UPtr click::Scope::search(unity::scopes::CannedQuery const& q, scopes::SearchMetadata const& metadata)80scopes::SearchQueryBase::UPtr click::Scope::search(unity::scopes::CannedQuery const& q, scopes::SearchMetadata const& metadata)
80{81{
81 return scopes::SearchQueryBase::UPtr(new click::Query(q, *index, metadata));82 return scopes::SearchQueryBase::UPtr(new click::apps::Query(q, metadata));
82}83}
8384
8485
8586
=== modified file 'scope/tests/CMakeLists.txt'
--- scope/tests/CMakeLists.txt 2014-06-23 15:00:28 +0000
+++ scope/tests/CMakeLists.txt 2014-07-03 13:14:19 +0000
@@ -1,4 +1,5 @@
1set (CLICKSCOPE_TESTS_TARGET click-scope-tests)1set (CLICKSCOPE_TESTS_TARGET click-scope-tests)
2set (APPS_SCOPE_TESTS_TARGET apps-scope-tests)
2find_package(Threads)3find_package(Threads)
34
4# Qt5 bits5# Qt5 bits
@@ -19,7 +20,12 @@
19 test_query.cpp20 test_query.cpp
20)21)
2122
23add_executable (${APPS_SCOPE_TESTS_TARGET}
24 test_apps_query.cpp
25)
26
22qt5_use_modules(${CLICKSCOPE_TESTS_TARGET} Core DBus Network Test)27qt5_use_modules(${CLICKSCOPE_TESTS_TARGET} Core DBus Network Test)
28qt5_use_modules(${APPS_SCOPE_TESTS_TARGET} Core DBus Network Test)
2329
24target_link_libraries(${CLICKSCOPE_TESTS_TARGET}30target_link_libraries(${CLICKSCOPE_TESTS_TARGET}
25 ${STORE_LIB_UNVERSIONED}31 ${STORE_LIB_UNVERSIONED}
@@ -37,6 +43,22 @@
37 ${CMAKE_THREAD_LIBS_INIT}43 ${CMAKE_THREAD_LIBS_INIT}
38)44)
3945
46target_link_libraries(${APPS_SCOPE_TESTS_TARGET}
47 ${APPS_LIB_UNVERSIONED}
48 ${SCOPE_LIB_NAME}
49
50 ${UNITY_SCOPES_LDFLAGS}
51 ${UBUNTUONE_LDFLAGS}
52 ${UBUNTU_DOWNLOAD_MANAGER_CLIENT_LDFLAGS}
53 ${UBUNTU_DOWNLOAD_MANAGER_COMMON_LDFLAGS}
54 ${JSON_CPP_LDFLAGS}
55
56 gmock
57 gmock_main
58
59 ${CMAKE_THREAD_LIBS_INIT}
60)
61
40add_custom_target (test-click-scope62add_custom_target (test-click-scope
41 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${CLICKSCOPE_TESTS_TARGET}63 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${CLICKSCOPE_TESTS_TARGET}
42 DEPENDS ${CLICKSCOPE_TESTS_TARGET}64 DEPENDS ${CLICKSCOPE_TESTS_TARGET}
@@ -56,6 +78,28 @@
56 DEPENDS ${CLICKSCOPE_TESTS_TARGET}78 DEPENDS ${CLICKSCOPE_TESTS_TARGET}
57)79)
5880
81# ---
82
83add_custom_target (test-apps-scope
84 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${APPS_SCOPE_TESTS_TARGET}
85 DEPENDS ${APPS_SCOPE_TESTS_TARGET}
86)
87
88add_custom_target(test-apps-scope-valgrind
89 COMMAND valgrind --tool=memcheck ${CMAKE_CURRENT_BINARY_DIR}/${APPS_SCOPE_TESTS_TARGET}
90 DEPENDS ${APPS_SCOPE_TESTS_TARGET}
91)
92
93add_custom_target(test-apps-scope-leaks
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}
95 DEPENDS ${APPS_SCOPE_TESTS_TARGET}
96)
97add_custom_target (test-apps-scope-disabled
98 COMMAND GTEST_ALSO_RUN_DISABLED_TESTS=1 ${CMAKE_CURRENT_BINARY_DIR}/${APPS_SCOPE_TESTS_TARGET}
99 DEPENDS ${APPS_SCOPE_TESTS_TARGET}
100)
101
102
59add_subdirectory(integration)103add_subdirectory(integration)
60add_subdirectory(download_manager_tool)104add_subdirectory(download_manager_tool)
61add_subdirectory(click_interface_tool)105add_subdirectory(click_interface_tool)
62106
=== added file 'scope/tests/test_apps_query.cpp'
--- scope/tests/test_apps_query.cpp 1970-01-01 00:00:00 +0000
+++ scope/tests/test_apps_query.cpp 2014-07-03 13:14:19 +0000
@@ -0,0 +1,69 @@
1/*
2 * Copyright (C) 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * In addition, as a special exception, the copyright holders give
17 * permission to link the code of portions of this program with the
18 * OpenSSL library under certain conditions as described in each
19 * individual source file, and distribute linked combinations
20 * including the two.
21 * You must obey the GNU General Public License in all respects
22 * for all of the code used other than OpenSSL. If you modify
23 * file(s) with this exception, you may extend this exception to your
24 * version of the file(s), but you are not obligated to do so. If you
25 * do not wish to do so, delete this exception statement from your
26 * version. If you delete this exception statement from all source
27 * files in the program, then also delete it here.
28 */
29
30#include <string>
31#include <memory>
32
33#include <gtest/gtest.h>
34#include <gmock/gmock.h>
35
36#include <clickapps/apps-query.h>
37
38#include <unity/scopes/SearchReply.h>
39#include <unity/scopes/testing/MockSearchReply.h>
40
41#include "test_helpers.h"
42
43using namespace click::test::helpers;
44
45class ResultPusherTest : public ::testing::Test
46{
47protected:
48 click::Configuration fake_configuration;
49 click::apps::ResultPusher pusher;
50 scopes::SearchReplyProxy reply;
51public:
52 ResultPusherTest() : pusher(reply, fake_configuration)
53 {
54 reply.reset(new scopes::testing::MockSearchReply());
55 }
56};
57
58TEST_F(ResultPusherTest, testPushLocalResults)
59{
60 std::string categoryTemplate;
61 std::vector<click::Application> apps{};
62 auto apps2 = pusher.push_top_results(reply, apps, categoryTemplate);
63}
64
65TEST_F(ResultPusherTest, testPushOneResult)
66{
67
68// pusher.push_one_result();
69}
070
=== added file 'scope/tests/test_helpers.h'
--- scope/tests/test_helpers.h 1970-01-01 00:00:00 +0000
+++ scope/tests/test_helpers.h 2014-07-03 13:14:19 +0000
@@ -0,0 +1,68 @@
1#ifndef TEST_HELPERS_H
2#define TEST_HELPERS_H
3
4#include <click/department-lookup.h>
5#include <click/highlights.h>
6#include "click/index.h"
7#include <click/interface.h>
8#include <click/package.h>
9
10namespace click
11{
12namespace test
13{
14namespace helpers
15{
16static const std::string FAKE_QUERY {"FAKE_QUERY"};
17static const std::string FAKE_CATEGORY_TEMPLATE {"{}"};
18
19
20class MockIndex : public click::Index {
21 click::Packages packages;
22 click::DepartmentList departments;
23 click::DepartmentList bootstrap_departments;
24 click::HighlightList bootstrap_highlights;
25public:
26 MockIndex(click::Packages packages = click::Packages(),
27 click::DepartmentList departments = click::DepartmentList(),
28 click::DepartmentList boot_departments = click::DepartmentList())
29 : Index(QSharedPointer<click::web::Client>()),
30 packages(packages),
31 departments(departments),
32 bootstrap_departments(boot_departments)
33 {
34
35 }
36
37 click::web::Cancellable search(const std::string &query, std::function<void (click::Packages)> callback) override
38 {
39 do_search(query, callback);
40 callback(packages);
41 return click::web::Cancellable();
42 }
43
44 click::web::Cancellable bootstrap(std::function<void(const click::DepartmentList&, const click::HighlightList&, Error, int)> callback) override
45 {
46 callback(bootstrap_departments, bootstrap_highlights, click::Index::Error::NoError, 0);
47 return click::web::Cancellable();
48 }
49
50 MOCK_METHOD2(do_search, void(const std::string&, std::function<void(click::Packages)>));
51};
52
53
54class FakeCategory : public scopes::Category
55{
56public:
57 FakeCategory(std::string const& id, std::string const& title,
58 std::string const& icon, scopes::CategoryRenderer const& renderer) :
59 scopes::Category(id, title, icon, renderer)
60 {
61 }
62
63};
64} // namespace helpers
65} // namespace test
66} // namespace click
67
68#endif // TEST_HELPERS_H
069
=== modified file 'scope/tests/test_query.cpp'
--- scope/tests/test_query.cpp 2014-06-24 17:18:53 +0000
+++ scope/tests/test_query.cpp 2014-07-03 13:14:19 +0000
@@ -35,8 +35,8 @@
3535
36#include "click/qtbridge.h"36#include "click/qtbridge.h"
37#include "clickstore/store-query.h"37#include "clickstore/store-query.h"
38#include "click/index.h"
39#include "click/application.h"38#include "click/application.h"
39#include "test_helpers.h"
4040
41#include <tests/mock_network_access_manager.h>41#include <tests/mock_network_access_manager.h>
4242
@@ -49,9 +49,11 @@
4949
50using namespace ::testing;50using namespace ::testing;
51using namespace click;51using namespace click;
52using namespace click::test::helpers;
5253
53namespace54namespace
54{55{
56<<<<<<< TREE
55static const std::string FAKE_QUERY {"FAKE_QUERY"};57static const std::string FAKE_QUERY {"FAKE_QUERY"};
56static const std::string FAKE_CATEGORY_TEMPLATE {"{}"};58static const std::string FAKE_CATEGORY_TEMPLATE {"{}"};
5759
@@ -94,6 +96,8 @@
94 std::function<void(click::Packages, click::Packages)>));96 std::function<void(click::Packages, click::Packages)>));
95};97};
9698
99=======
100>>>>>>> MERGE-SOURCE
97class MockQueryBase : public click::Query {101class MockQueryBase : public click::Query {
98public:102public:
99 MockQueryBase(const unity::scopes::CannedQuery& query, click::Index& index,103 MockQueryBase(const unity::scopes::CannedQuery& query, click::Index& index,
@@ -140,7 +144,7 @@
140public:144public:
141 MockQueryRun(const unity::scopes::CannedQuery& query, click::Index& index,145 MockQueryRun(const unity::scopes::CannedQuery& query, click::Index& index,
142 click::DepartmentLookup& depts,146 click::DepartmentLookup& depts,
143 click::HighlightList& highlights, 147 click::HighlightList& highlights,
144 scopes::SearchMetadata const& metadata) : MockQueryBase(query, index, depts, highlights, metadata)148 scopes::SearchMetadata const& metadata) : MockQueryBase(query, index, depts, highlights, metadata)
145 {149 {
146150
@@ -154,17 +158,6 @@
154 std::string& categoryTemplate));158 std::string& categoryTemplate));
155 MOCK_METHOD0(get_installed_packages, PackageSet());159 MOCK_METHOD0(get_installed_packages, PackageSet());
156};160};
157
158class FakeCategory : public scopes::Category
159{
160public:
161 FakeCategory(std::string const& id, std::string const& title,
162 std::string const& icon, scopes::CategoryRenderer const& renderer) :
163 scopes::Category(id, title, icon, renderer)
164 {
165 }
166
167};
168} // namespace161} // namespace
169162
170TEST(QueryTest, testAddAvailableAppsCallsClickIndex)163TEST(QueryTest, testAddAvailableAppsCallsClickIndex)

Subscribers

People subscribed via source and target branches

to all changes: