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
1=== modified file 'libclickscope/click/preview.cpp'
2--- libclickscope/click/preview.cpp 2014-08-19 21:42:44 +0000
3+++ libclickscope/click/preview.cpp 2014-08-20 20:46:14 +0000
4@@ -350,20 +350,22 @@
5 widgets.push_back(summary);
6 }
7
8- scopes::PreviewWidget other_metadata("other_metadata", "text");
9- other_metadata.add_attribute_value("text", scopes::Variant(build_other_metadata(details)));
10- widgets.push_back(other_metadata);
11-
12- scopes::PreviewWidget updates("updates", "text");
13- updates.add_attribute_value("title", scopes::Variant(_("Updates")));
14- updates.add_attribute_value("text", scopes::Variant(build_updates_table(details)));
15- widgets.push_back(updates);
16-
17- scopes::PreviewWidget whats_new("whats_new", "text");
18- whats_new.add_attribute_value("title", scopes::Variant(_("What's new")));
19- whats_new.add_attribute_value("text", scopes::Variant(build_whats_new(details)));
20- widgets.push_back(whats_new);
21-
22+ if (!details.download_url.empty())
23+ {
24+ scopes::PreviewWidget other_metadata("other_metadata", "text");
25+ other_metadata.add_attribute_value("text", scopes::Variant(build_other_metadata(details)));
26+ widgets.push_back(other_metadata);
27+
28+ scopes::PreviewWidget updates("updates", "text");
29+ updates.add_attribute_value("title", scopes::Variant(_("Updates")));
30+ updates.add_attribute_value("text", scopes::Variant(build_updates_table(details)));
31+ widgets.push_back(updates);
32+
33+ scopes::PreviewWidget whats_new("whats_new", "text");
34+ whats_new.add_attribute_value("title", scopes::Variant(_("What's new")));
35+ whats_new.add_attribute_value("text", scopes::Variant(build_whats_new(details)));
36+ widgets.push_back(whats_new);
37+ }
38 return widgets;
39 }
40
41
42=== modified file 'libclickscope/tests/fake_json.cpp'
43--- libclickscope/tests/fake_json.cpp 2014-08-11 18:30:00 +0000
44+++ libclickscope/tests/fake_json.cpp 2014-08-20 20:46:14 +0000
45@@ -225,6 +225,16 @@
46 }
47 )foo";
48
49+const std::string FAKE_JSON_PACKAGE_DETAILS_DEB = R"foo(
50+ {
51+ "name": "weather-app",
52+ "icon_url": "theme://weather-app",
53+ "title": "\u1F4A9 Weather",
54+ "description": "A weather application.",
55+ "keywords": "these, are, key, words"
56+ }
57+)foo";
58+
59 const std::string FAKE_JSON_BOOTSTRAP = R"(
60 {
61 "_embedded": {
62
63=== modified file 'libclickscope/tests/fake_json.h'
64--- libclickscope/tests/fake_json.h 2014-08-05 19:00:03 +0000
65+++ libclickscope/tests/fake_json.h 2014-08-20 20:46:14 +0000
66@@ -39,6 +39,7 @@
67 extern const std::string FAKE_JSON_SEARCH_RESULT_MANY;
68 extern const std::string FAKE_JSON_SEARCH_RESULT_RECOMMENDS;
69 extern const std::string FAKE_JSON_PACKAGE_DETAILS;
70+extern const std::string FAKE_JSON_PACKAGE_DETAILS_DEB;
71 extern const std::string FAKE_JSON_BOOTSTRAP;
72 extern const std::string FAKE_JSON_BROKEN_BOOTSTRAP;
73 extern const std::string FAKE_JSON_DEPARTMENTS_ONLY;
74
75=== modified file 'libclickscope/tests/test_preview.cpp'
76--- libclickscope/tests/test_preview.cpp 2014-08-19 21:42:44 +0000
77+++ libclickscope/tests/test_preview.cpp 2014-08-20 20:46:14 +0000
78@@ -111,10 +111,8 @@
79 click::PackageDetails details;
80 unity::scopes::PreviewWidgetList widgets;
81
82- PreviewStrategyDescriptionTest() : details(click::PackageDetails::from_json(FAKE_JSON_PACKAGE_DETAILS))
83+ PreviewStrategyDescriptionTest()
84 {
85- widgets = preview.descriptionWidgets(details);
86-
87 }
88 void assertWidgetAttribute(int n, std::string attribute_name, std::string expected_value)
89 {
90@@ -125,8 +123,11 @@
91 }
92 };
93
94-TEST_F(PreviewStrategyDescriptionTest, testDescriptionWidgets)
95+TEST_F(PreviewStrategyDescriptionTest, testDescriptionWidgetsFull)
96 {
97+ details = click::PackageDetails::from_json(FAKE_JSON_PACKAGE_DETAILS);
98+ widgets = preview.descriptionWidgets(details);
99+
100 assertWidgetAttribute(0, "title", "Info");
101 assertWidgetAttribute(0, "text", details.description);
102
103@@ -140,6 +141,23 @@
104
105 }
106
107+TEST_F(PreviewStrategyDescriptionTest, testDescriptionWidgetsMinimal)
108+{
109+ details = click::PackageDetails::from_json(FAKE_JSON_PACKAGE_DETAILS_DEB);
110+ widgets = preview.descriptionWidgets(details);
111+
112+ ASSERT_EQ(1, widgets.size());
113+
114+ assertWidgetAttribute(0, "title", "Info");
115+ assertWidgetAttribute(0, "text", details.description);
116+}
117+
118+TEST_F(PreviewStrategyDescriptionTest, testDescriptionWidgetsNone)
119+{
120+ widgets = preview.descriptionWidgets(details);
121+ ASSERT_EQ(0, widgets.size());
122+}
123+
124 class FakePreviewStrategy : public click::PreviewStrategy
125 {
126 public:

Subscribers

People subscribed via source and target branches

to all changes: