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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 FormFieldData field_data; | 128 FormFieldData field_data; |
129 field_data.form_control_type = "text"; | 129 field_data.form_control_type = "text"; |
130 | 130 |
131 field_data.label = ASCIIToUTF16("Address line1"); | 131 field_data.label = ASCIIToUTF16("Address line1"); |
132 fields.push_back(new AutofillField(field_data, field_data.label)); | 132 fields.push_back(new AutofillField(field_data, field_data.label)); |
133 | 133 |
134 field_data.is_checkable = true; | 134 field_data.is_checkable = true; |
135 field_data.label = ASCIIToUTF16("Is PO Box"); | 135 field_data.label = ASCIIToUTF16("Is PO Box"); |
136 fields.push_back(new AutofillField(field_data, field_data.label)); | 136 fields.push_back(new AutofillField(field_data, field_data.label)); |
137 | 137 |
138 // reset is_checkable to false. | 138 // reset |is_checkable| to false. |
139 field_data.is_checkable = false; | 139 field_data.is_checkable = false; |
| 140 |
140 field_data.label = ASCIIToUTF16("Address line2"); | 141 field_data.label = ASCIIToUTF16("Address line2"); |
141 fields.push_back(new AutofillField(field_data, field_data.label)); | 142 fields.push_back(new AutofillField(field_data, field_data.label)); |
142 | 143 |
143 ServerFieldTypeMap field_type_map; | 144 ServerFieldTypeMap field_type_map; |
144 FormField::ParseFormFields(fields.get(), &field_type_map); | 145 FormField::ParseFormFields(fields.get(), true, &field_type_map); |
| 146 // Does not parse since there are only 2 recognized fields. |
| 147 ASSERT_EQ(0U, field_type_map.size()); |
| 148 |
| 149 field_data.label = ASCIIToUTF16("City"); |
| 150 fields.push_back(new AutofillField(field_data, field_data.label)); |
| 151 |
145 // Checkable element shouldn't interfere with inference of Address line2. | 152 // Checkable element shouldn't interfere with inference of Address line2. |
146 EXPECT_EQ(2U, field_type_map.size()); | 153 field_type_map.clear(); |
| 154 FormField::ParseFormFields(fields.get(), true, &field_type_map); |
| 155 ASSERT_EQ(3U, field_type_map.size()); |
147 | 156 |
148 EXPECT_EQ(ADDRESS_HOME_LINE1, | 157 EXPECT_EQ(ADDRESS_HOME_LINE1, |
149 field_type_map.find(ASCIIToUTF16("Address line1"))->second); | 158 field_type_map.find(ASCIIToUTF16("Address line1"))->second); |
150 EXPECT_EQ(ADDRESS_HOME_LINE2, | 159 EXPECT_EQ(ADDRESS_HOME_LINE2, |
151 field_type_map.find(ASCIIToUTF16("Address line2"))->second); | 160 field_type_map.find(ASCIIToUTF16("Address line2"))->second); |
152 } | 161 } |
153 | 162 |
154 } // namespace autofill | 163 } // namespace autofill |
OLD | NEW |