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

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

Issue 12457033: Implements SendAutocheckoutStatus API calls for stats tracking. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DCHECK Created 7 years, 8 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 (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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 MOCK_METHOD2(OnDidSaveAddress, 540 MOCK_METHOD2(OnDidSaveAddress,
541 void(const std::string& address_id, 541 void(const std::string& address_id,
542 const std::vector<RequiredAction>& required_actions)); 542 const std::vector<RequiredAction>& required_actions));
543 MOCK_METHOD2(OnDidSaveInstrument, 543 MOCK_METHOD2(OnDidSaveInstrument,
544 void(const std::string& instrument_id, 544 void(const std::string& instrument_id,
545 const std::vector<RequiredAction>& required_actions)); 545 const std::vector<RequiredAction>& required_actions));
546 MOCK_METHOD3(OnDidSaveInstrumentAndAddress, 546 MOCK_METHOD3(OnDidSaveInstrumentAndAddress,
547 void(const std::string& instrument_id, 547 void(const std::string& instrument_id,
548 const std::string& shipping_address_id, 548 const std::string& shipping_address_id,
549 const std::vector<RequiredAction>& required_actions)); 549 const std::vector<RequiredAction>& required_actions));
550 MOCK_METHOD0(OnDidSendAutocheckoutStatus, void());
551 MOCK_METHOD2(OnDidUpdateAddress, 550 MOCK_METHOD2(OnDidUpdateAddress,
552 void(const std::string& address_id, 551 void(const std::string& address_id,
553 const std::vector<RequiredAction>& required_actions)); 552 const std::vector<RequiredAction>& required_actions));
554 MOCK_METHOD2(OnDidUpdateInstrument, 553 MOCK_METHOD2(OnDidUpdateInstrument,
555 void(const std::string& instrument_id, 554 void(const std::string& instrument_id,
556 const std::vector<RequiredAction>& required_actions)); 555 const std::vector<RequiredAction>& required_actions));
557 MOCK_METHOD1(OnWalletError, void(WalletClient::ErrorType error_type)); 556 MOCK_METHOD1(OnWalletError, void(WalletClient::ErrorType error_type));
558 MOCK_METHOD0(OnMalformedResponse, void()); 557 MOCK_METHOD0(OnMalformedResponse, void());
559 MOCK_METHOD1(OnNetworkError, void(int response_code)); 558 MOCK_METHOD1(OnNetworkError, void(int response_code));
560 559
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 scoped_ptr<Address> address = GetTestAddress(); 1364 scoped_ptr<Address> address = GetTestAddress();
1366 wallet_client_->UpdateInstrument("instrument_id", 1365 wallet_client_->UpdateInstrument("instrument_id",
1367 *address, 1366 *address,
1368 GURL(kMerchantUrl)); 1367 GURL(kMerchantUrl));
1369 VerifyAndFinishRequest(net::HTTP_OK, 1368 VerifyAndFinishRequest(net::HTTP_OK,
1370 kUpdateInstrumentValidRequest, 1369 kUpdateInstrumentValidRequest,
1371 kUpdateMalformedResponse); 1370 kUpdateMalformedResponse);
1372 } 1371 }
1373 1372
1374 TEST_F(WalletClientTest, SendAutocheckoutOfStatusSuccess) { 1373 TEST_F(WalletClientTest, SendAutocheckoutOfStatusSuccess) {
1375 EXPECT_CALL(delegate_, OnDidSendAutocheckoutStatus()).Times(1);
1376
1377 wallet_client_->SendAutocheckoutStatus(autofill::SUCCESS, 1374 wallet_client_->SendAutocheckoutStatus(autofill::SUCCESS,
1378 GURL(kMerchantUrl), 1375 GURL(kMerchantUrl),
1379 "google_transaction_id"); 1376 "google_transaction_id");
1380 net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0); 1377 VerifyAndFinishRequest(net::HTTP_OK,
1381 ASSERT_TRUE(fetcher); 1378 kSendAutocheckoutStatusOfSuccessValidRequest,
1382 EXPECT_EQ(kSendAutocheckoutStatusOfSuccessValidRequest, GetData(fetcher)); 1379 ")]}"); // Invalid JSON. Should be ignored.
1383 fetcher->SetResponseString(")]}'"); // Invalid JSON. Should be ignored.
1384 fetcher->set_response_code(net::HTTP_OK);
1385 fetcher->delegate()->OnURLFetchComplete(fetcher);
1386 } 1380 }
1387 1381
1388 TEST_F(WalletClientTest, SendAutocheckoutStatusOfFailure) { 1382 TEST_F(WalletClientTest, SendAutocheckoutStatusOfFailure) {
1389 EXPECT_CALL(delegate_, OnDidSendAutocheckoutStatus()).Times(1);
1390
1391 wallet_client_->SendAutocheckoutStatus(autofill::CANNOT_PROCEED, 1383 wallet_client_->SendAutocheckoutStatus(autofill::CANNOT_PROCEED,
1392 GURL(kMerchantUrl), 1384 GURL(kMerchantUrl),
1393 "google_transaction_id"); 1385 "google_transaction_id");
1394 net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0); 1386 VerifyAndFinishRequest(net::HTTP_OK,
1395 ASSERT_TRUE(fetcher); 1387 kSendAutocheckoutStatusOfFailureValidRequest,
1396 EXPECT_EQ(kSendAutocheckoutStatusOfFailureValidRequest, GetData(fetcher)); 1388 ")]}"); // Invalid JSON. Should be ignored.
1397 fetcher->set_response_code(net::HTTP_OK);
1398 fetcher->SetResponseString(")]}'"); // Invalid JSON. Should be ignored.
1399 fetcher->delegate()->OnURLFetchComplete(fetcher);
1400 } 1389 }
1401 1390
1402 TEST_F(WalletClientTest, HasRequestInProgress) { 1391 TEST_F(WalletClientTest, HasRequestInProgress) {
1403 EXPECT_FALSE(wallet_client_->HasRequestInProgress()); 1392 EXPECT_FALSE(wallet_client_->HasRequestInProgress());
1404 1393
1405 wallet_client_->GetWalletItems(GURL(kMerchantUrl), 1394 wallet_client_->GetWalletItems(GURL(kMerchantUrl),
1406 std::vector<WalletClient::RiskCapability>()); 1395 std::vector<WalletClient::RiskCapability>());
1407 EXPECT_TRUE(wallet_client_->HasRequestInProgress()); 1396 EXPECT_TRUE(wallet_client_->HasRequestInProgress());
1408 1397
1409 VerifyAndFinishRequest(net::HTTP_OK, 1398 VerifyAndFinishRequest(net::HTTP_OK,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 wallet_client_->GetWalletItems(GURL(kMerchantUrl), risk_capabilities); 1434 wallet_client_->GetWalletItems(GURL(kMerchantUrl), risk_capabilities);
1446 wallet_client_->GetWalletItems(GURL(kMerchantUrl), risk_capabilities); 1435 wallet_client_->GetWalletItems(GURL(kMerchantUrl), risk_capabilities);
1447 EXPECT_EQ(2U, wallet_client_->pending_requests_.size()); 1436 EXPECT_EQ(2U, wallet_client_->pending_requests_.size());
1448 1437
1449 wallet_client_->CancelPendingRequests(); 1438 wallet_client_->CancelPendingRequests();
1450 EXPECT_EQ(0U, wallet_client_->pending_requests_.size()); 1439 EXPECT_EQ(0U, wallet_client_->pending_requests_.size());
1451 } 1440 }
1452 1441
1453 } // namespace wallet 1442 } // namespace wallet
1454 } // namespace autofill 1443 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698