~ci-train-bot/unity-scope-click/unity-scope-click-ubuntu-zesty-2172

« back to all changes in this revision

Viewing changes to libclickscope/tests/mock_pay.h

  • Committer: Bileto Bot
  • Author(s): Rodney Dawes
  • Date: 2016-10-25 17:38:18 UTC
  • mfrom: (492.1.4 rm-store-pay)
  • Revision ID: ci-train-bot@canonical.com-20161025173818-tts28j35xx0uy8ty
Remove the store scope code and libpay usage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2014 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 <click/pay.h>
31
 
 
32
 
#include <click/webclient.h>
33
 
 
34
 
#include <gtest/gtest.h>
35
 
#include <gmock/gmock.h>
36
 
 
37
 
 
38
 
namespace
39
 
{
40
 
 
41
 
    constexpr static const char* FAKE_PURCHASES_LIST_JSON{R"foo(
42
 
            [
43
 
                {
44
 
                    "state": "Complete",
45
 
                    "package_name": "com.example.fake",
46
 
                    "refundable_until": "1970-01-01T00:01:23Z",
47
 
                    "open_id": "https:\/\/login.ubuntu.com/+openid/fakeuser"
48
 
                }
49
 
            ]
50
 
        )foo"};
51
 
 
52
 
 
53
 
    constexpr static const char* FAKE_PURCHASES_LIST_JSON_NULL_TIMESTAMP{R"foo(
54
 
            [
55
 
                {
56
 
                    "state": "Complete",
57
 
                    "package_name": "com.example.fake",
58
 
                    "refundable_until": null,
59
 
                    "open_id": "https:\/\/login.ubuntu.com/+openid/fakeuser"
60
 
                }
61
 
            ]
62
 
        )foo"};
63
 
 
64
 
 
65
 
 
66
 
    class MockPayPackage : public pay::Package {
67
 
    public:
68
 
        MockPayPackage()
69
 
            : Package(QSharedPointer<click::web::Client>())
70
 
        {
71
 
        }
72
 
 
73
 
        MockPayPackage(const QSharedPointer<click::web::Client>& client)
74
 
            : Package(client)
75
 
        {
76
 
        }
77
 
 
78
 
        void pay_package_refund(const std::string& pkg_name)
79
 
        {
80
 
            callbacks[pkg_name + pay::APPENDAGE_REFUND](pkg_name, success);
81
 
            do_pay_package_refund(pkg_name);
82
 
        }
83
 
 
84
 
        void pay_package_verify(const std::string& pkg_name)
85
 
        {
86
 
            callbacks[pkg_name + pay::APPENDAGE_VERIFY](pkg_name, success);
87
 
            do_pay_package_verify(pkg_name);
88
 
        }
89
 
 
90
 
        bool is_refundable(const std::string& pkg_name)
91
 
        {
92
 
            do_is_refundable(pkg_name);
93
 
            return refundable;
94
 
        }
95
 
 
96
 
        MOCK_METHOD0(setup_pay_service, void());
97
 
        MOCK_METHOD1(do_pay_package_refund, void(const std::string&));
98
 
        MOCK_METHOD1(do_pay_package_verify, void(const std::string&));
99
 
        MOCK_METHOD1(do_is_refundable, void(const std::string&));
100
 
 
101
 
        bool refundable = false;
102
 
        bool success = false;
103
 
        pay::PurchaseSet purchases;
104
 
};
105
 
 
106
 
} // namespace