| OLD | NEW |
| 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/guid.h" | 6 #include "base/guid.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "components/autofill/core/browser/autofill_test_utils.h" | 8 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 9 #include "components/autofill/core/browser/autofill_type.h" | 9 #include "components/autofill/core/browser/autofill_type.h" |
| 10 #include "components/autofill/core/browser/credit_card.h" | 10 #include "components/autofill/core/browser/credit_card.h" |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 | 439 |
| 440 card.SetInfo( | 440 card.SetInfo( |
| 441 AutofillType(CREDIT_CARD_EXP_MONTH), ASCIIToUTF16("January"), "en-US"); | 441 AutofillType(CREDIT_CARD_EXP_MONTH), ASCIIToUTF16("January"), "en-US"); |
| 442 EXPECT_EQ(ASCIIToUTF16("01"), card.GetRawInfo(CREDIT_CARD_EXP_MONTH)); | 442 EXPECT_EQ(ASCIIToUTF16("01"), card.GetRawInfo(CREDIT_CARD_EXP_MONTH)); |
| 443 EXPECT_EQ(1, card.expiration_month()); | 443 EXPECT_EQ(1, card.expiration_month()); |
| 444 | 444 |
| 445 card.SetInfo( | 445 card.SetInfo( |
| 446 AutofillType(CREDIT_CARD_EXP_MONTH), ASCIIToUTF16("Apr"), "en-US"); | 446 AutofillType(CREDIT_CARD_EXP_MONTH), ASCIIToUTF16("Apr"), "en-US"); |
| 447 EXPECT_EQ(ASCIIToUTF16("04"), card.GetRawInfo(CREDIT_CARD_EXP_MONTH)); | 447 EXPECT_EQ(ASCIIToUTF16("04"), card.GetRawInfo(CREDIT_CARD_EXP_MONTH)); |
| 448 EXPECT_EQ(4, card.expiration_month()); | 448 EXPECT_EQ(4, card.expiration_month()); |
| 449 |
| 450 card.SetInfo( |
| 451 AutofillType(CREDIT_CARD_EXP_MONTH), UTF8ToUTF16("F\xc3\x89VRIER"), |
| 452 "fr-FR"); |
| 453 EXPECT_EQ(ASCIIToUTF16("02"), card.GetRawInfo(CREDIT_CARD_EXP_MONTH)); |
| 454 EXPECT_EQ(2, card.expiration_month()); |
| 449 } | 455 } |
| 450 | 456 |
| 451 TEST(CreditCardTest, CreditCardType) { | 457 TEST(CreditCardTest, CreditCardType) { |
| 452 CreditCard card(base::GenerateGUID(), "https://www.example.com/"); | 458 CreditCard card(base::GenerateGUID(), "https://www.example.com/"); |
| 453 | 459 |
| 454 // The card type cannot be set directly. | 460 // The card type cannot be set directly. |
| 455 card.SetRawInfo(CREDIT_CARD_TYPE, ASCIIToUTF16("Visa")); | 461 card.SetRawInfo(CREDIT_CARD_TYPE, ASCIIToUTF16("Visa")); |
| 456 EXPECT_EQ(base::string16(), card.GetRawInfo(CREDIT_CARD_TYPE)); | 462 EXPECT_EQ(base::string16(), card.GetRawInfo(CREDIT_CARD_TYPE)); |
| 457 | 463 |
| 458 // Setting the number should implicitly set the type. | 464 // Setting the number should implicitly set the type. |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 base::string16 card_number = base::ASCIIToUTF16("test"); | 658 base::string16 card_number = base::ASCIIToUTF16("test"); |
| 653 int month = 1; | 659 int month = 1; |
| 654 int year = 3000; | 660 int year = 3000; |
| 655 CreditCard card(card_number, month, year); | 661 CreditCard card(card_number, month, year); |
| 656 EXPECT_EQ(card_number, card.number()); | 662 EXPECT_EQ(card_number, card.number()); |
| 657 EXPECT_EQ(month, card.expiration_month()); | 663 EXPECT_EQ(month, card.expiration_month()); |
| 658 EXPECT_EQ(year, card.expiration_year()); | 664 EXPECT_EQ(year, card.expiration_year()); |
| 659 } | 665 } |
| 660 | 666 |
| 661 } // namespace autofill | 667 } // namespace autofill |
| OLD | NEW |