OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_MOCK_WALLET_CLIENT_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_MOCK_WALLET_CLIENT_H_ |
6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_MOCK_WALLET_CLIENT_H_ | 6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_MOCK_WALLET_CLIENT_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "components/autofill/content/browser/wallet/instrument.h" | 11 #include "components/autofill/content/browser/wallet/instrument.h" |
12 #include "components/autofill/content/browser/wallet/wallet_address.h" | 12 #include "components/autofill/content/browser/wallet/wallet_address.h" |
13 #include "components/autofill/content/browser/wallet/wallet_client.h" | 13 #include "components/autofill/content/browser/wallet/wallet_client.h" |
14 #include "components/autofill/content/browser/wallet/wallet_items.h" | 14 #include "components/autofill/content/browser/wallet/wallet_items.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
16 | 16 |
17 namespace autofill { | 17 namespace autofill { |
18 namespace wallet { | 18 namespace wallet { |
19 | 19 |
20 // A mock version of WalletClient that never issues real requests, just records | 20 // A mock version of WalletClient that never issues real requests, just records |
21 // mock calls to each entry point. | 21 // mock calls to each entry point. |
22 class MockWalletClient : public WalletClient { | 22 class MockWalletClient : public WalletClient { |
23 public: | 23 public: |
24 MockWalletClient(net::URLRequestContextGetter* context, | 24 MockWalletClient(net::URLRequestContextGetter* context, |
25 WalletClientDelegate* delegate, | 25 WalletClientDelegate* delegate, |
26 const GURL& source_url); | 26 const GURL& source_url); |
27 virtual ~MockWalletClient(); | 27 ~MockWalletClient() override; |
28 | 28 |
29 MOCK_METHOD2(GetWalletItems, | 29 MOCK_METHOD2(GetWalletItems, |
30 void(const base::string16&, const base::string16&)); | 30 void(const base::string16&, const base::string16&)); |
31 | 31 |
32 MOCK_METHOD2(AcceptLegalDocuments, | 32 MOCK_METHOD2(AcceptLegalDocuments, |
33 void(const std::vector<WalletItems::LegalDocument*>& documents, | 33 void(const std::vector<WalletItems::LegalDocument*>& documents, |
34 const std::string& google_transaction_id)); | 34 const std::string& google_transaction_id)); |
35 | 35 |
36 MOCK_METHOD2(AuthenticateInstrument, | 36 MOCK_METHOD2(AuthenticateInstrument, |
37 void(const std::string& instrument_id, | 37 void(const std::string& instrument_id, |
38 const std::string& card_verification_number)); | 38 const std::string& card_verification_number)); |
39 | 39 |
40 MOCK_METHOD1(GetFullWallet, | 40 MOCK_METHOD1(GetFullWallet, |
41 void(const WalletClient::FullWalletRequest& request)); | 41 void(const WalletClient::FullWalletRequest& request)); |
42 | 42 |
43 // Methods with scoped_ptrs can't be mocked but by using the implementation | 43 // Methods with scoped_ptrs can't be mocked but by using the implementation |
44 // below the same effect can be achieved. | 44 // below the same effect can be achieved. |
45 virtual void SaveToWallet( | 45 void SaveToWallet( |
46 scoped_ptr<Instrument> instrument, | 46 scoped_ptr<Instrument> instrument, |
47 scoped_ptr<Address> address, | 47 scoped_ptr<Address> address, |
48 const WalletItems::MaskedInstrument* reference_instrument, | 48 const WalletItems::MaskedInstrument* reference_instrument, |
49 const Address* reference_address) override; | 49 const Address* reference_address) override; |
50 | 50 |
51 MOCK_METHOD4(SaveToWalletMock, | 51 MOCK_METHOD4(SaveToWalletMock, |
52 void(Instrument* instrument, | 52 void(Instrument* instrument, |
53 Address* address, | 53 Address* address, |
54 const WalletItems::MaskedInstrument* reference_instrument, | 54 const WalletItems::MaskedInstrument* reference_instrument, |
55 const Address* reference_address)); | 55 const Address* reference_address)); |
56 | 56 |
57 private: | 57 private: |
58 DISALLOW_COPY_AND_ASSIGN(MockWalletClient); | 58 DISALLOW_COPY_AND_ASSIGN(MockWalletClient); |
59 }; | 59 }; |
60 | 60 |
61 } // namespace wallet | 61 } // namespace wallet |
62 } // namespace autofill | 62 } // namespace autofill |
63 | 63 |
64 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_MOCK_WALLET_CLIENT_H_ | 64 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_MOCK_WALLET_CLIENT_H_ |
OLD | NEW |