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

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

Issue 100743006: Fix DCHECK() when updating instruments with no phone number. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: dcheck Created 7 years 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/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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 "\"use_minimal_addresses\":false" 485 "\"use_minimal_addresses\":false"
486 "}"; 486 "}";
487 487
488 const char kUpdateAddressValidRequest[] = 488 const char kUpdateAddressValidRequest[] =
489 "{" 489 "{"
490 "\"merchant_domain\":\"https://example.com/\"," 490 "\"merchant_domain\":\"https://example.com/\","
491 "\"phone_number_required\":true," 491 "\"phone_number_required\":true,"
492 "\"risk_params\":\"risky business\"," 492 "\"risk_params\":\"risky business\","
493 "\"shipping_address\":" 493 "\"shipping_address\":"
494 "{" 494 "{"
495 "\"id\":\"shipping_address_id\"," 495 "\"id\":\"address_id\","
496 "\"phone_number\":\"ship_phone_number\"," 496 "\"phone_number\":\"ship_phone_number\","
497 "\"postal_address\":" 497 "\"postal_address\":"
498 "{" 498 "{"
499 "\"address_line\":" 499 "\"address_line\":"
500 "[" 500 "["
501 "\"ship_address_line_1\"," 501 "\"ship_address_line_1\","
502 "\"ship_address_line_2\"" 502 "\"ship_address_line_2\""
503 "]," 503 "],"
504 "\"administrative_area_name\":\"ship_admin_area_name\"," 504 "\"administrative_area_name\":\"ship_admin_area_name\","
505 "\"country_name_code\":\"US\"," 505 "\"country_name_code\":\"US\","
(...skipping 17 matching lines...) Expand all
523 "[" 523 "["
524 "\"address_line_1\"," 524 "\"address_line_1\","
525 "\"address_line_2\"" 525 "\"address_line_2\""
526 "]," 526 "],"
527 "\"administrative_area_name\":\"admin_area_name\"," 527 "\"administrative_area_name\":\"admin_area_name\","
528 "\"country_name_code\":\"US\"," 528 "\"country_name_code\":\"US\","
529 "\"locality_name\":\"locality_name\"," 529 "\"locality_name\":\"locality_name\","
530 "\"postal_code_number\":\"postal_code_number\"," 530 "\"postal_code_number\":\"postal_code_number\","
531 "\"recipient_name\":\"recipient_name\"" 531 "\"recipient_name\":\"recipient_name\""
532 "}," 532 "},"
533 "\"upgraded_instrument_id\":\"instrument_id\"," 533 "\"upgraded_instrument_id\":\"default_instrument_id\","
534 "\"use_minimal_addresses\":false" 534 "\"use_minimal_addresses\":false"
535 "}"; 535 "}";
536 536
537 const char kUpdateInstrumentAddressWithNameChangeValidRequest[] = 537 const char kUpdateInstrumentAddressWithNameChangeValidRequest[] =
538 "{" 538 "{"
539 "\"instrument_phone_number\":\"phone_number\"," 539 "\"instrument_phone_number\":\"phone_number\","
540 "\"merchant_domain\":\"https://example.com/\"," 540 "\"merchant_domain\":\"https://example.com/\","
541 "\"phone_number_required\":true," 541 "\"phone_number_required\":true,"
542 "\"risk_params\":\"risky business\"," 542 "\"risk_params\":\"risky business\","
543 "\"upgraded_billing_address\":" 543 "\"upgraded_billing_address\":"
544 "{" 544 "{"
545 "\"address_line\":" 545 "\"address_line\":"
546 "[" 546 "["
547 "\"address_line_1\"," 547 "\"address_line_1\","
548 "\"address_line_2\"" 548 "\"address_line_2\""
549 "]," 549 "],"
550 "\"administrative_area_name\":\"admin_area_name\"," 550 "\"administrative_area_name\":\"admin_area_name\","
551 "\"country_name_code\":\"US\"," 551 "\"country_name_code\":\"US\","
552 "\"locality_name\":\"locality_name\"," 552 "\"locality_name\":\"locality_name\","
553 "\"postal_code_number\":\"postal_code_number\"," 553 "\"postal_code_number\":\"postal_code_number\","
554 "\"recipient_name\":\"recipient_name\"" 554 "\"recipient_name\":\"recipient_name\""
555 "}," 555 "},"
556 "\"upgraded_instrument_id\":\"instrument_id\"," 556 "\"upgraded_instrument_id\":\"default_instrument_id\","
557 "\"use_minimal_addresses\":false" 557 "\"use_minimal_addresses\":false"
558 "}"; 558 "}";
559 559
560 const char kUpdateInstrumentExpirationDateValidRequest[] = 560 const char kUpdateInstrumentExpirationDateValidRequest[] =
561 "{" 561 "{"
562 "\"instrument\":" 562 "\"instrument\":"
563 "{" 563 "{"
564 "\"credit_card\":" 564 "\"credit_card\":"
565 "{" 565 "{"
566 "\"exp_month\":12," 566 "\"exp_month\":12,"
567 "\"exp_year\":3000" 567 "\"exp_year\":3001"
568 "}," 568 "},"
569 "\"type\":\"CREDIT_CARD\"" 569 "\"type\":\"CREDIT_CARD\""
570 "}," 570 "},"
571 "\"merchant_domain\":\"https://example.com/\"," 571 "\"merchant_domain\":\"https://example.com/\","
572 "\"phone_number_required\":true," 572 "\"phone_number_required\":true,"
573 "\"risk_params\":\"risky business\"," 573 "\"risk_params\":\"risky business\","
574 "\"upgraded_instrument_id\":\"instrument_id\"," 574 "\"upgraded_instrument_id\":\"instrument_id\","
575 "\"use_minimal_addresses\":false" 575 "\"use_minimal_addresses\":false"
576 "}"; 576 "}";
577 577
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 EXPECT_CALL(delegate_, 1187 EXPECT_CALL(delegate_,
1188 OnDidSaveToWallet(std::string(), 1188 OnDidSaveToWallet(std::string(),
1189 "saved_address_id", 1189 "saved_address_id",
1190 std::vector<RequiredAction>(), 1190 std::vector<RequiredAction>(),
1191 std::vector<FormFieldError>())).Times(1); 1191 std::vector<FormFieldError>())).Times(1);
1192 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1); 1192 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
1193 delegate_.ExpectBaselineMetrics(); 1193 delegate_.ExpectBaselineMetrics();
1194 1194
1195 scoped_ptr<Address> address = GetTestSaveableAddress(); 1195 scoped_ptr<Address> address = GetTestSaveableAddress();
1196 wallet_client_->SaveToWallet(scoped_ptr<Instrument>(), 1196 wallet_client_->SaveToWallet(scoped_ptr<Instrument>(),
1197 address.Pass()); 1197 address.Pass(),
1198 NULL,
1199 NULL);
1198 VerifyAndFinishRequest(net::HTTP_OK, 1200 VerifyAndFinishRequest(net::HTTP_OK,
1199 kSaveAddressValidRequest, 1201 kSaveAddressValidRequest,
1200 kSaveAddressValidResponse); 1202 kSaveAddressValidResponse);
1201 } 1203 }
1202 1204
1203 TEST_F(WalletClientTest, SaveAddressWithRequiredActionsSucceeded) { 1205 TEST_F(WalletClientTest, SaveAddressWithRequiredActionsSucceeded) {
1204 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1); 1206 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
1205 delegate_.ExpectBaselineMetrics(); 1207 delegate_.ExpectBaselineMetrics();
1206 delegate_.ExpectWalletRequiredActionMetric( 1208 delegate_.ExpectWalletRequiredActionMetric(
1207 AutofillMetrics::REQUIRE_PHONE_NUMBER); 1209 AutofillMetrics::REQUIRE_PHONE_NUMBER);
1208 delegate_.ExpectWalletRequiredActionMetric( 1210 delegate_.ExpectWalletRequiredActionMetric(
1209 AutofillMetrics::INVALID_FORM_FIELD); 1211 AutofillMetrics::INVALID_FORM_FIELD);
1210 1212
1211 std::vector<RequiredAction> required_actions; 1213 std::vector<RequiredAction> required_actions;
1212 required_actions.push_back(REQUIRE_PHONE_NUMBER); 1214 required_actions.push_back(REQUIRE_PHONE_NUMBER);
1213 required_actions.push_back(INVALID_FORM_FIELD); 1215 required_actions.push_back(INVALID_FORM_FIELD);
1214 1216
1215 std::vector<FormFieldError> form_errors; 1217 std::vector<FormFieldError> form_errors;
1216 form_errors.push_back(FormFieldError(FormFieldError::INVALID_POSTAL_CODE, 1218 form_errors.push_back(FormFieldError(FormFieldError::INVALID_POSTAL_CODE,
1217 FormFieldError::SHIPPING_ADDRESS)); 1219 FormFieldError::SHIPPING_ADDRESS));
1218 1220
1219 EXPECT_CALL(delegate_, 1221 EXPECT_CALL(delegate_,
1220 OnDidSaveToWallet(std::string(), 1222 OnDidSaveToWallet(std::string(),
1221 std::string(), 1223 std::string(),
1222 required_actions, 1224 required_actions,
1223 form_errors)).Times(1); 1225 form_errors)).Times(1);
1224 1226
1225 scoped_ptr<Address> address = GetTestSaveableAddress(); 1227 scoped_ptr<Address> address = GetTestSaveableAddress();
1226 wallet_client_->SaveToWallet(scoped_ptr<Instrument>(), 1228 wallet_client_->SaveToWallet(scoped_ptr<Instrument>(),
1227 address.Pass()); 1229 address.Pass(),
1230 NULL,
1231 NULL);
1228 VerifyAndFinishRequest(net::HTTP_OK, 1232 VerifyAndFinishRequest(net::HTTP_OK,
1229 kSaveAddressValidRequest, 1233 kSaveAddressValidRequest,
1230 kSaveAddressWithRequiredActionsValidResponse); 1234 kSaveAddressWithRequiredActionsValidResponse);
1231 } 1235 }
1232 1236
1233 TEST_F(WalletClientTest, SaveAddressFailedInvalidRequiredAction) { 1237 TEST_F(WalletClientTest, SaveAddressFailedInvalidRequiredAction) {
1234 EXPECT_CALL(delegate_, 1238 EXPECT_CALL(delegate_,
1235 OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1); 1239 OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
1236 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1); 1240 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
1237 delegate_.ExpectBaselineMetrics(); 1241 delegate_.ExpectBaselineMetrics();
1238 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE); 1242 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
1239 delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET); 1243 delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET);
1240 1244
1241 scoped_ptr<Address> address = GetTestSaveableAddress(); 1245 scoped_ptr<Address> address = GetTestSaveableAddress();
1242 wallet_client_->SaveToWallet(scoped_ptr<Instrument>(), 1246 wallet_client_->SaveToWallet(scoped_ptr<Instrument>(),
1243 address.Pass()); 1247 address.Pass(),
1248 NULL,
1249 NULL);
1244 VerifyAndFinishRequest(net::HTTP_OK, 1250 VerifyAndFinishRequest(net::HTTP_OK,
1245 kSaveAddressValidRequest, 1251 kSaveAddressValidRequest,
1246 kSaveWithInvalidRequiredActionsResponse); 1252 kSaveWithInvalidRequiredActionsResponse);
1247 } 1253 }
1248 1254
1249 TEST_F(WalletClientTest, SaveAddressFailedMalformedResponse) { 1255 TEST_F(WalletClientTest, SaveAddressFailedMalformedResponse) {
1250 EXPECT_CALL(delegate_, 1256 EXPECT_CALL(delegate_,
1251 OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1); 1257 OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
1252 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1); 1258 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
1253 delegate_.ExpectBaselineMetrics(); 1259 delegate_.ExpectBaselineMetrics();
1254 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE); 1260 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
1255 delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET); 1261 delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET);
1256 1262
1257 scoped_ptr<Address> address = GetTestSaveableAddress(); 1263 scoped_ptr<Address> address = GetTestSaveableAddress();
1258 wallet_client_->SaveToWallet(scoped_ptr<Instrument>(), 1264 wallet_client_->SaveToWallet(scoped_ptr<Instrument>(),
1259 address.Pass()); 1265 address.Pass(),
1266 NULL,
1267 NULL);
1260 VerifyAndFinishRequest(net::HTTP_OK, 1268 VerifyAndFinishRequest(net::HTTP_OK,
1261 kSaveAddressValidRequest, 1269 kSaveAddressValidRequest,
1262 kSaveInvalidResponse); 1270 kSaveInvalidResponse);
1263 } 1271 }
1264 1272
1265 TEST_F(WalletClientTest, SaveInstrumentSucceeded) { 1273 TEST_F(WalletClientTest, SaveInstrumentSucceeded) {
1266 EXPECT_CALL(delegate_, 1274 EXPECT_CALL(delegate_,
1267 OnDidSaveToWallet("instrument_id", 1275 OnDidSaveToWallet("instrument_id",
1268 std::string(), 1276 std::string(),
1269 std::vector<RequiredAction>(), 1277 std::vector<RequiredAction>(),
1270 std::vector<FormFieldError>())).Times(1); 1278 std::vector<FormFieldError>())).Times(1);
1271 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1); 1279 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
1272 delegate_.ExpectBaselineMetrics(); 1280 delegate_.ExpectBaselineMetrics();
1273 1281
1274 scoped_ptr<Instrument> instrument = GetTestInstrument(); 1282 scoped_ptr<Instrument> instrument = GetTestInstrument();
1275 wallet_client_->SaveToWallet(instrument.Pass(), 1283 wallet_client_->SaveToWallet(instrument.Pass(),
1276 scoped_ptr<Address>()); 1284 scoped_ptr<Address>(),
1285 NULL,
1286 NULL);
1277 1287
1278 VerifyAndFinishFormEncodedRequest(net::HTTP_OK, 1288 VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
1279 kSaveInstrumentValidRequest, 1289 kSaveInstrumentValidRequest,
1280 kSaveInstrumentValidResponse, 1290 kSaveInstrumentValidResponse,
1281 4U); 1291 4U);
1282 } 1292 }
1283 1293
1284 TEST_F(WalletClientTest, SaveInstrumentWithRequiredActionsSucceeded) { 1294 TEST_F(WalletClientTest, SaveInstrumentWithRequiredActionsSucceeded) {
1285 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1); 1295 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
1286 delegate_.ExpectBaselineMetrics(); 1296 delegate_.ExpectBaselineMetrics();
(...skipping 11 matching lines...) Expand all
1298 FormFieldError::SHIPPING_ADDRESS)); 1308 FormFieldError::SHIPPING_ADDRESS));
1299 1309
1300 EXPECT_CALL(delegate_, 1310 EXPECT_CALL(delegate_,
1301 OnDidSaveToWallet(std::string(), 1311 OnDidSaveToWallet(std::string(),
1302 std::string(), 1312 std::string(),
1303 required_actions, 1313 required_actions,
1304 form_errors)).Times(1); 1314 form_errors)).Times(1);
1305 1315
1306 scoped_ptr<Instrument> instrument = GetTestInstrument(); 1316 scoped_ptr<Instrument> instrument = GetTestInstrument();
1307 wallet_client_->SaveToWallet(instrument.Pass(), 1317 wallet_client_->SaveToWallet(instrument.Pass(),
1308 scoped_ptr<Address>()); 1318 scoped_ptr<Address>(),
1319 NULL,
1320 NULL);
1309 1321
1310 VerifyAndFinishFormEncodedRequest( 1322 VerifyAndFinishFormEncodedRequest(
1311 net::HTTP_OK, 1323 net::HTTP_OK,
1312 kSaveInstrumentValidRequest, 1324 kSaveInstrumentValidRequest,
1313 kSaveInstrumentWithRequiredActionsValidResponse, 1325 kSaveInstrumentWithRequiredActionsValidResponse,
1314 4U); 1326 4U);
1315 } 1327 }
1316 1328
1317 TEST_F(WalletClientTest, SaveInstrumentFailedInvalidRequiredActions) { 1329 TEST_F(WalletClientTest, SaveInstrumentFailedInvalidRequiredActions) {
1318 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1); 1330 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
1319 delegate_.ExpectBaselineMetrics(); 1331 delegate_.ExpectBaselineMetrics();
1320 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE); 1332 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
1321 delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET); 1333 delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET);
1322 1334
1323 EXPECT_CALL(delegate_, 1335 EXPECT_CALL(delegate_,
1324 OnWalletError(WalletClient::MALFORMED_RESPONSE)); 1336 OnWalletError(WalletClient::MALFORMED_RESPONSE));
1325 1337
1326 scoped_ptr<Instrument> instrument = GetTestInstrument(); 1338 scoped_ptr<Instrument> instrument = GetTestInstrument();
1327 wallet_client_->SaveToWallet(instrument.Pass(), 1339 wallet_client_->SaveToWallet(instrument.Pass(),
1328 scoped_ptr<Address>()); 1340 scoped_ptr<Address>(),
1341 NULL,
1342 NULL);
1329 1343
1330 VerifyAndFinishFormEncodedRequest(net::HTTP_OK, 1344 VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
1331 kSaveInstrumentValidRequest, 1345 kSaveInstrumentValidRequest,
1332 kSaveWithInvalidRequiredActionsResponse, 1346 kSaveWithInvalidRequiredActionsResponse,
1333 4U); 1347 4U);
1334 } 1348 }
1335 1349
1336 TEST_F(WalletClientTest, SaveInstrumentFailedMalformedResponse) { 1350 TEST_F(WalletClientTest, SaveInstrumentFailedMalformedResponse) {
1337 EXPECT_CALL(delegate_, 1351 EXPECT_CALL(delegate_,
1338 OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1); 1352 OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
1339 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1); 1353 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
1340 delegate_.ExpectBaselineMetrics(); 1354 delegate_.ExpectBaselineMetrics();
1341 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE); 1355 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
1342 delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET); 1356 delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET);
1343 1357
1344 scoped_ptr<Instrument> instrument = GetTestInstrument(); 1358 scoped_ptr<Instrument> instrument = GetTestInstrument();
1345 wallet_client_->SaveToWallet(instrument.Pass(), 1359 wallet_client_->SaveToWallet(instrument.Pass(),
1346 scoped_ptr<Address>()); 1360 scoped_ptr<Address>(),
1361 NULL,
1362 NULL);
1347 1363
1348 VerifyAndFinishFormEncodedRequest(net::HTTP_OK, 1364 VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
1349 kSaveInstrumentValidRequest, 1365 kSaveInstrumentValidRequest,
1350 kSaveInvalidResponse, 1366 kSaveInvalidResponse,
1351 4U); 1367 4U);
1352 } 1368 }
1353 1369
1354 TEST_F(WalletClientTest, SaveInstrumentAndAddressSucceeded) { 1370 TEST_F(WalletClientTest, SaveInstrumentAndAddressSucceeded) {
1355 EXPECT_CALL(delegate_, 1371 EXPECT_CALL(delegate_,
1356 OnDidSaveToWallet("saved_instrument_id", 1372 OnDidSaveToWallet("saved_instrument_id",
1357 "saved_address_id", 1373 "saved_address_id",
1358 std::vector<RequiredAction>(), 1374 std::vector<RequiredAction>(),
1359 std::vector<FormFieldError>())).Times(1); 1375 std::vector<FormFieldError>())).Times(1);
1360 delegate_.ExpectLogWalletApiCallDuration( 1376 delegate_.ExpectLogWalletApiCallDuration(
1361 AutofillMetrics::SAVE_TO_WALLET, 1377 AutofillMetrics::SAVE_TO_WALLET,
1362 1); 1378 1);
1363 delegate_.ExpectBaselineMetrics(); 1379 delegate_.ExpectBaselineMetrics();
1364 1380
1365 scoped_ptr<Instrument> instrument = GetTestInstrument(); 1381 scoped_ptr<Instrument> instrument = GetTestInstrument();
1366 scoped_ptr<Address> address = GetTestSaveableAddress(); 1382 scoped_ptr<Address> address = GetTestSaveableAddress();
1367 wallet_client_->SaveToWallet(instrument.Pass(), 1383 wallet_client_->SaveToWallet(instrument.Pass(), address.Pass(), NULL, NULL);
1368 address.Pass());
1369 1384
1370 VerifyAndFinishFormEncodedRequest(net::HTTP_OK, 1385 VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
1371 kSaveInstrumentAndAddressValidRequest, 1386 kSaveInstrumentAndAddressValidRequest,
1372 kSaveInstrumentAndAddressValidResponse, 1387 kSaveInstrumentAndAddressValidResponse,
1373 4U); 1388 4U);
1374 } 1389 }
1375 1390
1376 TEST_F(WalletClientTest, SaveInstrumentAndAddressWithRequiredActionsSucceeded) { 1391 TEST_F(WalletClientTest, SaveInstrumentAndAddressWithRequiredActionsSucceeded) {
1377 delegate_.ExpectLogWalletApiCallDuration( 1392 delegate_.ExpectLogWalletApiCallDuration(
1378 AutofillMetrics::SAVE_TO_WALLET, 1393 AutofillMetrics::SAVE_TO_WALLET,
(...skipping 13 matching lines...) Expand all
1392 FormFieldError::SHIPPING_ADDRESS)); 1407 FormFieldError::SHIPPING_ADDRESS));
1393 1408
1394 EXPECT_CALL(delegate_, 1409 EXPECT_CALL(delegate_,
1395 OnDidSaveToWallet(std::string(), 1410 OnDidSaveToWallet(std::string(),
1396 std::string(), 1411 std::string(),
1397 required_actions, 1412 required_actions,
1398 form_errors)).Times(1); 1413 form_errors)).Times(1);
1399 1414
1400 scoped_ptr<Instrument> instrument = GetTestInstrument(); 1415 scoped_ptr<Instrument> instrument = GetTestInstrument();
1401 scoped_ptr<Address> address = GetTestSaveableAddress(); 1416 scoped_ptr<Address> address = GetTestSaveableAddress();
1402 wallet_client_->SaveToWallet(instrument.Pass(), 1417 wallet_client_->SaveToWallet(instrument.Pass(), address.Pass(), NULL, NULL);
1403 address.Pass());
1404 1418
1405 VerifyAndFinishFormEncodedRequest( 1419 VerifyAndFinishFormEncodedRequest(
1406 net::HTTP_OK, 1420 net::HTTP_OK,
1407 kSaveInstrumentAndAddressValidRequest, 1421 kSaveInstrumentAndAddressValidRequest,
1408 kSaveInstrumentAndAddressWithRequiredActionsValidResponse, 1422 kSaveInstrumentAndAddressWithRequiredActionsValidResponse,
1409 4U); 1423 4U);
1410 } 1424 }
1411 1425
1412 TEST_F(WalletClientTest, SaveInstrumentAndAddressFailedInvalidRequiredAction) { 1426 TEST_F(WalletClientTest, SaveInstrumentAndAddressFailedInvalidRequiredAction) {
1413 EXPECT_CALL(delegate_, 1427 EXPECT_CALL(delegate_,
1414 OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1); 1428 OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
1415 delegate_.ExpectLogWalletApiCallDuration( 1429 delegate_.ExpectLogWalletApiCallDuration(
1416 AutofillMetrics::SAVE_TO_WALLET, 1430 AutofillMetrics::SAVE_TO_WALLET,
1417 1); 1431 1);
1418 delegate_.ExpectBaselineMetrics(); 1432 delegate_.ExpectBaselineMetrics();
1419 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE); 1433 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
1420 delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET); 1434 delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET);
1421 1435
1422 scoped_ptr<Instrument> instrument = GetTestInstrument(); 1436 scoped_ptr<Instrument> instrument = GetTestInstrument();
1423 scoped_ptr<Address> address = GetTestSaveableAddress(); 1437 scoped_ptr<Address> address = GetTestSaveableAddress();
1424 wallet_client_->SaveToWallet(instrument.Pass(), 1438 wallet_client_->SaveToWallet(instrument.Pass(), address.Pass(), NULL, NULL);
1425 address.Pass());
1426 1439
1427 VerifyAndFinishFormEncodedRequest(net::HTTP_OK, 1440 VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
1428 kSaveInstrumentAndAddressValidRequest, 1441 kSaveInstrumentAndAddressValidRequest,
1429 kSaveWithInvalidRequiredActionsResponse, 1442 kSaveWithInvalidRequiredActionsResponse,
1430 4U); 1443 4U);
1431 } 1444 }
1432 1445
1433 TEST_F(WalletClientTest, UpdateAddressSucceeded) { 1446 TEST_F(WalletClientTest, UpdateAddressSucceeded) {
1434 EXPECT_CALL(delegate_, 1447 EXPECT_CALL(delegate_,
1435 OnDidSaveToWallet(std::string(), 1448 OnDidSaveToWallet(std::string(),
1436 "shipping_address_id", 1449 "shipping_address_id",
1437 std::vector<RequiredAction>(), 1450 std::vector<RequiredAction>(),
1438 std::vector<FormFieldError>())).Times(1); 1451 std::vector<FormFieldError>())).Times(1);
1439 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1); 1452 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
1440 delegate_.ExpectBaselineMetrics(); 1453 delegate_.ExpectBaselineMetrics();
1441 1454
1442 scoped_ptr<Address> address = GetTestShippingAddress(); 1455 scoped_ptr<Address> server_address = GetTestNonDefaultShippingAddress();
1443 address->set_object_id("shipping_address_id"); 1456 wallet_client_->SaveToWallet(scoped_ptr<Instrument>(),
1457 GetTestShippingAddress(),
1458 NULL,
1459 server_address.get());
1444 1460
1445 wallet_client_->SaveToWallet(scoped_ptr<Instrument>(),
1446 address.Pass());
1447 VerifyAndFinishRequest(net::HTTP_OK, 1461 VerifyAndFinishRequest(net::HTTP_OK,
1448 kUpdateAddressValidRequest, 1462 kUpdateAddressValidRequest,
1449 kUpdateAddressValidResponse); 1463 kUpdateAddressValidResponse);
1450 } 1464 }
1451 1465
1452 TEST_F(WalletClientTest, UpdateAddressWithRequiredActionsSucceeded) { 1466 TEST_F(WalletClientTest, UpdateAddressWithRequiredActionsSucceeded) {
1453 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1); 1467 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
1454 delegate_.ExpectBaselineMetrics(); 1468 delegate_.ExpectBaselineMetrics();
1455 delegate_.ExpectWalletRequiredActionMetric( 1469 delegate_.ExpectWalletRequiredActionMetric(
1456 AutofillMetrics::REQUIRE_PHONE_NUMBER); 1470 AutofillMetrics::REQUIRE_PHONE_NUMBER);
1457 delegate_.ExpectWalletRequiredActionMetric( 1471 delegate_.ExpectWalletRequiredActionMetric(
1458 AutofillMetrics::INVALID_FORM_FIELD); 1472 AutofillMetrics::INVALID_FORM_FIELD);
1459 1473
1460 std::vector<RequiredAction> required_actions; 1474 std::vector<RequiredAction> required_actions;
1461 required_actions.push_back(REQUIRE_PHONE_NUMBER); 1475 required_actions.push_back(REQUIRE_PHONE_NUMBER);
1462 required_actions.push_back(INVALID_FORM_FIELD); 1476 required_actions.push_back(INVALID_FORM_FIELD);
1463 1477
1464 std::vector<FormFieldError> form_errors; 1478 std::vector<FormFieldError> form_errors;
1465 form_errors.push_back(FormFieldError(FormFieldError::INVALID_POSTAL_CODE, 1479 form_errors.push_back(FormFieldError(FormFieldError::INVALID_POSTAL_CODE,
1466 FormFieldError::SHIPPING_ADDRESS)); 1480 FormFieldError::SHIPPING_ADDRESS));
1467 1481
1468 EXPECT_CALL(delegate_, OnDidSaveToWallet(std::string(), 1482 EXPECT_CALL(delegate_, OnDidSaveToWallet(std::string(),
1469 std::string(), 1483 std::string(),
1470 required_actions, 1484 required_actions,
1471 form_errors)).Times(1); 1485 form_errors)).Times(1);
1472 1486
1473 scoped_ptr<Address> address = GetTestShippingAddress(); 1487 scoped_ptr<Address> server_address = GetTestNonDefaultShippingAddress();
1474 address->set_object_id("shipping_address_id"); 1488 wallet_client_->SaveToWallet(scoped_ptr<Instrument>(),
1489 GetTestShippingAddress(),
1490 NULL,
1491 server_address.get());
1475 1492
1476 wallet_client_->SaveToWallet(scoped_ptr<Instrument>(),
1477 address.Pass());
1478 VerifyAndFinishRequest(net::HTTP_OK, 1493 VerifyAndFinishRequest(net::HTTP_OK,
1479 kUpdateAddressValidRequest, 1494 kUpdateAddressValidRequest,
1480 kUpdateWithRequiredActionsValidResponse); 1495 kUpdateWithRequiredActionsValidResponse);
1481 } 1496 }
1482 1497
1483 TEST_F(WalletClientTest, UpdateAddressFailedInvalidRequiredAction) { 1498 TEST_F(WalletClientTest, UpdateAddressFailedInvalidRequiredAction) {
1484 EXPECT_CALL(delegate_, 1499 EXPECT_CALL(delegate_,
1485 OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1); 1500 OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
1486 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1); 1501 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
1487 delegate_.ExpectBaselineMetrics(); 1502 delegate_.ExpectBaselineMetrics();
1488 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE); 1503 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
1489 delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET); 1504 delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET);
1490 1505
1491 scoped_ptr<Address> address = GetTestShippingAddress(); 1506 scoped_ptr<Address> server_address = GetTestNonDefaultShippingAddress();
1492 address->set_object_id("shipping_address_id"); 1507 wallet_client_->SaveToWallet(scoped_ptr<Instrument>(),
1508 GetTestShippingAddress(),
1509 NULL,
1510 server_address.get());
1493 1511
1494 wallet_client_->SaveToWallet(scoped_ptr<Instrument>(),
1495 address.Pass());
1496 VerifyAndFinishRequest(net::HTTP_OK, 1512 VerifyAndFinishRequest(net::HTTP_OK,
1497 kUpdateAddressValidRequest, 1513 kUpdateAddressValidRequest,
1498 kSaveWithInvalidRequiredActionsResponse); 1514 kSaveWithInvalidRequiredActionsResponse);
1499 } 1515 }
1500 1516
1501 TEST_F(WalletClientTest, UpdateAddressMalformedResponse) { 1517 TEST_F(WalletClientTest, UpdateAddressMalformedResponse) {
1502 EXPECT_CALL(delegate_, 1518 EXPECT_CALL(delegate_,
1503 OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1); 1519 OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
1504 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1); 1520 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1);
1505 delegate_.ExpectBaselineMetrics(); 1521 delegate_.ExpectBaselineMetrics();
1506 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE); 1522 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
1507 delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET); 1523 delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET);
1508 1524
1509 scoped_ptr<Address> address = GetTestShippingAddress(); 1525 scoped_ptr<Address> server_address = GetTestNonDefaultShippingAddress();
1510 address->set_object_id("shipping_address_id"); 1526 wallet_client_->SaveToWallet(scoped_ptr<Instrument>(),
1527 GetTestShippingAddress(),
1528 NULL,
1529 server_address.get());
1511 1530
1512 wallet_client_->SaveToWallet(scoped_ptr<Instrument>(),
1513 address.Pass());
1514 VerifyAndFinishRequest(net::HTTP_OK, 1531 VerifyAndFinishRequest(net::HTTP_OK,
1515 kUpdateAddressValidRequest, 1532 kUpdateAddressValidRequest,
1516 kUpdateMalformedResponse); 1533 kUpdateMalformedResponse);
1517 } 1534 }
1518 1535
1519 TEST_F(WalletClientTest, UpdateInstrumentAddressSucceeded) { 1536 TEST_F(WalletClientTest, UpdateInstrumentAddressSucceeded) {
1520 EXPECT_CALL(delegate_, 1537 EXPECT_CALL(delegate_,
1521 OnDidSaveToWallet("instrument_id", 1538 OnDidSaveToWallet("instrument_id",
1522 std::string(), 1539 std::string(),
1523 std::vector<RequiredAction>(), 1540 std::vector<RequiredAction>(),
1524 std::vector<FormFieldError>())).Times(1); 1541 std::vector<FormFieldError>())).Times(1);
1525 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1542 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET,
1526 1); 1543 1);
1527 delegate_.ExpectBaselineMetrics(); 1544 delegate_.ExpectBaselineMetrics();
1528 1545
1546 scoped_ptr<WalletItems::MaskedInstrument> server_instrument =
1547 GetTestMaskedInstrument();
1529 wallet_client_->SaveToWallet(GetTestAddressUpgradeInstrument(), 1548 wallet_client_->SaveToWallet(GetTestAddressUpgradeInstrument(),
1530 scoped_ptr<Address>()); 1549 scoped_ptr<Address>(),
1550 server_instrument.get(),
1551 NULL);
1531 1552
1532 VerifyAndFinishRequest(net::HTTP_OK, 1553 VerifyAndFinishRequest(net::HTTP_OK,
1533 kUpdateInstrumentAddressValidRequest, 1554 kUpdateInstrumentAddressValidRequest,
1534 kUpdateInstrumentValidResponse); 1555 kUpdateInstrumentValidResponse);
1535 } 1556 }
1536 1557
1537 TEST_F(WalletClientTest, UpdateInstrumentExpirationDateSuceeded) { 1558 TEST_F(WalletClientTest, UpdateInstrumentExpirationDateSuceeded) {
1538 EXPECT_CALL(delegate_, 1559 EXPECT_CALL(delegate_,
1539 OnDidSaveToWallet("instrument_id", 1560 OnDidSaveToWallet("instrument_id",
1540 std::string(), 1561 std::string(),
1541 std::vector<RequiredAction>(), 1562 std::vector<RequiredAction>(),
1542 std::vector<FormFieldError>())).Times(1); 1563 std::vector<FormFieldError>())).Times(1);
1543 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1564 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET,
1544 1); 1565 1);
1545 delegate_.ExpectBaselineMetrics(); 1566 delegate_.ExpectBaselineMetrics();
1546 1567
1547 wallet_client_->SaveToWallet(GetTestExpirationDateChangeInstrument(), 1568 scoped_ptr<Instrument> instrument = GetTestExpirationDateChangeInstrument();
1548 scoped_ptr<Address>()); 1569 scoped_ptr<WalletItems::MaskedInstrument> server_instrument =
1570 GetTestMaskedInstrumentWithId("instrument_id");
1571
1572 int new_month = instrument->expiration_month();
1573 int new_year = instrument->expiration_year();
1574 ASSERT_TRUE(new_month != server_instrument->expiration_month() ||
1575 new_year != server_instrument->expiration_year());
1576
1577 wallet_client_->SaveToWallet(instrument.Pass(),
1578 scoped_ptr<Address>(),
1579 server_instrument.get(),
1580 NULL);
1549 1581
1550 VerifyAndFinishFormEncodedRequest(net::HTTP_OK, 1582 VerifyAndFinishFormEncodedRequest(net::HTTP_OK,
1551 kUpdateInstrumentExpirationDateValidRequest, 1583 kUpdateInstrumentExpirationDateValidRequest,
1552 kUpdateInstrumentValidResponse, 1584 kUpdateInstrumentValidResponse,
1553 3U); 1585 3U);
1554 } 1586 }
1555 1587
1556 TEST_F(WalletClientTest, UpdateInstrumentAddressWithNameChangeSucceeded) { 1588 TEST_F(WalletClientTest, UpdateInstrumentAddressWithNameChangeSucceeded) {
1557 EXPECT_CALL(delegate_, 1589 EXPECT_CALL(delegate_,
1558 OnDidSaveToWallet("instrument_id", 1590 OnDidSaveToWallet("instrument_id",
1559 std::string(), 1591 std::string(),
1560 std::vector<RequiredAction>(), 1592 std::vector<RequiredAction>(),
1561 std::vector<FormFieldError>())).Times(1); 1593 std::vector<FormFieldError>())).Times(1);
1562 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1594 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET,
1563 1); 1595 1);
1564 delegate_.ExpectBaselineMetrics(); 1596 delegate_.ExpectBaselineMetrics();
1565 1597
1598 scoped_ptr<WalletItems::MaskedInstrument> server_instrument =
1599 GetTestMaskedInstrument();
1566 wallet_client_->SaveToWallet(GetTestAddressNameChangeInstrument(), 1600 wallet_client_->SaveToWallet(GetTestAddressNameChangeInstrument(),
1567 scoped_ptr<Address>()); 1601 scoped_ptr<Address>(),
1602 server_instrument.get(),
1603 NULL);
1568 1604
1569 VerifyAndFinishFormEncodedRequest( 1605 VerifyAndFinishFormEncodedRequest(
1570 net::HTTP_OK, 1606 net::HTTP_OK,
1571 kUpdateInstrumentAddressWithNameChangeValidRequest, 1607 kUpdateInstrumentAddressWithNameChangeValidRequest,
1572 kUpdateInstrumentValidResponse, 1608 kUpdateInstrumentValidResponse,
1573 3U); 1609 3U);
1574 } 1610 }
1575 1611
1576 TEST_F(WalletClientTest, UpdateInstrumentWithRequiredActionsSucceeded) { 1612 TEST_F(WalletClientTest, UpdateInstrumentWithRequiredActionsSucceeded) {
1577 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1613 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET,
(...skipping 11 matching lines...) Expand all
1589 std::vector<FormFieldError> form_errors; 1625 std::vector<FormFieldError> form_errors;
1590 form_errors.push_back(FormFieldError(FormFieldError::INVALID_POSTAL_CODE, 1626 form_errors.push_back(FormFieldError(FormFieldError::INVALID_POSTAL_CODE,
1591 FormFieldError::SHIPPING_ADDRESS)); 1627 FormFieldError::SHIPPING_ADDRESS));
1592 1628
1593 EXPECT_CALL(delegate_, 1629 EXPECT_CALL(delegate_,
1594 OnDidSaveToWallet(std::string(), 1630 OnDidSaveToWallet(std::string(),
1595 std::string(), 1631 std::string(),
1596 required_actions, 1632 required_actions,
1597 form_errors)).Times(1); 1633 form_errors)).Times(1);
1598 1634
1635 scoped_ptr<WalletItems::MaskedInstrument> server_instrument =
1636 GetTestMaskedInstrument();
1599 wallet_client_->SaveToWallet(GetTestAddressUpgradeInstrument(), 1637 wallet_client_->SaveToWallet(GetTestAddressUpgradeInstrument(),
1600 scoped_ptr<Address>()); 1638 scoped_ptr<Address>(),
1639 server_instrument.get(),
1640 NULL);
1601 1641
1602 VerifyAndFinishRequest(net::HTTP_OK, 1642 VerifyAndFinishRequest(net::HTTP_OK,
1603 kUpdateInstrumentAddressValidRequest, 1643 kUpdateInstrumentAddressValidRequest,
1604 kUpdateWithRequiredActionsValidResponse); 1644 kUpdateWithRequiredActionsValidResponse);
1605 } 1645 }
1606 1646
1607 TEST_F(WalletClientTest, UpdateInstrumentFailedInvalidRequiredAction) { 1647 TEST_F(WalletClientTest, UpdateInstrumentFailedInvalidRequiredAction) {
1608 EXPECT_CALL(delegate_, 1648 EXPECT_CALL(delegate_,
1609 OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1); 1649 OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
1610 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1650 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET,
1611 1); 1651 1);
1612 delegate_.ExpectBaselineMetrics(); 1652 delegate_.ExpectBaselineMetrics();
1613 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE); 1653 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
1614 delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET); 1654 delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET);
1615 1655
1656 scoped_ptr<WalletItems::MaskedInstrument> server_instrument =
1657 GetTestMaskedInstrument();
1616 wallet_client_->SaveToWallet(GetTestAddressUpgradeInstrument(), 1658 wallet_client_->SaveToWallet(GetTestAddressUpgradeInstrument(),
1617 scoped_ptr<Address>()); 1659 scoped_ptr<Address>(),
1660 server_instrument.get(),
1661 NULL);
1618 1662
1619 VerifyAndFinishRequest(net::HTTP_OK, 1663 VerifyAndFinishRequest(net::HTTP_OK,
1620 kUpdateInstrumentAddressValidRequest, 1664 kUpdateInstrumentAddressValidRequest,
1621 kSaveWithInvalidRequiredActionsResponse); 1665 kSaveWithInvalidRequiredActionsResponse);
1622 } 1666 }
1623 1667
1624 TEST_F(WalletClientTest, UpdateInstrumentMalformedResponse) { 1668 TEST_F(WalletClientTest, UpdateInstrumentMalformedResponse) {
1625 EXPECT_CALL(delegate_, 1669 EXPECT_CALL(delegate_,
1626 OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1); 1670 OnWalletError(WalletClient::MALFORMED_RESPONSE)).Times(1);
1627 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET, 1671 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::SAVE_TO_WALLET,
1628 1); 1672 1);
1629 delegate_.ExpectBaselineMetrics(); 1673 delegate_.ExpectBaselineMetrics();
1630 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE); 1674 delegate_.ExpectWalletErrorMetric(AutofillMetrics::WALLET_MALFORMED_RESPONSE);
1631 delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET); 1675 delegate_.ExpectLogWalletMalformedResponse(AutofillMetrics::SAVE_TO_WALLET);
1632 1676
1677 scoped_ptr<WalletItems::MaskedInstrument> server_instrument =
1678 GetTestMaskedInstrument();
1633 wallet_client_->SaveToWallet(GetTestAddressUpgradeInstrument(), 1679 wallet_client_->SaveToWallet(GetTestAddressUpgradeInstrument(),
1634 scoped_ptr<Address>()); 1680 scoped_ptr<Address>(),
1681 server_instrument.get(),
1682 NULL);
1635 1683
1636 VerifyAndFinishRequest(net::HTTP_OK, 1684 VerifyAndFinishRequest(net::HTTP_OK,
1637 kUpdateInstrumentAddressValidRequest, 1685 kUpdateInstrumentAddressValidRequest,
1638 kUpdateMalformedResponse); 1686 kUpdateMalformedResponse);
1639 } 1687 }
1640 1688
1641 TEST_F(WalletClientTest, HasRequestInProgress) { 1689 TEST_F(WalletClientTest, HasRequestInProgress) {
1642 EXPECT_FALSE(wallet_client_->HasRequestInProgress()); 1690 EXPECT_FALSE(wallet_client_->HasRequestInProgress());
1643 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_WALLET_ITEMS, 1691 delegate_.ExpectLogWalletApiCallDuration(AutofillMetrics::GET_WALLET_ITEMS,
1644 1); 1692 1);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 wallet_client_->GetWalletItems(); 1746 wallet_client_->GetWalletItems();
1699 EXPECT_EQ(2U, wallet_client_->pending_requests_.size()); 1747 EXPECT_EQ(2U, wallet_client_->pending_requests_.size());
1700 1748
1701 wallet_client_->CancelRequests(); 1749 wallet_client_->CancelRequests();
1702 EXPECT_EQ(0U, wallet_client_->pending_requests_.size()); 1750 EXPECT_EQ(0U, wallet_client_->pending_requests_.size());
1703 EXPECT_FALSE(wallet_client_->HasRequestInProgress()); 1751 EXPECT_FALSE(wallet_client_->HasRequestInProgress());
1704 } 1752 }
1705 1753
1706 } // namespace wallet 1754 } // namespace wallet
1707 } // namespace autofill 1755 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698