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
=== modified file 'libclickscope/click/preview.cpp'
--- libclickscope/click/preview.cpp 2015-08-06 20:07:24 +0000
+++ libclickscope/click/preview.cpp 2015-08-24 18:05:31 +0000
@@ -549,6 +549,11 @@
549549
550bool PreviewStrategy::isRefundable()550bool PreviewStrategy::isRefundable()
551{551{
552 if (!result.contains("price"))
553 {
554 return false;
555 }
556
552 if (pay_package.isNull())557 if (pay_package.isNull())
553 {558 {
554 return false;559 return false;
@@ -796,7 +801,7 @@
796 getApplicationUri(manifest, [this, reply, manifest, app_name, &review, userid](const std::string& uri) {801 getApplicationUri(manifest, [this, reply, manifest, app_name, &review, userid](const std::string& uri) {
797 populateDetails([this, reply, uri, manifest, app_name](const PackageDetails &details){802 populateDetails([this, reply, uri, manifest, app_name](const PackageDetails &details){
798 store_department(details);803 store_department(details);
799 pushPackagePreviewWidgets(reply, details, createButtons(uri, manifest, details));804 pushPackagePreviewWidgets(reply, details, createButtons(uri, manifest));
800 },805 },
801 [this, reply, &review, manifest, userid](const ReviewList& reviewlist,806 [this, reply, &review, manifest, userid](const ReviewList& reviewlist,
802 click::Reviews::Error error) {807 click::Reviews::Error error) {
@@ -836,8 +841,7 @@
836}841}
837842
838scopes::PreviewWidgetList InstalledPreview::createButtons(const std::string& uri,843scopes::PreviewWidgetList InstalledPreview::createButtons(const std::string& uri,
839 const Manifest& manifest,844 const Manifest& manifest)
840 const PackageDetails& details)
841{845{
842 scopes::PreviewWidgetList widgets;846 scopes::PreviewWidgetList widgets;
843 scopes::PreviewWidget buttons("buttons", "actions");847 scopes::PreviewWidget buttons("buttons", "actions");
@@ -862,7 +866,8 @@
862 }866 }
863 if (manifest.removable)867 if (manifest.removable)
864 {868 {
865 if (details.package.price > 0.00f && isRefundable()) {869 auto price = result.contains("price") ? result["price"].get_double() : 0.00f;
870 if (price > 0.00f && isRefundable()) {
866 builder.add_tuple({871 builder.add_tuple({
867 {"id", scopes::Variant(click::Preview::Actions::CANCEL_PURCHASE_INSTALLED)},872 {"id", scopes::Variant(click::Preview::Actions::CANCEL_PURCHASE_INSTALLED)},
868 {"label", scopes::Variant(_("Cancel Purchase"))}873 {"label", scopes::Variant(_("Cancel Purchase"))}
869874
=== modified file 'libclickscope/click/preview.h'
--- libclickscope/click/preview.h 2015-08-06 20:07:24 +0000
+++ libclickscope/click/preview.h 2015-08-24 18:05:31 +0000
@@ -225,8 +225,7 @@
225 void getApplicationUri(const Manifest& manifest, std::function<void(const std::string&)> callback);225 void getApplicationUri(const Manifest& manifest, std::function<void(const std::string&)> callback);
226 std::string get_consumer_key();226 std::string get_consumer_key();
227 scopes::PreviewWidgetList createButtons(const std::string& uri,227 scopes::PreviewWidgetList createButtons(const std::string& uri,
228 const click::Manifest& manifest,228 const click::Manifest& manifest);
229 const PackageDetails& details);
230private:229private:
231 scopes::ActionMetadata metadata;230 scopes::ActionMetadata metadata;
232};231};
233232
=== modified file 'libclickscope/tests/test_preview.cpp'
--- libclickscope/tests/test_preview.cpp 2015-08-06 20:07:24 +0000
+++ libclickscope/tests/test_preview.cpp 2015-08-24 18:05:31 +0000
@@ -487,26 +487,35 @@
487 MOCK_METHOD0(isRefundable, bool());487 MOCK_METHOD0(isRefundable, bool());
488};488};
489489
490TEST_F(InstalledPreviewTest, testIsRefundableButtonShown) {490TEST_F(InstalledPreviewTest, testIsRefundableButtonShownFromStore) {
491 result["price"] = 3.99f;
491 FakeInstalledRefundablePreview preview(result, metadata, client, pay_package, depts);492 FakeInstalledRefundablePreview preview(result, metadata, client, pay_package, depts);
492 EXPECT_CALL(preview, isRefundable()).Times(1)493 EXPECT_CALL(preview, isRefundable()).Times(1)
493 .WillOnce(Return(true));494 .WillOnce(Return(true));
494 click::Manifest manifest;495 click::Manifest manifest;
495 manifest.removable = true;496 manifest.removable = true;
496 click::PackageDetails details;497 auto widgets = preview.createButtons("fake uri", manifest);
497 details.package.price = 0.99f;
498 auto widgets = preview.createButtons("fake uri", manifest, details);
499 ASSERT_EQ(get_actions_from_widgets(widgets, 0).size(), 2);498 ASSERT_EQ(get_actions_from_widgets(widgets, 0).size(), 2);
500 ASSERT_EQ(get_action_from_widgets(widgets, 0, 1), "cancel_purchase_installed");499 ASSERT_EQ(get_action_from_widgets(widgets, 0, 1), "cancel_purchase_installed");
501}500}
502501
502TEST_F(InstalledPreviewTest, testIsRefundableButtonNotShownFromApps) {
503 FakeInstalledRefundablePreview preview(result, metadata, client, pay_package, depts);
504 EXPECT_CALL(preview, isRefundable()).Times(0);
505 click::Manifest manifest;
506 manifest.removable = true;
507 auto widgets = preview.createButtons("fake uri", manifest);
508 ASSERT_EQ(get_actions_from_widgets(widgets, 0).size(), 2);
509 ASSERT_EQ(get_action_from_widgets(widgets, 0, 1), "uninstall_click");
510}
511
503TEST_F(InstalledPreviewTest, testIsRefundableButtonNotShown) {512TEST_F(InstalledPreviewTest, testIsRefundableButtonNotShown) {
504 FakeInstalledRefundablePreview preview(result, metadata, client, pay_package, depts);513 FakeInstalledRefundablePreview preview(result, metadata, client, pay_package, depts);
505 EXPECT_CALL(preview, isRefundable()).Times(0);514 EXPECT_CALL(preview, isRefundable()).Times(0);
506 click::Manifest manifest;515 click::Manifest manifest;
507 manifest.removable = true;516 manifest.removable = true;
508 click::PackageDetails details;517 click::PackageDetails details;
509 auto widgets = preview.createButtons("fake uri", manifest, details);518 auto widgets = preview.createButtons("fake uri", manifest);
510 ASSERT_EQ(get_actions_from_widgets(widgets, 0).size(), 2);519 ASSERT_EQ(get_actions_from_widgets(widgets, 0).size(), 2);
511 ASSERT_EQ(get_action_from_widgets(widgets, 0, 1), "uninstall_click");520 ASSERT_EQ(get_action_from_widgets(widgets, 0, 1), "uninstall_click");
512}521}
513522
=== modified file 'scope/clickapps/apps-scope.cpp'
--- scope/clickapps/apps-scope.cpp 2015-06-30 14:03:57 +0000
+++ scope/clickapps/apps-scope.cpp 2015-08-24 18:05:31 +0000
@@ -132,6 +132,12 @@
132 } else if (action_id == click::Preview::Actions::SHOW_UNINSTALLED) {132 } else if (action_id == click::Preview::Actions::SHOW_UNINSTALLED) {
133 activation->setHint(click::Preview::Actions::SHOW_UNINSTALLED, unity::scopes::Variant(true));133 activation->setHint(click::Preview::Actions::SHOW_UNINSTALLED, unity::scopes::Variant(true));
134 activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview);134 activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview);
135 } else if (action_id == click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_UNINSTALLED) {
136 activation->setHint(click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_UNINSTALLED, unity::scopes::Variant(true));
137 activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview);
138 } else if (action_id == click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_INSTALLED) {
139 activation->setHint(click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_INSTALLED, unity::scopes::Variant(true));
140 activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview);
135 } else if (action_id == click::Preview::Actions::RATED) {141 } else if (action_id == click::Preview::Actions::RATED) {
136 scopes::VariantMap rating_info = metadata.scope_data().get_dict();142 scopes::VariantMap rating_info = metadata.scope_data().get_dict();
137 // Cast to int because widget gives us double, which is wrong.143 // Cast to int because widget gives us double, which is wrong.
138144
=== modified file 'scope/tests/test_apps_scope.cpp'
--- scope/tests/test_apps_scope.cpp 2015-08-18 01:44:50 +0000
+++ scope/tests/test_apps_scope.cpp 2015-08-24 18:05:31 +0000
@@ -95,6 +95,22 @@
95 EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::SHOW_UNINSTALLED].get_bool());95 EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::SHOW_UNINSTALLED].get_bool());
96}96}
9797
98TEST_F(AppsScopeTest, testConfirmCancelPurchaseUninstalled)
99{
100 auto activation = scope.perform_action(result, metadata, "widget_id",
101 click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_UNINSTALLED);
102 auto response = activation->activate();
103 EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_UNINSTALLED].get_bool());
104}
105
106TEST_F(AppsScopeTest, testConfirmCancelPurcahseInstalled)
107{
108 auto activation = scope.perform_action(result, metadata, "widget_id",
109 click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_INSTALLED);
110 auto response = activation->activate();
111 EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_INSTALLED].get_bool());
112}
113
98TEST_F(AppsScopeTest, testRatingNew)114TEST_F(AppsScopeTest, testRatingNew)
99{115{
100 auto activation = scope.perform_action(result, metadata, "rating",116 auto activation = scope.perform_action(result, metadata, "rating",

Subscribers

People subscribed via source and target branches

to all changes: