| 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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 449 |
| 450 card.SetInfo( | 450 card.SetInfo(AutofillType(CREDIT_CARD_EXP_MONTH), |
| 451 AutofillType(CREDIT_CARD_EXP_MONTH), UTF8ToUTF16("F\xc3\x89VRIER"), | 451 UTF8ToUTF16("F\xc3\x89VRIER"), "fr-FR"); |
| 452 "fr-FR"); | |
| 453 EXPECT_EQ(ASCIIToUTF16("02"), card.GetRawInfo(CREDIT_CARD_EXP_MONTH)); | 452 EXPECT_EQ(ASCIIToUTF16("02"), card.GetRawInfo(CREDIT_CARD_EXP_MONTH)); |
| 454 EXPECT_EQ(2, card.expiration_month()); | 453 EXPECT_EQ(2, card.expiration_month()); |
| 455 } | 454 } |
| 456 | 455 |
| 457 TEST(CreditCardTest, CreditCardType) { | 456 TEST(CreditCardTest, CreditCardType) { |
| 458 CreditCard card(base::GenerateGUID(), "https://www.example.com/"); | 457 CreditCard card(base::GenerateGUID(), "https://www.example.com/"); |
| 459 | 458 |
| 460 // The card type cannot be set directly. | 459 // The card type cannot be set directly. |
| 461 card.SetRawInfo(CREDIT_CARD_TYPE, ASCIIToUTF16("Visa")); | 460 card.SetRawInfo(CREDIT_CARD_TYPE, ASCIIToUTF16("Visa")); |
| 462 EXPECT_EQ(base::string16(), card.GetRawInfo(CREDIT_CARD_TYPE)); | 461 EXPECT_EQ(base::string16(), card.GetRawInfo(CREDIT_CARD_TYPE)); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 base::string16 card_number = base::ASCIIToUTF16("test"); | 657 base::string16 card_number = base::ASCIIToUTF16("test"); |
| 659 int month = 1; | 658 int month = 1; |
| 660 int year = 3000; | 659 int year = 3000; |
| 661 CreditCard card(card_number, month, year); | 660 CreditCard card(card_number, month, year); |
| 662 EXPECT_EQ(card_number, card.number()); | 661 EXPECT_EQ(card_number, card.number()); |
| 663 EXPECT_EQ(month, card.expiration_month()); | 662 EXPECT_EQ(month, card.expiration_month()); |
| 664 EXPECT_EQ(year, card.expiration_year()); | 663 EXPECT_EQ(year, card.expiration_year()); |
| 665 } | 664 } |
| 666 | 665 |
| 667 } // namespace autofill | 666 } // namespace autofill |
| OLD | NEW |