OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 kSendAutocheckoutStatusOfSuccessValidRequest, | 803 kSendAutocheckoutStatusOfSuccessValidRequest, |
804 kErrorTypeMissingInResponse); | 804 kErrorTypeMissingInResponse); |
805 } | 805 } |
806 | 806 |
807 TEST_F(WalletClientTest, NetworkFailureOnExpectedVoidResponse) { | 807 TEST_F(WalletClientTest, NetworkFailureOnExpectedVoidResponse) { |
808 EXPECT_CALL(delegate_, OnNetworkError(net::HTTP_UNAUTHORIZED)).Times(1); | 808 EXPECT_CALL(delegate_, OnNetworkError(net::HTTP_UNAUTHORIZED)).Times(1); |
809 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SEND_STATUS, 1); | 809 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SEND_STATUS, 1); |
810 delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST); | 810 delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST); |
811 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_NETWORK_ERROR); | 811 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_NETWORK_ERROR); |
812 | 812 |
813 wallet_client_->SendAutocheckoutStatus(autofill::SUCCESS, | 813 wallet_client_->SendAutocheckoutStatus( |
814 GURL(kMerchantUrl), | 814 autofill::SUCCESS, GURL(kMerchantUrl), std::string()); |
815 ""); | |
816 net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0); | 815 net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0); |
817 ASSERT_TRUE(fetcher); | 816 ASSERT_TRUE(fetcher); |
818 fetcher->set_response_code(net::HTTP_UNAUTHORIZED); | 817 fetcher->set_response_code(net::HTTP_UNAUTHORIZED); |
819 fetcher->delegate()->OnURLFetchComplete(fetcher); | 818 fetcher->delegate()->OnURLFetchComplete(fetcher); |
820 } | 819 } |
821 | 820 |
822 TEST_F(WalletClientTest, NetworkFailureOnExpectedResponse) { | 821 TEST_F(WalletClientTest, NetworkFailureOnExpectedResponse) { |
823 EXPECT_CALL(delegate_, OnNetworkError(net::HTTP_UNAUTHORIZED)).Times(1); | 822 EXPECT_CALL(delegate_, OnNetworkError(net::HTTP_UNAUTHORIZED)).Times(1); |
824 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_WALLET_ITEMS, | 823 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_WALLET_ITEMS, |
825 1); | 824 1); |
826 delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST); | 825 delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST); |
827 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_NETWORK_ERROR); | 826 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_NETWORK_ERROR); |
828 | 827 |
829 wallet_client_->GetWalletItems(GURL(kMerchantUrl), | 828 wallet_client_->GetWalletItems(GURL(kMerchantUrl), |
830 std::vector<WalletClient::RiskCapability>()); | 829 std::vector<WalletClient::RiskCapability>()); |
831 net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0); | 830 net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0); |
832 ASSERT_TRUE(fetcher); | 831 ASSERT_TRUE(fetcher); |
833 fetcher->set_response_code(net::HTTP_UNAUTHORIZED); | 832 fetcher->set_response_code(net::HTTP_UNAUTHORIZED); |
834 fetcher->delegate()->OnURLFetchComplete(fetcher); | 833 fetcher->delegate()->OnURLFetchComplete(fetcher); |
835 } | 834 } |
836 | 835 |
837 TEST_F(WalletClientTest, RequestError) { | 836 TEST_F(WalletClientTest, RequestError) { |
838 EXPECT_CALL(delegate_, OnWalletError(WalletClient::BAD_REQUEST)).Times(1); | 837 EXPECT_CALL(delegate_, OnWalletError(WalletClient::BAD_REQUEST)).Times(1); |
839 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SEND_STATUS, 1); | 838 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SEND_STATUS, 1); |
840 delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST); | 839 delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST); |
841 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_BAD_REQUEST); | 840 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_BAD_REQUEST); |
842 | 841 |
843 wallet_client_->SendAutocheckoutStatus(autofill::SUCCESS, | 842 wallet_client_->SendAutocheckoutStatus( |
844 GURL(kMerchantUrl), | 843 autofill::SUCCESS, GURL(kMerchantUrl), std::string()); |
845 ""); | |
846 net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0); | 844 net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0); |
847 ASSERT_TRUE(fetcher); | 845 ASSERT_TRUE(fetcher); |
848 fetcher->set_response_code(net::HTTP_BAD_REQUEST); | 846 fetcher->set_response_code(net::HTTP_BAD_REQUEST); |
849 fetcher->delegate()->OnURLFetchComplete(fetcher); | 847 fetcher->delegate()->OnURLFetchComplete(fetcher); |
850 } | 848 } |
851 | 849 |
852 TEST_F(WalletClientTest, GetFullWalletSuccess) { | 850 TEST_F(WalletClientTest, GetFullWalletSuccess) { |
853 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_FULL_WALLET, 1); | 851 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_FULL_WALLET, 1); |
854 delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, HAS_WALLET_REQUEST); | 852 delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, HAS_WALLET_REQUEST); |
855 | 853 |
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1895 wallet_client_->GetWalletItems(GURL(kMerchantUrl), risk_capabilities); | 1893 wallet_client_->GetWalletItems(GURL(kMerchantUrl), risk_capabilities); |
1896 EXPECT_EQ(2U, wallet_client_->pending_requests_.size()); | 1894 EXPECT_EQ(2U, wallet_client_->pending_requests_.size()); |
1897 | 1895 |
1898 wallet_client_->CancelRequests(); | 1896 wallet_client_->CancelRequests(); |
1899 EXPECT_EQ(0U, wallet_client_->pending_requests_.size()); | 1897 EXPECT_EQ(0U, wallet_client_->pending_requests_.size()); |
1900 EXPECT_FALSE(wallet_client_->HasRequestInProgress()); | 1898 EXPECT_FALSE(wallet_client_->HasRequestInProgress()); |
1901 } | 1899 } |
1902 | 1900 |
1903 } // namespace wallet | 1901 } // namespace wallet |
1904 } // namespace autofill | 1902 } // namespace autofill |
OLD | NEW |