| Index: components/autofill/content/browser/wallet/wallet_client_unittest.cc
|
| diff --git a/components/autofill/content/browser/wallet/wallet_client_unittest.cc b/components/autofill/content/browser/wallet/wallet_client_unittest.cc
|
| index 0379cc9aa4686999f8089b9ab9a3ce49fa94b4df..1a7085cfa876d2feeac981f5ce2155baed4006b2 100644
|
| --- a/components/autofill/content/browser/wallet/wallet_client_unittest.cc
|
| +++ b/components/autofill/content/browser/wallet/wallet_client_unittest.cc
|
| @@ -7,6 +7,7 @@
|
| #include "base/logging.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/strings/string_number_conversions.h"
|
| +#include "base/strings/string_split.h"
|
| #include "base/strings/string_util.h"
|
| #include "base/values.h"
|
| #include "components/autofill/content/browser/autocheckout_steps.h"
|
| @@ -21,6 +22,7 @@
|
| #include "content/public/test/test_browser_context.h"
|
| #include "content/public/test/test_browser_thread.h"
|
| #include "googleurl/src/gurl.h"
|
| +#include "net/base/escape.h"
|
| #include "net/base/net_errors.h"
|
| #include "net/http/http_status_code.h"
|
| #include "net/url_request/test_url_fetcher_factory.h"
|
| @@ -210,16 +212,6 @@ const char kSaveInstrumentAndAddressWithRequiredActionsValidResponse[] =
|
| " ]"
|
| "}";
|
|
|
| -const char kSaveInstrumentAndAddressMissingAddressResponse[] =
|
| - "{"
|
| - " \"instrument_id\":\"instrument_id\""
|
| - "}";
|
| -
|
| -const char kSaveInstrumentAndAddressMissingInstrumentResponse[] =
|
| - "{"
|
| - " \"shipping_address_id\":\"saved_address_id\""
|
| - "}";
|
| -
|
| const char kUpdateInstrumentValidResponse[] =
|
| "{"
|
| " \"instrument_id\":\"instrument_id\""
|
| @@ -315,21 +307,18 @@ const char kAcceptLegalDocumentsValidRequest[] =
|
|
|
| const char kAuthenticateInstrumentValidRequest[] =
|
| "{"
|
| - "\"instrument_escrow_handle\":\"escrow_handle\","
|
| "\"instrument_id\":\"instrument_id\","
|
| "\"risk_params\":\"risky business\""
|
| "}";
|
|
|
| const char kGetFullWalletValidRequest[] =
|
| "{"
|
| - "\"encrypted_otp\":\"encrypted_one_time_pad\","
|
| "\"feature\":\"REQUEST_AUTOCOMPLETE\","
|
| "\"google_transaction_id\":\"google_transaction_id\","
|
| "\"merchant_domain\":\"https://example.com/\","
|
| "\"risk_params\":\"risky business\","
|
| "\"selected_address_id\":\"shipping_address_id\","
|
| "\"selected_instrument_id\":\"instrument_id\","
|
| - "\"session_material\":\"session_material\","
|
| "\"supported_risk_challenge\":"
|
| "["
|
| "]"
|
| @@ -337,14 +326,12 @@ const char kGetFullWalletValidRequest[] =
|
|
|
| const char kGetFullWalletWithRiskCapabilitesValidRequest[] =
|
| "{"
|
| - "\"encrypted_otp\":\"encrypted_one_time_pad\","
|
| "\"feature\":\"REQUEST_AUTOCOMPLETE\","
|
| "\"google_transaction_id\":\"google_transaction_id\","
|
| "\"merchant_domain\":\"https://example.com/\","
|
| "\"risk_params\":\"risky business\","
|
| "\"selected_address_id\":\"shipping_address_id\","
|
| "\"selected_instrument_id\":\"instrument_id\","
|
| - "\"session_material\":\"session_material\","
|
| "\"supported_risk_challenge\":"
|
| "["
|
| "\"VERIFY_CVC\""
|
| @@ -405,7 +392,6 @@ const char kSaveInstrumentValidRequest[] =
|
| "},"
|
| "\"type\":\"CREDIT_CARD\""
|
| "},"
|
| - "\"instrument_escrow_handle\":\"escrow_handle\","
|
| "\"instrument_phone_number\":\"phone_number\","
|
| "\"merchant_domain\":\"https://example.com/\","
|
| "\"risk_params\":\"risky business\""
|
| @@ -437,7 +423,6 @@ const char kSaveInstrumentAndAddressValidRequest[] =
|
| "},"
|
| "\"type\":\"CREDIT_CARD\""
|
| "},"
|
| - "\"instrument_escrow_handle\":\"escrow_handle\","
|
| "\"instrument_phone_number\":\"phone_number\","
|
| "\"merchant_domain\":\"https://example.com/\","
|
| "\"risk_params\":\"risky business\","
|
| @@ -531,38 +516,6 @@ const char kUpdateInstrumentAddressValidRequest[] =
|
|
|
| const char kUpdateInstrumentAddressWithNameChangeValidRequest[] =
|
| "{"
|
| - "\"instrument_escrow_handle\":\"escrow_handle\","
|
| - "\"instrument_phone_number\":\"phone_number\","
|
| - "\"merchant_domain\":\"https://example.com/\","
|
| - "\"risk_params\":\"risky business\","
|
| - "\"upgraded_billing_address\":"
|
| - "{"
|
| - "\"address_line\":"
|
| - "["
|
| - "\"address_line_1\","
|
| - "\"address_line_2\""
|
| - "],"
|
| - "\"administrative_area_name\":\"admin_area_name\","
|
| - "\"country_name_code\":\"US\","
|
| - "\"locality_name\":\"locality_name\","
|
| - "\"postal_code_number\":\"postal_code_number\","
|
| - "\"recipient_name\":\"recipient_name\""
|
| - "},"
|
| - "\"upgraded_instrument_id\":\"instrument_id\""
|
| - "}";
|
| -
|
| -const char kUpdateInstrumentAddressAndExpirationDateValidRequest[] =
|
| - "{"
|
| - "\"instrument\":"
|
| - "{"
|
| - "\"credit_card\":"
|
| - "{"
|
| - "\"exp_month\":12,"
|
| - "\"exp_year\":2015"
|
| - "},"
|
| - "\"type\":\"CREDIT_CARD\""
|
| - "},"
|
| - "\"instrument_escrow_handle\":\"escrow_handle\","
|
| "\"instrument_phone_number\":\"phone_number\","
|
| "\"merchant_domain\":\"https://example.com/\","
|
| "\"risk_params\":\"risky business\","
|
| @@ -589,11 +542,10 @@ const char kUpdateInstrumentExpirationDateValidRequest[] =
|
| "\"credit_card\":"
|
| "{"
|
| "\"exp_month\":12,"
|
| - "\"exp_year\":2015"
|
| + "\"exp_year\":3000"
|
| "},"
|
| "\"type\":\"CREDIT_CARD\""
|
| "},"
|
| - "\"instrument_escrow_handle\":\"escrow_handle\","
|
| "\"merchant_domain\":\"https://example.com/\","
|
| "\"risk_params\":\"risky business\","
|
| "\"upgraded_instrument_id\":\"instrument_id\""
|
| @@ -614,16 +566,6 @@ class MockAutofillMetrics : public AutofillMetrics {
|
| DISALLOW_COPY_AND_ASSIGN(MockAutofillMetrics);
|
| };
|
|
|
| -enum EscrowRequestPresence {
|
| - HAS_ESCROW_REQUEST,
|
| - NO_ESCROW_REQUEST,
|
| -};
|
| -
|
| -enum WalletRequestPresence {
|
| - HAS_WALLET_REQUEST,
|
| - NO_WALLET_REQUEST,
|
| -};
|
| -
|
| class MockWalletClientDelegate : public WalletClientDelegate {
|
| public:
|
| MockWalletClientDelegate()
|
| @@ -664,27 +606,15 @@ class MockWalletClientDelegate : public WalletClientDelegate {
|
| DIALOG_TYPE_REQUEST_AUTOCOMPLETE, metric)).Times(1);
|
| }
|
|
|
| - void ExpectBaselineMetrics(EscrowRequestPresence escrow_request_presence,
|
| - WalletRequestPresence wallet_request_presence) {
|
| - int num_requests = 0;
|
| - if (escrow_request_presence == HAS_ESCROW_REQUEST)
|
| - ++num_requests;
|
| - if (wallet_request_presence == HAS_WALLET_REQUEST)
|
| - ++num_requests;
|
| -
|
| - EXPECT_GT(num_requests, 0);
|
| -
|
| + void ExpectBaselineMetrics() {
|
| EXPECT_CALL(
|
| metric_logger_,
|
| LogWalletErrorMetric(
|
| DIALOG_TYPE_REQUEST_AUTOCOMPLETE,
|
| AutofillMetrics::WALLET_ERROR_BASELINE_ISSUED_REQUEST))
|
| - .Times(num_requests);
|
| -
|
| - if (wallet_request_presence == HAS_WALLET_REQUEST) {
|
| - ExpectWalletRequiredActionMetric(
|
| - AutofillMetrics::WALLET_REQUIRED_ACTION_BASELINE_ISSUED_REQUEST);
|
| - }
|
| + .Times(1);
|
| + ExpectWalletRequiredActionMetric(
|
| + AutofillMetrics::WALLET_REQUIRED_ACTION_BASELINE_ISSUED_REQUEST);
|
| }
|
|
|
| MockAutofillMetrics* metric_logger() {
|
| @@ -693,27 +623,11 @@ class MockWalletClientDelegate : public WalletClientDelegate {
|
|
|
| MOCK_METHOD0(OnDidAcceptLegalDocuments, void());
|
| MOCK_METHOD1(OnDidAuthenticateInstrument, void(bool success));
|
| - MOCK_METHOD3(OnDidSaveAddress,
|
| - void(const std::string& address_id,
|
| - const std::vector<RequiredAction>& required_actions,
|
| - const std::vector<FormFieldError>& form_field_errors));
|
| - MOCK_METHOD3(OnDidSaveInstrument,
|
| - void(const std::string& instrument_id,
|
| - const std::vector<RequiredAction>& required_actions,
|
| - const std::vector<FormFieldError>& form_field_errors));
|
| - MOCK_METHOD4(OnDidSaveInstrumentAndAddress,
|
| + MOCK_METHOD4(OnDidSaveToWallet,
|
| void(const std::string& instrument_id,
|
| const std::string& shipping_address_id,
|
| const std::vector<RequiredAction>& required_actions,
|
| const std::vector<FormFieldError>& form_field_errors));
|
| - MOCK_METHOD3(OnDidUpdateAddress,
|
| - void(const std::string& address_id,
|
| - const std::vector<RequiredAction>& required_actions,
|
| - const std::vector<FormFieldError>& form_field_errors));
|
| - MOCK_METHOD3(OnDidUpdateInstrument,
|
| - void(const std::string& instrument_id,
|
| - const std::vector<RequiredAction>& required_actions,
|
| - const std::vector<FormFieldError>& form_field_errors));
|
| MOCK_METHOD1(OnWalletError, void(WalletClient::ErrorType error_type));
|
|
|
| virtual void OnDidGetFullWallet(scoped_ptr<FullWallet> full_wallet) OVERRIDE {
|
| @@ -750,36 +664,46 @@ class WalletClientTest : public testing::Test {
|
| wallet_client_.reset();
|
| }
|
|
|
| - std::string GetData(net::TestURLFetcher* fetcher) {
|
| - std::string data = fetcher->upload_data();
|
| - scoped_ptr<Value> root(base::JSONReader::Read(data));
|
| -
|
| - // If this is not a JSON dictionary, return plain text.
|
| - if (root.get() == NULL || !root->IsType(Value::TYPE_DICTIONARY))
|
| - return data;
|
| -
|
| - // Remove api_key entry (to prevent accidental leak), return JSON as text.
|
| - DictionaryValue* dict = static_cast<DictionaryValue*>(root.get());
|
| - dict->Remove("api_key", NULL);
|
| - base::JSONWriter::Write(dict, &data);
|
| - return data;
|
| - }
|
| -
|
| - void DoEncryptionOrEscrowRequest(net::HttpStatusCode response_code,
|
| - const std::string& response_body) {
|
| - net::TestURLFetcher* encryption_fetcher = factory_.GetFetcherByID(1);
|
| - ASSERT_TRUE(encryption_fetcher);
|
| - encryption_fetcher->set_response_code(response_code);
|
| - encryption_fetcher->SetResponseString(response_body);
|
| - encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher);
|
| - }
|
| -
|
| void VerifyAndFinishRequest(net::HttpStatusCode response_code,
|
| const std::string& request_body,
|
| const std::string& response_body) {
|
| net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0);
|
| ASSERT_TRUE(fetcher);
|
| - EXPECT_EQ(request_body, GetData(fetcher));
|
| + EXPECT_EQ(request_body, GetData(fetcher->upload_data()));
|
| + fetcher->set_response_code(response_code);
|
| + fetcher->SetResponseString(response_body);
|
| + fetcher->delegate()->OnURLFetchComplete(fetcher);
|
| + }
|
| +
|
| + void VerifyAndFinishFormEncodedRequest(net::HttpStatusCode response_code,
|
| + const std::string& json_payload,
|
| + const std::string& response_body) {
|
| + net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0);
|
| + ASSERT_TRUE(fetcher);
|
| +
|
| + const std::string& upload_data = fetcher->upload_data();
|
| + std::vector<std::pair<std::string, std::string> > tokens;
|
| + base::SplitStringIntoKeyValuePairs(upload_data, '=', '&', &tokens);
|
| +
|
| + for (size_t i = 0; i < tokens.size(); ++i) {
|
| + const std::string& key = tokens[i].first;
|
| + const std::string& value = tokens[i].second;
|
| +
|
| + if (key == "request_content_type")
|
| + EXPECT_EQ("application/json", value);
|
| +
|
| + if (key == "request") {
|
| + EXPECT_EQ(json_payload,
|
| + GetData(
|
| + net::UnescapeURLComponent(
|
| + value, net::UnescapeRule::URL_SPECIAL_CHARS |
|
| + net::UnescapeRule::REPLACE_PLUS_WITH_SPACE)));
|
| + }
|
| +
|
| + // TODO(ahutter): Check that cvn and cc_number are present and that otp
|
| + // is non-empty.
|
| + }
|
| +
|
| fetcher->set_response_code(response_code);
|
| fetcher->SetResponseString(response_body);
|
| fetcher->delegate()->OnURLFetchComplete(fetcher);
|
| @@ -791,6 +715,21 @@ class WalletClientTest : public testing::Test {
|
| MockWalletClientDelegate delegate_;
|
|
|
| private:
|
| + std::string GetData(const std::string& upload_data) {
|
| + scoped_ptr<Value> root(base::JSONReader::Read(upload_data));
|
| +
|
| + // If this is not a JSON dictionary, return plain text.
|
| + if (!root || !root->IsType(Value::TYPE_DICTIONARY))
|
| + return upload_data;
|
| +
|
| + // Remove api_key entry (to prevent accidental leak), return JSON as text.
|
| + DictionaryValue* dict = static_cast<DictionaryValue*>(root.get());
|
| + dict->Remove("api_key", NULL);
|
| + std::string clean_upload_data;
|
| + base::JSONWriter::Write(dict, &clean_upload_data);
|
| + return clean_upload_data;
|
| + }
|
| +
|
| net::TestURLFetcherFactory factory_;
|
| };
|
|
|
| @@ -798,7 +737,7 @@ TEST_F(WalletClientTest, WalletError) {
|
| EXPECT_CALL(delegate_, OnWalletError(
|
| WalletClient::SERVICE_UNAVAILABLE)).Times(1);
|
| delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SEND_STATUS, 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletErrorMetric(
|
| AutofillMetrics::WALLET_SERVICE_UNAVAILABLE);
|
|
|
| @@ -816,7 +755,7 @@ TEST_F(WalletClientTest, WalletErrorResponseMissing) {
|
| EXPECT_CALL(delegate_, OnWalletError(
|
| WalletClient::UNKNOWN_ERROR)).Times(1);
|
| delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SEND_STATUS, 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_UNKNOWN_ERROR);
|
|
|
| std::vector<AutocheckoutStatistic> statistics;
|
| @@ -832,7 +771,7 @@ TEST_F(WalletClientTest, WalletErrorResponseMissing) {
|
| TEST_F(WalletClientTest, NetworkFailureOnExpectedVoidResponse) {
|
| EXPECT_CALL(delegate_, OnWalletError(WalletClient::NETWORK_ERROR)).Times(1);
|
| delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SEND_STATUS, 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_NETWORK_ERROR);
|
|
|
| std::vector<AutocheckoutStatistic> statistics;
|
| @@ -849,7 +788,7 @@ TEST_F(WalletClientTest, NetworkFailureOnExpectedResponse) {
|
| EXPECT_CALL(delegate_, OnWalletError(WalletClient::NETWORK_ERROR)).Times(1);
|
| delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_WALLET_ITEMS,
|
| 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_NETWORK_ERROR);
|
|
|
| wallet_client_->GetWalletItems(GURL(kMerchantUrl));
|
| @@ -861,7 +800,7 @@ TEST_F(WalletClientTest, NetworkFailureOnExpectedResponse) {
|
| TEST_F(WalletClientTest, RequestError) {
|
| EXPECT_CALL(delegate_, OnWalletError(WalletClient::BAD_REQUEST)).Times(1);
|
| delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SEND_STATUS, 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_BAD_REQUEST);
|
|
|
| std::vector<AutocheckoutStatistic> statistics;
|
| @@ -876,7 +815,7 @@ TEST_F(WalletClientTest, RequestError) {
|
|
|
| TEST_F(WalletClientTest, GetFullWalletSuccess) {
|
| delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_FULL_WALLET, 1);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
|
|
| WalletClient::FullWalletRequest full_wallet_request(
|
| "instrument_id",
|
| @@ -886,18 +825,15 @@ TEST_F(WalletClientTest, GetFullWalletSuccess) {
|
| std::vector<WalletClient::RiskCapability>());
|
| wallet_client_->GetFullWallet(full_wallet_request);
|
|
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK,
|
| - "session_material|encrypted_one_time_pad");
|
| -
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kGetFullWalletValidRequest,
|
| - kGetFullWalletValidResponse);
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kGetFullWalletValidRequest,
|
| + kGetFullWalletValidResponse);
|
| EXPECT_EQ(1U, delegate_.full_wallets_received());
|
| }
|
|
|
| TEST_F(WalletClientTest, GetFullWalletWithRiskCapabilitesSuccess) {
|
| delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_FULL_WALLET, 1);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
|
|
| std::vector<WalletClient::RiskCapability> risk_capabilities;
|
| risk_capabilities.push_back(WalletClient::VERIFY_CVC);
|
| @@ -909,60 +845,19 @@ TEST_F(WalletClientTest, GetFullWalletWithRiskCapabilitesSuccess) {
|
| risk_capabilities);
|
| wallet_client_->GetFullWallet(full_wallet_request);
|
|
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK,
|
| - "session_material|encrypted_one_time_pad");
|
| -
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kGetFullWalletWithRiskCapabilitesValidRequest,
|
| - kGetFullWalletValidResponse);
|
| + VerifyAndFinishFormEncodedRequest(
|
| + net::HTTP_OK,
|
| + kGetFullWalletWithRiskCapabilitesValidRequest,
|
| + kGetFullWalletValidResponse);
|
| EXPECT_EQ(1U, delegate_.full_wallets_received());
|
| }
|
|
|
| -TEST_F(WalletClientTest, GetFullWalletEncryptionDown) {
|
| - EXPECT_CALL(delegate_, OnWalletError(WalletClient::NETWORK_ERROR)).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_FULL_WALLET, 0);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, NO_WALLET_REQUEST);
|
| - delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_NETWORK_ERROR);
|
| -
|
| - WalletClient::FullWalletRequest full_wallet_request(
|
| - "instrument_id",
|
| - "shipping_address_id",
|
| - GURL(kMerchantUrl),
|
| - "google_transaction_id",
|
| - std::vector<WalletClient::RiskCapability>());
|
| - wallet_client_->GetFullWallet(full_wallet_request);
|
| -
|
| - DoEncryptionOrEscrowRequest(net::HTTP_INTERNAL_SERVER_ERROR, std::string());
|
| -
|
| - EXPECT_EQ(0U, delegate_.full_wallets_received());
|
| -}
|
| -
|
| -TEST_F(WalletClientTest, GetFullWalletEncryptionMalformed) {
|
| - EXPECT_CALL(delegate_,
|
| - OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_FULL_WALLET, 0);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, NO_WALLET_REQUEST);
|
| - delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
|
| -
|
| - WalletClient::FullWalletRequest full_wallet_request(
|
| - "instrument_id",
|
| - "shipping_address_id",
|
| - GURL(kMerchantUrl),
|
| - "google_transaction_id",
|
| - std::vector<WalletClient::RiskCapability>());
|
| - wallet_client_->GetFullWallet(full_wallet_request);
|
| -
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK,
|
| - "session_material:encrypted_one_time_pad");
|
| -
|
| - EXPECT_EQ(0U, delegate_.full_wallets_received());
|
| -}
|
|
|
| TEST_F(WalletClientTest, GetFullWalletMalformedResponse) {
|
| EXPECT_CALL(delegate_,
|
| OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
|
| delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_FULL_WALLET, 1);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
|
|
|
| WalletClient::FullWalletRequest full_wallet_request(
|
| @@ -973,12 +868,9 @@ TEST_F(WalletClientTest, GetFullWalletMalformedResponse) {
|
| std::vector<WalletClient::RiskCapability>());
|
| wallet_client_->GetFullWallet(full_wallet_request);
|
|
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK,
|
| - "session_material|encrypted_one_time_pad");
|
| -
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kGetFullWalletValidRequest,
|
| - kGetFullWalletInvalidResponse);
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kGetFullWalletValidRequest,
|
| + kGetFullWalletInvalidResponse);
|
| EXPECT_EQ(0U, delegate_.full_wallets_received());
|
| }
|
|
|
| @@ -987,7 +879,7 @@ TEST_F(WalletClientTest, AcceptLegalDocuments) {
|
| delegate_.ExpectLogWalletApiCallDuration(
|
| AutofillMetrics::ACCEPT_LEGAL_DOCUMENTS,
|
| 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
|
|
| ScopedVector<WalletItems::LegalDocument> docs;
|
| base::DictionaryValue document;
|
| @@ -1014,17 +906,13 @@ TEST_F(WalletClientTest, AuthenticateInstrumentSucceeded) {
|
| delegate_.ExpectLogWalletApiCallDuration(
|
| AutofillMetrics::AUTHENTICATE_INSTRUMENT,
|
| 1);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| -
|
| - wallet_client_->AuthenticateInstrument("instrument_id",
|
| - "cvv",
|
| - "obfuscated_gaia_id");
|
| + delegate_.ExpectBaselineMetrics();
|
|
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK, "escrow_handle");
|
| + wallet_client_->AuthenticateInstrument("instrument_id", "cvv");
|
|
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kAuthenticateInstrumentValidRequest,
|
| - kAuthenticateInstrumentSuccessResponse);
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kAuthenticateInstrumentValidRequest,
|
| + kAuthenticateInstrumentSuccessResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, AuthenticateInstrumentFailed) {
|
| @@ -1032,48 +920,13 @@ TEST_F(WalletClientTest, AuthenticateInstrumentFailed) {
|
| delegate_.ExpectLogWalletApiCallDuration(
|
| AutofillMetrics::AUTHENTICATE_INSTRUMENT,
|
| 1);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| -
|
| - wallet_client_->AuthenticateInstrument("instrument_id",
|
| - "cvv",
|
| - "obfuscated_gaia_id");
|
| + delegate_.ExpectBaselineMetrics();
|
|
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK, "escrow_handle");
|
| + wallet_client_->AuthenticateInstrument("instrument_id", "cvv");
|
|
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kAuthenticateInstrumentValidRequest,
|
| - kAuthenticateInstrumentFailureResponse);
|
| -}
|
| -
|
| -TEST_F(WalletClientTest, AuthenticateInstrumentEscrowDown) {
|
| - EXPECT_CALL(delegate_, OnWalletError(WalletClient::NETWORK_ERROR)).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(
|
| - AutofillMetrics::AUTHENTICATE_INSTRUMENT,
|
| - 0);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, NO_WALLET_REQUEST);
|
| - delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_NETWORK_ERROR);
|
| -
|
| - wallet_client_->AuthenticateInstrument("instrument_id",
|
| - "cvv",
|
| - "obfuscated_gaia_id");
|
| -
|
| - DoEncryptionOrEscrowRequest(net::HTTP_INTERNAL_SERVER_ERROR, std::string());
|
| -}
|
| -
|
| -TEST_F(WalletClientTest, AuthenticateInstrumentEscrowMalformed) {
|
| - EXPECT_CALL(delegate_,
|
| - OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(
|
| - AutofillMetrics::AUTHENTICATE_INSTRUMENT,
|
| - 0);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, NO_WALLET_REQUEST);
|
| - delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
|
| -
|
| - wallet_client_->AuthenticateInstrument("instrument_id",
|
| - "cvv",
|
| - "obfuscated_gaia_id");
|
| -
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK, std::string());
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kAuthenticateInstrumentValidRequest,
|
| + kAuthenticateInstrumentFailureResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, AuthenticateInstrumentFailedMalformedResponse) {
|
| @@ -1082,18 +935,14 @@ TEST_F(WalletClientTest, AuthenticateInstrumentFailedMalformedResponse) {
|
| delegate_.ExpectLogWalletApiCallDuration(
|
| AutofillMetrics::AUTHENTICATE_INSTRUMENT,
|
| 1);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
|
|
|
| - wallet_client_->AuthenticateInstrument("instrument_id",
|
| - "cvv",
|
| - "obfuscated_gaia_id");
|
| -
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK, "escrow_handle");
|
| + wallet_client_->AuthenticateInstrument("instrument_id", "cvv");
|
|
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kAuthenticateInstrumentValidRequest,
|
| - kSaveInvalidResponse);
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kAuthenticateInstrumentValidRequest,
|
| + kSaveInvalidResponse);
|
| }
|
|
|
| // TODO(ahutter): Add failure tests for GetWalletItems.
|
| @@ -1101,7 +950,7 @@ TEST_F(WalletClientTest, AuthenticateInstrumentFailedMalformedResponse) {
|
| TEST_F(WalletClientTest, GetWalletItems) {
|
| delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_WALLET_ITEMS,
|
| 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
|
|
| wallet_client_->GetWalletItems(GURL(kMerchantUrl));
|
|
|
| @@ -1113,22 +962,25 @@ TEST_F(WalletClientTest, GetWalletItems) {
|
|
|
| TEST_F(WalletClientTest, SaveAddressSucceeded) {
|
| EXPECT_CALL(delegate_,
|
| - OnDidSaveAddress("saved_address_id",
|
| - std::vector<RequiredAction>(),
|
| - std::vector<FormFieldError>())).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_ADDRESS, 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + OnDidSaveToWallet(std::string(),
|
| + "saved_address_id",
|
| + std::vector<RequiredAction>(),
|
| + std::vector<FormFieldError>())).Times(1);
|
| + delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
|
| + delegate_.ExpectBaselineMetrics();
|
|
|
| scoped_ptr<Address> address = GetTestSaveableAddress();
|
| - wallet_client_->SaveAddress(*address, GURL(kMerchantUrl));
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kSaveAddressValidRequest,
|
| - kSaveAddressValidResponse);
|
| + wallet_client_->SaveToWallet(scoped_ptr<Instrument>(),
|
| + address.Pass(),
|
| + GURL(kMerchantUrl));
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kSaveAddressValidRequest,
|
| + kSaveAddressValidResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, SaveAddressWithRequiredActionsSucceeded) {
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_ADDRESS, 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletRequiredActionMetric(
|
| AutofillMetrics::REQUIRE_PHONE_NUMBER);
|
| delegate_.ExpectWalletRequiredActionMetric(
|
| @@ -1143,68 +995,75 @@ TEST_F(WalletClientTest, SaveAddressWithRequiredActionsSucceeded) {
|
| FormFieldError::SHIPPING_ADDRESS));
|
|
|
| EXPECT_CALL(delegate_,
|
| - OnDidSaveAddress(std::string(),
|
| - required_actions,
|
| - form_errors)).Times(1);
|
| + OnDidSaveToWallet(std::string(),
|
| + std::string(),
|
| + required_actions,
|
| + form_errors)).Times(1);
|
|
|
| scoped_ptr<Address> address = GetTestSaveableAddress();
|
| - wallet_client_->SaveAddress(*address, GURL(kMerchantUrl));
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kSaveAddressValidRequest,
|
| - kSaveAddressWithRequiredActionsValidResponse);
|
| + wallet_client_->SaveToWallet(scoped_ptr<Instrument>(),
|
| + address.Pass(),
|
| + GURL(kMerchantUrl));
|
| + VerifyAndFinishFormEncodedRequest(
|
| + net::HTTP_OK,
|
| + kSaveAddressValidRequest,
|
| + kSaveAddressWithRequiredActionsValidResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, SaveAddressFailedInvalidRequiredAction) {
|
| EXPECT_CALL(delegate_,
|
| OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_ADDRESS, 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
|
|
|
| scoped_ptr<Address> address = GetTestSaveableAddress();
|
| - wallet_client_->SaveAddress(*address, GURL(kMerchantUrl));
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kSaveAddressValidRequest,
|
| - kSaveWithInvalidRequiredActionsResponse);
|
| + wallet_client_->SaveToWallet(scoped_ptr<Instrument>(),
|
| + address.Pass(),
|
| + GURL(kMerchantUrl));
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kSaveAddressValidRequest,
|
| + kSaveWithInvalidRequiredActionsResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, SaveAddressFailedMalformedResponse) {
|
| EXPECT_CALL(delegate_,
|
| OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_ADDRESS, 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
|
|
|
| scoped_ptr<Address> address = GetTestSaveableAddress();
|
| - wallet_client_->SaveAddress(*address, GURL(kMerchantUrl));
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kSaveAddressValidRequest,
|
| - kSaveInvalidResponse);
|
| + wallet_client_->SaveToWallet(scoped_ptr<Instrument>(),
|
| + address.Pass(),
|
| + GURL(kMerchantUrl));
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kSaveAddressValidRequest,
|
| + kSaveInvalidResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, SaveInstrumentSucceeded) {
|
| EXPECT_CALL(delegate_,
|
| - OnDidSaveInstrument("instrument_id",
|
| - std::vector<RequiredAction>(),
|
| - std::vector<FormFieldError>())).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_INSTRUMENT, 1);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + OnDidSaveToWallet("instrument_id",
|
| + std::string(),
|
| + std::vector<RequiredAction>(),
|
| + std::vector<FormFieldError>())).Times(1);
|
| + delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
|
| + delegate_.ExpectBaselineMetrics();
|
|
|
| scoped_ptr<Instrument> instrument = GetTestInstrument();
|
| - wallet_client_->SaveInstrument(*instrument,
|
| - "obfuscated_gaia_id",
|
| - GURL(kMerchantUrl));
|
| + wallet_client_->SaveToWallet(instrument.Pass(),
|
| + scoped_ptr<Address>(),
|
| + GURL(kMerchantUrl));
|
|
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK, "escrow_handle");
|
| -
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kSaveInstrumentValidRequest,
|
| - kSaveInstrumentValidResponse);
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kSaveInstrumentValidRequest,
|
| + kSaveInstrumentValidResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, SaveInstrumentWithRequiredActionsSucceeded) {
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_INSTRUMENT, 1);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletRequiredActionMetric(
|
| AutofillMetrics::REQUIRE_PHONE_NUMBER);
|
| delegate_.ExpectWalletRequiredActionMetric(
|
| @@ -1219,120 +1078,84 @@ TEST_F(WalletClientTest, SaveInstrumentWithRequiredActionsSucceeded) {
|
| FormFieldError::SHIPPING_ADDRESS));
|
|
|
| EXPECT_CALL(delegate_,
|
| - OnDidSaveInstrument(std::string(),
|
| - required_actions,
|
| - form_errors)).Times(1);
|
| + OnDidSaveToWallet(std::string(),
|
| + std::string(),
|
| + required_actions,
|
| + form_errors)).Times(1);
|
|
|
| scoped_ptr<Instrument> instrument = GetTestInstrument();
|
| - wallet_client_->SaveInstrument(*instrument,
|
| - "obfuscated_gaia_id",
|
| - GURL(kMerchantUrl));
|
| -
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK, "escrow_handle");
|
| + wallet_client_->SaveToWallet(instrument.Pass(),
|
| + scoped_ptr<Address>(),
|
| + GURL(kMerchantUrl));
|
|
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kSaveInstrumentValidRequest,
|
| - kSaveInstrumentWithRequiredActionsValidResponse);
|
| + VerifyAndFinishFormEncodedRequest(
|
| + net::HTTP_OK,
|
| + kSaveInstrumentValidRequest,
|
| + kSaveInstrumentWithRequiredActionsValidResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, SaveInstrumentFailedInvalidRequiredActions) {
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_INSTRUMENT, 1);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
|
|
|
| EXPECT_CALL(delegate_,
|
| OnWalletError(WalletClient::MALFORMED_RESPONSE));
|
|
|
| scoped_ptr<Instrument> instrument = GetTestInstrument();
|
| - wallet_client_->SaveInstrument(*instrument,
|
| - "obfuscated_gaia_id",
|
| - GURL(kMerchantUrl));
|
| + wallet_client_->SaveToWallet(instrument.Pass(),
|
| + scoped_ptr<Address>(),
|
| + GURL(kMerchantUrl));
|
|
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK, "escrow_handle");
|
| -
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kSaveInstrumentValidRequest,
|
| - kSaveWithInvalidRequiredActionsResponse);
|
| -}
|
| -
|
| -TEST_F(WalletClientTest, SaveInstrumentEscrowDown) {
|
| - EXPECT_CALL(delegate_, OnWalletError(WalletClient::NETWORK_ERROR)).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_INSTRUMENT, 0);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, NO_WALLET_REQUEST);
|
| - delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_NETWORK_ERROR);
|
| -
|
| - scoped_ptr<Instrument> instrument = GetTestInstrument();
|
| - wallet_client_->SaveInstrument(*instrument,
|
| - "obfuscated_gaia_id",
|
| - GURL(kMerchantUrl));
|
| -
|
| - DoEncryptionOrEscrowRequest(net::HTTP_INTERNAL_SERVER_ERROR, std::string());
|
| -}
|
| -
|
| -TEST_F(WalletClientTest, SaveInstrumentEscrowMalformed) {
|
| - EXPECT_CALL(delegate_,
|
| - OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_INSTRUMENT, 0);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, NO_WALLET_REQUEST);
|
| - delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
|
| -
|
| - scoped_ptr<Instrument> instrument = GetTestInstrument();
|
| - wallet_client_->SaveInstrument(*instrument,
|
| - "obfuscated_gaia_id",
|
| - GURL(kMerchantUrl));
|
| -
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK, std::string());
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kSaveInstrumentValidRequest,
|
| + kSaveWithInvalidRequiredActionsResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, SaveInstrumentFailedMalformedResponse) {
|
| EXPECT_CALL(delegate_,
|
| OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_INSTRUMENT, 1);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
|
|
|
| scoped_ptr<Instrument> instrument = GetTestInstrument();
|
| - wallet_client_->SaveInstrument(*instrument,
|
| - "obfuscated_gaia_id",
|
| - GURL(kMerchantUrl));
|
| + wallet_client_->SaveToWallet(instrument.Pass(),
|
| + scoped_ptr<Address>(),
|
| + GURL(kMerchantUrl));
|
|
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK, "escrow_handle");
|
| -
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kSaveInstrumentValidRequest,
|
| - kSaveInvalidResponse);
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kSaveInstrumentValidRequest,
|
| + kSaveInvalidResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, SaveInstrumentAndAddressSucceeded) {
|
| EXPECT_CALL(delegate_,
|
| - OnDidSaveInstrumentAndAddress(
|
| - "saved_instrument_id",
|
| - "saved_address_id",
|
| - std::vector<RequiredAction>(),
|
| - std::vector<FormFieldError>())).Times(1);
|
| + OnDidSaveToWallet("saved_instrument_id",
|
| + "saved_address_id",
|
| + std::vector<RequiredAction>(),
|
| + std::vector<FormFieldError>())).Times(1);
|
| delegate_.ExpectLogWalletApiCallDuration(
|
| - AutofillMetrics::SAVE_INSTRUMENT_AND_ADDRESS,
|
| + AutofillMetrics::SAVE_TO_WALLET,
|
| 1);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
|
|
| scoped_ptr<Instrument> instrument = GetTestInstrument();
|
| scoped_ptr<Address> address = GetTestSaveableAddress();
|
| - wallet_client_->SaveInstrumentAndAddress(*instrument,
|
| - *address,
|
| - "obfuscated_gaia_id",
|
| - GURL(kMerchantUrl));
|
| + wallet_client_->SaveToWallet(instrument.Pass(),
|
| + address.Pass(),
|
| + GURL(kMerchantUrl));
|
|
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK, "escrow_handle");
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kSaveInstrumentAndAddressValidRequest,
|
| - kSaveInstrumentAndAddressValidResponse);
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kSaveInstrumentAndAddressValidRequest,
|
| + kSaveInstrumentAndAddressValidResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, SaveInstrumentAndAddressWithRequiredActionsSucceeded) {
|
| delegate_.ExpectLogWalletApiCallDuration(
|
| - AutofillMetrics::SAVE_INSTRUMENT_AND_ADDRESS,
|
| + AutofillMetrics::SAVE_TO_WALLET,
|
| 1);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletRequiredActionMetric(
|
| AutofillMetrics::REQUIRE_PHONE_NUMBER);
|
| delegate_.ExpectWalletRequiredActionMetric(
|
| @@ -1347,21 +1170,18 @@ TEST_F(WalletClientTest, SaveInstrumentAndAddressWithRequiredActionsSucceeded) {
|
| FormFieldError::SHIPPING_ADDRESS));
|
|
|
| EXPECT_CALL(delegate_,
|
| - OnDidSaveInstrumentAndAddress(
|
| - std::string(),
|
| - std::string(),
|
| - required_actions,
|
| - form_errors)).Times(1);
|
| + OnDidSaveToWallet(std::string(),
|
| + std::string(),
|
| + required_actions,
|
| + form_errors)).Times(1);
|
|
|
| scoped_ptr<Instrument> instrument = GetTestInstrument();
|
| scoped_ptr<Address> address = GetTestSaveableAddress();
|
| - wallet_client_->SaveInstrumentAndAddress(*instrument,
|
| - *address,
|
| - "obfuscated_gaia_id",
|
| - GURL(kMerchantUrl));
|
| + wallet_client_->SaveToWallet(instrument.Pass(),
|
| + address.Pass(),
|
| + GURL(kMerchantUrl));
|
|
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK, "escrow_handle");
|
| - VerifyAndFinishRequest(
|
| + VerifyAndFinishFormEncodedRequest(
|
| net::HTTP_OK,
|
| kSaveInstrumentAndAddressValidRequest,
|
| kSaveInstrumentAndAddressWithRequiredActionsValidResponse);
|
| @@ -1371,128 +1191,45 @@ TEST_F(WalletClientTest, SaveInstrumentAndAddressFailedInvalidRequiredAction) {
|
| EXPECT_CALL(delegate_,
|
| OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
|
| delegate_.ExpectLogWalletApiCallDuration(
|
| - AutofillMetrics::SAVE_INSTRUMENT_AND_ADDRESS,
|
| + AutofillMetrics::SAVE_TO_WALLET,
|
| 1);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
|
|
|
| scoped_ptr<Instrument> instrument = GetTestInstrument();
|
| scoped_ptr<Address> address = GetTestSaveableAddress();
|
| - wallet_client_->SaveInstrumentAndAddress(*instrument,
|
| - *address,
|
| - "obfuscated_gaia_id",
|
| - GURL(kMerchantUrl));
|
| -
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK, "escrow_handle");
|
| + wallet_client_->SaveToWallet(instrument.Pass(),
|
| + address.Pass(),
|
| + GURL(kMerchantUrl));
|
|
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kSaveInstrumentAndAddressValidRequest,
|
| - kSaveWithInvalidRequiredActionsResponse);
|
| -}
|
| -
|
| -TEST_F(WalletClientTest, SaveInstrumentAndAddressEscrowDown) {
|
| - EXPECT_CALL(delegate_, OnWalletError(WalletClient::NETWORK_ERROR)).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(
|
| - AutofillMetrics::SAVE_INSTRUMENT_AND_ADDRESS,
|
| - 0);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, NO_WALLET_REQUEST);
|
| - delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_NETWORK_ERROR);
|
| -
|
| - scoped_ptr<Instrument> instrument = GetTestInstrument();
|
| - scoped_ptr<Address> address = GetTestSaveableAddress();
|
| - wallet_client_->SaveInstrumentAndAddress(*instrument,
|
| - *address,
|
| - "obfuscated_gaia_id",
|
| - GURL(kMerchantUrl));
|
| -
|
| - DoEncryptionOrEscrowRequest(net::HTTP_INTERNAL_SERVER_ERROR, std::string());
|
| -}
|
| -
|
| -TEST_F(WalletClientTest, SaveInstrumentAndAddressEscrowMalformed) {
|
| - EXPECT_CALL(delegate_,
|
| - OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(
|
| - AutofillMetrics::SAVE_INSTRUMENT_AND_ADDRESS,
|
| - 0);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, NO_WALLET_REQUEST);
|
| - delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
|
| -
|
| - scoped_ptr<Instrument> instrument = GetTestInstrument();
|
| - scoped_ptr<Address> address = GetTestSaveableAddress();
|
| - wallet_client_->SaveInstrumentAndAddress(*instrument,
|
| - *address,
|
| - "obfuscated_gaia_id",
|
| - GURL(kMerchantUrl));
|
| -
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK, std::string());
|
| -}
|
| -
|
| -TEST_F(WalletClientTest, SaveInstrumentAndAddressFailedAddressMissing) {
|
| - EXPECT_CALL(delegate_,
|
| - OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(
|
| - AutofillMetrics::SAVE_INSTRUMENT_AND_ADDRESS,
|
| - 1);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| - delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
|
| -
|
| - scoped_ptr<Instrument> instrument = GetTestInstrument();
|
| - scoped_ptr<Address> address = GetTestSaveableAddress();
|
| - wallet_client_->SaveInstrumentAndAddress(*instrument,
|
| - *address,
|
| - "obfuscated_gaia_id",
|
| - GURL(kMerchantUrl));
|
| -
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK, "escrow_handle");
|
| -
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kSaveInstrumentAndAddressValidRequest,
|
| - kSaveInstrumentAndAddressMissingAddressResponse);
|
| -}
|
| -
|
| -TEST_F(WalletClientTest, SaveInstrumentAndAddressFailedInstrumentMissing) {
|
| - EXPECT_CALL(delegate_,
|
| - OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(
|
| - AutofillMetrics::SAVE_INSTRUMENT_AND_ADDRESS,
|
| - 1);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| - delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
|
| -
|
| - scoped_ptr<Instrument> instrument = GetTestInstrument();
|
| - scoped_ptr<Address> address = GetTestSaveableAddress();
|
| - wallet_client_->SaveInstrumentAndAddress(*instrument,
|
| - *address,
|
| - "obfuscated_gaia_id",
|
| - GURL(kMerchantUrl));
|
| -
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK, "escrow_handle");
|
| -
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kSaveInstrumentAndAddressValidRequest,
|
| - kSaveInstrumentAndAddressMissingInstrumentResponse);
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kSaveInstrumentAndAddressValidRequest,
|
| + kSaveWithInvalidRequiredActionsResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, UpdateAddressSucceeded) {
|
| EXPECT_CALL(delegate_,
|
| - OnDidUpdateAddress("shipping_address_id",
|
| - std::vector<RequiredAction>(),
|
| - std::vector<FormFieldError>())).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::UPDATE_ADDRESS, 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + OnDidSaveToWallet(std::string(),
|
| + "shipping_address_id",
|
| + std::vector<RequiredAction>(),
|
| + std::vector<FormFieldError>())).Times(1);
|
| + delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
|
| + delegate_.ExpectBaselineMetrics();
|
|
|
| scoped_ptr<Address> address = GetTestShippingAddress();
|
| address->set_object_id("shipping_address_id");
|
|
|
| - wallet_client_->UpdateAddress(*address, GURL(kMerchantUrl));
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kUpdateAddressValidRequest,
|
| - kUpdateAddressValidResponse);
|
| + wallet_client_->SaveToWallet(scoped_ptr<Instrument>(),
|
| + address.Pass(),
|
| + GURL(kMerchantUrl));
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kUpdateAddressValidRequest,
|
| + kUpdateAddressValidResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, UpdateAddressWithRequiredActionsSucceeded) {
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::UPDATE_ADDRESS, 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletRequiredActionMetric(
|
| AutofillMetrics::REQUIRE_PHONE_NUMBER);
|
| delegate_.ExpectWalletRequiredActionMetric(
|
| @@ -1506,153 +1243,120 @@ TEST_F(WalletClientTest, UpdateAddressWithRequiredActionsSucceeded) {
|
| form_errors.push_back(FormFieldError(FormFieldError::INVALID_POSTAL_CODE,
|
| FormFieldError::SHIPPING_ADDRESS));
|
|
|
| - EXPECT_CALL(delegate_, OnDidUpdateAddress(std::string(),
|
| - required_actions,
|
| - form_errors)).Times(1);
|
| + EXPECT_CALL(delegate_, OnDidSaveToWallet(std::string(),
|
| + std::string(),
|
| + required_actions,
|
| + form_errors)).Times(1);
|
|
|
| scoped_ptr<Address> address = GetTestShippingAddress();
|
| address->set_object_id("shipping_address_id");
|
|
|
| - wallet_client_->UpdateAddress(*address, GURL(kMerchantUrl));
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kUpdateAddressValidRequest,
|
| - kUpdateWithRequiredActionsValidResponse);
|
| + wallet_client_->SaveToWallet(scoped_ptr<Instrument>(),
|
| + address.Pass(),
|
| + GURL(kMerchantUrl));
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kUpdateAddressValidRequest,
|
| + kUpdateWithRequiredActionsValidResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, UpdateAddressFailedInvalidRequiredAction) {
|
| EXPECT_CALL(delegate_,
|
| OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::UPDATE_ADDRESS, 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
|
|
|
| scoped_ptr<Address> address = GetTestShippingAddress();
|
| address->set_object_id("shipping_address_id");
|
|
|
| - wallet_client_->UpdateAddress(*address, GURL(kMerchantUrl));
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kUpdateAddressValidRequest,
|
| - kSaveWithInvalidRequiredActionsResponse);
|
| + wallet_client_->SaveToWallet(scoped_ptr<Instrument>(),
|
| + address.Pass(),
|
| + GURL(kMerchantUrl));
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kUpdateAddressValidRequest,
|
| + kSaveWithInvalidRequiredActionsResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, UpdateAddressMalformedResponse) {
|
| EXPECT_CALL(delegate_,
|
| OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::UPDATE_ADDRESS, 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
|
|
|
| scoped_ptr<Address> address = GetTestShippingAddress();
|
| address->set_object_id("shipping_address_id");
|
|
|
| - wallet_client_->UpdateAddress(*address, GURL(kMerchantUrl));
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kUpdateAddressValidRequest,
|
| - kUpdateMalformedResponse);
|
| + wallet_client_->SaveToWallet(scoped_ptr<Instrument>(),
|
| + address.Pass(),
|
| + GURL(kMerchantUrl));
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kUpdateAddressValidRequest,
|
| + kUpdateMalformedResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, UpdateInstrumentAddressSucceeded) {
|
| EXPECT_CALL(delegate_,
|
| - OnDidUpdateInstrument("instrument_id",
|
| - std::vector<RequiredAction>(),
|
| - std::vector<FormFieldError>())).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::UPDATE_INSTRUMENT,
|
| + OnDidSaveToWallet("instrument_id",
|
| + std::string(),
|
| + std::vector<RequiredAction>(),
|
| + std::vector<FormFieldError>())).Times(1);
|
| + delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET,
|
| 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| -
|
| - WalletClient::UpdateInstrumentRequest update_instrument_request(
|
| - "instrument_id",
|
| - GURL(kMerchantUrl));
|
| + delegate_.ExpectBaselineMetrics();
|
|
|
| - wallet_client_->UpdateInstrument(update_instrument_request, GetTestAddress());
|
| + wallet_client_->SaveToWallet(GetTestAddressUpgradeInstrument(),
|
| + scoped_ptr<Address>(),
|
| + GURL(kMerchantUrl));
|
|
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kUpdateInstrumentAddressValidRequest,
|
| - kUpdateInstrumentValidResponse);
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kUpdateInstrumentAddressValidRequest,
|
| + kUpdateInstrumentValidResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, UpdateInstrumentExpirationDateSuceeded) {
|
| EXPECT_CALL(delegate_,
|
| - OnDidUpdateInstrument("instrument_id",
|
| - std::vector<RequiredAction>(),
|
| - std::vector<FormFieldError>())).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::UPDATE_INSTRUMENT,
|
| + OnDidSaveToWallet("instrument_id",
|
| + std::string(),
|
| + std::vector<RequiredAction>(),
|
| + std::vector<FormFieldError>())).Times(1);
|
| + delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET,
|
| 1);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
|
|
| - WalletClient::UpdateInstrumentRequest update_instrument_request(
|
| - "instrument_id",
|
| - GURL(kMerchantUrl));
|
| - update_instrument_request.expiration_month = 12;
|
| - update_instrument_request.expiration_year = 2015;
|
| - update_instrument_request.card_verification_number =
|
| - "card_verification_number";
|
| - update_instrument_request.obfuscated_gaia_id = "obfuscated_gaia_id";
|
| - wallet_client_->UpdateInstrument(update_instrument_request,
|
| - scoped_ptr<Address>());
|
| -
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK, "escrow_handle");
|
| + wallet_client_->SaveToWallet(GetTestExpirationDateChangeInstrument(),
|
| + scoped_ptr<Address>(),
|
| + GURL(kMerchantUrl));
|
|
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kUpdateInstrumentExpirationDateValidRequest,
|
| - kUpdateInstrumentValidResponse);
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kUpdateInstrumentExpirationDateValidRequest,
|
| + kUpdateInstrumentValidResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, UpdateInstrumentAddressWithNameChangeSucceeded) {
|
| EXPECT_CALL(delegate_,
|
| - OnDidUpdateInstrument("instrument_id",
|
| - std::vector<RequiredAction>(),
|
| - std::vector<FormFieldError>())).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::UPDATE_INSTRUMENT,
|
| - 1);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| -
|
| - WalletClient::UpdateInstrumentRequest update_instrument_request(
|
| - "instrument_id",
|
| - GURL(kMerchantUrl));
|
| - update_instrument_request.card_verification_number =
|
| - "card_verification_number";
|
| - update_instrument_request.obfuscated_gaia_id = "obfuscated_gaia_id";
|
| -
|
| - wallet_client_->UpdateInstrument(update_instrument_request, GetTestAddress());
|
| -
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK, "escrow_handle");
|
| -
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kUpdateInstrumentAddressWithNameChangeValidRequest,
|
| - kUpdateInstrumentValidResponse);
|
| -}
|
| -
|
| -TEST_F(WalletClientTest, UpdateInstrumentAddressAndExpirationDateSucceeded) {
|
| - EXPECT_CALL(delegate_,
|
| - OnDidUpdateInstrument("instrument_id",
|
| - std::vector<RequiredAction>(),
|
| - std::vector<FormFieldError>())).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::UPDATE_INSTRUMENT,
|
| + OnDidSaveToWallet("instrument_id",
|
| + std::string(),
|
| + std::vector<RequiredAction>(),
|
| + std::vector<FormFieldError>())).Times(1);
|
| + delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET,
|
| 1);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
|
|
| - WalletClient::UpdateInstrumentRequest update_instrument_request(
|
| - "instrument_id",
|
| - GURL(kMerchantUrl));
|
| - update_instrument_request.expiration_month = 12;
|
| - update_instrument_request.expiration_year = 2015;
|
| - update_instrument_request.card_verification_number =
|
| - "card_verification_number";
|
| - update_instrument_request.obfuscated_gaia_id = "obfuscated_gaia_id";
|
| - wallet_client_->UpdateInstrument(update_instrument_request, GetTestAddress());
|
| -
|
| - DoEncryptionOrEscrowRequest(net::HTTP_OK, "escrow_handle");
|
| + wallet_client_->SaveToWallet(GetTestAddressNameChangeInstrument(),
|
| + scoped_ptr<Address>(),
|
| + GURL(kMerchantUrl));
|
|
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kUpdateInstrumentAddressAndExpirationDateValidRequest,
|
| - kUpdateInstrumentValidResponse);
|
| + VerifyAndFinishFormEncodedRequest(
|
| + net::HTTP_OK,
|
| + kUpdateInstrumentAddressWithNameChangeValidRequest,
|
| + kUpdateInstrumentValidResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, UpdateInstrumentWithRequiredActionsSucceeded) {
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::UPDATE_INSTRUMENT,
|
| + delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET,
|
| 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletRequiredActionMetric(
|
| AutofillMetrics::REQUIRE_PHONE_NUMBER);
|
| delegate_.ExpectWalletRequiredActionMetric(
|
| @@ -1667,81 +1371,57 @@ TEST_F(WalletClientTest, UpdateInstrumentWithRequiredActionsSucceeded) {
|
| FormFieldError::SHIPPING_ADDRESS));
|
|
|
| EXPECT_CALL(delegate_,
|
| - OnDidUpdateInstrument(std::string(),
|
| - required_actions,
|
| - form_errors)).Times(1);
|
| -
|
| - WalletClient::UpdateInstrumentRequest update_instrument_request(
|
| - "instrument_id",
|
| - GURL(kMerchantUrl));
|
| -
|
| - wallet_client_->UpdateInstrument(update_instrument_request, GetTestAddress());
|
| -
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kUpdateInstrumentAddressValidRequest,
|
| - kUpdateWithRequiredActionsValidResponse);
|
| + OnDidSaveToWallet(std::string(),
|
| + std::string(),
|
| + required_actions,
|
| + form_errors)).Times(1);
|
| +
|
| + wallet_client_->SaveToWallet(GetTestAddressUpgradeInstrument(),
|
| + scoped_ptr<Address>(),
|
| + GURL(kMerchantUrl));
|
| +
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kUpdateInstrumentAddressValidRequest,
|
| + kUpdateWithRequiredActionsValidResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, UpdateInstrumentFailedInvalidRequiredAction) {
|
| EXPECT_CALL(delegate_,
|
| OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::UPDATE_INSTRUMENT,
|
| + delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET,
|
| 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
|
|
|
| - WalletClient::UpdateInstrumentRequest update_instrument_request(
|
| - "instrument_id",
|
| - GURL(kMerchantUrl));
|
| -
|
| - wallet_client_->UpdateInstrument(update_instrument_request, GetTestAddress());
|
| -
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kUpdateInstrumentAddressValidRequest,
|
| - kSaveWithInvalidRequiredActionsResponse);
|
| -}
|
| -
|
| -TEST_F(WalletClientTest, UpdateInstrumentEscrowFailed) {
|
| - EXPECT_CALL(delegate_, OnWalletError(WalletClient::NETWORK_ERROR)).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::UPDATE_INSTRUMENT,
|
| - 0);
|
| - delegate_.ExpectBaselineMetrics(HAS_ESCROW_REQUEST, NO_WALLET_REQUEST);
|
| - delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_NETWORK_ERROR);
|
| -
|
| - WalletClient::UpdateInstrumentRequest update_instrument_request(
|
| - "instrument_id",
|
| - GURL(kMerchantUrl));
|
| - update_instrument_request.card_verification_number =
|
| - "card_verification_number";
|
| - update_instrument_request.obfuscated_gaia_id = "obfuscated_gaia_id";
|
| -
|
| - wallet_client_->UpdateInstrument(update_instrument_request, GetTestAddress());
|
| + wallet_client_->SaveToWallet(GetTestAddressUpgradeInstrument(),
|
| + scoped_ptr<Address>(),
|
| + GURL(kMerchantUrl));
|
|
|
| - DoEncryptionOrEscrowRequest(net::HTTP_INTERNAL_SERVER_ERROR, std::string());
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kUpdateInstrumentAddressValidRequest,
|
| + kSaveWithInvalidRequiredActionsResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, UpdateInstrumentMalformedResponse) {
|
| EXPECT_CALL(delegate_,
|
| OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
|
| - delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::UPDATE_INSTRUMENT,
|
| + delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET,
|
| 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
| delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
|
|
|
| - WalletClient::UpdateInstrumentRequest update_instrument_request(
|
| - "instrument_id",
|
| - GURL(kMerchantUrl));
|
| -
|
| - wallet_client_->UpdateInstrument(update_instrument_request, GetTestAddress());
|
| + wallet_client_->SaveToWallet(GetTestAddressUpgradeInstrument(),
|
| + scoped_ptr<Address>(),
|
| + GURL(kMerchantUrl));
|
|
|
| - VerifyAndFinishRequest(net::HTTP_OK,
|
| - kUpdateInstrumentAddressValidRequest,
|
| - kUpdateMalformedResponse);
|
| + VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
|
| + kUpdateInstrumentAddressValidRequest,
|
| + kUpdateMalformedResponse);
|
| }
|
|
|
| TEST_F(WalletClientTest, SendAutocheckoutOfStatusSuccess) {
|
| delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SEND_STATUS, 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
|
|
| AutocheckoutStatistic statistic;
|
| statistic.page_number = 1;
|
| @@ -1760,7 +1440,7 @@ TEST_F(WalletClientTest, SendAutocheckoutOfStatusSuccess) {
|
|
|
| TEST_F(WalletClientTest, SendAutocheckoutStatusOfFailure) {
|
| delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SEND_STATUS, 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
|
|
| std::vector<AutocheckoutStatistic> statistics;
|
| wallet_client_->SendAutocheckoutStatus(autofill::CANNOT_PROCEED,
|
| @@ -1776,7 +1456,7 @@ TEST_F(WalletClientTest, HasRequestInProgress) {
|
| EXPECT_FALSE(wallet_client_->HasRequestInProgress());
|
| delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_WALLET_ITEMS,
|
| 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
|
|
| wallet_client_->GetWalletItems(GURL(kMerchantUrl));
|
| EXPECT_TRUE(wallet_client_->HasRequestInProgress());
|
| @@ -1791,7 +1471,7 @@ TEST_F(WalletClientTest, PendingRequest) {
|
| EXPECT_EQ(0U, wallet_client_->pending_requests_.size());
|
|
|
| // Shouldn't queue the first request.
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
| wallet_client_->GetWalletItems(GURL(kMerchantUrl));
|
| EXPECT_EQ(0U, wallet_client_->pending_requests_.size());
|
| testing::Mock::VerifyAndClear(delegate_.metric_logger());
|
| @@ -1801,7 +1481,7 @@ TEST_F(WalletClientTest, PendingRequest) {
|
|
|
| delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_WALLET_ITEMS,
|
| 1);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
| VerifyAndFinishRequest(net::HTTP_OK,
|
| kGetWalletItemsValidRequest,
|
| kGetWalletItemsValidResponse);
|
| @@ -1825,7 +1505,7 @@ TEST_F(WalletClientTest, CancelRequests) {
|
| ASSERT_EQ(0U, wallet_client_->pending_requests_.size());
|
| delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_WALLET_ITEMS,
|
| 0);
|
| - delegate_.ExpectBaselineMetrics(NO_ESCROW_REQUEST, HAS_WALLET_REQUEST);
|
| + delegate_.ExpectBaselineMetrics();
|
|
|
| wallet_client_->GetWalletItems(GURL(kMerchantUrl));
|
| wallet_client_->GetWalletItems(GURL(kMerchantUrl));
|
|
|