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/memory/scoped_vector.h" | 5 #include "base/memory/scoped_vector.h" |
6 #include "base/strings/string16.h" | 6 #include "base/strings/string16.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "components/autofill/core/browser/autofill_field.h" | 8 #include "components/autofill/core/browser/autofill_field.h" |
9 #include "components/autofill/core/browser/form_field.h" | 9 #include "components/autofill/core/browser/form_field.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head_tail"), | 110 EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head_tail"), |
111 FormField::MATCH_LABEL)); | 111 FormField::MATCH_LABEL)); |
112 | 112 |
113 // Word boundaries. | 113 // Word boundaries. |
114 field.label = ASCIIToUTF16("contains word:"); | 114 field.label = ASCIIToUTF16("contains word:"); |
115 EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("\\bword\\b"), | 115 EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("\\bword\\b"), |
116 FormField::MATCH_LABEL)); | 116 FormField::MATCH_LABEL)); |
117 EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("\\bcon\\b"), | 117 EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("\\bcon\\b"), |
118 FormField::MATCH_LABEL)); | 118 FormField::MATCH_LABEL)); |
119 // Make sure the circumflex in 'crepe' is not treated as a word boundary. | 119 // Make sure the circumflex in 'crepe' is not treated as a word boundary. |
120 field.label = UTF8ToUTF16("cr" "\xC3\xAA" "pe"); | 120 field.label = base::UTF8ToUTF16("cr" "\xC3\xAA" "pe"); |
121 EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("\\bcr\\b"), | 121 EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("\\bcr\\b"), |
122 FormField::MATCH_LABEL)); | 122 FormField::MATCH_LABEL)); |
123 } | 123 } |
124 | 124 |
125 // Test that we ignore checkable elements. | 125 // Test that we ignore checkable elements. |
126 TEST(FormFieldTest, ParseFormFields) { | 126 TEST(FormFieldTest, ParseFormFields) { |
127 ScopedVector<AutofillField> fields; | 127 ScopedVector<AutofillField> fields; |
128 FormFieldData field_data; | 128 FormFieldData field_data; |
129 field_data.form_control_type = "text"; | 129 field_data.form_control_type = "text"; |
130 | 130 |
(...skipping 14 matching lines...) Expand all Loading... |
145 // Checkable element shouldn't interfere with inference of Address line2. | 145 // Checkable element shouldn't interfere with inference of Address line2. |
146 EXPECT_EQ(2U, field_type_map.size()); | 146 EXPECT_EQ(2U, field_type_map.size()); |
147 | 147 |
148 EXPECT_EQ(ADDRESS_HOME_LINE1, | 148 EXPECT_EQ(ADDRESS_HOME_LINE1, |
149 field_type_map.find(ASCIIToUTF16("Address line1"))->second); | 149 field_type_map.find(ASCIIToUTF16("Address line1"))->second); |
150 EXPECT_EQ(ADDRESS_HOME_LINE2, | 150 EXPECT_EQ(ADDRESS_HOME_LINE2, |
151 field_type_map.find(ASCIIToUTF16("Address line2"))->second); | 151 field_type_map.find(ASCIIToUTF16("Address line2"))->second); |
152 } | 152 } |
153 | 153 |
154 } // namespace autofill | 154 } // namespace autofill |
OLD | NEW |