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 #include "base/json/json_reader.h" | 5 #include "base/json/json_reader.h" |
6 #include "base/json/json_writer.h" | 6 #include "base/json/json_writer.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 } | 653 } |
654 | 654 |
655 class MockWalletClientDelegate : public WalletClientDelegate { | 655 class MockWalletClientDelegate : public WalletClientDelegate { |
656 public: | 656 public: |
657 MockWalletClientDelegate() | 657 MockWalletClientDelegate() |
658 : full_wallets_received_(0), | 658 : full_wallets_received_(0), |
659 wallet_items_received_(0), | 659 wallet_items_received_(0), |
660 is_shipping_required_(true) {} | 660 is_shipping_required_(true) {} |
661 ~MockWalletClientDelegate() {} | 661 ~MockWalletClientDelegate() {} |
662 | 662 |
663 virtual std::string GetRiskData() const override { | 663 std::string GetRiskData() const override { |
664 return "risky business"; | 664 return "risky business"; |
665 } | 665 } |
666 | 666 |
667 virtual std::string GetWalletCookieValue() const override { | 667 std::string GetWalletCookieValue() const override { |
668 return "gdToken"; | 668 return "gdToken"; |
669 } | 669 } |
670 | 670 |
671 virtual bool IsShippingAddressRequired() const override { | 671 bool IsShippingAddressRequired() const override { |
672 return is_shipping_required_; | 672 return is_shipping_required_; |
673 } | 673 } |
674 | 674 |
675 void SetIsShippingAddressRequired(bool is_shipping_required) { | 675 void SetIsShippingAddressRequired(bool is_shipping_required) { |
676 is_shipping_required_ = is_shipping_required; | 676 is_shipping_required_ = is_shipping_required; |
677 } | 677 } |
678 | 678 |
679 MOCK_METHOD0(OnDidAcceptLegalDocuments, void()); | 679 MOCK_METHOD0(OnDidAcceptLegalDocuments, void()); |
680 MOCK_METHOD1(OnDidAuthenticateInstrument, void(bool success)); | 680 MOCK_METHOD1(OnDidAuthenticateInstrument, void(bool success)); |
681 MOCK_METHOD4(OnDidSaveToWallet, | 681 MOCK_METHOD4(OnDidSaveToWallet, |
682 void(const std::string& instrument_id, | 682 void(const std::string& instrument_id, |
683 const std::string& shipping_address_id, | 683 const std::string& shipping_address_id, |
684 const std::vector<RequiredAction>& required_actions, | 684 const std::vector<RequiredAction>& required_actions, |
685 const std::vector<FormFieldError>& form_field_errors)); | 685 const std::vector<FormFieldError>& form_field_errors)); |
686 MOCK_METHOD1(OnWalletError, void(WalletClient::ErrorType error_type)); | 686 MOCK_METHOD1(OnWalletError, void(WalletClient::ErrorType error_type)); |
687 | 687 |
688 virtual void OnDidGetFullWallet(scoped_ptr<FullWallet> full_wallet) override { | 688 void OnDidGetFullWallet(scoped_ptr<FullWallet> full_wallet) override { |
689 EXPECT_TRUE(full_wallet); | 689 EXPECT_TRUE(full_wallet); |
690 ++full_wallets_received_; | 690 ++full_wallets_received_; |
691 } | 691 } |
692 virtual void OnDidGetWalletItems(scoped_ptr<WalletItems> wallet_items) | 692 void OnDidGetWalletItems(scoped_ptr<WalletItems> wallet_items) override { |
693 override { | |
694 EXPECT_TRUE(wallet_items); | 693 EXPECT_TRUE(wallet_items); |
695 ++wallet_items_received_; | 694 ++wallet_items_received_; |
696 } | 695 } |
697 size_t full_wallets_received() const { return full_wallets_received_; } | 696 size_t full_wallets_received() const { return full_wallets_received_; } |
698 size_t wallet_items_received() const { return wallet_items_received_; } | 697 size_t wallet_items_received() const { return wallet_items_received_; } |
699 | 698 |
700 private: | 699 private: |
701 size_t full_wallets_received_; | 700 size_t full_wallets_received_; |
702 size_t wallet_items_received_; | 701 size_t wallet_items_received_; |
703 bool is_shipping_required_; | 702 bool is_shipping_required_; |
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1895 EXPECT_TRUE(wallet_client_->HasRequestInProgress()); | 1894 EXPECT_TRUE(wallet_client_->HasRequestInProgress()); |
1896 wallet_client_->CancelRequest(); | 1895 wallet_client_->CancelRequest(); |
1897 EXPECT_FALSE(wallet_client_->HasRequestInProgress()); | 1896 EXPECT_FALSE(wallet_client_->HasRequestInProgress()); |
1898 | 1897 |
1899 ExpectBaselineMetrics(histogram); | 1898 ExpectBaselineMetrics(histogram); |
1900 histogram.ExpectTotalCount("Wallet.ApiCallDuration.GetWalletItems", 0); | 1899 histogram.ExpectTotalCount("Wallet.ApiCallDuration.GetWalletItems", 0); |
1901 } | 1900 } |
1902 | 1901 |
1903 } // namespace wallet | 1902 } // namespace wallet |
1904 } // namespace autofill | 1903 } // namespace autofill |
OLD | NEW |