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