Merge lp:~stolowski/unity-scope-click/update-for-design into lp:unity-scope-click/devel

Proposed by Paweł Stołowski
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 326
Merged at revision: 324
Proposed branch: lp:~stolowski/unity-scope-click/update-for-design
Merge into: lp:unity-scope-click/devel
Diff against target: 256 lines (+97/-32)
6 files modified
libclickscope/click/highlights.cpp (+10/-3)
libclickscope/click/highlights.h (+4/-1)
scope/clickapps/apps-query.cpp (+25/-22)
scope/clickapps/apps-query.h (+0/-1)
scope/clickstore/store-query.cpp (+27/-5)
scope/tests/test_apps_query.cpp (+31/-0)
To merge this branch: bzr merge lp:~stolowski/unity-scope-click/update-for-design
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+226307@code.launchpad.net

Commit message

Minor updates to be more in line with latest designs: use big card for app of the week, pass search string in a canned query of Ubuntu Store link.

Description of the change

Minor updates to be more in line with latest designs:
1) Use big card (full width) for App of the Week (note: app of the week is currently shown at a random position among other categories; this will be fixed on the server).
2) When searching in Apps scope, create "Ubuntu Store" card with a canned query that perform same search in the store scope (note: there is https://bugs.launchpad.net/unity8/+bug/1340195 that affects it).

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Please add unit tests to this branch.

review: Needs Fixing
325. By Paweł Stołowski

Merged devel.

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

Added test for fake ubuntu store result.

Revision history for this message
Paweł Stołowski (stolowski) wrote :

> Please add unit tests to this branch.

Done

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Looks mostly fine. There's a bit of code that could use one more test, and to not delay this branch I'm adding it here: lp:~alecu/unity-scope-click/update-for-design-onemoretest

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libclickscope/click/highlights.cpp'
--- libclickscope/click/highlights.cpp 2014-06-24 19:39:13 +0000
+++ libclickscope/click/highlights.cpp 2014-07-11 16:49:25 +0000
@@ -38,8 +38,9 @@
38{38{
39}39}
4040
41Highlight::Highlight(const std::string& name, const Packages& pkgs)41Highlight::Highlight(const std::string& slug, const std::string& name, const Packages& pkgs)
42 : name_(name),42 : slug_(slug),
43 name_(name),
43 packages_(pkgs)44 packages_(pkgs)
44{45{
45}46}
@@ -49,6 +50,11 @@
49 packages_.push_back(pkg);50 packages_.push_back(pkg);
50}51}
5152
53std::string Highlight::slug() const
54{
55 return slug_;
56}
57
52std::string Highlight::name() const58std::string Highlight::name() const
53{59{
54 return name_;60 return name_;
@@ -69,9 +75,10 @@
69 if (item.isObject() && item.isMember(Highlight::JsonKeys::name))75 if (item.isObject() && item.isMember(Highlight::JsonKeys::name))
70 {76 {
71 auto name = item[Highlight::JsonKeys::name].asString();77 auto name = item[Highlight::JsonKeys::name].asString();
78 auto slug = item[Highlight::JsonKeys::slug].asString();
72 auto pkg_node = item[Package::JsonKeys::embedded][Package::JsonKeys::ci_package];79 auto pkg_node = item[Package::JsonKeys::embedded][Package::JsonKeys::ci_package];
73 auto pkgs = package_list_from_json_node(pkg_node);80 auto pkgs = package_list_from_json_node(pkg_node);
74 highlights.push_back(Highlight(name, pkgs));81 highlights.push_back(Highlight(slug, name, pkgs));
75 }82 }
76 }83 }
7784
7885
=== modified file 'libclickscope/click/highlights.h'
--- libclickscope/click/highlights.h 2014-06-18 17:37:13 +0000
+++ libclickscope/click/highlights.h 2014-07-11 16:49:25 +0000
@@ -45,15 +45,17 @@
45 {45 {
46 JsonKeys() = delete;46 JsonKeys() = delete;
47 constexpr static const char* name {"name"};47 constexpr static const char* name {"name"};
48 constexpr static const char* slug {"slug"};
48 constexpr static const char* embedded {"_embedded"};49 constexpr static const char* embedded {"_embedded"};
49 constexpr static const char* highlight {"clickindex:highlight"};50 constexpr static const char* highlight {"clickindex:highlight"};
50 };51 };
5152
52 Highlight(const std::string& name);53 Highlight(const std::string& name);
53 Highlight(const std::string& name, const Packages& pkgs);54 Highlight(const std::string& slug, const std::string& name, const Packages& pkgs);
54 void add_package(const Package& pkg);55 void add_package(const Package& pkg);
5556
56 std::string name() const;57 std::string name() const;
58 std::string slug() const;
57 Packages packages() const;59 Packages packages() const;
5860
59 static std::list<Highlight> from_json_root_node(const Json::Value& val);61 static std::list<Highlight> from_json_root_node(const Json::Value& val);
@@ -61,6 +63,7 @@
61private:63private:
62 static std::list<Highlight> from_json_node(const Json::Value& val);64 static std::list<Highlight> from_json_node(const Json::Value& val);
6365
66 std::string slug_;
64 std::string name_;67 std::string name_;
65 Packages packages_;68 Packages packages_;
66};69};
6770
=== modified file 'scope/clickapps/apps-query.cpp'
--- scope/clickapps/apps-query.cpp 2014-07-07 14:57:25 +0000
+++ scope/clickapps/apps-query.cpp 2014-07-11 16:49:25 +0000
@@ -47,7 +47,7 @@
47namespace47namespace
48{48{
4949
50std::string CATEGORY_APPS_DISPLAY = R"(50static const std::string CATEGORY_APPS_DISPLAY = R"(
51 {51 {
52 "schema-version" : 1,52 "schema-version" : 1,
53 "template" : {53 "template" : {
@@ -238,30 +238,33 @@
238void click::apps::Query::add_fake_store_app(scopes::SearchReplyProxy const& searchReply)238void click::apps::Query::add_fake_store_app(scopes::SearchReplyProxy const& searchReply)
239{239{
240 static const std::string title = _("Ubuntu Store");240 static const std::string title = _("Ubuntu Store");
241 static const std::string cat_title = _("Get more apps from the store");241 std::string cat_title = _("Get more apps from the store");
242 auto name = title;
243242
244 std::string querystr = query().query_string();243 const std::string querystr = query().query_string();
245 std::transform(querystr.begin(), querystr.end(), querystr.begin(), ::tolower);244 if (!querystr.empty())
246 std::transform(name.begin(), name.end(), name.begin(), ::tolower);
247 if (querystr.empty() || name.find(querystr) != std::string::npos)
248 {245 {
249 scopes::CategoryRenderer rdr(CATEGORY_STORE);246 char tmp[512];
250 auto cat = searchReply->register_category("store", cat_title, "", rdr);247 if (snprintf(tmp, sizeof(tmp), _("Search for '%s' in the store"), querystr.c_str()) > 0)
251248 {
252 static const unity::scopes::CannedQuery store_scope("com.canonical.scopes.clickstore");249 cat_title = tmp;
253250 }
254 scopes::CategorisedResult res(cat);
255 res.set_title(title);
256 res.set_art(STORE_DATA_DIR "/store-scope-icon.svg");
257 res.set_uri(store_scope.to_uri());
258 res[click::apps::Query::ResultKeys::NAME] = title;
259 res[click::apps::Query::ResultKeys::DESCRIPTION] = "";
260 res[click::apps::Query::ResultKeys::MAIN_SCREENSHOT] = "";
261 res[click::apps::Query::ResultKeys::INSTALLED] = true;
262 res[click::apps::Query::ResultKeys::VERSION] = "";
263 searchReply->push(res);
264 }251 }
252
253 scopes::CategoryRenderer rdr(CATEGORY_STORE);
254 auto cat = searchReply->register_category("store", cat_title, "", rdr);
255
256 static const unity::scopes::CannedQuery store_scope("com.canonical.scopes.clickstore", querystr, "");
257
258 scopes::CategorisedResult res(cat);
259 res.set_title(title);
260 res.set_art(STORE_DATA_DIR "/store-scope-icon.svg");
261 res.set_uri(store_scope.to_uri());
262 res[click::apps::Query::ResultKeys::NAME] = title;
263 res[click::apps::Query::ResultKeys::DESCRIPTION] = "";
264 res[click::apps::Query::ResultKeys::MAIN_SCREENSHOT] = "";
265 res[click::apps::Query::ResultKeys::INSTALLED] = true;
266 res[click::apps::Query::ResultKeys::VERSION] = "";
267 searchReply->push(res);
265}268}
266269
267void click::apps::Query::run(scopes::SearchReplyProxy const& searchReply)270void click::apps::Query::run(scopes::SearchReplyProxy const& searchReply)
268271
=== modified file 'scope/clickapps/apps-query.h'
--- scope/clickapps/apps-query.h 2014-07-07 14:34:27 +0000
+++ scope/clickapps/apps-query.h 2014-07-11 16:49:25 +0000
@@ -72,7 +72,6 @@
7272
73 virtual void run(scopes::SearchReplyProxy const& reply) override;73 virtual void run(scopes::SearchReplyProxy const& reply) override;
7474
75protected:
76 virtual void add_fake_store_app(scopes::SearchReplyProxy const &replyProxy);75 virtual void add_fake_store_app(scopes::SearchReplyProxy const &replyProxy);
77private:76private:
78 struct Private;77 struct Private;
7978
=== modified file 'scope/clickstore/store-query.cpp'
--- scope/clickstore/store-query.cpp 2014-07-10 15:29:10 +0000
+++ scope/clickstore/store-query.cpp 2014-07-11 16:49:25 +0000
@@ -55,7 +55,7 @@
55namespace55namespace
56{56{
5757
58std::string CATEGORY_APPS_DISPLAY = R"(58static const std::string CATEGORY_APPS_DISPLAY = R"(
59 {59 {
60 "schema-version" : 1,60 "schema-version" : 1,
61 "template" : {61 "template" : {
@@ -73,7 +73,24 @@
73 }73 }
74)";74)";
7575
76std::string CATEGORY_APPS_SEARCH = R"(76static const std::string CATEGORY_APP_OF_THE_WEEK = R"(
77{
78 "schema-version" : 1,
79 "template": {
80 "category-layout": "grid",
81 "card-size": "large"
82 },
83 "components": {
84 "title": "title",
85 "subtitle": "subtitle",
86 "art": {
87 "aspect-ratio": 2.5,
88 "field": "art"
89 }
90 }
91})";
92
93static const std::string CATEGORY_APPS_SEARCH = R"(
77 {94 {
78 "schema-version" : 1,95 "schema-version" : 1,
79 "template" : {96 "template" : {
@@ -246,12 +263,17 @@
246263
247void click::Query::push_highlights(const scopes::SearchReplyProxy& searchReply, const HighlightList& highlights, const PackageSet &locallyInstalledApps)264void click::Query::push_highlights(const scopes::SearchReplyProxy& searchReply, const HighlightList& highlights, const PackageSet &locallyInstalledApps)
248{265{
249 std::string categoryTemplate = CATEGORY_APPS_DISPLAY; //FIXME266 const scopes::CategoryRenderer renderer(CATEGORY_APPS_DISPLAY);
250 scopes::CategoryRenderer renderer(categoryTemplate);267 const scopes::CategoryRenderer aotw_renderer(CATEGORY_APP_OF_THE_WEEK);
251268
252 for (auto const& hl: highlights)269 for (auto const& hl: highlights)
253 {270 {
254 auto category = register_category(searchReply, hl.name(), hl.name(), "", renderer); //FIXME: highlight slug271 scopes::CategoryRenderer const* rdr = &renderer;
272 if (hl.slug() == "app-of-the-week" || hl.packages().size() == 1)
273 {
274 rdr = &aotw_renderer;
275 }
276 auto category = register_category(searchReply, hl.slug(), hl.name(), "", *rdr);
255 for (auto const& pkg: hl.packages())277 for (auto const& pkg: hl.packages())
256 {278 {
257 push_package(searchReply, category, locallyInstalledApps, pkg);279 push_package(searchReply, category, locallyInstalledApps, pkg);
258280
=== modified file 'scope/tests/test_apps_query.cpp'
--- scope/tests/test_apps_query.cpp 2014-07-07 14:34:27 +0000
+++ scope/tests/test_apps_query.cpp 2014-07-11 16:49:25 +0000
@@ -36,6 +36,8 @@
36#include <clickapps/apps-query.h>36#include <clickapps/apps-query.h>
3737
38#include <unity/scopes/SearchReply.h>38#include <unity/scopes/SearchReply.h>
39#include <unity/scopes/SearchMetadata.h>
40#include <unity/scopes/CannedQuery.h>
39#include <unity/scopes/testing/MockSearchReply.h>41#include <unity/scopes/testing/MockSearchReply.h>
4042
41#include "test_helpers.h"43#include "test_helpers.h"
@@ -82,3 +84,32 @@
82 pusher.push_local_results(apps, categoryTemplate);84 pusher.push_local_results(apps, categoryTemplate);
83}85}
8486
87MATCHER_P(ResultUriMatchesCannedQuery, q, "") {
88 auto const query = unity::scopes::CannedQuery::from_uri(arg.uri());
89 return query.scope_id() == q.scope_id()
90 && query.query_string() == q.query_string()
91 && query.department_id() == q.department_id();
92}
93
94MATCHER_P(CategoryTitleContains, s, "") { return arg.find(s) != std::string::npos; }
95
96TEST(Query, testUbuntuStoreFakeResult)
97{
98 const scopes::SearchMetadata metadata("en_EN", "phone");
99 const unity::scopes::CannedQuery query("foo.scope", "FooBar", "");
100 click::apps::Query q(query, metadata);
101
102 scopes::testing::MockSearchReply mock_reply;
103 scopes::SearchReplyProxy reply(&mock_reply, [](unity::scopes::SearchReply*){});
104
105 scopes::CategoryRenderer renderer("{}");
106 auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);
107
108 const unity::scopes::CannedQuery target_query("com.canonical.scopes.clickstore", "FooBar", "");
109
110 EXPECT_CALL(mock_reply, register_category("store", CategoryTitleContains("FooBar"), _, _)).WillOnce(Return(ptrCat));
111 EXPECT_CALL(mock_reply, push(Matcher<const unity::scopes::CategorisedResult&>(ResultUriMatchesCannedQuery(target_query))));
112
113 q.add_fake_store_app(reply);
114}
115

Subscribers

People subscribed via source and target branches

to all changes: