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

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

Issue 123733002: WalletClient: don't bother queuing requests; we don't make multiple requests concurrently anyway (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 6 years, 11 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
« no previous file with comments | « components/autofill/content/browser/wallet/wallet_client.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 1684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 1695
1696 wallet_client_->GetWalletItems(); 1696 wallet_client_->GetWalletItems();
1697 EXPECT_TRUE(wallet_client_->HasRequestInProgress()); 1697 EXPECT_TRUE(wallet_client_->HasRequestInProgress());
1698 1698
1699 VerifyAndFinishRequest(net::HTTP_OK, 1699 VerifyAndFinishRequest(net::HTTP_OK,
1700 kGetWalletItemsValidRequest, 1700 kGetWalletItemsValidRequest,
1701 kGetWalletItemsValidResponse); 1701 kGetWalletItemsValidResponse);
1702 EXPECT_FALSE(wallet_client_->HasRequestInProgress()); 1702 EXPECT_FALSE(wallet_client_->HasRequestInProgress());
1703 } 1703 }
1704 1704
1705 TEST_F(WalletClientTest, PendingRequest) { 1705 TEST_F(WalletClientTest, ErrorResponse) {
1706 EXPECT_EQ(0U, wallet_client_->pending_requests_.size()); 1706 EXPECT_FALSE(wallet_client_->HasRequestInProgress());
1707
1708 // Shouldn't queue the first request.
1709 delegate_.ExpectBaselineMetrics(); 1707 delegate_.ExpectBaselineMetrics();
1710 wallet_client_->GetWalletItems(); 1708 wallet_client_->GetWalletItems();
1711 EXPECT_EQ(0U, wallet_client_->pending_requests_.size()); 1709 EXPECT_TRUE(wallet_client_->HasRequestInProgress());
1712 testing::Mock::VerifyAndClear(delegate_.metric_logger());
1713
1714 wallet_client_->GetWalletItems();
1715 EXPECT_EQ(1U, wallet_client_->pending_requests_.size());
1716
1717 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_WALLET_ITEMS,
1718 1);
1719 delegate_.ExpectBaselineMetrics();
1720 VerifyAndFinishRequest(net::HTTP_OK,
1721 kGetWalletItemsValidRequest,
1722 kGetWalletItemsValidResponse);
1723 EXPECT_EQ(0U, wallet_client_->pending_requests_.size());
1724 testing::Mock::VerifyAndClear(delegate_.metric_logger()); 1710 testing::Mock::VerifyAndClear(delegate_.metric_logger());
1725 1711
1726 EXPECT_CALL(delegate_, OnWalletError( 1712 EXPECT_CALL(delegate_, OnWalletError(
1727 WalletClient::SERVICE_UNAVAILABLE)).Times(1); 1713 WalletClient::SERVICE_UNAVAILABLE)).Times(1);
1728 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_WALLET_ITEMS, 1714 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_WALLET_ITEMS,
1729 1); 1715 1);
1730 delegate_.ExpectWalletErrorMetric( 1716 delegate_.ExpectWalletErrorMetric(
1731 AutofillMetrics::WALLET_SERVICE_UNAVAILABLE); 1717 AutofillMetrics::WALLET_SERVICE_UNAVAILABLE);
1732 1718
1733 // Finish the second request.
1734 VerifyAndFinishRequest(net::HTTP_INTERNAL_SERVER_ERROR, 1719 VerifyAndFinishRequest(net::HTTP_INTERNAL_SERVER_ERROR,
1735 kGetWalletItemsValidRequest, 1720 kGetWalletItemsValidRequest,
1736 kErrorResponse); 1721 kErrorResponse);
1737 } 1722 }
1738 1723
1739 TEST_F(WalletClientTest, CancelRequests) { 1724 TEST_F(WalletClientTest, CancelRequest) {
1740 ASSERT_EQ(0U, wallet_client_->pending_requests_.size()); 1725 EXPECT_FALSE(wallet_client_->HasRequestInProgress());
1741 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_WALLET_ITEMS, 1726 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_WALLET_ITEMS,
1742 0); 1727 0);
1743 delegate_.ExpectBaselineMetrics(); 1728 delegate_.ExpectBaselineMetrics();
1744 1729
1745 wallet_client_->GetWalletItems(); 1730 wallet_client_->GetWalletItems();
1746 wallet_client_->GetWalletItems(); 1731 EXPECT_TRUE(wallet_client_->HasRequestInProgress());
1747 wallet_client_->GetWalletItems(); 1732 wallet_client_->CancelRequest();
1748 EXPECT_EQ(2U, wallet_client_->pending_requests_.size());
1749
1750 wallet_client_->CancelRequests();
1751 EXPECT_EQ(0U, wallet_client_->pending_requests_.size());
1752 EXPECT_FALSE(wallet_client_->HasRequestInProgress()); 1733 EXPECT_FALSE(wallet_client_->HasRequestInProgress());
1753 } 1734 }
1754 1735
1755 } // namespace wallet 1736 } // namespace wallet
1756 } // namespace autofill 1737 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/content/browser/wallet/wallet_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698