Merge lp:~dobey/unity-scope-click/avoid-isrefundable into lp:unity-scope-click

Proposed by dobey
Status: Merged
Approved by: Charles Kerr
Approved revision: 359
Merged at revision: 359
Proposed branch: lp:~dobey/unity-scope-click/avoid-isrefundable
Merge into: lp:unity-scope-click
Diff against target: 107 lines (+19/-15)
4 files modified
libclickscope/click/package.h (+2/-2)
libclickscope/click/preview.cpp (+9/-8)
libclickscope/click/preview.h (+2/-1)
libclickscope/tests/test_preview.cpp (+6/-4)
To merge this branch: bzr merge lp:~dobey/unity-scope-click/avoid-isrefundable
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Charles Kerr (community) Approve
Review via email: mp+267265@code.launchpad.net

Commit message

Don't check refundability if price in details is 0 (or unspecified).
Initialize the price and rating to 0.0f in package details.

Description of the change

Same changes have already landed in vivid+overlay.

To post a comment you must log in.
Revision history for this message
Charles Kerr (charlesk) :
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/package.h'
2--- libclickscope/click/package.h 2015-01-20 03:40:54 +0000
3+++ libclickscope/click/package.h 2015-08-06 21:26:56 +0000
4@@ -98,12 +98,12 @@
5
6 std::string name; // formerly app_id
7 std::string title;
8- double price;
9+ double price = 0.0f;
10 std::string icon_url;
11 std::string url;
12 std::string version;
13 std::string publisher;
14- double rating;
15+ double rating = 0.0f;
16 void matches (std::string query, std::function<bool> callback);
17 std::string content;
18 std::map<std::string, double> prices;
19
20=== modified file 'libclickscope/click/preview.cpp'
21--- libclickscope/click/preview.cpp 2015-07-07 02:34:41 +0000
22+++ libclickscope/click/preview.cpp 2015-08-06 21:26:56 +0000
23@@ -796,7 +796,7 @@
24 getApplicationUri(manifest, [this, reply, manifest, app_name, &review, userid](const std::string& uri) {
25 populateDetails([this, reply, uri, manifest, app_name](const PackageDetails &details){
26 store_department(details);
27- pushPackagePreviewWidgets(reply, details, createButtons(uri, manifest));
28+ pushPackagePreviewWidgets(reply, details, createButtons(uri, manifest, details));
29 },
30 [this, reply, &review, manifest, userid](const ReviewList& reviewlist,
31 click::Reviews::Error error) {
32@@ -836,7 +836,8 @@
33 }
34
35 scopes::PreviewWidgetList InstalledPreview::createButtons(const std::string& uri,
36- const Manifest& manifest)
37+ const Manifest& manifest,
38+ const PackageDetails& details)
39 {
40 scopes::PreviewWidgetList widgets;
41 scopes::PreviewWidget buttons("buttons", "actions");
42@@ -861,16 +862,16 @@
43 }
44 if (manifest.removable)
45 {
46- if (!isRefundable()) {
47+ if (details.package.price > 0.00f && isRefundable()) {
48+ builder.add_tuple({
49+ {"id", scopes::Variant(click::Preview::Actions::CANCEL_PURCHASE_INSTALLED)},
50+ {"label", scopes::Variant(_("Cancel Purchase"))}
51+ });
52+ } else {
53 builder.add_tuple({
54 {"id", scopes::Variant(click::Preview::Actions::UNINSTALL_CLICK)},
55 {"label", scopes::Variant(_("Uninstall"))}
56 });
57- } else {
58- builder.add_tuple({
59- {"id", scopes::Variant(click::Preview::Actions::CANCEL_PURCHASE_INSTALLED)},
60- {"label", scopes::Variant(_("Cancel Purchase"))}
61- });
62 }
63 }
64 if (!uri.empty() || manifest.removable) {
65
66=== modified file 'libclickscope/click/preview.h'
67--- libclickscope/click/preview.h 2015-07-07 02:34:41 +0000
68+++ libclickscope/click/preview.h 2015-08-06 21:26:56 +0000
69@@ -225,7 +225,8 @@
70 void getApplicationUri(const Manifest& manifest, std::function<void(const std::string&)> callback);
71 std::string get_consumer_key();
72 scopes::PreviewWidgetList createButtons(const std::string& uri,
73- const click::Manifest& manifest);
74+ const click::Manifest& manifest,
75+ const PackageDetails& details);
76 private:
77 scopes::ActionMetadata metadata;
78 };
79
80=== modified file 'libclickscope/tests/test_preview.cpp'
81--- libclickscope/tests/test_preview.cpp 2015-07-07 02:48:11 +0000
82+++ libclickscope/tests/test_preview.cpp 2015-08-06 21:26:56 +0000
83@@ -493,18 +493,20 @@
84 .WillOnce(Return(true));
85 click::Manifest manifest;
86 manifest.removable = true;
87- auto widgets = preview.createButtons("fake uri", manifest);
88+ click::PackageDetails details;
89+ details.package.price = 0.99f;
90+ auto widgets = preview.createButtons("fake uri", manifest, details);
91 ASSERT_EQ(get_actions_from_widgets(widgets, 0).size(), 2);
92 ASSERT_EQ(get_action_from_widgets(widgets, 0, 1), "cancel_purchase_installed");
93 }
94
95 TEST_F(InstalledPreviewTest, testIsRefundableButtonNotShown) {
96 FakeInstalledRefundablePreview preview(result, metadata, client, pay_package, depts);
97- EXPECT_CALL(preview, isRefundable()).Times(1)
98- .WillOnce(Return(false));
99+ EXPECT_CALL(preview, isRefundable()).Times(0);
100 click::Manifest manifest;
101 manifest.removable = true;
102- auto widgets = preview.createButtons("fake uri", manifest);
103+ click::PackageDetails details;
104+ auto widgets = preview.createButtons("fake uri", manifest, details);
105 ASSERT_EQ(get_actions_from_widgets(widgets, 0).size(), 2);
106 ASSERT_EQ(get_action_from_widgets(widgets, 0, 1), "uninstall_click");
107 }

Subscribers

People subscribed via source and target branches

to all changes: