Merge lp:~alecu/unity-scope-click/separate-scopes-category into lp:unity-scope-click/devel

Proposed by Alejandro J. Cura
Status: Merged
Approved by: Ted Gould
Approved revision: 384
Merged at revision: 388
Proposed branch: lp:~alecu/unity-scope-click/separate-scopes-category
Merge into: lp:unity-scope-click/devel
Diff against target: 208 lines (+68/-8)
8 files modified
libclickscope/click/highlights.cpp (+17/-1)
libclickscope/click/package.cpp (+1/-0)
libclickscope/click/package.h (+8/-4)
libclickscope/tests/fake_json.cpp (+21/-0)
libclickscope/tests/fake_json.h (+1/-0)
libclickscope/tests/test_bootstrap.cpp (+5/-2)
libclickscope/tests/test_index.cpp (+3/-1)
libclickscope/tests/test_package.cpp (+12/-0)
To merge this branch: bzr merge lp:~alecu/unity-scope-click/separate-scopes-category
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+229675@code.launchpad.net

Commit message

A separate category for available scopes

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
Ted Gould (ted) wrote :

Comments inline.

384. By Alejandro J. Cura

Use const& to avoid extra copy

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

Cool.

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-08-02 00:07:43 +0000
3+++ libclickscope/click/highlights.cpp 2014-08-05 22:30:45 +0000
4@@ -101,7 +101,23 @@
5 {
6 auto pkg_node = emb[Package::JsonKeys::ci_package];
7 auto pkgs = package_list_from_json_node(pkg_node);
8- highlights.push_back(Highlight("__all-apps__", _("Apps"), pkgs));
9+ click::Packages apps;
10+ click::Packages scopes;
11+
12+ for (click::Package& p : pkgs) {
13+ if (p.content == "scope") {
14+ scopes.push_back(p);
15+ } else {
16+ apps.push_back(p);
17+ }
18+ }
19+
20+ if (apps.size() > 0) {
21+ highlights.push_back(Highlight("__all-apps__", _("Apps"), apps));
22+ }
23+ if (scopes.size() > 0) {
24+ highlights.push_back(Highlight("__all-scopes__", _("Scopes"), scopes));
25+ }
26 }
27 }
28
29
30=== modified file 'libclickscope/click/package.cpp'
31--- libclickscope/click/package.cpp 2014-07-25 05:44:43 +0000
32+++ libclickscope/click/package.cpp 2014-08-05 22:30:45 +0000
33@@ -82,6 +82,7 @@
34 p.price = item[Package::JsonKeys::price].asDouble();
35 p.icon_url = item[Package::JsonKeys::icon_url].asString();
36 p.url = item[Package::JsonKeys::links][Package::JsonKeys::self][Package::JsonKeys::href].asString();
37+ p.content = item[Package::JsonKeys::content].asString();
38 return p;
39 }
40
41
42=== modified file 'libclickscope/click/package.h'
43--- libclickscope/click/package.h 2014-07-25 05:35:28 +0000
44+++ libclickscope/click/package.h 2014-08-05 22:30:45 +0000
45@@ -60,10 +60,11 @@
46 constexpr static const char* title{"title"};
47 constexpr static const char* price{"price"};
48 constexpr static const char* icon_url{"icon_url"};
49+ constexpr static const char* content{"content"};
50 };
51
52 Package() = default;
53- Package(std::string name, std::string title, double price, std::string icon_url, std::string url) :
54+ Package(const std::string& name, const std::string& title, double price, const std::string& icon_url, const std::string& url) :
55 name(name),
56 title(title),
57 price(price),
58@@ -71,16 +72,18 @@
59 url(url)
60 {
61 }
62- Package(std::string name, std::string title, double price, std::string icon_url, std::string url, std::string version) :
63+ Package(const std::string& name, const std::string& title, double price, const std::string& icon_url, const std::string& url,
64+ const std::string& version, const std::string& content) :
65 name(name),
66 title(title),
67 price(price),
68 icon_url(icon_url),
69 url(url),
70- version(version)
71+ version(version),
72+ content(content)
73 {
74 }
75- Package(std::string name, std::string version) :
76+ Package(const std::string& name, const std::string& version) :
77 name(name),
78 version(version)
79 {
80@@ -94,6 +97,7 @@
81 std::string url;
82 std::string version;
83 void matches (std::string query, std::function<bool> callback);
84+ std::string content;
85
86 struct hash_name {
87 public :
88
89=== modified file 'libclickscope/tests/fake_json.cpp'
90--- libclickscope/tests/fake_json.cpp 2014-08-02 00:07:43 +0000
91+++ libclickscope/tests/fake_json.cpp 2014-08-05 22:30:45 +0000
92@@ -70,6 +70,27 @@
93 }
94 )foo";
95
96+const std::string FAKE_JSON_SEARCH_RESULT_ONE_SCOPE = R"foo({
97+ "_embedded": {
98+ "clickindex:package": [
99+ {
100+ "name": "org.example.awesomescope",
101+ "title": "Awesome Scope",
102+ "description": "This is an awesome scope.",
103+ "price": 0.0,
104+ "content": "scope",
105+ "icon_url": "http://software-center.ubuntu.com/site_media/appmedia/2012/09/SPAZ.png",
106+ "_links": {
107+ "self": {
108+ "href": "http://search.apps.ubuntu.com/api/v1/package/org.example.awesomescope"
109+ }
110+ }
111+ }
112+ ]
113+ }
114+ }
115+)foo";
116+
117 const std::string FAKE_JSON_SEARCH_RESULT_MISSING_DATA = R"foo({
118 "_embedded": {
119 "clickindex:package": [
120
121=== modified file 'libclickscope/tests/fake_json.h'
122--- libclickscope/tests/fake_json.h 2014-08-02 00:07:43 +0000
123+++ libclickscope/tests/fake_json.h 2014-08-05 22:30:45 +0000
124@@ -34,6 +34,7 @@
125
126 extern const std::string FAKE_JSON_REVIEWS_RESULT_ONE;
127 extern const std::string FAKE_JSON_SEARCH_RESULT_ONE;
128+extern const std::string FAKE_JSON_SEARCH_RESULT_ONE_SCOPE;
129 extern const std::string FAKE_JSON_SEARCH_RESULT_MISSING_DATA;
130 extern const std::string FAKE_JSON_SEARCH_RESULT_MANY;
131 extern const std::string FAKE_JSON_SEARCH_RESULT_RECOMMENDS;
132
133=== modified file 'libclickscope/tests/test_bootstrap.cpp'
134--- libclickscope/tests/test_bootstrap.cpp 2014-08-02 00:07:43 +0000
135+++ libclickscope/tests/test_bootstrap.cpp 2014-08-05 22:30:45 +0000
136@@ -180,7 +180,7 @@
137
138 {
139 auto highlights = click::Highlight::from_json_root_node(root);
140- EXPECT_EQ(4u, highlights.size());
141+ EXPECT_EQ(5u, highlights.size());
142 auto it = highlights.begin();
143 EXPECT_EQ("Top Apps", it->name());
144 EXPECT_EQ(2u, it->packages().size());
145@@ -192,7 +192,10 @@
146 EXPECT_EQ(2u, it->packages().size());
147 ++it;
148 EXPECT_EQ("Apps", it->name());
149- EXPECT_EQ(4u, it->packages().size());
150+ EXPECT_EQ(2u, it->packages().size());
151+ ++it;
152+ EXPECT_EQ("Scopes", it->name());
153+ EXPECT_EQ(2u, it->packages().size());
154 }
155
156 }
157
158=== modified file 'libclickscope/tests/test_index.cpp'
159--- libclickscope/tests/test_index.cpp 2014-07-25 05:35:28 +0000
160+++ libclickscope/tests/test_index.cpp 2014-08-05 22:30:45 +0000
161@@ -338,6 +338,7 @@
162 "http://developer.staging.ubuntu.com/site_media/appmedia/2013/07/weather-icone-6797-64.png",
163 "https://public.apps.staging.ubuntu.com/download/ar.com.beuno/wheather-touch/ar.com.beuno.wheather-touch-0.2",
164 "0.2",
165+ "app"
166 },
167 "\u1F4A9 Weather\nA weather application.",
168 "https://public.apps.staging.ubuntu.com/download/ar.com.beuno/wheather-touch/ar.com.beuno.wheather-touch-0.2",
169@@ -402,6 +403,7 @@
170 "http://developer.staging.ubuntu.com/site_media/appmedia/2013/07/weather-icone-6797-64.png",
171 "https://public.apps.staging.ubuntu.com/download/ar.com.beuno/wheather-touch/ar.com.beuno.wheather-touch-0.2",
172 "v0.1",
173+ "app"
174 },
175 (std::string("\u1F4A9 ") + std::string(appname_utf8.constData()) + "\nA weather application.").c_str(),
176 "https://public.apps.staging.ubuntu.com/download/ar.com.beuno/wheather-touch/ar.com.beuno.wheather-touch-0.2",
177@@ -500,7 +502,7 @@
178 click::Package package = {
179 "org.example.testapp", "Test App", 0.00,
180 "/tmp/foo.png",
181- "uri", "0.1.5"
182+ "uri", "0.1.5", "app"
183 };
184 std::string expected = "pkcon -p remove org.example.testapp;0.1.5;all;local:click";
185 EXPECT_CALL(*this, execute_uninstall_command(expected, _)).Times(1);
186
187=== modified file 'libclickscope/tests/test_package.cpp'
188--- libclickscope/tests/test_package.cpp 2014-06-26 17:52:31 +0000
189+++ libclickscope/tests/test_package.cpp 2014-08-05 22:30:45 +0000
190@@ -50,6 +50,18 @@
191 ASSERT_EQ(1, pl.size());
192 }
193
194+TEST_F(PackageTest, testPackageListFromJsonNodeSingleScope)
195+{
196+ Json::Value root;
197+ Json::Reader().parse(FAKE_JSON_SEARCH_RESULT_ONE_SCOPE, root);
198+ auto const embedded = root[Package::JsonKeys::embedded];
199+ auto const ci_package = embedded[Package::JsonKeys::ci_package];
200+
201+ Packages pl = package_list_from_json_node(ci_package);
202+ ASSERT_EQ(1, pl.size());
203+ EXPECT_EQ("scope", pl[0].content);
204+}
205+
206 TEST_F(PackageTest, testPackageListFromJsonNodeMany)
207 {
208 Json::Value root;

Subscribers

People subscribed via source and target branches

to all changes: