| Index: components/autofill/core/browser/form_structure_unittest.cc
|
| diff --git a/components/autofill/core/browser/form_structure_unittest.cc b/components/autofill/core/browser/form_structure_unittest.cc
|
| index 4d1812a3e88f58796042e7029f7c07fbefb2335c..21e9945456f52488d9573626f8f347ff8d9802df 100644
|
| --- a/components/autofill/core/browser/form_structure_unittest.cc
|
| +++ b/components/autofill/core/browser/form_structure_unittest.cc
|
| @@ -451,6 +451,58 @@ TEST_F(FormStructureTest, HeuristicsAutocompleteAttribute) {
|
| EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(2)->heuristic_type());
|
| }
|
|
|
| +// Verify that the heuristics are not run for non checkout formless forms.
|
| +TEST_F(FormStructureTest, Heuristics_FormlessNonCheckoutForm) {
|
| + scoped_ptr<FormStructure> form_structure;
|
| + FormData form;
|
| +
|
| + FormFieldData field;
|
| + field.form_control_type = "text";
|
| +
|
| + field.label = ASCIIToUTF16("First Name:");
|
| + field.name = ASCIIToUTF16("firstname");
|
| + field.autocomplete_attribute = "given-name";
|
| + form.fields.push_back(field);
|
| +
|
| + field.label = ASCIIToUTF16("Last Name:");
|
| + field.name = ASCIIToUTF16("lastname");
|
| + field.autocomplete_attribute = "family-name";
|
| + form.fields.push_back(field);
|
| +
|
| + field.label = ASCIIToUTF16("Email:");
|
| + field.name = ASCIIToUTF16("email");
|
| + field.autocomplete_attribute = "email";
|
| + form.fields.push_back(field);
|
| +
|
| + form_structure.reset(new FormStructure(form));
|
| + form_structure->DetermineHeuristicTypes();
|
| + EXPECT_TRUE(form_structure->IsAutofillable());
|
| +
|
| + // Expect the correct number of fields.
|
| + ASSERT_EQ(3U, form_structure->field_count());
|
| + ASSERT_EQ(3U, form_structure->autofill_count());
|
| +
|
| + // The heuristic type should be good.
|
| + EXPECT_EQ(HTML_TYPE_GIVEN_NAME, form_structure->field(0)->html_type());
|
| + EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
|
| +
|
| + // Set the form as a formless non checkout form.
|
| + form.is_formless_checkout = false;
|
| + form.is_form_tag = false;
|
| +
|
| + form_structure.reset(new FormStructure(form));
|
| + form_structure->DetermineHeuristicTypes();
|
| + EXPECT_TRUE(form_structure->IsAutofillable());
|
| +
|
| + // Expect the correct number of fields.
|
| + ASSERT_EQ(3U, form_structure->field_count());
|
| + ASSERT_EQ(3U, form_structure->autofill_count());
|
| +
|
| + // The heuristic type should be Unknown.
|
| + EXPECT_EQ(HTML_TYPE_GIVEN_NAME, form_structure->field(0)->html_type());
|
| + EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type());
|
| +}
|
| +
|
| // All fields share a common prefix which could confuse the heuristics. Test
|
| // that the common prefix is stripped out before running heuristics.
|
| TEST_F(FormStructureTest, StripCommonNamePrefix) {
|
|
|