Merge lp:~stolowski/unity-scope-click/apps-new-search-semantics into lp:unity-scope-click

Proposed by Paweł Stołowski
Status: Merged
Approved by: dobey
Approved revision: 400
Merged at revision: 430
Proposed branch: lp:~stolowski/unity-scope-click/apps-new-search-semantics
Merge into: lp:unity-scope-click
Diff against target: 514 lines (+132/-57)
13 files modified
libclickscope/click/index.cpp (+2/-2)
libclickscope/click/index.h (+1/-1)
libclickscope/click/interface.cpp (+1/-1)
libclickscope/tests/integration/webclient_integration.cpp (+1/-1)
libclickscope/tests/test_index.cpp (+9/-9)
scope/clickapps/apps-query.cpp (+3/-5)
scope/clickstore/store-query.cpp (+18/-2)
scope/clickstore/store-query.h (+1/-0)
scope/tests/test_apps_query.cpp (+34/-18)
scope/tests/test_helpers.h (+22/-4)
scope/tests/test_query.cpp (+40/-12)
tests/scope-harness/tests/test_apps.py (+0/-1)
tests/scope-harness/tests/test_store.py (+0/-1)
To merge this branch: bzr merge lp:~stolowski/unity-scope-click/apps-new-search-semantics
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
dobey (community) Approve
Review via email: mp+276634@code.launchpad.net

Commit message

Always push departments (departments should be available also in search mode) and allow searching inside departments.

Description of the change

Always push departments (departments should be available also in search mode) and allow searching inside departments.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
dobey (dobey) wrote :

Looks ok to me.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
401. By Paweł Stołowski

Merged trunk

402. By Paweł Stołowski

