Merge lp:~dobey/unity-scope-click/no-deb-dates into lp:unity-scope-click/devel

Proposed by dobey
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 415
Merged at revision: 416
Proposed branch: lp:~dobey/unity-scope-click/no-deb-dates
Merge into: lp:unity-scope-click/devel
Diff against target: 126 lines (+49/-18)
4 files modified
libclickscope/click/preview.cpp (+16/-14)
libclickscope/tests/fake_json.cpp (+10/-0)
libclickscope/tests/fake_json.h (+1/-0)
libclickscope/tests/test_preview.cpp (+22/-4)
To merge this branch: bzr merge lp:~dobey/unity-scope-click/no-deb-dates
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alejandro J. Cura (community) Approve
Review via email: mp+231600@code.launchpad.net

Commit message

Only show extended info when download_url is not empty.

To post a comment you must log in.
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Fix looks good, branch needs tests.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
415. By dobey

Add fake json details for a deb package.
Add more tests for the description widgets.

Revision history for this message
Alejandro J. Cura (alecu) wrote :

Code looks good.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libclickscope/click/preview.cpp'
--- libclickscope/click/preview.cpp 2014-08-19 21:42:44 +0000
+++ libclickscope/click/preview.cpp 2014-08-20 20:46:14 +0000
@@ -350,20 +350,22 @@
350 widgets.push_back(summary);350 widgets.push_back(summary);
351 }351 }
352352
353 scopes::PreviewWidget other_metadata("other_metadata", "text");353 if (!details.download_url.empty())
354 other_metadata.add_attribute_value("text", scopes::Variant(build_other_metadata(details)));354 {
355 widgets.push_back(other_metadata);355 scopes::PreviewWidget other_metadata("other_metadata", "text");
356356 other_metadata.add_attribute_value("text", scopes::Variant(build_other_metadata(details)));
357 scopes::PreviewWidget updates("updates", "text");357 widgets.push_back(other_metadata);
358 updates.add_attribute_value("title", scopes::Variant(_("Updates")));358
359 updates.add_attribute_value("text", scopes::Variant(build_updates_table(details)));359 scopes::PreviewWidget updates("updates", "text");
360 widgets.push_back(updates);360 updates.add_attribute_value("title", scopes::Variant(_("Updates")));
361361 updates.add_attribute_value("text", scopes::Variant(build_updates_table(details)));
362 scopes::PreviewWidget whats_new("whats_new", "text");362 widgets.push_back(updates);
363 whats_new.add_attribute_value("title", scopes::Variant(_("What's new")));363
364 whats_new.add_attribute_value("text", scopes::Variant(build_whats_new(details)));364 scopes::PreviewWidget whats_new("whats_new", "text");
365 widgets.push_back(whats_new);365 whats_new.add_attribute_value("title", scopes::Variant(_("What's new")));
366366 whats_new.add_attribute_value("text", scopes::Variant(build_whats_new(details)));
367 widgets.push_back(whats_new);
368 }
367 return widgets;369 return widgets;
368}370}
369371
370372
=== modified file 'libclickscope/tests/fake_json.cpp'
--- libclickscope/tests/fake_json.cpp 2014-08-11 18:30:00 +0000
+++ libclickscope/tests/fake_json.cpp 2014-08-20 20:46:14 +0000
@@ -225,6 +225,16 @@
225 }225 }
226)foo";226)foo";
227227
228const std::string FAKE_JSON_PACKAGE_DETAILS_DEB = R"foo(
229 {
230 "name": "weather-app",
231 "icon_url": "theme://weather-app",
232 "title": "\u1F4A9 Weather",
233 "description": "A weather application.",
234 "keywords": "these, are, key, words"
235 }
236)foo";
237
228const std::string FAKE_JSON_BOOTSTRAP = R"(238const std::string FAKE_JSON_BOOTSTRAP = R"(
229 {239 {
230 "_embedded": {240 "_embedded": {
231241
=== modified file 'libclickscope/tests/fake_json.h'
--- libclickscope/tests/fake_json.h 2014-08-05 19:00:03 +0000
+++ libclickscope/tests/fake_json.h 2014-08-20 20:46:14 +0000
@@ -39,6 +39,7 @@
39extern const std::string FAKE_JSON_SEARCH_RESULT_MANY;39extern const std::string FAKE_JSON_SEARCH_RESULT_MANY;
40extern const std::string FAKE_JSON_SEARCH_RESULT_RECOMMENDS;40extern const std::string FAKE_JSON_SEARCH_RESULT_RECOMMENDS;
41extern const std::string FAKE_JSON_PACKAGE_DETAILS;41extern const std::string FAKE_JSON_PACKAGE_DETAILS;
42extern const std::string FAKE_JSON_PACKAGE_DETAILS_DEB;
42extern const std::string FAKE_JSON_BOOTSTRAP;43extern const std::string FAKE_JSON_BOOTSTRAP;
43extern const std::string FAKE_JSON_BROKEN_BOOTSTRAP;44extern const std::string FAKE_JSON_BROKEN_BOOTSTRAP;
44extern const std::string FAKE_JSON_DEPARTMENTS_ONLY;45extern const std::string FAKE_JSON_DEPARTMENTS_ONLY;
4546
=== modified file 'libclickscope/tests/test_preview.cpp'
--- libclickscope/tests/test_preview.cpp 2014-08-19 21:42:44 +0000
+++ libclickscope/tests/test_preview.cpp 2014-08-20 20:46:14 +0000
@@ -111,10 +111,8 @@
111 click::PackageDetails details;111 click::PackageDetails details;
112 unity::scopes::PreviewWidgetList widgets;112 unity::scopes::PreviewWidgetList widgets;
113113
114 PreviewStrategyDescriptionTest() : details(click::PackageDetails::from_json(FAKE_JSON_PACKAGE_DETAILS))114 PreviewStrategyDescriptionTest()
115 {115 {
116 widgets = preview.descriptionWidgets(details);
117
118 }116 }
119 void assertWidgetAttribute(int n, std::string attribute_name, std::string expected_value)117 void assertWidgetAttribute(int n, std::string attribute_name, std::string expected_value)
120 {118 {
@@ -125,8 +123,11 @@
125 }123 }
126};124};
127125
128TEST_F(PreviewStrategyDescriptionTest, testDescriptionWidgets)126TEST_F(PreviewStrategyDescriptionTest, testDescriptionWidgetsFull)
129{127{
128 details = click::PackageDetails::from_json(FAKE_JSON_PACKAGE_DETAILS);
129 widgets = preview.descriptionWidgets(details);
130
130 assertWidgetAttribute(0, "title", "Info");131 assertWidgetAttribute(0, "title", "Info");
131 assertWidgetAttribute(0, "text", details.description);132 assertWidgetAttribute(0, "text", details.description);
132133
@@ -140,6 +141,23 @@
140141
141}142}
142143
144TEST_F(PreviewStrategyDescriptionTest, testDescriptionWidgetsMinimal)
145{
146 details = click::PackageDetails::from_json(FAKE_JSON_PACKAGE_DETAILS_DEB);
147 widgets = preview.descriptionWidgets(details);
148
149 ASSERT_EQ(1, widgets.size());
150
151 assertWidgetAttribute(0, "title", "Info");
152 assertWidgetAttribute(0, "text", details.description);
153}
154
155TEST_F(PreviewStrategyDescriptionTest, testDescriptionWidgetsNone)
156{
157 widgets = preview.descriptionWidgets(details);
158 ASSERT_EQ(0, widgets.size());
159}
160
143class FakePreviewStrategy : public click::PreviewStrategy161class FakePreviewStrategy : public click::PreviewStrategy
144{162{
145public:163public:

Subscribers

People subscribed via source and target branches

to all changes: