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

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

Issue 14425010: Handle expired Autofill credit cards in autofill dialog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 #include "base/json/json_writer.h" 6 #include "base/json/json_writer.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 22 matching lines...) Expand all
33 namespace wallet { 33 namespace wallet {
34 34
35 namespace { 35 namespace {
36 36
37 const char kGoogleTransactionId[] = "google-transaction-id"; 37 const char kGoogleTransactionId[] = "google-transaction-id";
38 const char kMerchantUrl[] = "https://example.com/path?key=value"; 38 const char kMerchantUrl[] = "https://example.com/path?key=value";
39 39
40 const char kGetFullWalletValidResponse[] = 40 const char kGetFullWalletValidResponse[] =
41 "{" 41 "{"
42 " \"expiration_month\":12," 42 " \"expiration_month\":12,"
43 " \"expiration_year\":2012," 43 " \"expiration_year\":3000,"
44 " \"iin\":\"iin\"," 44 " \"iin\":\"iin\","
45 " \"rest\":\"rest\"," 45 " \"rest\":\"rest\","
46 " \"billing_address\":" 46 " \"billing_address\":"
47 " {" 47 " {"
48 " \"id\":\"id\"," 48 " \"id\":\"id\","
49 " \"phone_number\":\"phone_number\"," 49 " \"phone_number\":\"phone_number\","
50 " \"postal_address\":" 50 " \"postal_address\":"
51 " {" 51 " {"
52 " \"recipient_name\":\"recipient_name\"," 52 " \"recipient_name\":\"recipient_name\","
53 " \"address_line\":" 53 " \"address_line\":"
54 " [" 54 " ["
55 " \"address_line_1\"," 55 " \"address_line_1\","
56 " \"address_line_2\"" 56 " \"address_line_2\""
57 " ]," 57 " ],"
58 " \"locality_name\":\"locality_name\"," 58 " \"locality_name\":\"locality_name\","
59 " \"administrative_area_name\":\"administrative_area_name\"," 59 " \"administrative_area_name\":\"administrative_area_name\","
60 " \"postal_code_number\":\"postal_code_number\"," 60 " \"postal_code_number\":\"postal_code_number\","
61 " \"country_name_code\":\"country_name_code\"" 61 " \"country_name_code\":\"US\""
62 " }" 62 " }"
63 " }," 63 " },"
64 " \"shipping_address\":" 64 " \"shipping_address\":"
65 " {" 65 " {"
66 " \"id\":\"ship_id\"," 66 " \"id\":\"ship_id\","
67 " \"phone_number\":\"ship_phone_number\"," 67 " \"phone_number\":\"ship_phone_number\","
68 " \"postal_address\":" 68 " \"postal_address\":"
69 " {" 69 " {"
70 " \"recipient_name\":\"ship_recipient_name\"," 70 " \"recipient_name\":\"ship_recipient_name\","
71 " \"address_line\":" 71 " \"address_line\":"
72 " [" 72 " ["
73 " \"ship_address_line_1\"," 73 " \"ship_address_line_1\","
74 " \"ship_address_line_2\"" 74 " \"ship_address_line_2\""
75 " ]," 75 " ],"
76 " \"locality_name\":\"ship_locality_name\"," 76 " \"locality_name\":\"ship_locality_name\","
77 " \"administrative_area_name\":\"ship_administrative_area_name\"," 77 " \"administrative_area_name\":\"ship_administrative_area_name\","
78 " \"postal_code_number\":\"ship_postal_code_number\"," 78 " \"postal_code_number\":\"ship_postal_code_number\","
79 " \"country_name_code\":\"ship_country_name_code\"" 79 " \"country_name_code\":\"US\""
80 " }" 80 " }"
81 " }," 81 " },"
82 " \"required_action\":" 82 " \"required_action\":"
83 " [" 83 " ["
84 " ]" 84 " ]"
85 "}"; 85 "}";
86 86
87 const char kGetFullWalletInvalidResponse[] = 87 const char kGetFullWalletInvalidResponse[] =
88 "{" 88 "{"
89 " \"garbage\":123" 89 " \"garbage\":123"
90 "}"; 90 "}";
91 91
92 const char kGetWalletItemsValidResponse[] = 92 const char kGetWalletItemsValidResponse[] =
93 "{" 93 "{"
94 " \"required_action\":" 94 " \"required_action\":"
95 " [" 95 " ["
96 " ]," 96 " ],"
97 " \"google_transaction_id\":\"google_transaction_id\"," 97 " \"google_transaction_id\":\"google_transaction_id\","
98 " \"instrument\":" 98 " \"instrument\":"
99 " [" 99 " ["
100 " {" 100 " {"
101 " \"descriptive_name\":\"descriptive_name\"," 101 " \"descriptive_name\":\"descriptive_name\","
102 " \"type\":\"VISA\"," 102 " \"type\":\"VISA\","
103 " \"supported_currency\":\"currency_code\"," 103 " \"supported_currency\":\"currency_code\","
104 " \"last_four_digits\":\"last_four_digits\"," 104 " \"last_four_digits\":\"4111\","
105 " \"expiration_month\":12," 105 " \"expiration_month\":12,"
106 " \"expiration_year\":2012," 106 " \"expiration_year\":3000,"
107 " \"brand\":\"monkeys\"," 107 " \"brand\":\"monkeys\","
108 " \"billing_address\":" 108 " \"billing_address\":"
109 " {" 109 " {"
110 " \"name\":\"name\"," 110 " \"name\":\"name\","
111 " \"address1\":\"address1\"," 111 " \"address1\":\"address1\","
112 " \"address2\":\"address2\"," 112 " \"address2\":\"address2\","
113 " \"city\":\"city\"," 113 " \"city\":\"city\","
114 " \"state\":\"state\"," 114 " \"state\":\"state\","
115 " \"postal_code\":\"postal_code\"," 115 " \"postal_code\":\"postal_code\","
116 " \"phone_number\":\"phone_number\"," 116 " \"phone_number\":\"phone_number\","
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 "{" 346 "{"
347 "\"phone_number\":\"save_phone_number\"," 347 "\"phone_number\":\"save_phone_number\","
348 "\"postal_address\":" 348 "\"postal_address\":"
349 "{" 349 "{"
350 "\"address_line\":" 350 "\"address_line\":"
351 "[" 351 "["
352 "\"save_address_line_1\"," 352 "\"save_address_line_1\","
353 "\"save_address_line_2\"" 353 "\"save_address_line_2\""
354 "]," 354 "],"
355 "\"administrative_area_name\":\"save_admin_area_name\"," 355 "\"administrative_area_name\":\"save_admin_area_name\","
356 "\"country_name_code\":\"save_country_name_code\"," 356 "\"country_name_code\":\"US\","
357 "\"locality_name\":\"save_locality_name\"," 357 "\"locality_name\":\"save_locality_name\","
358 "\"postal_code_number\":\"save_postal_code_number\"," 358 "\"postal_code_number\":\"save_postal_code_number\","
359 "\"recipient_name\":\"save_recipient_name\"" 359 "\"recipient_name\":\"save_recipient_name\""
360 "}" 360 "}"
361 "}" 361 "}"
362 "}"; 362 "}";
363 363
364 const char kSaveInstrumentValidRequest[] = 364 const char kSaveInstrumentValidRequest[] =
365 "{" 365 "{"
366 "\"instrument\":" 366 "\"instrument\":"
367 "{" 367 "{"
368 "\"credit_card\":" 368 "\"credit_card\":"
369 "{" 369 "{"
370 "\"address\":" 370 "\"address\":"
371 "{" 371 "{"
372 "\"address_line\":" 372 "\"address_line\":"
373 "[" 373 "["
374 "\"address_line_1\"," 374 "\"address_line_1\","
375 "\"address_line_2\"" 375 "\"address_line_2\""
376 "]," 376 "],"
377 "\"administrative_area_name\":\"admin_area_name\"," 377 "\"administrative_area_name\":\"admin_area_name\","
378 "\"country_name_code\":\"country_name_code\"," 378 "\"country_name_code\":\"US\","
379 "\"locality_name\":\"locality_name\"," 379 "\"locality_name\":\"locality_name\","
380 "\"postal_code_number\":\"postal_code_number\"," 380 "\"postal_code_number\":\"postal_code_number\","
381 "\"recipient_name\":\"recipient_name\"" 381 "\"recipient_name\":\"recipient_name\""
382 "}," 382 "},"
383 "\"exp_month\":12," 383 "\"exp_month\":12,"
384 "\"exp_year\":2012," 384 "\"exp_year\":3000,"
385 "\"fop_type\":\"VISA\"," 385 "\"fop_type\":\"VISA\","
386 "\"last_4_digits\":\"4448\"" 386 "\"last_4_digits\":\"4448\""
387 "}," 387 "},"
388 "\"type\":\"CREDIT_CARD\"" 388 "\"type\":\"CREDIT_CARD\""
389 "}," 389 "},"
390 "\"instrument_escrow_handle\":\"escrow_handle\"," 390 "\"instrument_escrow_handle\":\"escrow_handle\","
391 "\"instrument_phone_number\":\"phone_number\"," 391 "\"instrument_phone_number\":\"phone_number\","
392 "\"merchant_domain\":\"https://example.com/\"," 392 "\"merchant_domain\":\"https://example.com/\","
393 "\"risk_params\":\"risky business\"" 393 "\"risk_params\":\"risky business\""
394 "}"; 394 "}";
395 395
396 const char kSaveInstrumentAndAddressValidRequest[] = 396 const char kSaveInstrumentAndAddressValidRequest[] =
397 "{" 397 "{"
398 "\"instrument\":" 398 "\"instrument\":"
399 "{" 399 "{"
400 "\"credit_card\":" 400 "\"credit_card\":"
401 "{" 401 "{"
402 "\"address\":" 402 "\"address\":"
403 "{" 403 "{"
404 "\"address_line\":" 404 "\"address_line\":"
405 "[" 405 "["
406 "\"address_line_1\"," 406 "\"address_line_1\","
407 "\"address_line_2\"" 407 "\"address_line_2\""
408 "]," 408 "],"
409 "\"administrative_area_name\":\"admin_area_name\"," 409 "\"administrative_area_name\":\"admin_area_name\","
410 "\"country_name_code\":\"country_name_code\"," 410 "\"country_name_code\":\"US\","
411 "\"locality_name\":\"locality_name\"," 411 "\"locality_name\":\"locality_name\","
412 "\"postal_code_number\":\"postal_code_number\"," 412 "\"postal_code_number\":\"postal_code_number\","
413 "\"recipient_name\":\"recipient_name\"" 413 "\"recipient_name\":\"recipient_name\""
414 "}," 414 "},"
415 "\"exp_month\":12," 415 "\"exp_month\":12,"
416 "\"exp_year\":2012," 416 "\"exp_year\":3000,"
417 "\"fop_type\":\"VISA\"," 417 "\"fop_type\":\"VISA\","
418 "\"last_4_digits\":\"4448\"" 418 "\"last_4_digits\":\"4448\""
419 "}," 419 "},"
420 "\"type\":\"CREDIT_CARD\"" 420 "\"type\":\"CREDIT_CARD\""
421 "}," 421 "},"
422 "\"instrument_escrow_handle\":\"escrow_handle\"," 422 "\"instrument_escrow_handle\":\"escrow_handle\","
423 "\"instrument_phone_number\":\"phone_number\"," 423 "\"instrument_phone_number\":\"phone_number\","
424 "\"merchant_domain\":\"https://example.com/\"," 424 "\"merchant_domain\":\"https://example.com/\","
425 "\"risk_params\":\"risky business\"," 425 "\"risk_params\":\"risky business\","
426 "\"shipping_address\":" 426 "\"shipping_address\":"
427 "{" 427 "{"
428 "\"phone_number\":\"save_phone_number\"," 428 "\"phone_number\":\"save_phone_number\","
429 "\"postal_address\":" 429 "\"postal_address\":"
430 "{" 430 "{"
431 "\"address_line\":" 431 "\"address_line\":"
432 "[" 432 "["
433 "\"save_address_line_1\"," 433 "\"save_address_line_1\","
434 "\"save_address_line_2\"" 434 "\"save_address_line_2\""
435 "]," 435 "],"
436 "\"administrative_area_name\":\"save_admin_area_name\"," 436 "\"administrative_area_name\":\"save_admin_area_name\","
437 "\"country_name_code\":\"save_country_name_code\"," 437 "\"country_name_code\":\"US\","
438 "\"locality_name\":\"save_locality_name\"," 438 "\"locality_name\":\"save_locality_name\","
439 "\"postal_code_number\":\"save_postal_code_number\"," 439 "\"postal_code_number\":\"save_postal_code_number\","
440 "\"recipient_name\":\"save_recipient_name\"" 440 "\"recipient_name\":\"save_recipient_name\""
441 "}" 441 "}"
442 "}" 442 "}"
443 "}"; 443 "}";
444 444
445 const char kSendAutocheckoutStatusOfSuccessValidRequest[] = 445 const char kSendAutocheckoutStatusOfSuccessValidRequest[] =
446 "{" 446 "{"
447 "\"google_transaction_id\":\"google_transaction_id\"," 447 "\"google_transaction_id\":\"google_transaction_id\","
(...skipping 18 matching lines...) Expand all
466 "\"id\":\"shipping_address_id\"," 466 "\"id\":\"shipping_address_id\","
467 "\"phone_number\":\"ship_phone_number\"," 467 "\"phone_number\":\"ship_phone_number\","
468 "\"postal_address\":" 468 "\"postal_address\":"
469 "{" 469 "{"
470 "\"address_line\":" 470 "\"address_line\":"
471 "[" 471 "["
472 "\"ship_address_line_1\"," 472 "\"ship_address_line_1\","
473 "\"ship_address_line_2\"" 473 "\"ship_address_line_2\""
474 "]," 474 "],"
475 "\"administrative_area_name\":\"ship_admin_area_name\"," 475 "\"administrative_area_name\":\"ship_admin_area_name\","
476 "\"country_name_code\":\"ship_country_name_code\"," 476 "\"country_name_code\":\"US\","
477 "\"locality_name\":\"ship_locality_name\"," 477 "\"locality_name\":\"ship_locality_name\","
478 "\"postal_code_number\":\"ship_postal_code_number\"," 478 "\"postal_code_number\":\"ship_postal_code_number\","
479 "\"recipient_name\":\"ship_recipient_name\"" 479 "\"recipient_name\":\"ship_recipient_name\""
480 "}" 480 "}"
481 "}" 481 "}"
482 "}"; 482 "}";
483 483
484 const char kUpdateInstrumentAddressValidRequest[] = 484 const char kUpdateInstrumentAddressValidRequest[] =
485 "{" 485 "{"
486 "\"instrument_phone_number\":\"phone_number\"," 486 "\"instrument_phone_number\":\"phone_number\","
487 "\"merchant_domain\":\"https://example.com/\"," 487 "\"merchant_domain\":\"https://example.com/\","
488 "\"risk_params\":\"risky business\"," 488 "\"risk_params\":\"risky business\","
489 "\"upgraded_billing_address\":" 489 "\"upgraded_billing_address\":"
490 "{" 490 "{"
491 "\"address_line\":" 491 "\"address_line\":"
492 "[" 492 "["
493 "\"address_line_1\"," 493 "\"address_line_1\","
494 "\"address_line_2\"" 494 "\"address_line_2\""
495 "]," 495 "],"
496 "\"administrative_area_name\":\"admin_area_name\"," 496 "\"administrative_area_name\":\"admin_area_name\","
497 "\"country_name_code\":\"country_name_code\"," 497 "\"country_name_code\":\"US\","
498 "\"locality_name\":\"locality_name\"," 498 "\"locality_name\":\"locality_name\","
499 "\"postal_code_number\":\"postal_code_number\"," 499 "\"postal_code_number\":\"postal_code_number\","
500 "\"recipient_name\":\"recipient_name\"" 500 "\"recipient_name\":\"recipient_name\""
501 "}," 501 "},"
502 "\"upgraded_instrument_id\":\"instrument_id\"" 502 "\"upgraded_instrument_id\":\"instrument_id\""
503 "}"; 503 "}";
504 504
505 const char kUpdateInstrumentAddressWithNameChangeValidRequest[] = 505 const char kUpdateInstrumentAddressWithNameChangeValidRequest[] =
506 "{" 506 "{"
507 "\"instrument_escrow_handle\":\"escrow_handle\"," 507 "\"instrument_escrow_handle\":\"escrow_handle\","
508 "\"instrument_phone_number\":\"phone_number\"," 508 "\"instrument_phone_number\":\"phone_number\","
509 "\"merchant_domain\":\"https://example.com/\"," 509 "\"merchant_domain\":\"https://example.com/\","
510 "\"risk_params\":\"risky business\"," 510 "\"risk_params\":\"risky business\","
511 "\"upgraded_billing_address\":" 511 "\"upgraded_billing_address\":"
512 "{" 512 "{"
513 "\"address_line\":" 513 "\"address_line\":"
514 "[" 514 "["
515 "\"address_line_1\"," 515 "\"address_line_1\","
516 "\"address_line_2\"" 516 "\"address_line_2\""
517 "]," 517 "],"
518 "\"administrative_area_name\":\"admin_area_name\"," 518 "\"administrative_area_name\":\"admin_area_name\","
519 "\"country_name_code\":\"country_name_code\"," 519 "\"country_name_code\":\"US\","
520 "\"locality_name\":\"locality_name\"," 520 "\"locality_name\":\"locality_name\","
521 "\"postal_code_number\":\"postal_code_number\"," 521 "\"postal_code_number\":\"postal_code_number\","
522 "\"recipient_name\":\"recipient_name\"" 522 "\"recipient_name\":\"recipient_name\""
523 "}," 523 "},"
524 "\"upgraded_instrument_id\":\"instrument_id\"" 524 "\"upgraded_instrument_id\":\"instrument_id\""
525 "}"; 525 "}";
526 526
527 const char kUpdateInstrumentAddressAndExpirationDateValidRequest[] = 527 const char kUpdateInstrumentAddressAndExpirationDateValidRequest[] =
528 "{" 528 "{"
529 "\"instrument\":" 529 "\"instrument\":"
530 "{" 530 "{"
531 "\"credit_card\":" 531 "\"credit_card\":"
532 "{" 532 "{"
533 "\"exp_month\":12," 533 "\"exp_month\":12,"
534 "\"exp_year\":2015" 534 "\"exp_year\":2015"
535 "}" 535 "}"
536 "}," 536 "},"
537 "\"instrument_escrow_handle\":\"escrow_handle\"," 537 "\"instrument_escrow_handle\":\"escrow_handle\","
538 "\"instrument_phone_number\":\"phone_number\"," 538 "\"instrument_phone_number\":\"phone_number\","
539 "\"merchant_domain\":\"https://example.com/\"," 539 "\"merchant_domain\":\"https://example.com/\","
540 "\"risk_params\":\"risky business\"," 540 "\"risk_params\":\"risky business\","
541 "\"upgraded_billing_address\":" 541 "\"upgraded_billing_address\":"
542 "{" 542 "{"
543 "\"address_line\":" 543 "\"address_line\":"
544 "[" 544 "["
545 "\"address_line_1\"," 545 "\"address_line_1\","
546 "\"address_line_2\"" 546 "\"address_line_2\""
547 "]," 547 "],"
548 "\"administrative_area_name\":\"admin_area_name\"," 548 "\"administrative_area_name\":\"admin_area_name\","
549 "\"country_name_code\":\"country_name_code\"," 549 "\"country_name_code\":\"US\","
550 "\"locality_name\":\"locality_name\"," 550 "\"locality_name\":\"locality_name\","
551 "\"postal_code_number\":\"postal_code_number\"," 551 "\"postal_code_number\":\"postal_code_number\","
552 "\"recipient_name\":\"recipient_name\"" 552 "\"recipient_name\":\"recipient_name\""
553 "}," 553 "},"
554 "\"upgraded_instrument_id\":\"instrument_id\"" 554 "\"upgraded_instrument_id\":\"instrument_id\""
555 "}"; 555 "}";
556 556
557 const char kUpdateInstrumentExpirationDateValidRequest[] = 557 const char kUpdateInstrumentExpirationDateValidRequest[] =
558 "{" 558 "{"
559 "\"instrument\":" 559 "\"instrument\":"
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 wallet_client_->GetWalletItems(GURL(kMerchantUrl)); 1855 wallet_client_->GetWalletItems(GURL(kMerchantUrl));
1856 EXPECT_EQ(2U, wallet_client_->pending_requests_.size()); 1856 EXPECT_EQ(2U, wallet_client_->pending_requests_.size());
1857 1857
1858 wallet_client_->CancelRequests(); 1858 wallet_client_->CancelRequests();
1859 EXPECT_EQ(0U, wallet_client_->pending_requests_.size()); 1859 EXPECT_EQ(0U, wallet_client_->pending_requests_.size());
1860 EXPECT_FALSE(wallet_client_->HasRequestInProgress()); 1860 EXPECT_FALSE(wallet_client_->HasRequestInProgress());
1861 } 1861 }
1862 1862
1863 } // namespace wallet 1863 } // namespace wallet
1864 } // namespace autofill 1864 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/browser/wallet/instrument_unittest.cc ('k') | components/autofill/browser/wallet/wallet_items.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698