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
1=== modified file 'libclickscope/click/highlights.cpp'
2--- libclickscope/click/highlights.cpp 2014-06-24 19:39:13 +0000
3+++ libclickscope/click/highlights.cpp 2014-07-11 16:49:25 +0000
4@@ -38,8 +38,9 @@
5 {
6 }
7
8-Highlight::Highlight(const std::string& name, const Packages& pkgs)
9- : name_(name),
10+Highlight::Highlight(const std::string& slug, const std::string& name, const Packages& pkgs)
11+ : slug_(slug),
12+ name_(name),
13 packages_(pkgs)
14 {
15 }
16@@ -49,6 +50,11 @@
17 packages_.push_back(pkg);
18 }
19
20+std::string Highlight::slug() const
21+{
22+ return slug_;
23+}
24+
25 std::string Highlight::name() const
26 {
27 return name_;
28@@ -69,9 +75,10 @@
29 if (item.isObject() && item.isMember(Highlight::JsonKeys::name))
30 {
31 auto name = item[Highlight::JsonKeys::name].asString();
32+ auto slug = item[Highlight::JsonKeys::slug].asString();
33 auto pkg_node = item[Package::JsonKeys::embedded][Package::JsonKeys::ci_package];
34 auto pkgs = package_list_from_json_node(pkg_node);
35- highlights.push_back(Highlight(name, pkgs));
36+ highlights.push_back(Highlight(slug, name, pkgs));
37 }
38 }
39
40
41=== modified file 'libclickscope/click/highlights.h'
42--- libclickscope/click/highlights.h 2014-06-18 17:37:13 +0000
43+++ libclickscope/click/highlights.h 2014-07-11 16:49:25 +0000
44@@ -45,15 +45,17 @@
45 {
46 JsonKeys() = delete;
47 constexpr static const char* name {"name"};
48+ constexpr static const char* slug {"slug"};
49 constexpr static const char* embedded {"_embedded"};
50 constexpr static const char* highlight {"clickindex:highlight"};
51 };
52
53 Highlight(const std::string& name);
54- Highlight(const std::string& name, const Packages& pkgs);
55+ Highlight(const std::string& slug, const std::string& name, const Packages& pkgs);
56 void add_package(const Package& pkg);
57
58 std::string name() const;
59+ std::string slug() const;
60 Packages packages() const;
61
62 static std::list<Highlight> from_json_root_node(const Json::Value& val);
63@@ -61,6 +63,7 @@
64 private:
65 static std::list<Highlight> from_json_node(const Json::Value& val);
66
67+ std::string slug_;
68 std::string name_;
69 Packages packages_;
70 };
71
72=== modified file 'scope/clickapps/apps-query.cpp'
73--- scope/clickapps/apps-query.cpp 2014-07-07 14:57:25 +0000
74+++ scope/clickapps/apps-query.cpp 2014-07-11 16:49:25 +0000
75@@ -47,7 +47,7 @@
76 namespace
77 {
78
79-std::string CATEGORY_APPS_DISPLAY = R"(
80+static const std::string CATEGORY_APPS_DISPLAY = R"(
81 {
82 "schema-version" : 1,
83 "template" : {
84@@ -238,30 +238,33 @@
85 void click::apps::Query::add_fake_store_app(scopes::SearchReplyProxy const& searchReply)
86 {
87 static const std::string title = _("Ubuntu Store");
88- static const std::string cat_title = _("Get more apps from the store");
89- auto name = title;
90+ std::string cat_title = _("Get more apps from the store");
91
92- std::string querystr = query().query_string();
93- std::transform(querystr.begin(), querystr.end(), querystr.begin(), ::tolower);
94- std::transform(name.begin(), name.end(), name.begin(), ::tolower);
95- if (querystr.empty() || name.find(querystr) != std::string::npos)
96+ const std::string querystr = query().query_string();
97+ if (!querystr.empty())
98 {
99- scopes::CategoryRenderer rdr(CATEGORY_STORE);
100- auto cat = searchReply->register_category("store", cat_title, "", rdr);
101-
102- static const unity::scopes::CannedQuery store_scope("com.canonical.scopes.clickstore");
103-
104- scopes::CategorisedResult res(cat);
105- res.set_title(title);
106- res.set_art(STORE_DATA_DIR "/store-scope-icon.svg");
107- res.set_uri(store_scope.to_uri());
108- res[click::apps::Query::ResultKeys::NAME] = title;
109- res[click::apps::Query::ResultKeys::DESCRIPTION] = "";
110- res[click::apps::Query::ResultKeys::MAIN_SCREENSHOT] = "";
111- res[click::apps::Query::ResultKeys::INSTALLED] = true;
112- res[click::apps::Query::ResultKeys::VERSION] = "";
113- searchReply->push(res);
114+ char tmp[512];
115+ if (snprintf(tmp, sizeof(tmp), _("Search for '%s' in the store"), querystr.c_str()) > 0)
116+ {
117+ cat_title = tmp;
118+ }
119 }
120+
121+ scopes::CategoryRenderer rdr(CATEGORY_STORE);
122+ auto cat = searchReply->register_category("store", cat_title, "", rdr);
123+
124+ static const unity::scopes::CannedQuery store_scope("com.canonical.scopes.clickstore", querystr, "");
125+
126+ scopes::CategorisedResult res(cat);
127+ res.set_title(title);
128+ res.set_art(STORE_DATA_DIR "/store-scope-icon.svg");
129+ res.set_uri(store_scope.to_uri());
130+ res[click::apps::Query::ResultKeys::NAME] = title;
131+ res[click::apps::Query::ResultKeys::DESCRIPTION] = "";
132+ res[click::apps::Query::ResultKeys::MAIN_SCREENSHOT] = "";
133+ res[click::apps::Query::ResultKeys::INSTALLED] = true;
134+ res[click::apps::Query::ResultKeys::VERSION] = "";
135+ searchReply->push(res);
136 }
137
138 void click::apps::Query::run(scopes::SearchReplyProxy const& searchReply)
139
140=== modified file 'scope/clickapps/apps-query.h'
141--- scope/clickapps/apps-query.h 2014-07-07 14:34:27 +0000
142+++ scope/clickapps/apps-query.h 2014-07-11 16:49:25 +0000
143@@ -72,7 +72,6 @@
144
145 virtual void run(scopes::SearchReplyProxy const& reply) override;
146
147-protected:
148 virtual void add_fake_store_app(scopes::SearchReplyProxy const &replyProxy);
149 private:
150 struct Private;
151
152=== modified file 'scope/clickstore/store-query.cpp'
153--- scope/clickstore/store-query.cpp 2014-07-10 15:29:10 +0000
154+++ scope/clickstore/store-query.cpp 2014-07-11 16:49:25 +0000
155@@ -55,7 +55,7 @@
156 namespace
157 {
158
159-std::string CATEGORY_APPS_DISPLAY = R"(
160+static const std::string CATEGORY_APPS_DISPLAY = R"(
161 {
162 "schema-version" : 1,
163 "template" : {
164@@ -73,7 +73,24 @@
165 }
166 )";
167
168-std::string CATEGORY_APPS_SEARCH = R"(
169+static const std::string CATEGORY_APP_OF_THE_WEEK = R"(
170+{
171+ "schema-version" : 1,
172+ "template": {
173+ "category-layout": "grid",
174+ "card-size": "large"
175+ },
176+ "components": {
177+ "title": "title",
178+ "subtitle": "subtitle",
179+ "art": {
180+ "aspect-ratio": 2.5,
181+ "field": "art"
182+ }
183+ }
184+})";
185+
186+static const std::string CATEGORY_APPS_SEARCH = R"(
187 {
188 "schema-version" : 1,
189 "template" : {
190@@ -246,12 +263,17 @@
191
192 void click::Query::push_highlights(const scopes::SearchReplyProxy& searchReply, const HighlightList& highlights, const PackageSet &locallyInstalledApps)
193 {
194- std::string categoryTemplate = CATEGORY_APPS_DISPLAY; //FIXME
195- scopes::CategoryRenderer renderer(categoryTemplate);
196+ const scopes::CategoryRenderer renderer(CATEGORY_APPS_DISPLAY);
197+ const scopes::CategoryRenderer aotw_renderer(CATEGORY_APP_OF_THE_WEEK);
198
199 for (auto const& hl: highlights)
200 {
201- auto category = register_category(searchReply, hl.name(), hl.name(), "", renderer); //FIXME: highlight slug
202+ scopes::CategoryRenderer const* rdr = &renderer;
203+ if (hl.slug() == "app-of-the-week" || hl.packages().size() == 1)
204+ {
205+ rdr = &aotw_renderer;
206+ }
207+ auto category = register_category(searchReply, hl.slug(), hl.name(), "", *rdr);
208 for (auto const& pkg: hl.packages())
209 {
210 push_package(searchReply, category, locallyInstalledApps, pkg);
211
212=== modified file 'scope/tests/test_apps_query.cpp'
213--- scope/tests/test_apps_query.cpp 2014-07-07 14:34:27 +0000
214+++ scope/tests/test_apps_query.cpp 2014-07-11 16:49:25 +0000
215@@ -36,6 +36,8 @@
216 #include <clickapps/apps-query.h>
217
218 #include <unity/scopes/SearchReply.h>
219+#include <unity/scopes/SearchMetadata.h>
220+#include <unity/scopes/CannedQuery.h>
221 #include <unity/scopes/testing/MockSearchReply.h>
222
223 #include "test_helpers.h"
224@@ -82,3 +84,32 @@
225 pusher.push_local_results(apps, categoryTemplate);
226 }
227
228+MATCHER_P(ResultUriMatchesCannedQuery, q, "") {
229+ auto const query = unity::scopes::CannedQuery::from_uri(arg.uri());
230+ return query.scope_id() == q.scope_id()
231+ && query.query_string() == q.query_string()
232+ && query.department_id() == q.department_id();
233+}
234+
235+MATCHER_P(CategoryTitleContains, s, "") { return arg.find(s) != std::string::npos; }
236+
237+TEST(Query, testUbuntuStoreFakeResult)
238+{
239+ const scopes::SearchMetadata metadata("en_EN", "phone");
240+ const unity::scopes::CannedQuery query("foo.scope", "FooBar", "");
241+ click::apps::Query q(query, metadata);
242+
243+ scopes::testing::MockSearchReply mock_reply;
244+ scopes::SearchReplyProxy reply(&mock_reply, [](unity::scopes::SearchReply*){});
245+
246+ scopes::CategoryRenderer renderer("{}");
247+ auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);
248+
249+ const unity::scopes::CannedQuery target_query("com.canonical.scopes.clickstore", "FooBar", "");
250+
251+ EXPECT_CALL(mock_reply, register_category("store", CategoryTitleContains("FooBar"), _, _)).WillOnce(Return(ptrCat));
252+ EXPECT_CALL(mock_reply, push(Matcher<const unity::scopes::CategorisedResult&>(ResultUriMatchesCannedQuery(target_query))));
253+
254+ q.add_fake_store_app(reply);
255+}
256+

Subscribers

People subscribed via source and target branches

to all changes: