Merge lp:~alecu/unity-scope-click/all-apps-department into lp:unity-scope-click/devel

Proposed by Alejandro J. Cura
Status: Merged
Approved by: Paweł Stołowski
Approved revision: 380
Merged at revision: 383
Proposed branch: lp:~alecu/unity-scope-click/all-apps-department
Merge into: lp:unity-scope-click/devel
Diff against target: 299 lines (+231/-2)
5 files modified
libclickscope/click/highlights.cpp (+10/-2)
libclickscope/tests/fake_json.cpp (+193/-0)
libclickscope/tests/fake_json.h (+1/-0)
libclickscope/tests/test_bootstrap.cpp (+26/-0)
po/POTFILES.in (+1/-0)
To merge this branch: bzr merge lp:~alecu/unity-scope-click/all-apps-department
Reviewer Review Type Date Requested Status
Paweł Stołowski (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+229308@code.launchpad.net

Commit message

Show all remaining apps in the department.

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
Paweł Stołowski (stolowski) wrote :

Nice and clean, and works fine on the phone! Thanks!

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-07-10 10:11:04 +0000
3+++ libclickscope/click/highlights.cpp 2014-08-02 00:11:25 +0000
4@@ -27,6 +27,7 @@
5 * files in the program, then also delete it here.
6 */
7
8+#include <click/click-i18n.h>
9 #include "highlights.h"
10 #include <iostream>
11
12@@ -87,17 +88,24 @@
13
14 std::list<Highlight> Highlight::from_json_root_node(const Json::Value& root)
15 {
16+ std::list<Highlight> highlights;
17 if (root.isObject() && root.isMember(Highlight::JsonKeys::embedded))
18 {
19 auto const emb = root[Highlight::JsonKeys::embedded];
20 if (emb.isObject() && emb.isMember(Highlight::JsonKeys::highlight))
21 {
22 auto const hl = emb[Highlight::JsonKeys::highlight];
23- return from_json_node(hl);
24+ highlights = from_json_node(hl);
25+ }
26+ if (emb.isObject() && emb.isMember(Package::JsonKeys::ci_package))
27+ {
28+ auto pkg_node = emb[Package::JsonKeys::ci_package];
29+ auto pkgs = package_list_from_json_node(pkg_node);
30+ highlights.push_back(Highlight("__all-apps__", _("Apps"), pkgs));
31 }
32 }
33
34- return std::list<Highlight>();
35+ return highlights;
36 }
37
38 }
39
40=== modified file 'libclickscope/tests/fake_json.cpp'
41--- libclickscope/tests/fake_json.cpp 2014-07-22 22:34:43 +0000
42+++ libclickscope/tests/fake_json.cpp 2014-08-02 00:11:25 +0000
43@@ -539,6 +539,199 @@
44 }
45 })";
46
47+const std::string FAKE_JSON_DEPARTMENT_WITH_APPS = R"(
48+ {
49+ "_embedded": {
50+ "clickindex:package": [
51+ {
52+ "publisher": "Awesome Widget Company",
53+ "name": "org.example.awesomelauncher",
54+ "title": "Awesome Launcher",
55+ "price": 1.99,
56+ "_links": {
57+ "self": {
58+ "href": "https://search.apps.staging.ubuntu.com/api/v1/package/org.example.awesomelauncher"
59+ }
60+ },
61+ "icon": "http://example.org/media/org.example.awesomelauncher/icons/icon16.png"
62+ },
63+ {
64+ "publisher": "Awesome Widget Company",
65+ "name": "org.example.awesomewidget",
66+ "title": "Awesome Widget",
67+ "price": 1.99,
68+ "_links": {
69+ "self": {
70+ "href": "https://search.apps.staging.ubuntu.com/api/v1/package/org.example.awesomelauncher"
71+ }
72+ },
73+ "icon": "http://example.org/media/org.example.awesomelauncher/icons/icon16.png"
74+ },
75+ {
76+ "publisher": "Awesome Widget Company",
77+ "name": "org.example.awesomescope",
78+ "title": "Awesome Scope",
79+ "price": 1.99,
80+ "content": "scope",
81+ "_links": {
82+ "self": {
83+ "href": "https://search.apps.staging.ubuntu.com/api/v1/package/org.example.awesomescope"
84+ }
85+ },
86+ "icon": "http://example.org/media/org.example.awesomescope/icons/icon16.png"
87+ },
88+ {
89+ "publisher": "Awesome Widget Company",
90+ "name": "org.example.awesomescope2",
91+ "title": "Awesome Scope 2.0",
92+ "price": 1.99,
93+ "content": "scope",
94+ "_links": {
95+ "self": {
96+ "href": "https://search.apps.staging.ubuntu.com/api/v1/package/org.example.awesomescope2"
97+ }
98+ },
99+ "icon": "http://example.org/media/org.example.awesomescope2/icons/icon16.png"
100+ }
101+ ],
102+
103+ "clickindex:department": [
104+ {
105+ "has_children": false,
106+ "_links": {
107+ "self": {
108+ "href": "https://search.apps.staging.ubuntu.com/api/v1/departments/fake-subdepartment"}
109+ },
110+ "name": "Fake Subdepartment", "slug": "fake-subdepartment"}
111+ ],
112+ "clickindex:highlight": [
113+ {
114+ "_embedded": {
115+ "clickindex:package": [
116+ {
117+ "publisher": "Awesome Widget Company",
118+ "name": "org.example.awesomelauncher",
119+ "title": "Awesome Launcher",
120+ "price": 1.99,
121+ "_links": {
122+ "self": {
123+ "href": "https://search.apps.staging.ubuntu.com/api/v1/package/org.example.awesomelauncher"}
124+ },
125+ "icon": "http://example.org/media/org.example.awesomelauncher/icons/icon16.png"
126+ },
127+ {
128+ "publisher": "Awesome Widget Company",
129+ "name": "org.example.awesomewidget",
130+ "title": "Awesome Widget", "price": 1.99,
131+ "_links": {
132+ "self": {
133+ "href": "https://search.apps.staging.ubuntu.com/api/v1/package/org.example.awesomewidget"
134+ }
135+ },
136+ "icon": "http://example.org/media/org.example.awesomewidget/icons/icon16.png"}
137+ ]
138+ },
139+ "_links": {
140+ "self": {
141+ "href": "https://search.apps.staging.ubuntu.com/api/v1/highlights/top-apps"
142+ }
143+ },
144+ "name": "Top Apps", "slug": "top-apps"
145+ },
146+ {
147+ "_embedded": {
148+ "clickindex:package": [
149+ {
150+ "publisher": "Awesome Widget Company",
151+ "name": "org.example.awesomelauncher",
152+ "title": "Awesome Launcher",
153+ "price": 1.99,
154+ "_links": {
155+ "self": {
156+ "href": "https://search.apps.staging.ubuntu.com/api/v1/package/org.example.awesomelauncher"
157+ }
158+ },
159+ "icon": "http://example.org/media/org.example.awesomelauncher/icons/icon16.png"
160+ },
161+ {
162+ "publisher": "Awesome Widget Company",
163+ "name": "org.example.awesomewidget",
164+ "title": "Awesome Widget",
165+ "price": 1.99,
166+ "_links": {
167+ "self": {
168+ "href": "https://search.apps.staging.ubuntu.com/api/v1/package/org.example.awesomewidget"
169+ }
170+ },
171+ "icon": "http://example.org/media/org.example.awesomewidget/icons/icon16.png"
172+ }
173+ ]
174+ },
175+ "_links": {
176+ "self": {
177+ "href": "https://search.apps.staging.ubuntu.com/api/v1/highlights/most-purchased"
178+ }
179+ },
180+ "name": "Most Purchased",
181+ "slug": "most-purchased"
182+ },
183+ {
184+ "_embedded": {
185+ "clickindex:package": [
186+ {
187+ "publisher": "Awesome Widget Company",
188+ "name": "org.example.awesomelauncher",
189+ "title": "Awesome Launcher",
190+ "price": 1.99,
191+ "_links": {
192+ "self": {
193+ "href": "https://search.apps.staging.ubuntu.com/api/v1/package/org.example.awesomelauncher"
194+ }
195+ },
196+ "icon": "http://example.org/media/org.example.awesomelauncher/icons/icon16.png"
197+ },
198+ {
199+ "publisher": "Awesome Widget Company",
200+ "name": "org.example.awesomewidget",
201+ "title": "Awesome Widget",
202+ "price": 1.99,
203+ "_links": {
204+ "self": {
205+ "href": "https://search.apps.staging.ubuntu.com/api/v1/package/org.example.awesomewidget"
206+ }
207+ },
208+ "icon": "http://example.org/media/org.example.awesomewidget/icons/icon16.png"
209+ }
210+ ]
211+ },
212+ "_links": {
213+ "self": {
214+ "href": "https://search.apps.staging.ubuntu.com/api/v1/highlights/new-releases"
215+ }
216+ },
217+ "name": "New Releases",
218+ "slug": "new-releases"
219+ }
220+ ]
221+ }, "has_children": true,
222+ "_links": {
223+ "curies": [
224+ {
225+ "href": "https://search.apps.staging.ubuntu.com/docs/v1/relations.html{#rel}",
226+ "name": "clickindex", "templated": true
227+ }
228+ ],
229+ "self": {
230+ "href": "https://search.apps.staging.ubuntu.com/api/v1/departments/fake-department-with-subdepartments"
231+ },
232+ "collection": {
233+ "href": "https://search.apps.staging.ubuntu.com/api/v1/departments"
234+ }
235+ },
236+ "name": "Fake Department With Subdepartments",
237+ "slug": "fake-department-with-subdepartments"
238+ })";
239+
240 const std::string FAKE_JSON_MANIFEST_REMOVABLE = R"foo(
241 {
242 "_removable": 1,
243
244=== modified file 'libclickscope/tests/fake_json.h'
245--- libclickscope/tests/fake_json.h 2014-07-14 08:49:19 +0000
246+++ libclickscope/tests/fake_json.h 2014-08-02 00:11:25 +0000
247@@ -41,6 +41,7 @@
248 extern const std::string FAKE_JSON_BOOTSTRAP;
249 extern const std::string FAKE_JSON_BROKEN_BOOTSTRAP;
250 extern const std::string FAKE_JSON_DEPARTMENTS_ONLY;
251+extern const std::string FAKE_JSON_DEPARTMENT_WITH_APPS;
252 extern const std::string FAKE_JSON_BROKEN_DEPARTMENTS;
253 extern const std::string FAKE_JSON_MANIFEST_REMOVABLE;
254 extern const std::string FAKE_JSON_MANIFEST_NONREMOVABLE;
255
256=== modified file 'libclickscope/tests/test_bootstrap.cpp'
257--- libclickscope/tests/test_bootstrap.cpp 2014-07-11 19:01:40 +0000
258+++ libclickscope/tests/test_bootstrap.cpp 2014-08-02 00:11:25 +0000
259@@ -170,3 +170,29 @@
260 EXPECT_EQ(0u, depts.size());
261 }
262 }
263+
264+TEST_F(BootstrapTest, testDepartmentAllApps)
265+{
266+ Json::Reader reader;
267+ Json::Value root;
268+
269+ EXPECT_TRUE(reader.parse(FAKE_JSON_DEPARTMENT_WITH_APPS, root));
270+
271+ {
272+ auto highlights = click::Highlight::from_json_root_node(root);
273+ EXPECT_EQ(4u, highlights.size());
274+ auto it = highlights.begin();
275+ EXPECT_EQ("Top Apps", it->name());
276+ EXPECT_EQ(2u, it->packages().size());
277+ ++it;
278+ EXPECT_EQ("Most Purchased", it->name());
279+ EXPECT_EQ(2u, it->packages().size());
280+ ++it;
281+ EXPECT_EQ("New Releases", it->name());
282+ EXPECT_EQ(2u, it->packages().size());
283+ ++it;
284+ EXPECT_EQ("Apps", it->name());
285+ EXPECT_EQ(4u, it->packages().size());
286+ }
287+
288+}
289
290=== modified file 'po/POTFILES.in'
291--- po/POTFILES.in 2014-07-25 22:06:11 +0000
292+++ po/POTFILES.in 2014-08-02 00:11:25 +0000
293@@ -1,5 +1,6 @@
294 [type: gettext/ini] data/com.canonical.scopes.clickstore.ini.in.in
295 [type: gettext/ini] data/clickscope.ini.in.in
296+libclickscope/click/highlights.cpp
297 libclickscope/click/preview.cpp
298 libclickscope/click/utils.cpp
299 scope/clickapps/apps-query.cpp

Subscribers

People subscribed via source and target branches

to all changes: