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

Side by Side Diff: chrome/browser/autofill/wallet/full_wallet_unittest.cc

Issue 12388059: Adds wallet::Address::CreateAddress() for when IDs are optional (for billing addresses). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 9 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/logging.h" 6 #include "base/logging.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/autofill/wallet/full_wallet.h" 10 #include "chrome/browser/autofill/wallet/full_wallet.h"
11 #include "chrome/browser/autofill/wallet/required_action.h" 11 #include "chrome/browser/autofill/wallet/required_action.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace { 14 namespace {
15 15
16 const char kFullWalletValidResponse[] = 16 const char kFullWalletValidResponse[] =
17 "{" 17 "{"
18 " \"expiration_month\":12," 18 " \"expiration_month\":12,"
19 " \"expiration_year\":2012," 19 " \"expiration_year\":2012,"
20 " \"iin\":\"iin\"," 20 " \"iin\":\"iin\","
21 " \"rest\":\"rest\"," 21 " \"rest\":\"rest\","
22 " \"billing_address\":" 22 " \"billing_address\":"
23 " {" 23 " {"
24 " \"id\":\"id\","
25 " \"phone_number\":\"phone_number\"," 24 " \"phone_number\":\"phone_number\","
26 " \"postal_address\":" 25 " \"postal_address\":"
27 " {" 26 " {"
28 " \"recipient_name\":\"recipient_name\"," 27 " \"recipient_name\":\"recipient_name\","
29 " \"address_line\":" 28 " \"address_line\":"
30 " [" 29 " ["
31 " \"address_line_1\"," 30 " \"address_line_1\","
32 " \"address_line_2\"" 31 " \"address_line_2\""
33 " ]," 32 " ],"
34 " \"locality_name\":\"locality_name\"," 33 " \"locality_name\":\"locality_name\","
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 "}"; 296 "}";
298 297
299 const char kFullWalletMalformedBillingAddress[] = 298 const char kFullWalletMalformedBillingAddress[] =
300 "{" 299 "{"
301 " \"expiration_month\":12," 300 " \"expiration_month\":12,"
302 " \"expiration_year\":2012," 301 " \"expiration_year\":2012,"
303 " \"iin\":\"iin\"," 302 " \"iin\":\"iin\","
304 " \"rest\":\"rest\"," 303 " \"rest\":\"rest\","
305 " \"billing_address\":" 304 " \"billing_address\":"
306 " {" 305 " {"
307 " \"id\":\"id\","
308 " \"phone_number\":\"phone_number\"," 306 " \"phone_number\":\"phone_number\","
309 " \"postal_address\":" 307 " \"postal_address\":"
310 " {" 308 " {"
311 " \"recipient_name\":\"recipient_name\"," 309 " \"recipient_name\":\"recipient_name\","
312 " \"address_line\":" 310 " \"address_line\":"
313 " [" 311 " ["
314 " \"address_line_1\"," 312 " \"address_line_1\","
315 " \"address_line_2\"" 313 " \"address_line_2\""
316 " ]," 314 " ],"
317 " \"locality_name\":\"locality_name\"," 315 " \"locality_name\":\"locality_name\","
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 EXPECT_NE(full_wallet, different_required_actions); 418 EXPECT_NE(full_wallet, different_required_actions);
421 } 419 }
422 420
423 TEST_F(FullWalletTest, CreateFullWalletWithInvalidRequiredActions) { 421 TEST_F(FullWalletTest, CreateFullWalletWithInvalidRequiredActions) {
424 SetUpDictionary(kFullWalletWithInvalidRequiredActions); 422 SetUpDictionary(kFullWalletWithInvalidRequiredActions);
425 EXPECT_EQ(NULL, FullWallet::CreateFullWallet(*dict).get()); 423 EXPECT_EQ(NULL, FullWallet::CreateFullWallet(*dict).get());
426 } 424 }
427 425
428 TEST_F(FullWalletTest, CreateFullWallet) { 426 TEST_F(FullWalletTest, CreateFullWallet) {
429 SetUpDictionary(kFullWalletValidResponse); 427 SetUpDictionary(kFullWalletValidResponse);
428 // NOTE: FullWallet billing address doesn't require an ID.
430 scoped_ptr<Address> billing_address(new Address( 429 scoped_ptr<Address> billing_address(new Address(
431 "country_name_code", 430 "country_name_code",
432 ASCIIToUTF16("recipient_name"), 431 ASCIIToUTF16("recipient_name"),
433 ASCIIToUTF16("address_line_1"), 432 ASCIIToUTF16("address_line_1"),
434 ASCIIToUTF16("address_line_2"), 433 ASCIIToUTF16("address_line_2"),
435 ASCIIToUTF16("locality_name"), 434 ASCIIToUTF16("locality_name"),
436 ASCIIToUTF16("administrative_area_name"), 435 ASCIIToUTF16("administrative_area_name"),
437 ASCIIToUTF16("postal_code_number"), 436 ASCIIToUTF16("postal_code_number"),
438 ASCIIToUTF16("phone_number"), 437 ASCIIToUTF16("phone_number"),
439 "id")); 438 ""));
440 scoped_ptr<Address> shipping_address(new Address( 439 scoped_ptr<Address> shipping_address(new Address(
441 "ship_country_name_code", 440 "ship_country_name_code",
442 ASCIIToUTF16("ship_recipient_name"), 441 ASCIIToUTF16("ship_recipient_name"),
443 ASCIIToUTF16("ship_address_line_1"), 442 ASCIIToUTF16("ship_address_line_1"),
444 ASCIIToUTF16("ship_address_line_2"), 443 ASCIIToUTF16("ship_address_line_2"),
445 ASCIIToUTF16("ship_locality_name"), 444 ASCIIToUTF16("ship_locality_name"),
446 ASCIIToUTF16("ship_admin_area_name"), 445 ASCIIToUTF16("ship_admin_area_name"),
447 ASCIIToUTF16("ship_postal_code_number"), 446 ASCIIToUTF16("ship_postal_code_number"),
448 ASCIIToUTF16("ship_phone_number"), 447 ASCIIToUTF16("ship_phone_number"),
449 "ship_id")); 448 "ship_id"));
450 std::vector<RequiredAction> required_actions; 449 std::vector<RequiredAction> required_actions;
451 FullWallet full_wallet(12, 450 FullWallet full_wallet(12,
452 2012, 451 2012,
453 "iin", 452 "iin",
454 "rest", 453 "rest",
455 billing_address.Pass(), 454 billing_address.Pass(),
456 shipping_address.Pass(), 455 shipping_address.Pass(),
457 required_actions); 456 required_actions);
458 EXPECT_EQ(full_wallet, *FullWallet::CreateFullWallet(*dict)); 457 EXPECT_EQ(full_wallet, *FullWallet::CreateFullWallet(*dict));
459 } 458 }
460 459
461 // TODO(ahutter): Add tests for GetPan and GetCvn. 460 // TODO(ahutter): Add tests for GetPan and GetCvn.
462 461
463 } // namespace wallet 462 } // namespace wallet
464 } // namespace autofill 463 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/autofill/wallet/full_wallet.cc ('k') | chrome/browser/autofill/wallet/wallet_address.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698