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 "components/autofill/core/browser/autofill_field.h" | 5 #include "components/autofill/core/browser/autofill_field.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "components/autofill/core/browser/autofill_type.h" | 10 #include "components/autofill/core/browser/autofill_type.h" |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 AutofillField field( | 395 AutofillField field( |
396 GenerateSelectFieldWithOptions(kMonthsFull, arraysize(kMonthsFull)), | 396 GenerateSelectFieldWithOptions(kMonthsFull, arraysize(kMonthsFull)), |
397 base::string16()); | 397 base::string16()); |
398 field.set_heuristic_type(CREDIT_CARD_EXP_MONTH); | 398 field.set_heuristic_type(CREDIT_CARD_EXP_MONTH); |
399 | 399 |
400 AutofillField::FillFormField( | 400 AutofillField::FillFormField( |
401 field, ASCIIToUTF16("04"), "en-US", "en-US", &field); | 401 field, ASCIIToUTF16("04"), "en-US", "en-US", &field); |
402 EXPECT_EQ(ASCIIToUTF16("April"), field.value); | 402 EXPECT_EQ(ASCIIToUTF16("April"), field.value); |
403 } | 403 } |
404 | 404 |
| 405 TEST(AutofillFieldTest, FillSelectControlWithFrenchMonthName) { |
| 406 const char* const kMonthsFrench[] = { |
| 407 "JANV", "FÉVR.", "MARS", "décembre" |
| 408 }; |
| 409 AutofillField field( |
| 410 GenerateSelectFieldWithOptions(kMonthsFrench, arraysize(kMonthsFrench)), |
| 411 base::string16()); |
| 412 field.set_heuristic_type(CREDIT_CARD_EXP_MONTH); |
| 413 |
| 414 AutofillField::FillFormField( |
| 415 field, ASCIIToUTF16("02"), "fr-FR", "fr-FR", &field); |
| 416 EXPECT_EQ(UTF8ToUTF16("FÉVR."), field.value); |
| 417 |
| 418 AutofillField::FillFormField( |
| 419 field, ASCIIToUTF16("01"), "fr-FR", "fr-FR", &field); |
| 420 EXPECT_EQ(UTF8ToUTF16("JANV"), field.value); |
| 421 |
| 422 AutofillField::FillFormField( |
| 423 field, ASCIIToUTF16("12"), "fr-FR", "fr-FR", &field); |
| 424 EXPECT_EQ(UTF8ToUTF16("décembre"), field.value); |
| 425 } |
| 426 |
405 TEST(AutofillFieldTest, FillSelectControlWithNumericMonthSansLeadingZero) { | 427 TEST(AutofillFieldTest, FillSelectControlWithNumericMonthSansLeadingZero) { |
406 const char* const kMonthsNumeric[] = { | 428 const char* const kMonthsNumeric[] = { |
407 "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", | 429 "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", |
408 }; | 430 }; |
409 AutofillField field( | 431 AutofillField field( |
410 GenerateSelectFieldWithOptions(kMonthsNumeric, arraysize(kMonthsNumeric)), | 432 GenerateSelectFieldWithOptions(kMonthsNumeric, arraysize(kMonthsNumeric)), |
411 base::string16()); | 433 base::string16()); |
412 field.set_heuristic_type(CREDIT_CARD_EXP_MONTH); | 434 field.set_heuristic_type(CREDIT_CARD_EXP_MONTH); |
413 | 435 |
414 AutofillField::FillFormField( | 436 AutofillField::FillFormField( |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 index = kBadIndex; | 689 index = kBadIndex; |
668 ret = AutofillField::FindValueInSelectControl( | 690 ret = AutofillField::FindValueInSelectControl( |
669 field, UTF8ToUTF16("NoVaScOtIa"), &index); | 691 field, UTF8ToUTF16("NoVaScOtIa"), &index); |
670 EXPECT_TRUE(ret); | 692 EXPECT_TRUE(ret); |
671 EXPECT_EQ(2U, index); | 693 EXPECT_EQ(2U, index); |
672 } | 694 } |
673 } | 695 } |
674 | 696 |
675 } // namespace | 697 } // namespace |
676 } // namespace autofill | 698 } // namespace autofill |
OLD | NEW |