Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Side by Side Diff: components/autofill/content/browser/wallet/wallet_client_unittest.cc

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup TODOs. merge code. kill more threads. i never get tired of thread carnage. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "components/autofill/content/browser/autocheckout_steps.h" 12 #include "components/autofill/content/browser/autocheckout_steps.h"
13 #include "components/autofill/content/browser/wallet/full_wallet.h" 13 #include "components/autofill/content/browser/wallet/full_wallet.h"
14 #include "components/autofill/content/browser/wallet/instrument.h" 14 #include "components/autofill/content/browser/wallet/instrument.h"
15 #include "components/autofill/content/browser/wallet/wallet_client.h" 15 #include "components/autofill/content/browser/wallet/wallet_client.h"
16 #include "components/autofill/content/browser/wallet/wallet_client_delegate.h" 16 #include "components/autofill/content/browser/wallet/wallet_client_delegate.h"
17 #include "components/autofill/content/browser/wallet/wallet_items.h" 17 #include "components/autofill/content/browser/wallet/wallet_items.h"
18 #include "components/autofill/content/browser/wallet/wallet_test_util.h" 18 #include "components/autofill/content/browser/wallet/wallet_test_util.h"
19 #include "components/autofill/core/browser/autofill_metrics.h" 19 #include "components/autofill/core/browser/autofill_metrics.h"
20 #include "components/autofill/core/common/autocheckout_status.h" 20 #include "components/autofill/core/common/autocheckout_status.h"
21 #include "content/public/test/test_browser_context.h" 21 #include "content/public/test/test_browser_context.h"
22 #include "content/public/test/test_browser_thread.h" 22 #include "content/public/test/test_browser_thread_bundle.h"
23 #include "net/base/net_errors.h" 23 #include "net/base/net_errors.h"
24 #include "net/http/http_request_headers.h" 24 #include "net/http/http_request_headers.h"
25 #include "net/http/http_status_code.h" 25 #include "net/http/http_status_code.h"
26 #include "net/url_request/test_url_fetcher_factory.h" 26 #include "net/url_request/test_url_fetcher_factory.h"
27 #include "net/url_request/url_fetcher_delegate.h" 27 #include "net/url_request/url_fetcher_delegate.h"
28 #include "net/url_request/url_request_status.h" 28 #include "net/url_request/url_request_status.h"
29 #include "testing/gmock/include/gmock/gmock.h" 29 #include "testing/gmock/include/gmock/gmock.h"
30 #include "testing/gtest/include/gtest/gtest.h" 30 #include "testing/gtest/include/gtest/gtest.h"
31 #include "url/gurl.h" 31 #include "url/gurl.h"
32 32
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 size_t full_wallets_received_; 737 size_t full_wallets_received_;
738 size_t wallet_items_received_; 738 size_t wallet_items_received_;
739 739
740 testing::StrictMock<MockAutofillMetrics> metric_logger_; 740 testing::StrictMock<MockAutofillMetrics> metric_logger_;
741 }; 741 };
742 742
743 } // namespace 743 } // namespace
744 744
745 class WalletClientTest : public testing::Test { 745 class WalletClientTest : public testing::Test {
746 public: 746 public:
747 WalletClientTest() {}
748
749 virtual void SetUp() OVERRIDE { 747 virtual void SetUp() OVERRIDE {
750 wallet_client_.reset( 748 wallet_client_.reset(
751 new WalletClient(browser_context_.GetRequestContext(), &delegate_)); 749 new WalletClient(browser_context_.GetRequestContext(), &delegate_));
752 } 750 }
753 751
754 virtual void TearDown() OVERRIDE { 752 virtual void TearDown() OVERRIDE {
755 wallet_client_.reset(); 753 wallet_client_.reset();
756 } 754 }
757 755
758 std::string GetData(net::TestURLFetcher* fetcher) { 756 std::string GetData(net::TestURLFetcher* fetcher) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 fetcher->SetResponseString(response_body); 794 fetcher->SetResponseString(response_body);
797 fetcher->delegate()->OnURLFetchComplete(fetcher); 795 fetcher->delegate()->OnURLFetchComplete(fetcher);
798 } 796 }
799 797
800 protected: 798 protected:
801 scoped_ptr<WalletClient> wallet_client_; 799 scoped_ptr<WalletClient> wallet_client_;
802 content::TestBrowserContext browser_context_; 800 content::TestBrowserContext browser_context_;
803 MockWalletClientDelegate delegate_; 801 MockWalletClientDelegate delegate_;
804 802
805 private: 803 private:
804 // The profile's request context must be released on the IO thread.
805 content::TestBrowserThreadBundle thread_bundle_;
806 net::TestURLFetcherFactory factory_; 806 net::TestURLFetcherFactory factory_;
807 }; 807 };
808 808
809 TEST_F(WalletClientTest, WalletError) { 809 TEST_F(WalletClientTest, WalletError) {
810 EXPECT_CALL(delegate_, OnWalletError( 810 EXPECT_CALL(delegate_, OnWalletError(
811 WalletClient::SERVICE_UNAVAILABLE)).Times(1); 811 WalletClient::SERVICE_UNAVAILABLE)).Times(1);
812 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SEND_STATUS, 1); 812 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SEND_STATUS, 1);
813 delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST); 813 delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
814 delegate_.ExpectWalletErrorMetric( 814 delegate_.ExpectWalletErrorMetric(
815 AutofillMetrics::WALLET_SERVICE_UNAVAILABLE); 815 AutofillMetrics::WALLET_SERVICE_UNAVAILABLE);
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 wallet_client_->GetWalletItems(GURL(kMerchantUrl)); 1844 wallet_client_->GetWalletItems(GURL(kMerchantUrl));
1845 EXPECT_EQ(2U, wallet_client_->pending_requests_.size()); 1845 EXPECT_EQ(2U, wallet_client_->pending_requests_.size());
1846 1846
1847 wallet_client_->CancelRequests(); 1847 wallet_client_->CancelRequests();
1848 EXPECT_EQ(0U, wallet_client_->pending_requests_.size()); 1848 EXPECT_EQ(0U, wallet_client_->pending_requests_.size());
1849 EXPECT_FALSE(wallet_client_->HasRequestInProgress()); 1849 EXPECT_FALSE(wallet_client_->HasRequestInProgress());
1850 } 1850 }
1851 1851
1852 } // namespace wallet 1852 } // namespace wallet
1853 } // namespace autofill 1853 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698