| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 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.check_status = FormFieldData::CHECKABLE_BUT_UNCHECKED; |
| 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.check_status = FormFieldData::NOT_CHECKABLE; |
| 140 | 140 |
| 141 field_data.label = ASCIIToUTF16("Address line2"); | 141 field_data.label = ASCIIToUTF16("Address line2"); |
| 142 fields.push_back(new AutofillField(field_data, field_data.label)); | 142 fields.push_back(new AutofillField(field_data, field_data.label)); |
| 143 | 143 |
| 144 // Does not parse since there are only 2 recognized fields. | 144 // Does not parse since there are only 2 recognized fields. |
| 145 ASSERT_TRUE(FormField::ParseFormFields(fields.get(), true).empty()); | 145 ASSERT_TRUE(FormField::ParseFormFields(fields.get(), true).empty()); |
| 146 | 146 |
| 147 field_data.label = ASCIIToUTF16("City"); | 147 field_data.label = ASCIIToUTF16("City"); |
| 148 fields.push_back(new AutofillField(field_data, field_data.label)); | 148 fields.push_back(new AutofillField(field_data, field_data.label)); |
| 149 | 149 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 EXPECT_TRUE(field_candidates_map.find(unique_name) != | 185 EXPECT_TRUE(field_candidates_map.find(unique_name) != |
| 186 field_candidates_map.end()); | 186 field_candidates_map.end()); |
| 187 | 187 |
| 188 // Because we use a handcrafted field name, we can expect it to match more | 188 // Because we use a handcrafted field name, we can expect it to match more |
| 189 // than just one parser (at least email, but probably some more from the other | 189 // than just one parser (at least email, but probably some more from the other |
| 190 // parsers). | 190 // parsers). |
| 191 EXPECT_LT(1U, field_candidates_map.at(unique_name).field_candidates().size()); | 191 EXPECT_LT(1U, field_candidates_map.at(unique_name).field_candidates().size()); |
| 192 } | 192 } |
| 193 | 193 |
| 194 } // namespace autofill | 194 } // namespace autofill |
| OLD | NEW |