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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
792 AutofillField field; | 792 AutofillField field; |
793 test::CreateTestSelectField(kYears, &field); | 793 test::CreateTestSelectField(kYears, &field); |
794 field.set_heuristic_type(CREDIT_CARD_EXP_2_DIGIT_YEAR); | 794 field.set_heuristic_type(CREDIT_CARD_EXP_2_DIGIT_YEAR); |
795 | 795 |
796 AutofillField::FillFormField( | 796 AutofillField::FillFormField( |
797 field, ASCIIToUTF16("2017"), "en-US", "en-US", &field); | 797 field, ASCIIToUTF16("2017"), "en-US", "en-US", &field); |
798 EXPECT_EQ(ASCIIToUTF16("17"), field.value); | 798 EXPECT_EQ(ASCIIToUTF16("17"), field.value); |
799 } | 799 } |
800 | 800 |
801 TEST_F(AutofillFieldTest, FillSelectControlWithCreditCardType) { | 801 TEST_F(AutofillFieldTest, FillSelectControlWithCreditCardType) { |
802 std::vector<const char*> kCreditCardTypes = {"Visa", "Master Card", "AmEx", | 802 std::vector<const char*> kCreditCardTypes = {"Visa", "Master card", "AmEx", |
803 "discover"}; | 803 "discover"}; |
804 AutofillField field; | 804 AutofillField field; |
805 test::CreateTestSelectField(kCreditCardTypes, &field); | 805 test::CreateTestSelectField(kCreditCardTypes, &field); |
806 field.set_heuristic_type(CREDIT_CARD_TYPE); | 806 field.set_heuristic_type(CREDIT_CARD_TYPE); |
807 | 807 |
808 // Normal case: | 808 // Normal case: |
809 AutofillField::FillFormField( | 809 AutofillField::FillFormField( |
810 field, ASCIIToUTF16("Visa"), "en-US", "en-US", &field); | 810 field, ASCIIToUTF16("Visa"), "en-US", "en-US", &field); |
811 EXPECT_EQ(ASCIIToUTF16("Visa"), field.value); | 811 EXPECT_EQ(ASCIIToUTF16("Visa"), field.value); |
812 | 812 |
813 // Filling should be able to handle intervening whitespace: | 813 // Filling should be able to handle intervening whitespace: |
814 AutofillField::FillFormField( | 814 AutofillField::FillFormField( |
815 field, ASCIIToUTF16("MasterCard"), "en-US", "en-US", &field); | 815 field, ASCIIToUTF16("Mastercard"), "en-US", "en-US", &field); |
Mathieu
2017/04/23 08:23:48
Could we add cases for variations of Mastercard su
Jared Saul
2017/04/24 17:41:08
I was under the impression while reviewing that th
jiahuiguo
2017/04/25 20:20:32
Done.
| |
816 EXPECT_EQ(ASCIIToUTF16("Master Card"), field.value); | 816 EXPECT_EQ(ASCIIToUTF16("Master card"), field.value); |
817 | 817 |
818 // American Express is sometimes abbreviated as AmEx: | 818 // American Express is sometimes abbreviated as AmEx: |
819 AutofillField::FillFormField( | 819 AutofillField::FillFormField( |
820 field, ASCIIToUTF16("American Express"), "en-US", "en-US", &field); | 820 field, ASCIIToUTF16("American Express"), "en-US", "en-US", &field); |
821 EXPECT_EQ(ASCIIToUTF16("AmEx"), field.value); | 821 EXPECT_EQ(ASCIIToUTF16("AmEx"), field.value); |
822 | 822 |
823 // Case insensitivity: | 823 // Case insensitivity: |
824 AutofillField::FillFormField( | 824 AutofillField::FillFormField( |
825 field, ASCIIToUTF16("Discover"), "en-US", "en-US", &field); | 825 field, ASCIIToUTF16("Discover"), "en-US", "en-US", &field); |
826 EXPECT_EQ(ASCIIToUTF16("discover"), field.value); | 826 EXPECT_EQ(ASCIIToUTF16("discover"), field.value); |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1081 false}, | 1081 false}, |
1082 FillStateTextTestCase{HTML_TYPE_ADDRESS_LEVEL1, 1, "NY", "", false}, | 1082 FillStateTextTestCase{HTML_TYPE_ADDRESS_LEVEL1, 1, "NY", "", false}, |
1083 // Filling a state to a text field with a maxlength value lower than the | 1083 // Filling a state to a text field with a maxlength value lower than the |
1084 // value's length and that has no associated abbreviation should not | 1084 // value's length and that has no associated abbreviation should not |
1085 // fill at all. | 1085 // fill at all. |
1086 FillStateTextTestCase{HTML_TYPE_ADDRESS_LEVEL1, 3, "Quebec", "", | 1086 FillStateTextTestCase{HTML_TYPE_ADDRESS_LEVEL1, 3, "Quebec", "", |
1087 false})); | 1087 false})); |
1088 | 1088 |
1089 } // namespace | 1089 } // namespace |
1090 } // namespace autofill | 1090 } // namespace autofill |
OLD | NEW |