Merge lp:~dobey/unity-scope-click/rate-widget-id into lp:unity-scope-click/touch-15-04

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 331
Merged at revision: 331
Proposed branch: lp:~dobey/unity-scope-click/rate-widget-id
Merge into: lp:unity-scope-click/touch-15-04
Diff against target: 140 lines (+87/-2)
4 files modified
scope/clickstore/store-scope.cpp (+2/-1)
scope/tests/CMakeLists.txt (+1/-0)
scope/tests/test_apps_scope.cpp (+67/-0)
scope/tests/test_store_scope.cpp (+17/-1)
To merge this branch: bzr merge lp:~dobey/unity-scope-click/rate-widget-id
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Kyle Fazzari (community) Approve
Review via email: mp+268260@code.launchpad.net

Commit message

Add missing setting of widget_id when rating from store scope.
Add tests.

To post a comment you must log in.
Revision history for this message
Kyle Fazzari (kyrofa) wrote :

Looks good to me.

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 'scope/clickstore/store-scope.cpp'
2--- scope/clickstore/store-scope.cpp 2015-07-07 02:48:20 +0000
3+++ scope/clickstore/store-scope.cpp 2015-08-17 17:53:00 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright (C) 2014 Canonical Ltd.
7+ * Copyright (C) 2014-2015 Canonical Ltd.
8 *
9 * This program is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 3, as published
11@@ -184,6 +184,7 @@
12 activation->setHint("review", scopes::Variant(review_text));
13 activation->setHint(click::Preview::Actions::RATED,
14 scopes::Variant(true));
15+ activation->setHint("widget_id", scopes::Variant(widget_id));
16 activation->setStatus(scopes::ActivationResponse::Status::ShowPreview);
17 }
18 return scopes::ActivationQueryBase::UPtr(activation);
19
20=== modified file 'scope/tests/CMakeLists.txt'
21--- scope/tests/CMakeLists.txt 2015-04-14 20:43:12 +0000
22+++ scope/tests/CMakeLists.txt 2015-08-17 17:53:00 +0000
23@@ -26,6 +26,7 @@
24
25 add_executable (${APPS_SCOPE_TESTS_TARGET}
26 test_apps_query.cpp
27+ test_apps_scope.cpp
28 )
29
30 qt5_use_modules(${CLICKSCOPE_TESTS_TARGET} Core DBus Network Test Sql)
31
32=== added file 'scope/tests/test_apps_scope.cpp'
33--- scope/tests/test_apps_scope.cpp 1970-01-01 00:00:00 +0000
34+++ scope/tests/test_apps_scope.cpp 2015-08-17 17:53:00 +0000
35@@ -0,0 +1,67 @@
36+/*
37+ * Copyright (C) 2015 Canonical Ltd.
38+ *
39+ * This program is free software: you can redistribute it and/or modify it
40+ * under the terms of the GNU General Public License version 3, as published
41+ * by the Free Software Foundation.
42+ *
43+ * This program is distributed in the hope that it will be useful, but
44+ * WITHOUT ANY WARRANTY; without even the implied warranties of
45+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
46+ * PURPOSE. See the GNU General Public License for more details.
47+ *
48+ * You should have received a copy of the GNU General Public License along
49+ * with this program. If not, see <http://www.gnu.org/licenses/>.
50+ *
51+ * In addition, as a special exception, the copyright holders give
52+ * permission to link the code of portions of this program with the
53+ * OpenSSL library under certain conditions as described in each
54+ * individual source file, and distribute linked combinations
55+ * including the two.
56+ * You must obey the GNU General Public License in all respects
57+ * for all of the code used other than OpenSSL. If you modify
58+ * file(s) with this exception, you may extend this exception to your
59+ * version of the file(s), but you are not obligated to do so. If you
60+ * do not wish to do so, delete this exception statement from your
61+ * version. If you delete this exception statement from all source
62+ * files in the program, then also delete it here.
63+ */
64+
65+#include <gtest/gtest.h>
66+#include <gmock/gmock.h>
67+
68+#include <unity/scopes/testing/Result.h>
69+
70+#include <click/preview.h>
71+#include <clickapps/apps-scope.h>
72+
73+using namespace ::testing;
74+
75+class AppsScopeTest : public Test {
76+protected:
77+ click::Scope scope;
78+ unity::scopes::testing::Result result;
79+ unity::scopes::ActionMetadata metadata;
80+ unity::scopes::VariantMap metadict;
81+
82+public:
83+ AppsScopeTest() : metadata("en_EN", "phone") {
84+ metadict["rating"] = unity::scopes::Variant(4.0f);
85+ metadict["review"] = "This is a review.";
86+ metadata.set_scope_data(unity::scopes::Variant(metadict));
87+ }
88+};
89+
90+TEST_F(AppsScopeTest, testStoreScopeRatingNew)
91+{
92+ auto activation = scope.perform_action(result, metadata, "rating", click::Preview::Actions::RATED);
93+ auto response = activation->activate();
94+ EXPECT_EQ("rating", response.scope_data().get_dict()["widget_id"].get_string());
95+}
96+
97+TEST_F(AppsScopeTest, testStoreScopeRatingEdit)
98+{
99+ auto activation = scope.perform_action(result, metadata, "93345", click::Preview::Actions::RATED);
100+ auto response = activation->activate();
101+ EXPECT_EQ("93345", response.scope_data().get_dict()["widget_id"].get_string());
102+}
103
104=== modified file 'scope/tests/test_store_scope.cpp'
105--- scope/tests/test_store_scope.cpp 2014-08-13 14:43:32 +0000
106+++ scope/tests/test_store_scope.cpp 2015-08-17 17:53:00 +0000
107@@ -1,5 +1,5 @@
108 /*
109- * Copyright (C) 2014 Canonical Ltd.
110+ * Copyright (C) 2014-2015 Canonical Ltd.
111 *
112 * This program is free software: you can redistribute it and/or modify it
113 * under the terms of the GNU General Public License version 3, as published
114@@ -49,6 +49,8 @@
115 StoreScopeTest() : metadata("en_EN", "phone") {
116 metadict["download_url"] = "fake_download_url";
117 metadict["download_sha512"] = FAKE_SHA512;
118+ metadict["rating"] = unity::scopes::Variant(4.0f);
119+ metadict["review"] = "This is a review.";
120 metadata.set_scope_data(unity::scopes::Variant(metadict));
121 }
122 };
123@@ -66,3 +68,17 @@
124 auto response = activation->activate();
125 EXPECT_EQ(FAKE_SHA512, response.scope_data().get_dict()["download_sha512"].get_string());
126 }
127+
128+TEST_F(StoreScopeTest, testStoreScopeRatingNew)
129+{
130+ auto activation = scope.perform_action(result, metadata, "rating", click::Preview::Actions::RATED);
131+ auto response = activation->activate();
132+ EXPECT_EQ("rating", response.scope_data().get_dict()["widget_id"].get_string());
133+}
134+
135+TEST_F(StoreScopeTest, testStoreScopeRatingEdit)
136+{
137+ auto activation = scope.perform_action(result, metadata, "93345", click::Preview::Actions::RATED);
138+ auto response = activation->activate();
139+ EXPECT_EQ("93345", response.scope_data().get_dict()["widget_id"].get_string());
140+}

Subscribers

People subscribed via source and target branches

to all changes: