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

Side by Side Diff: components/autofill/core/browser/autofill_field_unittest.cc

Issue 1080883002: Remove some more bad ASCII-centric autofill code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests Created 5 years, 8 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
OLDNEW
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
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"
Evan Stade 2015/04/11 01:00:46 I thought we had to use escape sequences but elsew
Lei Zhang 2015/04/11 02:44:17 That's what I did for Quebec.
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698