Merge lp:~dobey/unity-scope-click/cancel-purchase-apps into lp:unity-scope-click

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 371
Merged at revision: 371
Proposed branch: lp:~dobey/unity-scope-click/cancel-purchase-apps
Merge into: lp:unity-scope-click
Diff against target: 147 lines (+46/-11)
5 files modified
libclickscope/click/preview.cpp (+9/-4)
libclickscope/click/preview.h (+1/-2)
libclickscope/tests/test_preview.cpp (+14/-5)
scope/clickapps/apps-scope.cpp (+6/-0)
scope/tests/test_apps_scope.cpp (+16/-0)
To merge this branch: bzr merge lp:~dobey/unity-scope-click/cancel-purchase-apps
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Alejandro J. Cura (community) Approve
Review via email: mp+268598@code.launchpad.net

Commit message

Only show Cancel Purchase button from within store scope for now.

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
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
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 2015-08-06 20:07:24 +0000
3+++ libclickscope/click/preview.cpp 2015-08-24 18:05:31 +0000
4@@ -549,6 +549,11 @@
5
6 bool PreviewStrategy::isRefundable()
7 {
8+ if (!result.contains("price"))
9+ {
10+ return false;
11+ }
12+
13 if (pay_package.isNull())
14 {
15 return false;
16@@ -796,7 +801,7 @@
17 getApplicationUri(manifest, [this, reply, manifest, app_name, &review, userid](const std::string& uri) {
18 populateDetails([this, reply, uri, manifest, app_name](const PackageDetails &details){
19 store_department(details);
20- pushPackagePreviewWidgets(reply, details, createButtons(uri, manifest, details));
21+ pushPackagePreviewWidgets(reply, details, createButtons(uri, manifest));
22 },
23 [this, reply, &review, manifest, userid](const ReviewList& reviewlist,
24 click::Reviews::Error error) {
25@@ -836,8 +841,7 @@
26 }
27
28 scopes::PreviewWidgetList InstalledPreview::createButtons(const std::string& uri,
29- const Manifest& manifest,
30- const PackageDetails& details)
31+ const Manifest& manifest)
32 {
33 scopes::PreviewWidgetList widgets;
34 scopes::PreviewWidget buttons("buttons", "actions");
35@@ -862,7 +866,8 @@
36 }
37 if (manifest.removable)
38 {
39- if (details.package.price > 0.00f && isRefundable()) {
40+ auto price = result.contains("price") ? result["price"].get_double() : 0.00f;
41+ if (price > 0.00f && isRefundable()) {
42 builder.add_tuple({
43 {"id", scopes::Variant(click::Preview::Actions::CANCEL_PURCHASE_INSTALLED)},
44 {"label", scopes::Variant(_("Cancel Purchase"))}
45
46=== modified file 'libclickscope/click/preview.h'
47--- libclickscope/click/preview.h 2015-08-06 20:07:24 +0000
48+++ libclickscope/click/preview.h 2015-08-24 18:05:31 +0000
49@@ -225,8 +225,7 @@
50 void getApplicationUri(const Manifest& manifest, std::function<void(const std::string&)> callback);
51 std::string get_consumer_key();
52 scopes::PreviewWidgetList createButtons(const std::string& uri,
53- const click::Manifest& manifest,
54- const PackageDetails& details);
55+ const click::Manifest& manifest);
56 private:
57 scopes::ActionMetadata metadata;
58 };
59
60=== modified file 'libclickscope/tests/test_preview.cpp'
61--- libclickscope/tests/test_preview.cpp 2015-08-06 20:07:24 +0000
62+++ libclickscope/tests/test_preview.cpp 2015-08-24 18:05:31 +0000
63@@ -487,26 +487,35 @@
64 MOCK_METHOD0(isRefundable, bool());
65 };
66
67-TEST_F(InstalledPreviewTest, testIsRefundableButtonShown) {
68+TEST_F(InstalledPreviewTest, testIsRefundableButtonShownFromStore) {
69+ result["price"] = 3.99f;
70 FakeInstalledRefundablePreview preview(result, metadata, client, pay_package, depts);
71 EXPECT_CALL(preview, isRefundable()).Times(1)
72 .WillOnce(Return(true));
73 click::Manifest manifest;
74 manifest.removable = true;
75- click::PackageDetails details;
76- details.package.price = 0.99f;
77- auto widgets = preview.createButtons("fake uri", manifest, details);
78+ auto widgets = preview.createButtons("fake uri", manifest);
79 ASSERT_EQ(get_actions_from_widgets(widgets, 0).size(), 2);
80 ASSERT_EQ(get_action_from_widgets(widgets, 0, 1), "cancel_purchase_installed");
81 }
82
83+TEST_F(InstalledPreviewTest, testIsRefundableButtonNotShownFromApps) {
84+ FakeInstalledRefundablePreview preview(result, metadata, client, pay_package, depts);
85+ EXPECT_CALL(preview, isRefundable()).Times(0);
86+ click::Manifest manifest;
87+ manifest.removable = true;
88+ auto widgets = preview.createButtons("fake uri", manifest);
89+ ASSERT_EQ(get_actions_from_widgets(widgets, 0).size(), 2);
90+ ASSERT_EQ(get_action_from_widgets(widgets, 0, 1), "uninstall_click");
91+}
92+
93 TEST_F(InstalledPreviewTest, testIsRefundableButtonNotShown) {
94 FakeInstalledRefundablePreview preview(result, metadata, client, pay_package, depts);
95 EXPECT_CALL(preview, isRefundable()).Times(0);
96 click::Manifest manifest;
97 manifest.removable = true;
98 click::PackageDetails details;
99- auto widgets = preview.createButtons("fake uri", manifest, details);
100+ auto widgets = preview.createButtons("fake uri", manifest);
101 ASSERT_EQ(get_actions_from_widgets(widgets, 0).size(), 2);
102 ASSERT_EQ(get_action_from_widgets(widgets, 0, 1), "uninstall_click");
103 }
104
105=== modified file 'scope/clickapps/apps-scope.cpp'
106--- scope/clickapps/apps-scope.cpp 2015-06-30 14:03:57 +0000
107+++ scope/clickapps/apps-scope.cpp 2015-08-24 18:05:31 +0000
108@@ -132,6 +132,12 @@
109 } else if (action_id == click::Preview::Actions::SHOW_UNINSTALLED) {
110 activation->setHint(click::Preview::Actions::SHOW_UNINSTALLED, unity::scopes::Variant(true));
111 activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview);
112+ } else if (action_id == click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_UNINSTALLED) {
113+ activation->setHint(click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_UNINSTALLED, unity::scopes::Variant(true));
114+ activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview);
115+ } else if (action_id == click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_INSTALLED) {
116+ activation->setHint(click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_INSTALLED, unity::scopes::Variant(true));
117+ activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview);
118 } else if (action_id == click::Preview::Actions::RATED) {
119 scopes::VariantMap rating_info = metadata.scope_data().get_dict();
120 // Cast to int because widget gives us double, which is wrong.
121
122=== modified file 'scope/tests/test_apps_scope.cpp'
123--- scope/tests/test_apps_scope.cpp 2015-08-18 01:44:50 +0000
124+++ scope/tests/test_apps_scope.cpp 2015-08-24 18:05:31 +0000
125@@ -95,6 +95,22 @@
126 EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::SHOW_UNINSTALLED].get_bool());
127 }
128
129+TEST_F(AppsScopeTest, testConfirmCancelPurchaseUninstalled)
130+{
131+ auto activation = scope.perform_action(result, metadata, "widget_id",
132+ click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_UNINSTALLED);
133+ auto response = activation->activate();
134+ EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_UNINSTALLED].get_bool());
135+}
136+
137+TEST_F(AppsScopeTest, testConfirmCancelPurcahseInstalled)
138+{
139+ auto activation = scope.perform_action(result, metadata, "widget_id",
140+ click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_INSTALLED);
141+ auto response = activation->activate();
142+ EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_INSTALLED].get_bool());
143+}
144+
145 TEST_F(AppsScopeTest, testRatingNew)
146 {
147 auto activation = scope.perform_action(result, metadata, "rating",

Subscribers

People subscribed via source and target branches

to all changes: