Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(598)

Unified Diff: components/autofill/core/browser/form_structure_unittest.cc

Issue 1411363003: [Autofill] Always show available data when encountering autocomplete attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 5a0cb53bdeb142b8c79c26956d3808a4ff800e95..4aa8bb19e4ab6e601b36d6c03ee3694010290ceb 100644
--- a/components/autofill/core/browser/form_structure_unittest.cc
+++ b/components/autofill/core/browser/form_structure_unittest.cc
@@ -305,11 +305,36 @@ TEST_F(FormStructureTest, ShouldBeParsed) {
EXPECT_TRUE(form_structure->ShouldBeParsed());
form.fields[0].form_control_type = "select-one";
+
// Now, no text fields.
form_structure.reset(new FormStructure(form));
EXPECT_FALSE(form_structure->ShouldBeParsed());
}
+// Tests that ShouldBeParsed returns true for a form containing less than three
+// fields if at least one has an autocomplete attribute.
+TEST_F(FormStructureTest, ShouldBeParsed_TwoFields_HasAutocomplete) {
+ scoped_ptr<FormStructure> form_structure;
+ FormData form;
+ FormFieldData field;
+
+ field.label = ASCIIToUTF16("Name");
+ field.name = ASCIIToUTF16("name");
+ field.form_control_type = "name";
+ field.autocomplete_attribute = "name";
+ form.fields.push_back(field);
+
+ field.label = ASCIIToUTF16("Address");
+ field.name = ASCIIToUTF16("Address");
+ field.form_control_type = "select-one";
+ field.autocomplete_attribute = "";
+ form.fields.push_back(field);
+
+ form_structure.reset(new FormStructure(form));
+ form_structure->ParseFieldTypesFromAutocompleteAttributes();
+ EXPECT_TRUE(form_structure->ShouldBeParsed());
+}
+
TEST_F(FormStructureTest, HeuristicsContactInfo) {
scoped_ptr<FormStructure> form_structure;
FormData form;
@@ -2968,8 +2993,7 @@ TEST_F(FormStructureTest, PossibleValues) {
form_data.fields.push_back(field);
FormStructure form_structure(form_data);
- bool unused;
- form_structure.ParseFieldTypesFromAutocompleteAttributes(&unused, &unused);
+ form_structure.ParseFieldTypesFromAutocompleteAttributes();
// All values in <option> value= or contents are returned, set to upper case.
std::set<base::string16> possible_values =
@@ -2991,7 +3015,7 @@ TEST_F(FormStructureTest, PossibleValues) {
freeform_field.autocomplete_attribute = "billing country";
form_data.fields.push_back(freeform_field);
FormStructure form_structure2(form_data);
- form_structure2.ParseFieldTypesFromAutocompleteAttributes(&unused, &unused);
+ form_structure2.ParseFieldTypesFromAutocompleteAttributes();
EXPECT_EQ(0U, form_structure2.PossibleValues(ADDRESS_BILLING_COUNTRY).size());
}

Powered by Google App Engine
This is Rietveld 408576698