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

Subscribers

People subscribed via source and target branches

to all changes: