Chromium Code Reviews| 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 EXPECT_EQ(kMasterCard, card.type()); | 302 EXPECT_EQ(kMasterCard, card.type()); |
| 303 EXPECT_FALSE(card.IsComplete()); | 303 EXPECT_FALSE(card.IsComplete()); |
| 304 } | 304 } |
| 305 | 305 |
| 306 // Verify that we preserve exactly what the user typed for credit card numbers. | 306 // Verify that we preserve exactly what the user typed for credit card numbers. |
| 307 TEST(CreditCardTest, SetRawInfoCreditCardNumber) { | 307 TEST(CreditCardTest, SetRawInfoCreditCardNumber) { |
| 308 CreditCard card(base::GenerateGUID(), "https://www.example.com/"); | 308 CreditCard card(base::GenerateGUID(), "https://www.example.com/"); |
| 309 | 309 |
| 310 test::SetCreditCardInfo(&card, "Bob Dylan", | 310 test::SetCreditCardInfo(&card, "Bob Dylan", |
| 311 "4321-5432-6543-xxxx", "07", "2013"); | 311 "4321-5432-6543-xxxx", "07", "2013"); |
| 312 EXPECT_EQ(ASCIIToUTF16("4321-5432-6543-xxxx"), | 312 EXPECT_EQ(ASCIIToUTF16("432154326543xxxx"), |
|
kbalazs
2014/07/25 00:30:08
Shouldn't we add a new test case instead of changi
Ilya Sherman
2014/07/25 03:37:49
+1. Your changes should not regress this test.
Pritam Nikam
2014/07/26 11:29:50
Done.
Pritam Nikam
2014/07/26 11:29:50
Done.
| |
| 313 card.GetRawInfo(CREDIT_CARD_NUMBER)); | 313 card.GetRawInfo(CREDIT_CARD_NUMBER)); |
| 314 } | 314 } |
| 315 | 315 |
| 316 // Verify that we can handle both numeric and named months. | 316 // Verify that we can handle both numeric and named months. |
| 317 TEST(CreditCardTest, SetExpirationMonth) { | 317 TEST(CreditCardTest, SetExpirationMonth) { |
| 318 CreditCard card(base::GenerateGUID(), "https://www.example.com/"); | 318 CreditCard card(base::GenerateGUID(), "https://www.example.com/"); |
| 319 | 319 |
| 320 card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("05")); | 320 card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("05")); |
| 321 EXPECT_EQ(ASCIIToUTF16("05"), card.GetRawInfo(CREDIT_CARD_EXP_MONTH)); | 321 EXPECT_EQ(ASCIIToUTF16("05"), card.GetRawInfo(CREDIT_CARD_EXP_MONTH)); |
| 322 EXPECT_EQ(5, card.expiration_month()); | 322 EXPECT_EQ(5, card.expiration_month()); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 520 | 520 |
| 521 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 521 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { |
| 522 base::string16 card_number = ASCIIToUTF16(test_cases[i].card_number); | 522 base::string16 card_number = ASCIIToUTF16(test_cases[i].card_number); |
| 523 SCOPED_TRACE(card_number); | 523 SCOPED_TRACE(card_number); |
| 524 EXPECT_EQ(test_cases[i].type, CreditCard::GetCreditCardType(card_number)); | 524 EXPECT_EQ(test_cases[i].type, CreditCard::GetCreditCardType(card_number)); |
| 525 EXPECT_EQ(test_cases[i].is_valid, IsValidCreditCardNumber(card_number)); | 525 EXPECT_EQ(test_cases[i].is_valid, IsValidCreditCardNumber(card_number)); |
| 526 } | 526 } |
| 527 } | 527 } |
| 528 | 528 |
| 529 } // namespace autofill | 529 } // namespace autofill |
| OLD | NEW |