Fix test

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libclickscope/click/index.cpp'
--- libclickscope/click/index.cpp 2016-01-21 23:25:38 +0000
+++ libclickscope/click/index.cpp 2016-03-09 13:08:23 +0000
@@ -147,11 +147,11 @@
147 return std::pair<Packages, Packages>(pl, recommends);147 return std::pair<Packages, Packages>(pl, recommends);
148}148}
149149
150click::web::Cancellable Index::search (const std::string& query,150click::web::Cancellable Index::search (const std::string& query, const std::string& department,
151 std::function<void(click::Packages search_results, click::Packages recommendations)> callback)151 std::function<void(click::Packages search_results, click::Packages recommendations)> callback)
152{152{
153 click::web::CallParams params;153 click::web::CallParams params;
154 const std::string built_query(build_index_query(query, ""));154 const std::string built_query(build_index_query(query, department));
155 params.add(click::QUERY_ARGNAME, built_query.c_str());155 params.add(click::QUERY_ARGNAME, built_query.c_str());
156 QSharedPointer<click::web::Response> response(client->call(156 QSharedPointer<click::web::Response> response(client->call(
157 get_base_url() + click::SEARCH_PATH, "GET", true, build_headers(), "", params));157 get_base_url() + click::SEARCH_PATH, "GET", true, build_headers(), "", params));
158158
=== modified file 'libclickscope/click/index.h'
--- libclickscope/click/index.h 2015-11-24 18:23:23 +0000
+++ libclickscope/click/index.h 2016-03-09 13:08:23 +0000
@@ -79,7 +79,7 @@
79 Index(const QSharedPointer<click::web::Client>& client,79 Index(const QSharedPointer<click::web::Client>& client,
80 const QSharedPointer<Configuration> configuration=QSharedPointer<Configuration>(new Configuration()));80 const QSharedPointer<Configuration> configuration=QSharedPointer<Configuration>(new Configuration()));
81 virtual std::pair<Packages, Packages> package_lists_from_json(const std::string& json);81 virtual std::pair<Packages, Packages> package_lists_from_json(const std::string& json);
82 virtual click::web::Cancellable search (const std::string& query, std::function<void(Packages, Packages)> callback);82 virtual click::web::Cancellable search (const std::string& query, const std::string& department, std::function<void(Packages, Packages)> callback);
83 virtual click::web::Cancellable get_details(const std::string& package_name, std::function<void(PackageDetails, Error)> callback);83 virtual click::web::Cancellable get_details(const std::string& package_name, std::function<void(PackageDetails, Error)> callback);
84 virtual click::web::Cancellable bootstrap(std::function<void(const DepartmentList&, const HighlightList&, Error, int)> callback);84 virtual click::web::Cancellable bootstrap(std::function<void(const DepartmentList&, const HighlightList&, Error, int)> callback);
85 virtual click::web::Cancellable departments(const std::string& department_href, std::function<void(const DepartmentList&, const HighlightList&, Error, int)> callback);85 virtual click::web::Cancellable departments(const std::string& department_href, std::function<void(const DepartmentList&, const HighlightList&, Error, int)> callback);
8686
=== modified file 'libclickscope/click/interface.cpp'
--- libclickscope/click/interface.cpp 2016-03-07 14:10:22 +0000
+++ libclickscope/click/interface.cpp 2016-03-09 13:08:23 +0000
@@ -274,7 +274,7 @@
274{274{
275 //275 //
276 // only apply department filtering if not in root of all departments.276 // only apply department filtering if not in root of all departments.
277 bool apply_department_filter = (search_query.empty() && !current_department.empty());277 bool apply_department_filter = !current_department.empty();
278278
279 // get the set of packages that belong to current deparment;279 // get the set of packages that belong to current deparment;
280 std::unordered_set<std::string> packages_in_department;280 std::unordered_set<std::string> packages_in_department;
281281
=== modified file 'libclickscope/tests/integration/webclient_integration.cpp'
--- libclickscope/tests/integration/webclient_integration.cpp 2014-06-24 17:18:53 +0000
+++ libclickscope/tests/integration/webclient_integration.cpp 2016-03-09 13:08:23 +0000
@@ -103,7 +103,7 @@
103 new click::web::Client(namPtr));103 new click::web::Client(namPtr));
104 click::Index index(clientPtr);104 click::Index index(clientPtr);
105 click::Packages packages;105 click::Packages packages;
106 index.search("qr", [&, this](click::Packages found_packages,106 index.search("qr", "", [&, this](click::Packages found_packages,
107 click::Packages){107 click::Packages){
108 packages = found_packages;108 packages = found_packages;
109 Quit();109 Quit();
110110
=== modified file 'libclickscope/tests/test_index.cpp'
--- libclickscope/tests/test_index.cpp 2016-01-21 23:25:38 +0000
+++ libclickscope/tests/test_index.cpp 2016-03-09 13:08:23 +0000
@@ -109,7 +109,7 @@
109 .Times(1)109 .Times(1)
110 .WillOnce(Return(response));110 .WillOnce(Return(response));
111111
112 indexPtr->search("", [](click::Packages, click::Packages) {});112 indexPtr->search("", "", [](click::Packages, click::Packages) {});
113}113}
114114
115MATCHER_P(QueryContains, query, "")115MATCHER_P(QueryContains, query, "")
@@ -132,7 +132,7 @@
132 .Times(1)132 .Times(1)
133 .WillOnce(Return(response));133 .WillOnce(Return(response));
134134
135 indexPtr->search("FooBar", [](click::Packages, click::Packages) {});135 indexPtr->search("FooBar", "", [](click::Packages, click::Packages) {});
136}136}
137137
138138
@@ -151,7 +151,7 @@
151 .Times(1)151 .Times(1)
152 .WillOnce(Return(response));152 .WillOnce(Return(response));
153153
154 indexPtr->search("", [](click::Packages, click::Packages) {});154 indexPtr->search("", "", [](click::Packages, click::Packages) {});
155}155}
156156
157TEST_F(IndexTest, testBootstrapSignsCall)157TEST_F(IndexTest, testBootstrapSignsCall)
@@ -206,7 +206,7 @@
206 .Times(1)206 .Times(1)
207 .WillOnce(Return(response));207 .WillOnce(Return(response));
208208
209 indexPtr->search("", [](click::Packages, click::Packages) {});209 indexPtr->search("", "", [](click::Packages, click::Packages) {});
210}210}
211211
212TEST_F(IndexTest, testSearchCallbackIsCalled)212TEST_F(IndexTest, testSearchCallbackIsCalled)
@@ -229,7 +229,7 @@
229 .WillOnce(Return(response));229 .WillOnce(Return(response));
230 EXPECT_CALL(*this, search_callback(_, _)).Times(1);230 EXPECT_CALL(*this, search_callback(_, _)).Times(1);
231231
232 indexPtr->search("", [this](click::Packages packages,232 indexPtr->search("", "", [this](click::Packages packages,
233 click::Packages recommends){233 click::Packages recommends){
234 search_callback(packages, recommends);234 search_callback(packages, recommends);
235 });235 });
@@ -257,7 +257,7 @@
257 click::Packages empty_package_list;257 click::Packages empty_package_list;
258 EXPECT_CALL(*this, search_callback(empty_package_list, _)).Times(1);258 EXPECT_CALL(*this, search_callback(empty_package_list, _)).Times(1);
259259
260 indexPtr->search("", [this](click::Packages packages,260 indexPtr->search("", "", [this](click::Packages packages,
261 click::Packages recommends){261 click::Packages recommends){
262 search_callback(packages, recommends);262 search_callback(packages, recommends);
263 });263 });
@@ -293,7 +293,7 @@
293 };293 };
294 EXPECT_CALL(*this, search_callback(single_package_list, _)).Times(1);294 EXPECT_CALL(*this, search_callback(single_package_list, _)).Times(1);
295295
296 indexPtr->search("", [this](click::Packages packages,296 indexPtr->search("", "", [this](click::Packages packages,
297 click::Packages recommends){297 click::Packages recommends){
298 search_callback(packages, recommends);298 search_callback(packages, recommends);
299 });299 });
@@ -315,7 +315,7 @@
315 .Times(1)315 .Times(1)
316 .WillOnce(Return(response));316 .WillOnce(Return(response));
317317
318 auto search_operation = indexPtr->search("", [](click::Packages,318 auto search_operation = indexPtr->search("", "", [](click::Packages,
319 click::Packages) {});319 click::Packages) {});
320 EXPECT_CALL(reply.instance, abort()).Times(1);320 EXPECT_CALL(reply.instance, abort()).Times(1);
321 search_operation.cancel();321 search_operation.cancel();
@@ -341,7 +341,7 @@
341 .Times(1)341 .Times(1)
342 .WillOnce(Return(response));342 .WillOnce(Return(response));
343 EXPECT_CALL(reply.instance, errorString()).Times(1).WillOnce(Return("fake error"));343 EXPECT_CALL(reply.instance, errorString()).Times(1).WillOnce(Return("fake error"));
344 indexPtr->search("", [this](click::Packages packages,344 indexPtr->search("", "", [this](click::Packages packages,
345 click::Packages recommends){345 click::Packages recommends){
346 search_callback(packages, recommends);346 search_callback(packages, recommends);
347 });347 });
348348
=== modified file 'scope/clickapps/apps-query.cpp'
--- scope/clickapps/apps-query.cpp 2016-02-19 03:35:43 +0000
+++ scope/clickapps/apps-query.cpp 2016-03-09 13:08:23 +0000
@@ -412,11 +412,9 @@
412 auto const ignoredApps = impl->configuration.get_ignored_apps();412 auto const ignoredApps = impl->configuration.get_ignored_apps();
413 auto const localResults = clickInterfaceInstance().find_installed_apps(querystr, ignoredApps, current_dept, impl->depts_db);413 auto const localResults = clickInterfaceInstance().find_installed_apps(querystr, ignoredApps, current_dept, impl->depts_db);
414414
415 if (querystr.empty()) {415 if (impl->depts_db)
416 if (impl->depts_db)416 {
417 {417 push_local_departments(searchReply, localResults);
418 push_local_departments(searchReply, localResults);
419 }
420 }418 }
421419
422 if (show_top_apps)420 if (show_top_apps)
423421
=== modified file 'scope/clickstore/store-query.cpp'
--- scope/clickstore/store-query.cpp 2016-01-06 18:08:33 +0000
+++ scope/clickstore/store-query.cpp 2016-03-09 13:08:23 +0000
@@ -429,6 +429,20 @@
429 }429 }
430}430}
431431
432void click::Query::push_departments(scopes::SearchReplyProxy const& searchReply)
433{
434 auto rootdep = impl->department_lookup.get_department_info("");
435 if (!rootdep)
436 {
437 qWarning() << "No department information available";
438 return;
439 }
440
441 auto subdepts = rootdep->sub_departments();
442 auto root = populate_departments(subdepts, "");
443 push_departments(searchReply, root);
444}
445
432//446//
433// push highlights and departments447// push highlights and departments
434// use cached highlights for root department, otherwise run an async job for highlights of current department.448// use cached highlights for root department, otherwise run an async job for highlights of current department.
@@ -559,7 +573,8 @@
559 else573 else
560 {574 {
561 qDebug() << "starting search of" << QString::fromStdString(query().query_string());575 qDebug() << "starting search of" << QString::fromStdString(query().query_string());
562 impl->search_operation = impl->index.search(query().query_string(), search_cb);576 push_departments(searchReply);
577 impl->search_operation = impl->index.search(query().query_string(), query().department_id(), search_cb);
563 }578 }
564 }579 }
565 });580 });
@@ -573,7 +588,8 @@
573 else // normal search588 else // normal search
574 {589 {
575 qDebug() << "starting search of" << QString::fromStdString(query().query_string());590 qDebug() << "starting search of" << QString::fromStdString(query().query_string());
576 impl->search_operation = impl->index.search(query().query_string(), search_cb);591 push_departments(searchReply);
592 impl->search_operation = impl->index.search(query().query_string(), query().department_id(), search_cb);
577 }593 }
578 }594 }
579 });595 });
580596
=== modified file 'scope/clickstore/store-query.h'
--- scope/clickstore/store-query.h 2015-11-24 18:23:23 +0000
+++ scope/clickstore/store-query.h 2016-03-09 13:08:23 +0000
@@ -88,6 +88,7 @@
88 virtual unity::scopes::Department::SPtr populate_departments(const click::DepartmentList& depts, const std::string& current_department_id);88 virtual unity::scopes::Department::SPtr populate_departments(const click::DepartmentList& depts, const std::string& current_department_id);
89 virtual void store_departments(const click::DepartmentList& depts);89 virtual void store_departments(const click::DepartmentList& depts);
90 virtual void push_departments(const scopes::SearchReplyProxy& searchReply, const scopes::Department::SCPtr& root);90 virtual void push_departments(const scopes::SearchReplyProxy& searchReply, const scopes::Department::SCPtr& root);
91 virtual void push_departments(scopes::SearchReplyProxy const& searchReply);
91 virtual void add_highlights(scopes::SearchReplyProxy const& searchReply, const PackageSet& installedPackages);92 virtual void add_highlights(scopes::SearchReplyProxy const& searchReply, const PackageSet& installedPackages);
92 virtual void add_available_apps(const scopes::SearchReplyProxy &searchReply, const PackageSet &installedPackages, const std::string &category);93 virtual void add_available_apps(const scopes::SearchReplyProxy &searchReply, const PackageSet &installedPackages, const std::string &category);
93 virtual click::Interface& clickInterfaceInstance();94 virtual click::Interface& clickInterfaceInstance();
9495
=== modified file 'scope/tests/test_apps_query.cpp'
--- scope/tests/test_apps_query.cpp 2016-02-19 03:35:43 +0000
+++ scope/tests/test_apps_query.cpp 2016-03-09 13:08:23 +0000
@@ -172,24 +172,6 @@
172 q.add_fake_store_app(reply);172 q.add_fake_store_app(reply);
173}173}
174174
175// this matcher expects a list of department ids in depts:
176// first on the list is the root, followed by children ids.
177// the arg of the matcher is unity::scopes::Department ptr.
178MATCHER_P(MatchesDepartments, depts, "") {
179 auto it = depts.begin();
180 if (arg->id() != *it)
181 return false;
182 auto const subdeps = arg->subdepartments();
183 if (subdeps.size() != depts.size() - 1)
184 return false;
185 for (auto const& sub: subdeps)
186 {
187 if (sub->id() != *(++it))
188 return false;
189 }
190 return true;
191}
192
193class DepartmentsTest : public ::testing::Test {175class DepartmentsTest : public ::testing::Test {
194protected:176protected:
195 virtual void SetUp() override177 virtual void SetUp() override
@@ -323,3 +305,37 @@
323 q.run(reply);305 q.run(reply);
324 }306 }
325}307}
308
309TEST_F(DepartmentsTest, testSearchInDepartment)
310{
311 auto clickif = std::make_shared<MockClickInterface>();
312 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);
313 auto depts_db = std::make_shared<MockDepartmentsDb>(":memory:", true);
314
315 // query for a leaf department
316 {
317 const unity::scopes::CannedQuery query("foo.scope", "Fooo", "games");
318
319 MockAppsQuery q(query, depts_db, metadata, clickif);
320
321 scopes::testing::MockSearchReply mock_reply;
322 scopes::SearchReplyProxy reply(&mock_reply, [](unity::scopes::SearchReply*){});
323
324 std::list<std::string> expected_departments({"", "games"});
325
326 EXPECT_CALL(*clickif, find_installed_apps("Fooo", _, "games", _)).WillOnce(Return(installed_apps));
327 EXPECT_CALL(mock_reply, register_category("local", StrEq(""), _, _)).WillOnce(Return(ptrCat));
328 EXPECT_CALL(mock_reply, register_category("store", _, _, _)).WillOnce(Return(ptrCat));
329 EXPECT_CALL(*depts_db, get_department_name("games", expected_locales)).WillOnce(Return("Games"));
330 EXPECT_CALL(*depts_db, get_children_departments("games")).WillOnce(Return(
331 std::list<click::DepartmentsDb::DepartmentInfo>({})
332 ));
333
334 EXPECT_CALL(mock_reply, register_departments(MatchesDepartments(expected_departments)));
335
336 EXPECT_CALL(mock_reply, push(Matcher<unity::scopes::CategorisedResult const&>(_))).Times(3).WillRepeatedly(Return(true));
337
338 q.run(reply);
339 }
340
341}
326342
=== modified file 'scope/tests/test_helpers.h'
--- scope/tests/test_helpers.h 2014-08-07 15:34:47 +0000
+++ scope/tests/test_helpers.h 2016-03-09 13:08:23 +0000
@@ -6,6 +6,7 @@
6#include "click/index.h"6#include "click/index.h"
7#include <click/interface.h>7#include <click/interface.h>
8#include <click/package.h>8#include <click/package.h>
9#include <gtest/gtest.h>
910
10namespace click11namespace click
11{12{
@@ -16,6 +17,23 @@
16static const std::string FAKE_QUERY {"FAKE_QUERY"};17static const std::string FAKE_QUERY {"FAKE_QUERY"};
17static const std::string FAKE_CATEGORY_TEMPLATE {"{}"};18static const std::string FAKE_CATEGORY_TEMPLATE {"{}"};
1819
20// this matcher expects a list of department ids in depts:
21// first on the list is the root, followed by children ids.
22// the arg of the matcher is unity::scopes::Department ptr.
23MATCHER_P(MatchesDepartments, depts, "") {
24 auto it = depts.begin();
25 if (arg->id() != *it)
26 return false;
27 auto const subdeps = arg->subdepartments();
28 if (subdeps.size() != depts.size() - 1)
29 return false;
30 for (auto const& sub: subdeps)
31 {
32 if (sub->id() != *(++it))
33 return false;
34 }
35 return true;
36}
1937
20class MockIndex : public click::Index {38class MockIndex : public click::Index {
21 click::Packages packages;39 click::Packages packages;
@@ -35,9 +53,9 @@
3553
36 }54 }
3755
38 click::web::Cancellable search(const std::string &query, std::function<void (click::Packages, click::Packages)> callback) override56 click::web::Cancellable search(const std::string &query, const std::string &department, std::function<void (click::Packages, click::Packages)> callback) override
39 {57 {
40 do_search(query, callback);58 do_search(query, department, callback);
41 callback(packages, recommends);59 callback(packages, recommends);
42 return click::web::Cancellable();60 return click::web::Cancellable();
43 }61 }
@@ -48,8 +66,8 @@
48 return click::web::Cancellable();66 return click::web::Cancellable();
49 }67 }
5068
51 MOCK_METHOD2(do_search,69 MOCK_METHOD3(do_search,
52 void(const std::string&,70 void(const std::string&, const std::string&,
53 std::function<void(click::Packages, click::Packages)>));71 std::function<void(click::Packages, click::Packages)>));
54};72};
5573
5674
=== modified file 'scope/tests/test_query.cpp'
--- scope/tests/test_query.cpp 2015-07-31 20:06:49 +0000
+++ scope/tests/test_query.cpp 2016-03-09 13:08:23 +0000
@@ -141,7 +141,7 @@
141 PackageSet no_installed_packages;141 PackageSet no_installed_packages;
142 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");142 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");
143 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);143 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);
144 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _)).Times(1);144 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _, _)).Times(1);
145145
146 scopes::testing::MockSearchReply mock_reply;146 scopes::testing::MockSearchReply mock_reply;
147 scopes::SearchReplyProxy reply(&mock_reply, [](unity::scopes::SearchReply*){});147 scopes::SearchReplyProxy reply(&mock_reply, [](unity::scopes::SearchReply*){});
@@ -168,7 +168,7 @@
168 PackageSet no_installed_packages;168 PackageSet no_installed_packages;
169 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");169 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");
170 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);170 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);
171 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _));171 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _, _));
172172
173 scopes::CategoryRenderer renderer("{}");173 scopes::CategoryRenderer renderer("{}");
174 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);174 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);
@@ -199,7 +199,7 @@
199 PackageSet no_installed_packages;199 PackageSet no_installed_packages;
200 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");200 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");
201 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);201 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);
202 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _));202 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _, _));
203203
204 scopes::CategoryRenderer renderer("{}");204 scopes::CategoryRenderer renderer("{}");
205 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);205 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);
@@ -254,7 +254,7 @@
254 MockPayPackage pay_pkg;254 MockPayPackage pay_pkg;
255 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");255 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");
256 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);256 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);
257 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _));257 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _, _));
258258
259 scopes::CategoryRenderer renderer("{}");259 scopes::CategoryRenderer renderer("{}");
260 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);260 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);
@@ -286,7 +286,7 @@
286 MockPayPackage pay_pkg;286 MockPayPackage pay_pkg;
287 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");287 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");
288 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);288 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);
289 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _));289 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _, _));
290290
291 scopes::CategoryRenderer renderer("{}");291 scopes::CategoryRenderer renderer("{}");
292 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);292 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);
@@ -325,7 +325,7 @@
325 MockPayPackage pay_pkg;325 MockPayPackage pay_pkg;
326 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");326 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");
327 MockQuery q(query, mock_index, dept_lookup, depts_db, highlights, metadata, pay_pkg);327 MockQuery q(query, mock_index, dept_lookup, depts_db, highlights, metadata, pay_pkg);
328 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _));328 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _, _));
329329
330 scopes::CategoryRenderer renderer("{}");330 scopes::CategoryRenderer renderer("{}");
331 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);331 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);
@@ -337,6 +337,34 @@
337 q.wrap_add_available_apps(reply, one_installed_package, FAKE_CATEGORY_TEMPLATE);337 q.wrap_add_available_apps(reply, one_installed_package, FAKE_CATEGORY_TEMPLATE);
338}338}
339339
340TEST(QueryTest, testSearchInDepartment)
341{
342 auto dept1 = std::make_shared<click::Department>("1", "Department one", "http://one.com", true);
343 DepartmentList init_departments({dept1});
344 auto depts_db = std::make_shared<MockDepartmentsDb>(":memory:", true);
345
346 MockIndex mock_index(click::Packages(), click::DepartmentList(), init_departments);
347 scopes::SearchMetadata metadata("en_EN", "phone");
348
349 click::DepartmentLookup dept_lookup;
350 click::HighlightList highlights;
351 MockPayPackage pay_pkg;
352 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "1");
353 MockQuery q(query, mock_index, dept_lookup, depts_db, highlights, metadata, pay_pkg);
354 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, "1", _));
355
356 scopes::CategoryRenderer renderer("{}");
357 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);
358 EXPECT_CALL(q, register_category(_, _, _, _, _)).Times(2).WillRepeatedly(Return(ptrCat));
359
360 std::list<std::string> expected_departments({"", "1"});
361 scopes::testing::MockSearchReply mock_reply;
362 EXPECT_CALL(mock_reply, register_departments(MatchesDepartments(expected_departments)));
363 scopes::SearchReplyProxy reply(&mock_reply, [](unity::scopes::SearchReply*){});
364 EXPECT_CALL(q, finished(_)).Times(1);
365 q.wrap_add_available_apps(reply, PackageSet(), FAKE_CATEGORY_TEMPLATE);
366}
367
340class FakeInterface : public click::Interface368class FakeInterface : public click::Interface
341{369{
342public:370public:
@@ -385,7 +413,7 @@
385 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");413 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");
386 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);414 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);
387 q.purchased_apps.insert({"name"});415 q.purchased_apps.insert({"name"});
388 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _));416 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _, _));
389417
390 scopes::CategoryRenderer renderer("{}");418 scopes::CategoryRenderer renderer("{}");
391 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);419 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);
@@ -421,7 +449,7 @@
421 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");449 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");
422 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);450 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);
423 q.purchased_apps.insert({"name"});451 q.purchased_apps.insert({"name"});
424 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _));452 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _, _));
425453
426 scopes::CategoryRenderer renderer("{}");454 scopes::CategoryRenderer renderer("{}");
427 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);455 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);
@@ -456,7 +484,7 @@
456 MockPayPackage pay_pkg;484 MockPayPackage pay_pkg;
457 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");485 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");
458 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);486 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);
459 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _));487 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _, _));
460488
461 scopes::CategoryRenderer renderer("{}");489 scopes::CategoryRenderer renderer("{}");
462 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);490 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);
@@ -488,7 +516,7 @@
488 MockPayPackage pay_pkg;516 MockPayPackage pay_pkg;
489 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");517 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");
490 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);518 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);
491 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _));519 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _, _));
492520
493 scopes::CategoryRenderer renderer("{}");521 scopes::CategoryRenderer renderer("{}");
494 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);522 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);
@@ -521,7 +549,7 @@
521 MockPayPackage pay_pkg;549 MockPayPackage pay_pkg;
522 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");550 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");
523 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);551 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);
524 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _));552 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _, _));
525553
526 scopes::CategoryRenderer renderer("{}");554 scopes::CategoryRenderer renderer("{}");
527 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);555 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);
@@ -617,7 +645,7 @@
617 MockPayPackage pay_pkg;645 MockPayPackage pay_pkg;
618 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");646 const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, "");
619 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);647 MockQuery q(query, mock_index, dept_lookup, nullptr, highlights, metadata, pay_pkg);
620 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _));648 EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _, _));
621649
622 scopes::CategoryRenderer renderer("{}");650 scopes::CategoryRenderer renderer("{}");
623 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);651 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);
624652
=== modified file 'tests/scope-harness/tests/test_apps.py'
--- tests/scope-harness/tests/test_apps.py 2015-06-22 17:05:41 +0000
+++ tests/scope-harness/tests/test_apps.py 2016-03-09 13:08:23 +0000
@@ -107,7 +107,6 @@
107 departments = self.view.browse_department('')107 departments = self.view.browse_department('')
108108
109 self.assertTrue(self.view.has_departments)109 self.assertTrue(self.view.has_departments)
110 self.assertFalse(self.view.has_alt_departments)
111110
112 # TODO: list all expected departments (depending on installed apps)111 # TODO: list all expected departments (depending on installed apps)
113 match = DepartmentMatcher() \112 match = DepartmentMatcher() \
114113
=== modified file 'tests/scope-harness/tests/test_store.py'
--- tests/scope-harness/tests/test_store.py 2015-04-03 18:33:10 +0000
+++ tests/scope-harness/tests/test_store.py 2016-03-09 13:08:23 +0000
@@ -111,7 +111,6 @@
111 departments = self.view.browse_department('')111 departments = self.view.browse_department('')
112112
113 self.assertTrue(self.view.has_departments)113 self.assertTrue(self.view.has_departments)
114 self.assertFalse(self.view.has_alt_departments)
115114
116 match = DepartmentMatcher() \115 match = DepartmentMatcher() \
117 .mode(DepartmentMatcherMode.STARTS_WITH) \116 .mode(DepartmentMatcherMode.STARTS_WITH) \

Subscribers

People subscribed via source and target branches