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 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 }; | 650 }; |
651 | 651 |
652 class MockWalletClientDelegate : public WalletClientDelegate { | 652 class MockWalletClientDelegate : public WalletClientDelegate { |
653 public: | 653 public: |
654 MockWalletClientDelegate() | 654 MockWalletClientDelegate() |
655 : full_wallets_received_(0), | 655 : full_wallets_received_(0), |
656 wallet_items_received_(0), | 656 wallet_items_received_(0), |
657 is_shipping_required_(true) {} | 657 is_shipping_required_(true) {} |
658 ~MockWalletClientDelegate() {} | 658 ~MockWalletClientDelegate() {} |
659 | 659 |
660 virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE { | 660 virtual const AutofillMetrics& GetMetricLogger() const override { |
661 return metric_logger_; | 661 return metric_logger_; |
662 } | 662 } |
663 | 663 |
664 virtual std::string GetRiskData() const OVERRIDE { | 664 virtual std::string GetRiskData() const override { |
665 return "risky business"; | 665 return "risky business"; |
666 } | 666 } |
667 | 667 |
668 virtual std::string GetWalletCookieValue() const OVERRIDE { | 668 virtual std::string GetWalletCookieValue() const override { |
669 return "gdToken"; | 669 return "gdToken"; |
670 } | 670 } |
671 | 671 |
672 virtual bool IsShippingAddressRequired() const OVERRIDE { | 672 virtual bool IsShippingAddressRequired() const override { |
673 return is_shipping_required_; | 673 return is_shipping_required_; |
674 } | 674 } |
675 | 675 |
676 void SetIsShippingAddressRequired(bool is_shipping_required) { | 676 void SetIsShippingAddressRequired(bool is_shipping_required) { |
677 is_shipping_required_ = is_shipping_required; | 677 is_shipping_required_ = is_shipping_required; |
678 } | 678 } |
679 | 679 |
680 void ExpectLogWalletApiCallDuration( | 680 void ExpectLogWalletApiCallDuration( |
681 AutofillMetrics::WalletApiCallMetric metric, | 681 AutofillMetrics::WalletApiCallMetric metric, |
682 size_t times) { | 682 size_t times) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 | 716 |
717 MOCK_METHOD0(OnDidAcceptLegalDocuments, void()); | 717 MOCK_METHOD0(OnDidAcceptLegalDocuments, void()); |
718 MOCK_METHOD1(OnDidAuthenticateInstrument, void(bool success)); | 718 MOCK_METHOD1(OnDidAuthenticateInstrument, void(bool success)); |
719 MOCK_METHOD4(OnDidSaveToWallet, | 719 MOCK_METHOD4(OnDidSaveToWallet, |
720 void(const std::string& instrument_id, | 720 void(const std::string& instrument_id, |
721 const std::string& shipping_address_id, | 721 const std::string& shipping_address_id, |
722 const std::vector<RequiredAction>& required_actions, | 722 const std::vector<RequiredAction>& required_actions, |
723 const std::vector<FormFieldError>& form_field_errors)); | 723 const std::vector<FormFieldError>& form_field_errors)); |
724 MOCK_METHOD1(OnWalletError, void(WalletClient::ErrorType error_type)); | 724 MOCK_METHOD1(OnWalletError, void(WalletClient::ErrorType error_type)); |
725 | 725 |
726 virtual void OnDidGetFullWallet(scoped_ptr<FullWallet> full_wallet) OVERRIDE { | 726 virtual void OnDidGetFullWallet(scoped_ptr<FullWallet> full_wallet) override { |
727 EXPECT_TRUE(full_wallet); | 727 EXPECT_TRUE(full_wallet); |
728 ++full_wallets_received_; | 728 ++full_wallets_received_; |
729 } | 729 } |
730 virtual void OnDidGetWalletItems(scoped_ptr<WalletItems> wallet_items) | 730 virtual void OnDidGetWalletItems(scoped_ptr<WalletItems> wallet_items) |
731 OVERRIDE { | 731 override { |
732 EXPECT_TRUE(wallet_items); | 732 EXPECT_TRUE(wallet_items); |
733 ++wallet_items_received_; | 733 ++wallet_items_received_; |
734 } | 734 } |
735 size_t full_wallets_received() const { return full_wallets_received_; } | 735 size_t full_wallets_received() const { return full_wallets_received_; } |
736 size_t wallet_items_received() const { return wallet_items_received_; } | 736 size_t wallet_items_received() const { return wallet_items_received_; } |
737 | 737 |
738 private: | 738 private: |
739 size_t full_wallets_received_; | 739 size_t full_wallets_received_; |
740 size_t wallet_items_received_; | 740 size_t wallet_items_received_; |
741 bool is_shipping_required_; | 741 bool is_shipping_required_; |
742 | 742 |
743 testing::StrictMock<MockAutofillMetrics> metric_logger_; | 743 testing::StrictMock<MockAutofillMetrics> metric_logger_; |
744 }; | 744 }; |
745 | 745 |
746 } // namespace | 746 } // namespace |
747 | 747 |
748 class WalletClientTest : public testing::Test { | 748 class WalletClientTest : public testing::Test { |
749 public: | 749 public: |
750 WalletClientTest() | 750 WalletClientTest() |
751 : request_context_(new net::TestURLRequestContextGetter( | 751 : request_context_(new net::TestURLRequestContextGetter( |
752 base::MessageLoopProxy::current())) {} | 752 base::MessageLoopProxy::current())) {} |
753 virtual ~WalletClientTest() {} | 753 virtual ~WalletClientTest() {} |
754 | 754 |
755 virtual void SetUp() OVERRIDE { | 755 virtual void SetUp() override { |
756 wallet_client_.reset(new WalletClient( | 756 wallet_client_.reset(new WalletClient( |
757 request_context_.get(), &delegate_, GURL(kMerchantUrl))); | 757 request_context_.get(), &delegate_, GURL(kMerchantUrl))); |
758 } | 758 } |
759 | 759 |
760 virtual void TearDown() OVERRIDE { | 760 virtual void TearDown() override { |
761 wallet_client_.reset(); | 761 wallet_client_.reset(); |
762 } | 762 } |
763 | 763 |
764 void VerifyAndFinishRequest(net::HttpStatusCode response_code, | 764 void VerifyAndFinishRequest(net::HttpStatusCode response_code, |
765 const std::string& request_body, | 765 const std::string& request_body, |
766 const std::string& response_body) { | 766 const std::string& response_body) { |
767 net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0); | 767 net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0); |
768 ASSERT_TRUE(fetcher); | 768 ASSERT_TRUE(fetcher); |
769 | 769 |
770 const std::string& upload_data = fetcher->upload_data(); | 770 const std::string& upload_data = fetcher->upload_data(); |
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1862 delegate_.ExpectBaselineMetrics(); | 1862 delegate_.ExpectBaselineMetrics(); |
1863 | 1863 |
1864 wallet_client_->GetWalletItems(base::string16(), base::string16()); | 1864 wallet_client_->GetWalletItems(base::string16(), base::string16()); |
1865 EXPECT_TRUE(wallet_client_->HasRequestInProgress()); | 1865 EXPECT_TRUE(wallet_client_->HasRequestInProgress()); |
1866 wallet_client_->CancelRequest(); | 1866 wallet_client_->CancelRequest(); |
1867 EXPECT_FALSE(wallet_client_->HasRequestInProgress()); | 1867 EXPECT_FALSE(wallet_client_->HasRequestInProgress()); |
1868 } | 1868 } |
1869 | 1869 |
1870 } // namespace wallet | 1870 } // namespace wallet |
1871 } // namespace autofill | 1871 } // namespace autofill |
OLD | NEW |