Merge lp:~dobey/unity-scope-click/hide-cancel-purchase-vivid into lp:unity-scope-click/touch-15-04

Proposed by dobey
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 334
Merged at revision: 333
Proposed branch: lp:~dobey/unity-scope-click/hide-cancel-purchase-vivid
Merge into: lp:unity-scope-click/touch-15-04
Diff against target: 356 lines (+197/-23)
6 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 (+69/-8)
scope/tests/test_store_scope.cpp (+98/-4)
To merge this branch: bzr merge lp:~dobey/unity-scope-click/hide-cancel-purchase-vivid
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+269980@code.launchpad.net

Commit message

Only show Cancel Purchase button from within store scope for now.
Add more test coverage for conditionals.

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
Alejandro J. Cura (alecu) wrote :

Backported from trunk, looks right.

review: Approve

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-05 14:37:36 +0000
3+++ libclickscope/click/preview.cpp 2015-09-02 20:39:57 +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-05 14:37:36 +0000
48+++ libclickscope/click/preview.h 2015-09-02 20:39:57 +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-05 14:37:36 +0000
62+++ libclickscope/tests/test_preview.cpp 2015-09-02 20:39:57 +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-07-06 18:42:06 +0000
107+++ scope/clickapps/apps-scope.cpp 2015-09-02 20:39:57 +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-17 17:49:34 +0000
124+++ scope/tests/test_apps_scope.cpp 2015-09-02 20:39:57 +0000
125@@ -27,14 +27,15 @@
126 * files in the program, then also delete it here.
127 */
128
129+#include <clickapps/apps-scope.h>
130+#include <click/preview.h>
131+#include <clickapps/apps-query.h>
132+
133 #include <gtest/gtest.h>
134 #include <gmock/gmock.h>
135
136 #include <unity/scopes/testing/Result.h>
137
138-#include <click/preview.h>
139-#include <clickapps/apps-scope.h>
140-
141 using namespace ::testing;
142
143 class AppsScopeTest : public Test {
144@@ -52,16 +53,76 @@
145 }
146 };
147
148-TEST_F(AppsScopeTest, testStoreScopeRatingNew)
149-{
150- auto activation = scope.perform_action(result, metadata, "rating", click::Preview::Actions::RATED);
151+TEST_F(AppsScopeTest, DISABLED_testConfirmUninstall)
152+{
153+ result.set_title("foo");
154+ result[click::apps::Query::ResultKeys::NAME] = "foo.name";
155+ result[click::apps::Query::ResultKeys::VERSION] = "0.1";
156+ auto activation = scope.perform_action(result, metadata, "widget",
157+ click::Preview::Actions::CONFIRM_UNINSTALL);
158+ auto response = activation->activate();
159+}
160+
161+TEST_F(AppsScopeTest, testCancelPurchaseInstalled)
162+{
163+ auto activation = scope.perform_action(result, metadata, "button",
164+ click::Preview::Actions::CANCEL_PURCHASE_INSTALLED);
165+ auto response = activation->activate();
166+ EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::CANCEL_PURCHASE_INSTALLED].get_bool());
167+}
168+
169+TEST_F(AppsScopeTest, testCancelPurchaseUninstalled)
170+{
171+ auto activation = scope.perform_action(result, metadata, "button",
172+ click::Preview::Actions::CANCEL_PURCHASE_UNINSTALLED);
173+ auto response = activation->activate();
174+ EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::CANCEL_PURCHASE_UNINSTALLED].get_bool());
175+}
176+
177+TEST_F(AppsScopeTest, testShowInstalled)
178+{
179+ auto activation = scope.perform_action(result, metadata, "button",
180+ click::Preview::Actions::SHOW_INSTALLED);
181+ auto response = activation->activate();
182+ EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::SHOW_INSTALLED].get_bool());
183+}
184+
185+TEST_F(AppsScopeTest, testShowUninstalled)
186+{
187+ auto activation = scope.perform_action(result, metadata, "button",
188+ click::Preview::Actions::SHOW_UNINSTALLED);
189+ auto response = activation->activate();
190+ EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::SHOW_UNINSTALLED].get_bool());
191+}
192+
193+TEST_F(AppsScopeTest, testConfirmCancelPurchaseUninstalled)
194+{
195+ auto activation = scope.perform_action(result, metadata, "widget_id",
196+ click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_UNINSTALLED);
197+ auto response = activation->activate();
198+ EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_UNINSTALLED].get_bool());
199+}
200+
201+TEST_F(AppsScopeTest, testConfirmCancelPurcahseInstalled)
202+{
203+ auto activation = scope.perform_action(result, metadata, "widget_id",
204+ click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_INSTALLED);
205+ auto response = activation->activate();
206+ EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_INSTALLED].get_bool());
207+}
208+
209+TEST_F(AppsScopeTest, testRatingNew)
210+{
211+ auto activation = scope.perform_action(result, metadata, "rating",
212+ click::Preview::Actions::RATED);
213 auto response = activation->activate();
214 EXPECT_EQ("rating", response.scope_data().get_dict()["widget_id"].get_string());
215 }
216
217-TEST_F(AppsScopeTest, testStoreScopeRatingEdit)
218+TEST_F(AppsScopeTest, testRatingEdit)
219 {
220- auto activation = scope.perform_action(result, metadata, "93345", click::Preview::Actions::RATED);
221+ auto activation = scope.perform_action(result, metadata, "93345",
222+ click::Preview::Actions::RATED);
223 auto response = activation->activate();
224 EXPECT_EQ("93345", response.scope_data().get_dict()["widget_id"].get_string());
225 }
226
227=== modified file 'scope/tests/test_store_scope.cpp'
228--- scope/tests/test_store_scope.cpp 2015-08-17 17:49:34 +0000
229+++ scope/tests/test_store_scope.cpp 2015-09-02 20:39:57 +0000
230@@ -57,28 +57,122 @@
231
232 TEST_F(StoreScopeTest, testPurchaseCompletedPassesHash)
233 {
234- auto activation = scope.perform_action(result, metadata, "widget_id", "purchaseCompleted");
235+ auto activation = scope.perform_action(result, metadata, "widget_id",
236+ "purchaseCompleted");
237 auto response = activation->activate();
238 EXPECT_EQ(FAKE_SHA512, response.scope_data().get_dict()["download_sha512"].get_string());
239+ EXPECT_TRUE(response.scope_data().get_dict()["purchased"].get_bool());
240+}
241+
242+TEST_F(StoreScopeTest, testPurchaseError)
243+{
244+ auto activation = scope.perform_action(result, metadata, "widget_id",
245+ "purchaseError");
246+ auto response = activation->activate();
247+ EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::DOWNLOAD_FAILED].get_bool());
248 }
249
250 TEST_F(StoreScopeTest, testInstallClickPassesHash)
251 {
252- auto activation = scope.perform_action(result, metadata, "widget_id", click::Preview::Actions::INSTALL_CLICK);
253+ auto activation = scope.perform_action(result, metadata, "widget_id",
254+ click::Preview::Actions::INSTALL_CLICK);
255 auto response = activation->activate();
256 EXPECT_EQ(FAKE_SHA512, response.scope_data().get_dict()["download_sha512"].get_string());
257 }
258
259+TEST_F(StoreScopeTest, testDownloadFailed)
260+{
261+ auto activation = scope.perform_action(result, metadata, "widget_id",
262+ click::Preview::Actions::DOWNLOAD_FAILED);
263+ auto response = activation->activate();
264+ EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::DOWNLOAD_FAILED].get_bool());
265+}
266+
267+TEST_F(StoreScopeTest, testDownloadCompleted)
268+{
269+ auto activation = scope.perform_action(result, metadata, "widget_id",
270+ click::Preview::Actions::DOWNLOAD_COMPLETED);
271+ auto response = activation->activate();
272+ EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::DOWNLOAD_COMPLETED].get_bool());
273+ EXPECT_TRUE(response.scope_data().get_dict()["installed"].get_bool());
274+}
275+
276+TEST_F(StoreScopeTest, testCancelPurchaseInstalled)
277+{
278+ auto activation = scope.perform_action(result, metadata, "widget_id",
279+ click::Preview::Actions::CANCEL_PURCHASE_INSTALLED);
280+ auto response = activation->activate();
281+ EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::CANCEL_PURCHASE_INSTALLED].get_bool());
282+}
283+
284+TEST_F(StoreScopeTest, testCancelPurchaseUninstalled)
285+{
286+ auto activation = scope.perform_action(result, metadata, "widget_id",
287+ click::Preview::Actions::CANCEL_PURCHASE_UNINSTALLED);
288+ auto response = activation->activate();
289+ EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::CANCEL_PURCHASE_UNINSTALLED].get_bool());
290+}
291+
292+TEST_F(StoreScopeTest, testUninstallClick)
293+{
294+ auto activation = scope.perform_action(result, metadata, "widget_id",
295+ click::Preview::Actions::UNINSTALL_CLICK);
296+ auto response = activation->activate();
297+ EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::UNINSTALL_CLICK].get_bool());
298+}
299+
300+TEST_F(StoreScopeTest, testShowUninstalled)
301+{
302+ auto activation = scope.perform_action(result, metadata, "widget_id",
303+ click::Preview::Actions::SHOW_UNINSTALLED);
304+ auto response = activation->activate();
305+ EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::SHOW_UNINSTALLED].get_bool());
306+}
307+
308+TEST_F(StoreScopeTest, testShowInstalled)
309+{
310+ auto activation = scope.perform_action(result, metadata, "widget_id",
311+ click::Preview::Actions::SHOW_INSTALLED);
312+ auto response = activation->activate();
313+ EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::SHOW_INSTALLED].get_bool());
314+}
315+
316+TEST_F(StoreScopeTest, testConfirmUninstall)
317+{
318+ auto activation = scope.perform_action(result, metadata, "widget_id",
319+ click::Preview::Actions::CONFIRM_UNINSTALL);
320+ auto response = activation->activate();
321+ EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::CONFIRM_UNINSTALL].get_bool());
322+}
323+
324+TEST_F(StoreScopeTest, testConfirmCancelPurchaseUninstalled)
325+{
326+ auto activation = scope.perform_action(result, metadata, "widget_id",
327+ click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_UNINSTALLED);
328+ auto response = activation->activate();
329+ EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_UNINSTALLED].get_bool());
330+}
331+
332+TEST_F(StoreScopeTest, testConfirmCancelPurcahseInstalled)
333+{
334+ auto activation = scope.perform_action(result, metadata, "widget_id",
335+ click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_INSTALLED);
336+ auto response = activation->activate();
337+ EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_INSTALLED].get_bool());
338+}
339+
340 TEST_F(StoreScopeTest, testStoreScopeRatingNew)
341 {
342- auto activation = scope.perform_action(result, metadata, "rating", click::Preview::Actions::RATED);
343+ auto activation = scope.perform_action(result, metadata, "rating",
344+ click::Preview::Actions::RATED);
345 auto response = activation->activate();
346 EXPECT_EQ("rating", response.scope_data().get_dict()["widget_id"].get_string());
347 }
348
349 TEST_F(StoreScopeTest, testStoreScopeRatingEdit)
350 {
351- auto activation = scope.perform_action(result, metadata, "93345", click::Preview::Actions::RATED);
352+ auto activation = scope.perform_action(result, metadata, "93345",
353+ click::Preview::Actions::RATED);
354 auto response = activation->activate();
355 EXPECT_EQ("93345", response.scope_data().get_dict()["widget_id"].get_string());
356 }

Subscribers

People subscribed via source and target branches

to all changes: