diff options
author | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-09 01:33:46 +0000 |
---|---|---|
committer | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-09 01:33:46 +0000 |
commit | eb4b8b4779e5209e47f1002177786c2a51bf44b8 (patch) | |
tree | b27812fd5d41ff8ce205753b34204e806972b2b4 /chrome/browser/autofill | |
parent | 0e7f8d0b2aaf1eea1671c1ea4a1352b827566f94 (diff) | |
download | chromium_src-eb4b8b4779e5209e47f1002177786c2a51bf44b8.zip chromium_src-eb4b8b4779e5209e47f1002177786c2a51bf44b8.tar.gz chromium_src-eb4b8b4779e5209e47f1002177786c2a51bf44b8.tar.bz2 |
Refactor webkit_glue::FormField to remove hacky methods: Remove webkit_glue::FormField's unwieldy full constructor and StricktlyEqualsHack() method. The only clients are in test code, and we can better support these clients in other ways.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7576001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95928 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r-- | chrome/browser/autofill/address_field_unittest.cc | 244 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_common_test.cc | 7 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_download_unittest.cc | 191 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_manager_unittest.cc | 98 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_merge_unittest.cc | 11 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_metrics_unittest.cc | 11 | ||||
-rw-r--r-- | chrome/browser/autofill/credit_card_field_unittest.cc | 319 | ||||
-rw-r--r-- | chrome/browser/autofill/form_structure_unittest.cc | 1541 | ||||
-rw-r--r-- | chrome/browser/autofill/name_field_unittest.cc | 342 | ||||
-rw-r--r-- | chrome/browser/autofill/phone_field_unittest.cc | 322 |
10 files changed, 1320 insertions, 1766 deletions
diff --git a/chrome/browser/autofill/address_field_unittest.cc b/chrome/browser/autofill/address_field_unittest.cc index ab82df9..89e0ccb 100644 --- a/chrome/browser/autofill/address_field_unittest.cc +++ b/chrome/browser/autofill/address_field_unittest.cc @@ -43,14 +43,13 @@ TEST_F(AddressFieldTest, NonParse) { } TEST_F(AddressFieldTest, ParseOneLineAddress) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Address"), - ASCIIToUTF16("address"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("addr1"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Address"); + field.name = ASCIIToUTF16("address"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("addr1"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); @@ -62,14 +61,13 @@ TEST_F(AddressFieldTest, ParseOneLineAddress) { } TEST_F(AddressFieldTest, ParseOneLineAddressBilling) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Address"), - ASCIIToUTF16("billingAddress"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("addr1"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Address"); + field.name = ASCIIToUTF16("billingAddress"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("addr1"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); @@ -81,14 +79,13 @@ TEST_F(AddressFieldTest, ParseOneLineAddressBilling) { } TEST_F(AddressFieldTest, ParseOneLineAddressShipping) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Address"), - ASCIIToUTF16("shippingAddress"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("addr1"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Address"); + field.name = ASCIIToUTF16("shippingAddress"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("addr1"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); @@ -100,22 +97,17 @@ TEST_F(AddressFieldTest, ParseOneLineAddressShipping) { } TEST_F(AddressFieldTest, ParseTwoLineAddress) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Address"), - ASCIIToUTF16("address"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("addr1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(string16(), - string16(), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("addr2"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Address"); + field.name = ASCIIToUTF16("address"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("addr1"))); + + field.label = string16(); + field.name = string16(); + list_.push_back(new AutofillField(field, ASCIIToUTF16("addr2"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); @@ -130,30 +122,21 @@ TEST_F(AddressFieldTest, ParseTwoLineAddress) { } TEST_F(AddressFieldTest, ParseThreeLineAddress) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Address Line1"), - ASCIIToUTF16("Address"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("addr1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Address Line2"), - ASCIIToUTF16("Address"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("addr2"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Address Line3"), - ASCIIToUTF16("Address"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("addr3"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Address Line1"); + field.name = ASCIIToUTF16("Address1"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("addr1"))); + + field.label = ASCIIToUTF16("Address Line2"); + field.name = ASCIIToUTF16("Address2"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("addr2"))); + + field.label = ASCIIToUTF16("Address Line3"); + field.name = ASCIIToUTF16("Address3"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("addr3"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); @@ -170,14 +153,13 @@ TEST_F(AddressFieldTest, ParseThreeLineAddress) { } TEST_F(AddressFieldTest, ParseCity) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("City"), - ASCIIToUTF16("city"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("city1"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("City"); + field.name = ASCIIToUTF16("city"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("city1"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); @@ -189,14 +171,13 @@ TEST_F(AddressFieldTest, ParseCity) { } TEST_F(AddressFieldTest, ParseState) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("State"), - ASCIIToUTF16("state"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("state1"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("State"); + field.name = ASCIIToUTF16("state"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("state1"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); @@ -208,14 +189,13 @@ TEST_F(AddressFieldTest, ParseState) { } TEST_F(AddressFieldTest, ParseZip) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Zip"), - ASCIIToUTF16("zip"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("zip1"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Zip"); + field.name = ASCIIToUTF16("zip"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("zip1"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); @@ -227,26 +207,17 @@ TEST_F(AddressFieldTest, ParseZip) { } TEST_F(AddressFieldTest, ParseStateAndZipOneLabel) { - list_.push_back( - new AutofillField( - webkit_glue::FormField( - ASCIIToUTF16("State/Province, Zip/Postal Code"), - ASCIIToUTF16("state"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("state"))); - list_.push_back( - new AutofillField( - webkit_glue::FormField( - ASCIIToUTF16("State/Province, Zip/Postal Code"), - ASCIIToUTF16("zip"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("zip"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("State/Province, Zip/Postal Code"); + field.name = ASCIIToUTF16("state"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("state"))); + + field.label = ASCIIToUTF16("State/Province, Zip/Postal Code"); + field.name = ASCIIToUTF16("zip"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("zip"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); @@ -261,14 +232,13 @@ TEST_F(AddressFieldTest, ParseStateAndZipOneLabel) { } TEST_F(AddressFieldTest, ParseCountry) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Country"), - ASCIIToUTF16("country"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("country1"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Country"); + field.name = ASCIIToUTF16("country"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("country1"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); @@ -280,22 +250,17 @@ TEST_F(AddressFieldTest, ParseCountry) { } TEST_F(AddressFieldTest, ParseTwoLineAddressMissingLabel) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Address"), - ASCIIToUTF16("address"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("addr1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(string16(), - ASCIIToUTF16("bogus"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("addr2"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Address"); + field.name = ASCIIToUTF16("address"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("addr1"))); + + field.label = ASCIIToUTF16(""); + field.name = ASCIIToUTF16("bogus"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("addr2"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); @@ -310,14 +275,13 @@ TEST_F(AddressFieldTest, ParseTwoLineAddressMissingLabel) { } TEST_F(AddressFieldTest, ParseCompany) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Company"), - ASCIIToUTF16("company"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("company1"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Company"); + field.name = ASCIIToUTF16("company"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("company1"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); diff --git a/chrome/browser/autofill/autofill_common_test.cc b/chrome/browser/autofill/autofill_common_test.cc index 8ea8aef..25ae16f 100644 --- a/chrome/browser/autofill/autofill_common_test.cc +++ b/chrome/browser/autofill/autofill_common_test.cc @@ -20,9 +20,10 @@ void CreateTestFormField(const char* label, const char* value, const char* type, webkit_glue::FormField* field) { - *field = webkit_glue::FormField(ASCIIToUTF16(label), ASCIIToUTF16(name), - ASCIIToUTF16(value), ASCIIToUTF16(type), 0, - false); + field->label = ASCIIToUTF16(label); + field->name = ASCIIToUTF16(name); + field->value = ASCIIToUTF16(value); + field->form_control_type = ASCIIToUTF16(type); } inline void check_and_set( diff --git a/chrome/browser/autofill/autofill_download_unittest.cc b/chrome/browser/autofill/autofill_download_unittest.cc index 57c6328..2bbdfae 100644 --- a/chrome/browser/autofill/autofill_download_unittest.cc +++ b/chrome/browser/autofill/autofill_download_unittest.cc @@ -24,6 +24,7 @@ #include "webkit/glue/form_data.h" using webkit_glue::FormData; +using webkit_glue::FormField; using WebKit::WebInputElement; namespace { @@ -124,78 +125,69 @@ TEST_F(AutofillDownloadTest, QueryAndUploadTest) { FormData form; form.method = ASCIIToUTF16("post"); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"), - ASCIIToUTF16("username"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), - ASCIIToUTF16("firstname"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"), - ASCIIToUTF16("lastname"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("email"), - ASCIIToUTF16("email"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("email2"), - ASCIIToUTF16("email2"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"), - ASCIIToUTF16("password"), - string16(), - ASCIIToUTF16("password"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(string16(), - ASCIIToUTF16("Submit"), - string16(), - ASCIIToUTF16("submit"), - 0, - false)); + + FormField field; + field.label = ASCIIToUTF16("username"); + field.name = ASCIIToUTF16("username"); + field.form_control_type = ASCIIToUTF16("text"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("First Name"); + field.name = ASCIIToUTF16("firstname"); + field.form_control_type = ASCIIToUTF16("text"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Last Name"); + field.name = ASCIIToUTF16("lastname"); + field.form_control_type = ASCIIToUTF16("text"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("email"); + field.name = ASCIIToUTF16("email"); + field.form_control_type = ASCIIToUTF16("text"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("email2"); + field.name = ASCIIToUTF16("email2"); + field.form_control_type = ASCIIToUTF16("text"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("password"); + field.name = ASCIIToUTF16("password"); + field.form_control_type = ASCIIToUTF16("password"); + form.fields.push_back(field); + + field.label = string16(); + field.name = ASCIIToUTF16("Submit"); + field.form_control_type = ASCIIToUTF16("submit"); + form.fields.push_back(field); FormStructure *form_structure = new FormStructure(form); ScopedVector<FormStructure> form_structures; form_structures.push_back(form_structure); form.fields.clear(); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("address"), - ASCIIToUTF16("address"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("address2"), - ASCIIToUTF16("address2"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("city"), - ASCIIToUTF16("city"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(string16(), - ASCIIToUTF16("Submit"), - string16(), - ASCIIToUTF16("submit"), - 0, - false)); + + field.label = ASCIIToUTF16("address"); + field.name = ASCIIToUTF16("address"); + field.form_control_type = ASCIIToUTF16("text"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("address2"); + field.name = ASCIIToUTF16("address2"); + field.form_control_type = ASCIIToUTF16("text"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("city"); + field.name = ASCIIToUTF16("city"); + field.form_control_type = ASCIIToUTF16("text"); + form.fields.push_back(field); + + field.label = string16(); + field.name = ASCIIToUTF16("Submit"); + field.form_control_type = ASCIIToUTF16("submit"); + form.fields.push_back(field); + form_structure = new FormStructure(form); form_structures.push_back(form_structure); @@ -300,12 +292,10 @@ TEST_F(AutofillDownloadTest, QueryAndUploadTest) { EXPECT_EQ(NULL, fetcher); // Modify form structures to miss the cache. - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address line 2"), - ASCIIToUTF16("address2"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + field.label = ASCIIToUTF16("Address line 2"); + field.name = ASCIIToUTF16("address2"); + field.form_control_type = ASCIIToUTF16("text"); + form.fields.push_back(field); form_structure = new FormStructure(form); form_structures.push_back(form_structure); @@ -373,46 +363,39 @@ TEST_F(AutofillDownloadTest, CacheQueryTest) { FormData form; form.method = ASCIIToUTF16("post"); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"), - ASCIIToUTF16("username"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), - ASCIIToUTF16("firstname"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"), - ASCIIToUTF16("lastname"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("username"); + field.name = ASCIIToUTF16("username"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("First Name"); + field.name = ASCIIToUTF16("firstname"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Last Name"); + field.name = ASCIIToUTF16("lastname"); + form.fields.push_back(field); + FormStructure *form_structure = new FormStructure(form); ScopedVector<FormStructure> form_structures0; form_structures0.push_back(form_structure); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("email"), - ASCIIToUTF16("email"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - // Slightly different form - so different request. + // Add a slightly different form, which should result in a different request. + field.label = ASCIIToUTF16("email"); + field.name = ASCIIToUTF16("email"); + form.fields.push_back(field); form_structure = new FormStructure(form); ScopedVector<FormStructure> form_structures1; form_structures1.push_back(form_structure); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("email2"), - ASCIIToUTF16("email2"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - // Slightly different form - so different request. + // Add another slightly different form, which should also result in a + // different request. + field.label = ASCIIToUTF16("email2"); + field.name = ASCIIToUTF16("email2"); + form.fields.push_back(field); form_structure = new FormStructure(form); ScopedVector<FormStructure> form_structures2; form_structures2.push_back(form_structure); diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc index 2a2c329..2796187 100644 --- a/chrome/browser/autofill/autofill_manager_unittest.cc +++ b/chrome/browser/autofill/autofill_manager_unittest.cc @@ -257,6 +257,18 @@ void ExpectSuggestions(int page_id, } } +void ExpectFilledField(const char* expected_label, + const char* expected_name, + const char* expected_value, + const char* expected_form_control_type, + const webkit_glue::FormField& field) { + SCOPED_TRACE(expected_label); + EXPECT_EQ(UTF8ToUTF16(expected_label), field.label); + EXPECT_EQ(UTF8ToUTF16(expected_name), field.name); + EXPECT_EQ(UTF8ToUTF16(expected_value), field.value); + EXPECT_EQ(UTF8ToUTF16(expected_form_control_type), field.form_control_type); +} + // Verifies that the |filled_form| has been filled with the given data. // Verifies address fields if |has_address_fields| is true, and verifies // credit card fields if |has_credit_card_fields| is true. Verifies both if both @@ -308,68 +320,52 @@ void ExpectFilledForm(int page_id, FormField field; if (has_address_fields) { - autofill_test::CreateTestFormField( - "First Name", "firstname", first, "text", &field); - EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[0])); - autofill_test::CreateTestFormField( - "Middle Name", "middlename", middle, "text", &field); - EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[1])); - autofill_test::CreateTestFormField( - "Last Name", "lastname", last, "text", &field); - EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[2])); - autofill_test::CreateTestFormField( - "Address Line 1", "addr1", address1, "text", &field); - EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[3])); - autofill_test::CreateTestFormField( - "Address Line 2", "addr2", address2, "text", &field); - EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[4])); - autofill_test::CreateTestFormField( - "City", "city", city, "text", &field); - EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[5])); - autofill_test::CreateTestFormField( - "State", "state", state, "text", &field); - EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[6])); - autofill_test::CreateTestFormField( - "Postal Code", "zipcode", postal_code, "text", &field); - EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[7])); - autofill_test::CreateTestFormField( - "Country", "country", country, "text", &field); - EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[8])); - autofill_test::CreateTestFormField( - "Phone Number", "phonenumber", phone, "tel", &field); - EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[9])); - autofill_test::CreateTestFormField( - "Fax", "fax", fax, "text", &field); - EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[10])); - autofill_test::CreateTestFormField( - "Email", "email", email, "email", &field); - EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[11])); + ExpectFilledField("First Name", "firstname", first, "text", + filled_form.fields[0]); + ExpectFilledField("Middle Name", "middlename", middle, "text", + filled_form.fields[1]); + ExpectFilledField("Last Name", "lastname", last, "text", + filled_form.fields[2]); + ExpectFilledField("Address Line 1", "addr1", address1, "text", + filled_form.fields[3]); + ExpectFilledField("Address Line 2", "addr2", address2, "text", + filled_form.fields[4]); + ExpectFilledField("City", "city", city, "text", + filled_form.fields[5]); + ExpectFilledField("State", "state", state, "text", + filled_form.fields[6]); + ExpectFilledField("Postal Code", "zipcode", postal_code, "text", + filled_form.fields[7]); + ExpectFilledField("Country", "country", country, "text", + filled_form.fields[8]); + ExpectFilledField("Phone Number", "phonenumber", phone, "tel", + filled_form.fields[9]); + ExpectFilledField("Fax", "fax", fax, "text", + filled_form.fields[10]); + ExpectFilledField("Email", "email", email, "email", + filled_form.fields[11]); } if (has_credit_card_fields) { size_t offset = has_address_fields? kAddressFormSize : 0; - autofill_test::CreateTestFormField( - "Name on Card", "nameoncard", name_on_card, "text", &field); - EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 0])); - autofill_test::CreateTestFormField( - "Card Number", "cardnumber", card_number, "text", &field); - EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 1])); + ExpectFilledField("Name on Card", "nameoncard", name_on_card, "text", + filled_form.fields[offset + 0]); + ExpectFilledField("Card Number", "cardnumber", card_number, "text", + filled_form.fields[offset + 1]); if (use_month_type) { std::string exp_year = expiration_year; std::string exp_month = expiration_month; std::string date; if (!exp_year.empty() && !exp_month.empty()) date = exp_year + "-" + exp_month; - autofill_test::CreateTestFormField( - "Expiration Date", "ccmonth", date.c_str(), "month", &field); - EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 2])); + + ExpectFilledField("Expiration Date", "ccmonth", date.c_str(), "month", + filled_form.fields[offset + 2]); } else { - autofill_test::CreateTestFormField( - "Expiration Date", "ccmonth", expiration_month, "text", &field); - EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 2])); - autofill_test::CreateTestFormField( - "", "ccyear", expiration_year, "text", &field); - EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 3])); + ExpectFilledField("Expiration Date", "ccmonth", expiration_month, "text", + filled_form.fields[offset + 2]); + ExpectFilledField("", "ccyear", expiration_year, "text", + filled_form.fields[offset + 3]); } } } diff --git a/chrome/browser/autofill/autofill_merge_unittest.cc b/chrome/browser/autofill/autofill_merge_unittest.cc index 9b8071c..325cd92 100644 --- a/chrome/browser/autofill/autofill_merge_unittest.cc +++ b/chrome/browser/autofill/autofill_merge_unittest.cc @@ -179,12 +179,11 @@ void AutofillMergeTest::MergeProfiles(const std::string& profiles, string16 field_type = UTF8ToUTF16(line.substr(0, separator_pos)); string16 value = UTF8ToUTF16(line.substr(separator_pos + kFieldOffset)); - webkit_glue::FormField field(field_type, - field_type, - value, - ASCIIToUTF16("text"), - WebKit::WebInputElement::defaultMaxLength(), - false); + webkit_glue::FormField field; + field.label = field_type; + field.name = field_type; + field.value = value; + field.form_control_type = ASCIIToUTF16("text"); form.fields.push_back(field); } diff --git a/chrome/browser/autofill/autofill_metrics_unittest.cc b/chrome/browser/autofill/autofill_metrics_unittest.cc index f0c4a33..95eb844 100644 --- a/chrome/browser/autofill/autofill_metrics_unittest.cc +++ b/chrome/browser/autofill/autofill_metrics_unittest.cc @@ -271,24 +271,28 @@ TEST_F(AutofillMetricsTest, QualityMetrics) { autofill_test::CreateTestFormField( "Autofill Failed", "autofillfailed", "buddy@gmail.com", "text", &field); + field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(PHONE_HOME_NUMBER); server_types.push_back(EMAIL_ADDRESS); autofill_test::CreateTestFormField( "Empty", "empty", "", "text", &field); + field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(NAME_FULL); server_types.push_back(NAME_FIRST); autofill_test::CreateTestFormField( "Unknown", "unknown", "garbage", "text", &field); + field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(PHONE_HOME_NUMBER); server_types.push_back(EMAIL_ADDRESS); autofill_test::CreateTestFormField( "Select", "select", "USA", "select-one", &field); + field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(UNKNOWN_TYPE); server_types.push_back(NO_SERVER_DATA); @@ -529,16 +533,19 @@ TEST_F(AutofillMetricsTest, SaneMetricsWithCacheMismatch) { server_types.push_back(NAME_FULL); autofill_test::CreateTestFormField( "Both mismatch", "mismatch", "buddy@gmail.com", "text", &field); + field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(PHONE_HOME_NUMBER); server_types.push_back(PHONE_HOME_NUMBER); autofill_test::CreateTestFormField( "Only heuristics match", "mixed", "Memphis", "text", &field); + field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(ADDRESS_HOME_CITY); server_types.push_back(PHONE_HOME_NUMBER); autofill_test::CreateTestFormField( "Unknown", "unknown", "garbage", "text", &field); + field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(UNKNOWN_TYPE); server_types.push_back(UNKNOWN_TYPE); @@ -721,24 +728,28 @@ TEST_F(AutofillMetricsTest, QualityMetricsWithExperimentId) { autofill_test::CreateTestFormField( "Autofill Failed", "autofillfailed", "buddy@gmail.com", "text", &field); + field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(PHONE_HOME_NUMBER); server_types.push_back(EMAIL_ADDRESS); autofill_test::CreateTestFormField( "Empty", "empty", "", "text", &field); + field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(NAME_FULL); server_types.push_back(NAME_FIRST); autofill_test::CreateTestFormField( "Unknown", "unknown", "garbage", "text", &field); + field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(PHONE_HOME_NUMBER); server_types.push_back(EMAIL_ADDRESS); autofill_test::CreateTestFormField( "Select", "select", "USA", "select-one", &field); + field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(UNKNOWN_TYPE); server_types.push_back(NO_SERVER_DATA); diff --git a/chrome/browser/autofill/credit_card_field_unittest.cc b/chrome/browser/autofill/credit_card_field_unittest.cc index f480783..28e8c9c 100644 --- a/chrome/browser/autofill/credit_card_field_unittest.cc +++ b/chrome/browser/autofill/credit_card_field_unittest.cc @@ -43,66 +43,51 @@ TEST_F(CreditCardFieldTest, NonParse) { } TEST_F(CreditCardFieldTest, ParseCreditCardNoNumber) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Exp Month"), - ASCIIToUTF16("ccmonth"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("month1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Exp Year"), - ASCIIToUTF16("ccyear"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("year1"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Exp Month"); + field.name = ASCIIToUTF16("ccmonth"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("month1"))); + + field.label = ASCIIToUTF16("Exp Year"); + field.name = ASCIIToUTF16("ccyear"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("year2"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_EQ(static_cast<CreditCardField*>(NULL), field_.get()); } TEST_F(CreditCardFieldTest, ParseCreditCardNoDate) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Card Number"), - ASCIIToUTF16("card_number"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("number1"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Card Number"); + field.name = ASCIIToUTF16("card_number"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("number1"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_EQ(static_cast<CreditCardField*>(NULL), field_.get()); } TEST_F(CreditCardFieldTest, ParseMiniumCreditCard) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Card Number"), - ASCIIToUTF16("card_number"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("number1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Exp Month"), - ASCIIToUTF16("ccmonth"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("month1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Exp Year"), - ASCIIToUTF16("ccyear"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("year1"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Card Number"); + field.name = ASCIIToUTF16("card_number"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("number1"))); + + field.label = ASCIIToUTF16("Exp Month"); + field.name = ASCIIToUTF16("ccmonth"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("month2"))); + + field.label = ASCIIToUTF16("Exp Year"); + field.name = ASCIIToUTF16("ccyear"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("year3"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<CreditCardField*>(NULL), field_.get()); @@ -111,55 +96,38 @@ TEST_F(CreditCardFieldTest, ParseMiniumCreditCard) { field_type_map_.find(ASCIIToUTF16("number1")) != field_type_map_.end()); EXPECT_EQ(CREDIT_CARD_NUMBER, field_type_map_[ASCIIToUTF16("number1")]); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("month1")) != field_type_map_.end()); - EXPECT_EQ(CREDIT_CARD_EXP_MONTH, field_type_map_[ASCIIToUTF16("month1")]); + field_type_map_.find(ASCIIToUTF16("month2")) != field_type_map_.end()); + EXPECT_EQ(CREDIT_CARD_EXP_MONTH, field_type_map_[ASCIIToUTF16("month2")]); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("year1")) != field_type_map_.end()); + field_type_map_.find(ASCIIToUTF16("year3")) != field_type_map_.end()); EXPECT_EQ(CREDIT_CARD_EXP_4_DIGIT_YEAR, - field_type_map_[ASCIIToUTF16("year1")]); + field_type_map_[ASCIIToUTF16("year3")]); } TEST_F(CreditCardFieldTest, ParseFullCreditCard) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Name on Card"), - ASCIIToUTF16("name on card"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Card Number"), - ASCIIToUTF16("card_number"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("number1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Exp Month"), - ASCIIToUTF16("ccmonth"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("month1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Exp Year"), - ASCIIToUTF16("ccyear"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("year1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Verification"), - ASCIIToUTF16("verification"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("cvc1"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Name on Card"); + field.name = ASCIIToUTF16("name_on_card"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name1"))); + + field.label = ASCIIToUTF16("Card Number"); + field.name = ASCIIToUTF16("card_number"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("number2"))); + + field.label = ASCIIToUTF16("Exp Month"); + field.name = ASCIIToUTF16("ccmonth"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("month3"))); + + field.label = ASCIIToUTF16("Exp Year"); + field.name = ASCIIToUTF16("ccyear"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("year4"))); + + field.label = ASCIIToUTF16("Verification"); + field.name = ASCIIToUTF16("verification"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("cvc5"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<CreditCardField*>(NULL), field_.get()); @@ -168,137 +136,106 @@ TEST_F(CreditCardFieldTest, ParseFullCreditCard) { field_type_map_.find(ASCIIToUTF16("name1")) != field_type_map_.end()); EXPECT_EQ(CREDIT_CARD_NAME, field_type_map_[ASCIIToUTF16("name1")]); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("number1")) != field_type_map_.end()); - EXPECT_EQ(CREDIT_CARD_NUMBER, field_type_map_[ASCIIToUTF16("number1")]); + field_type_map_.find(ASCIIToUTF16("number2")) != field_type_map_.end()); + EXPECT_EQ(CREDIT_CARD_NUMBER, field_type_map_[ASCIIToUTF16("number2")]); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("month1")) != field_type_map_.end()); - EXPECT_EQ(CREDIT_CARD_EXP_MONTH, field_type_map_[ASCIIToUTF16("month1")]); + field_type_map_.find(ASCIIToUTF16("month3")) != field_type_map_.end()); + EXPECT_EQ(CREDIT_CARD_EXP_MONTH, field_type_map_[ASCIIToUTF16("month3")]); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("year1")) != field_type_map_.end()); + field_type_map_.find(ASCIIToUTF16("year4")) != field_type_map_.end()); EXPECT_EQ(CREDIT_CARD_EXP_4_DIGIT_YEAR, - field_type_map_[ASCIIToUTF16("year1")]); + field_type_map_[ASCIIToUTF16("year4")]); // We don't store CVV. EXPECT_TRUE( - field_type_map_.find(ASCIIToUTF16("cvc1")) == field_type_map_.end()); + field_type_map_.find(ASCIIToUTF16("cvc5")) == field_type_map_.end()); } TEST_F(CreditCardFieldTest, ParseExpMonthYear) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Name on Card"), - ASCIIToUTF16("Name"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Card Number"), - ASCIIToUTF16("Card"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("number"))); - list_.push_back( - new AutofillField( - webkit_glue::FormField(ASCIIToUTF16("ExpDate Month / Year"), - ASCIIToUTF16("ExpDate"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("month"))); - list_.push_back( - new AutofillField( - webkit_glue::FormField(ASCIIToUTF16("ExpDate Month / Year"), - ASCIIToUTF16("ExpDate"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("year"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Name on Card"); + field.name = ASCIIToUTF16("name_on_card"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name1"))); + + field.label = ASCIIToUTF16("Card Number"); + field.name = ASCIIToUTF16("card_number"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("number2"))); + + field.label = ASCIIToUTF16("ExpDate Month / Year"); + field.name = ASCIIToUTF16("ExpDate"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("month3"))); + + field.label = ASCIIToUTF16("ExpDate Month / Year"); + field.name = ASCIIToUTF16("ExpDate"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("year4"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<CreditCardField*>(NULL), field_.get()); ASSERT_TRUE(field_->ClassifyField(&field_type_map_)); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("name")) != field_type_map_.end()); - EXPECT_EQ(CREDIT_CARD_NAME, field_type_map_[ASCIIToUTF16("name")]); + field_type_map_.find(ASCIIToUTF16("name1")) != field_type_map_.end()); + EXPECT_EQ(CREDIT_CARD_NAME, field_type_map_[ASCIIToUTF16("name1")]); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("number")) != field_type_map_.end()); - EXPECT_EQ(CREDIT_CARD_NUMBER, field_type_map_[ASCIIToUTF16("number")]); + field_type_map_.find(ASCIIToUTF16("number2")) != field_type_map_.end()); + EXPECT_EQ(CREDIT_CARD_NUMBER, field_type_map_[ASCIIToUTF16("number2")]); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("month")) != field_type_map_.end()); - EXPECT_EQ(CREDIT_CARD_EXP_MONTH, field_type_map_[ASCIIToUTF16("month")]); + field_type_map_.find(ASCIIToUTF16("month3")) != field_type_map_.end()); + EXPECT_EQ(CREDIT_CARD_EXP_MONTH, field_type_map_[ASCIIToUTF16("month3")]); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("year")) != field_type_map_.end()); + field_type_map_.find(ASCIIToUTF16("year4")) != field_type_map_.end()); EXPECT_EQ(CREDIT_CARD_EXP_4_DIGIT_YEAR, - field_type_map_[ASCIIToUTF16("year")]); + field_type_map_[ASCIIToUTF16("year4")]); } TEST_F(CreditCardFieldTest, ParseExpMonthYear2) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Name on Card"), - ASCIIToUTF16("Name"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Card Number"), - ASCIIToUTF16("Card"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("number"))); - list_.push_back( - new AutofillField( - webkit_glue::FormField(ASCIIToUTF16("Expiration date Month / Year"), - ASCIIToUTF16("ExpDate"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("month"))); - list_.push_back( - new AutofillField( - webkit_glue::FormField(ASCIIToUTF16("Expiration date Month / Year"), - ASCIIToUTF16("ExpDate"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("year"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Name on Card"); + field.name = ASCIIToUTF16("name_on_card"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name1"))); + + field.label = ASCIIToUTF16("Card Number"); + field.name = ASCIIToUTF16("card_number"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("number2"))); + + field.label = ASCIIToUTF16("Expiration date Month / Year"); + field.name = ASCIIToUTF16("ExpDate"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("month3"))); + + field.label = ASCIIToUTF16("Expiration date Month / Year"); + field.name = ASCIIToUTF16("ExpDate"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("year4"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<CreditCardField*>(NULL), field_.get()); ASSERT_TRUE(field_->ClassifyField(&field_type_map_)); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("name")) != field_type_map_.end()); - EXPECT_EQ(CREDIT_CARD_NAME, field_type_map_[ASCIIToUTF16("name")]); + field_type_map_.find(ASCIIToUTF16("name1")) != field_type_map_.end()); + EXPECT_EQ(CREDIT_CARD_NAME, field_type_map_[ASCIIToUTF16("name1")]); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("number")) != field_type_map_.end()); - EXPECT_EQ(CREDIT_CARD_NUMBER, field_type_map_[ASCIIToUTF16("number")]); + field_type_map_.find(ASCIIToUTF16("number2")) != field_type_map_.end()); + EXPECT_EQ(CREDIT_CARD_NUMBER, field_type_map_[ASCIIToUTF16("number2")]); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("month")) != field_type_map_.end()); - EXPECT_EQ(CREDIT_CARD_EXP_MONTH, field_type_map_[ASCIIToUTF16("month")]); + field_type_map_.find(ASCIIToUTF16("month3")) != field_type_map_.end()); + EXPECT_EQ(CREDIT_CARD_EXP_MONTH, field_type_map_[ASCIIToUTF16("month3")]); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("year")) != field_type_map_.end()); + field_type_map_.find(ASCIIToUTF16("year4")) != field_type_map_.end()); EXPECT_EQ(CREDIT_CARD_EXP_4_DIGIT_YEAR, - field_type_map_[ASCIIToUTF16("year")]); + field_type_map_[ASCIIToUTF16("year4")]); } TEST_F(CreditCardFieldTest, ParseCreditCardHolderNameWithCCFullName) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Name"), - ASCIIToUTF16("ccfullname"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name1"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Name"); + field.name = ASCIIToUTF16("ccfullname"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name1"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<CreditCardField*>(NULL), field_.get()); diff --git a/chrome/browser/autofill/form_structure_unittest.cc b/chrome/browser/autofill/form_structure_unittest.cc index 0936300..4bfeb77 100644 --- a/chrome/browser/autofill/form_structure_unittest.cc +++ b/chrome/browser/autofill/form_structure_unittest.cc @@ -13,6 +13,7 @@ #include "webkit/glue/form_field.h" using webkit_glue::FormData; +using webkit_glue::FormField; using WebKit::WebInputElement; namespace webkit_glue { @@ -51,24 +52,23 @@ namespace { TEST(FormStructureTest, FieldCount) { FormData form; form.method = ASCIIToUTF16("post"); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"), - ASCIIToUTF16("username"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"), - ASCIIToUTF16("password"), - string16(), - ASCIIToUTF16("password"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(string16(), - ASCIIToUTF16("Submit"), - string16(), - ASCIIToUTF16("submit"), - 0, - false)); + + FormField field; + field.label = ASCIIToUTF16("username"); + field.name = ASCIIToUTF16("username"); + field.form_control_type = ASCIIToUTF16("text"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("password"); + field.name = ASCIIToUTF16("password"); + field.form_control_type = ASCIIToUTF16("password"); + form.fields.push_back(field); + + field.label = string16(); + field.name = ASCIIToUTF16("Submit"); + field.form_control_type = ASCIIToUTF16("submit"); + form.fields.push_back(field); + FormStructure form_structure(form); // All fields are counted. @@ -78,30 +78,28 @@ TEST(FormStructureTest, FieldCount) { TEST(FormStructureTest, AutofillCount) { FormData form; form.method = ASCIIToUTF16("post"); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"), - ASCIIToUTF16("username"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"), - ASCIIToUTF16("password"), - string16(), - ASCIIToUTF16("password"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("state"), - ASCIIToUTF16("state"), - string16(), - ASCIIToUTF16("select-one"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(string16(), - ASCIIToUTF16("Submit"), - string16(), - ASCIIToUTF16("submit"), - 0, - false)); + + FormField field; + field.label = ASCIIToUTF16("username"); + field.name = ASCIIToUTF16("username"); + field.form_control_type = ASCIIToUTF16("text"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("password"); + field.name = ASCIIToUTF16("password"); + field.form_control_type = ASCIIToUTF16("password"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("state"); + field.name = ASCIIToUTF16("state"); + field.form_control_type = ASCIIToUTF16("select-one"); + form.fields.push_back(field); + + field.label = string16(); + field.name = ASCIIToUTF16("Submit"); + field.form_control_type = ASCIIToUTF16("submit"); + form.fields.push_back(field); + FormStructure form_structure(form); form_structure.DetermineHeuristicTypes(); @@ -124,52 +122,48 @@ TEST(FormStructureTest, IsAutofillable) { // We need at least three text fields to be auto-fillable. form.method = ASCIIToUTF16("post"); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"), - ASCIIToUTF16("username"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"), - ASCIIToUTF16("password"), - string16(), - ASCIIToUTF16("password"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(string16(), - ASCIIToUTF16("Submit"), - string16(), - ASCIIToUTF16("submit"), - 0, - false)); + + FormField field; + field.label = ASCIIToUTF16("username"); + field.name = ASCIIToUTF16("username"); + field.form_control_type = ASCIIToUTF16("text"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("password"); + field.name = ASCIIToUTF16("password"); + field.form_control_type = ASCIIToUTF16("password"); + form.fields.push_back(field); + + field.label = string16(); + field.name = ASCIIToUTF16("Submit"); + field.form_control_type = ASCIIToUTF16("submit"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); form_structure->DetermineHeuristicTypes(); EXPECT_FALSE(form_structure->IsAutofillable(true)); // We now have three text fields, but only two auto-fillable fields. - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), - ASCIIToUTF16("firstname"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"), - ASCIIToUTF16("lastname"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + field.label = ASCIIToUTF16("First Name"); + field.name = ASCIIToUTF16("firstname"); + field.form_control_type = ASCIIToUTF16("text"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Last Name"); + field.name = ASCIIToUTF16("lastname"); + field.form_control_type = ASCIIToUTF16("text"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); form_structure->DetermineHeuristicTypes(); EXPECT_FALSE(form_structure->IsAutofillable(true)); // We now have three auto-fillable fields. - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Email"), - ASCIIToUTF16("email"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + field.label = ASCIIToUTF16("Email"); + field.name = ASCIIToUTF16("email"); + field.form_control_type = ASCIIToUTF16("email"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); form_structure->DetermineHeuristicTypes(); EXPECT_TRUE(form_structure->IsAutofillable(true)); @@ -202,28 +196,27 @@ TEST(FormStructureTest, ShouldBeParsed) { // We need at least three text fields to be parseable. form.method = ASCIIToUTF16("post"); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"), - ASCIIToUTF16("username"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + FormField field; + field.label = ASCIIToUTF16("username"); + field.name = ASCIIToUTF16("username"); + field.form_control_type = ASCIIToUTF16("text"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); EXPECT_FALSE(form_structure->ShouldBeParsed(true)); // We now have three text fields, though only two are auto-fillable. - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), - ASCIIToUTF16("firstname"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"), - ASCIIToUTF16("lastname"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + field.label = ASCIIToUTF16("First Name"); + field.name = ASCIIToUTF16("firstname"); + field.form_control_type = ASCIIToUTF16("text"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Last Name"); + field.name = ASCIIToUTF16("lastname"); + field.form_control_type = ASCIIToUTF16("text"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); EXPECT_TRUE(form_structure->ShouldBeParsed(true)); @@ -248,24 +241,22 @@ TEST(FormStructureTest, ShouldBeParsed) { // The form need only have three fields, but at least one must be a text // field. form.fields.clear(); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Email"), - ASCIIToUTF16("email"), - string16(), - ASCIIToUTF16("email"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("State"), - ASCIIToUTF16("state"), - string16(), - ASCIIToUTF16("select-one"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Country"), - ASCIIToUTF16("country"), - string16(), - ASCIIToUTF16("select-one"), - 0, - false)); + + field.label = ASCIIToUTF16("Email"); + field.name = ASCIIToUTF16("email"); + field.form_control_type = ASCIIToUTF16("email"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("State"); + field.name = ASCIIToUTF16("state"); + field.form_control_type = ASCIIToUTF16("select-one"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Country"); + field.name = ASCIIToUTF16("country"); + field.form_control_type = ASCIIToUTF16("select-one"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); EXPECT_TRUE(form_structure->ShouldBeParsed(true)); @@ -277,62 +268,48 @@ TEST(FormStructureTest, ShouldBeParsed) { TEST(FormStructureTest, HeuristicsContactInfo) { scoped_ptr<FormStructure> form_structure; FormData form; - form.method = ASCIIToUTF16("post"); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), - ASCIIToUTF16("firstname"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"), - ASCIIToUTF16("lastname"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"), - ASCIIToUTF16("email"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"), - ASCIIToUTF16("phone"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"), - ASCIIToUTF16("fax"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"), - ASCIIToUTF16("address"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("City"), - ASCIIToUTF16("city"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Zip code"), - ASCIIToUTF16("zipcode"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(string16(), - ASCIIToUTF16("Submit"), - string16(), - ASCIIToUTF16("submit"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("First Name"); + field.name = ASCIIToUTF16("firstname"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Last Name"); + field.name = ASCIIToUTF16("lastname"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Email"); + field.name = ASCIIToUTF16("email"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Phone"); + field.name = ASCIIToUTF16("phone"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Fax"); + field.name = ASCIIToUTF16("fax"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Address"); + field.name = ASCIIToUTF16("address"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("City"); + field.name = ASCIIToUTF16("city"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Zip code"); + field.name = ASCIIToUTF16("zipcode"); + form.fields.push_back(field); + + field.label = string16(); + field.name = ASCIIToUTF16("Submit"); + field.form_control_type = ASCIIToUTF16("submit"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); form_structure->DetermineHeuristicTypes(); EXPECT_TRUE(form_structure->IsAutofillable(true)); @@ -365,78 +342,52 @@ TEST(FormStructureTest, HeuristicsContactInfo) { TEST(FormStructureTest, HeuristicsSample8) { scoped_ptr<FormStructure> form_structure; FormData form; - form.method = ASCIIToUTF16("post"); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Your First Name:"), - ASCIIToUTF16("bill.first"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Your Last Name:"), - ASCIIToUTF16("bill.last"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Street Address Line 1:"), - ASCIIToUTF16("bill.street1"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Street Address Line 2:"), - ASCIIToUTF16("bill.street2"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("City:"), - ASCIIToUTF16("bill.city"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("State (U.S.):"), - ASCIIToUTF16("bill.state"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Zip/Postal Code:"), - ASCIIToUTF16("BillTo.PostalCode"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Country:"), - ASCIIToUTF16("bill.country"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Phone Number:"), - ASCIIToUTF16("BillTo.Phone"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(string16(), - ASCIIToUTF16("Submit"), - string16(), - ASCIIToUTF16("submit"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Your First Name:"); + field.name = ASCIIToUTF16("bill.first"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Your Last Name:"); + field.name = ASCIIToUTF16("bill.last"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Street Address Line 1:"); + field.name = ASCIIToUTF16("bill.street1"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Street Address Line 2:"); + field.name = ASCIIToUTF16("bill.street2"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("City"); + field.name = ASCIIToUTF16("bill.city"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("State (U.S.):"); + field.name = ASCIIToUTF16("bill.state"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Zip/Postal Code:"); + field.name = ASCIIToUTF16("BillTo.PostalCode"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Country:"); + field.name = ASCIIToUTF16("bill.country"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Phone Number:"); + field.name = ASCIIToUTF16("BillTo.Phone"); + form.fields.push_back(field); + + field.label = string16(); + field.name = ASCIIToUTF16("Submit"); + field.form_control_type = ASCIIToUTF16("submit"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); form_structure->DetermineHeuristicTypes(); EXPECT_TRUE(form_structure->IsAutofillable(true)); @@ -470,59 +421,41 @@ TEST(FormStructureTest, HeuristicsSample8) { TEST(FormStructureTest, HeuristicsSample6) { scoped_ptr<FormStructure> form_structure; FormData form; - form.method = ASCIIToUTF16("post"); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("E-mail address"), - ASCIIToUTF16("email"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Full name"), - ASCIIToUTF16("name"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Company"), - ASCIIToUTF16("company"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Address"), - ASCIIToUTF16("address"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("City"), - ASCIIToUTF16("city"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - // TODO(jhawkins): Add state select control. - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Zip Code"), - ASCIIToUTF16("Home.PostalCode"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - // TODO(jhawkins): Phone number. - form.fields.push_back( - webkit_glue::FormField(string16(), - ASCIIToUTF16("Submit"), - ASCIIToUTF16("continue"), - ASCIIToUTF16("submit"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("E-mail address"); + field.name = ASCIIToUTF16("email"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Full name"); + field.name = ASCIIToUTF16("name"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Company"); + field.name = ASCIIToUTF16("company"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Address"); + field.name = ASCIIToUTF16("address"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("City"); + field.name = ASCIIToUTF16("city"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Zip Code"); + field.name = ASCIIToUTF16("Home.PostalCode"); + form.fields.push_back(field); + + field.label = string16(); + field.name = ASCIIToUTF16("Submit"); + field.value = ASCIIToUTF16("continue"); + field.form_control_type = ASCIIToUTF16("submit"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); form_structure->DetermineHeuristicTypes(); EXPECT_TRUE(form_structure->IsAutofillable(true)); @@ -551,62 +484,48 @@ TEST(FormStructureTest, HeuristicsSample6) { TEST(FormStructureTest, HeuristicsLabelsOnly) { scoped_ptr<FormStructure> form_structure; FormData form; - form.method = ASCIIToUTF16("post"); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), - string16(), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"), - string16(), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"), - string16(), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"), - string16(), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"), - string16(), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"), - string16(), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"), - string16(), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Zip code"), - string16(), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(string16(), - ASCIIToUTF16("Submit"), - string16(), - ASCIIToUTF16("submit"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("First Name"); + field.name = string16(); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Last Name"); + field.name = string16(); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Email"); + field.name = string16(); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Phone"); + field.name = string16(); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Fax"); + field.name = string16(); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Address"); + field.name = string16(); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Address"); + field.name = string16(); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Zip code"); + field.name = string16(); + form.fields.push_back(field); + + field.label = string16(); + field.name = ASCIIToUTF16("Submit"); + field.form_control_type = ASCIIToUTF16("submit"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); form_structure->DetermineHeuristicTypes(); EXPECT_TRUE(form_structure->IsAutofillable(true)); @@ -637,44 +556,36 @@ TEST(FormStructureTest, HeuristicsLabelsOnly) { TEST(FormStructureTest, HeuristicsCreditCardInfo) { scoped_ptr<FormStructure> form_structure; FormData form; - form.method = ASCIIToUTF16("post"); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Name on Card"), - ASCIIToUTF16("name on card"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Card Number"), - ASCIIToUTF16("card_number"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Month"), - ASCIIToUTF16("ccmonth"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Year"), - ASCIIToUTF16("ccyear"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Verification"), - ASCIIToUTF16("verification"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(string16(), - ASCIIToUTF16("Submit"), - string16(), - ASCIIToUTF16("submit"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Name on Card"); + field.name = ASCIIToUTF16("name_on_card"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Card Number"); + field.name = ASCIIToUTF16("card_number"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Exp Month"); + field.name = ASCIIToUTF16("ccmonth"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Exp Year"); + field.name = ASCIIToUTF16("ccyear"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Verification"); + field.name = ASCIIToUTF16("verification"); + form.fields.push_back(field); + + field.label = string16(); + field.name = ASCIIToUTF16("Submit"); + field.form_control_type = ASCIIToUTF16("submit"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); form_structure->DetermineHeuristicTypes(); EXPECT_TRUE(form_structure->IsAutofillable(true)); @@ -699,52 +610,42 @@ TEST(FormStructureTest, HeuristicsCreditCardInfo) { TEST(FormStructureTest, HeuristicsCreditCardInfoWithUnknownCardField) { scoped_ptr<FormStructure> form_structure; FormData form; - form.method = ASCIIToUTF16("post"); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Name on Card"), - ASCIIToUTF16("name on card"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Name on Card"); + field.name = ASCIIToUTF16("name_on_card"); + form.fields.push_back(field); + // This is not a field we know how to process. But we should skip over it // and process the other fields in the card block. - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Card Type"), - ASCIIToUTF16("card_type"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Card Number"), - ASCIIToUTF16("card_number"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Month"), - ASCIIToUTF16("ccmonth"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Year"), - ASCIIToUTF16("ccyear"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Verification"), - ASCIIToUTF16("verification"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(string16(), - ASCIIToUTF16("Submit"), - string16(), - ASCIIToUTF16("submit"), - 0, - false)); + field.label = ASCIIToUTF16("Card Type"); + field.name = ASCIIToUTF16("card_type"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Card Number"); + field.name = ASCIIToUTF16("card_number"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Exp Month"); + field.name = ASCIIToUTF16("ccmonth"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Exp Year"); + field.name = ASCIIToUTF16("ccyear"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Verification"); + field.name = ASCIIToUTF16("verification"); + form.fields.push_back(field); + + field.label = string16(); + field.name = ASCIIToUTF16("Submit"); + field.form_control_type = ASCIIToUTF16("submit"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); form_structure->DetermineHeuristicTypes(); EXPECT_TRUE(form_structure->IsAutofillable(true)); @@ -771,36 +672,27 @@ TEST(FormStructureTest, HeuristicsCreditCardInfoWithUnknownCardField) { TEST(FormStructureTest, ThreeAddressLines) { scoped_ptr<FormStructure> form_structure; FormData form; - form.method = ASCIIToUTF16("post"); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Address Line1"), - ASCIIToUTF16("Address"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Address Line2"), - ASCIIToUTF16("Address"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Address Line3"), - ASCIIToUTF16("Address"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("City"), - ASCIIToUTF16("city"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Address Line1"); + field.name = ASCIIToUTF16("Address"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Address Line2"); + field.name = ASCIIToUTF16("Address"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Address Line3"); + field.name = ASCIIToUTF16("Address"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("City"); + field.name = ASCIIToUTF16("city"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); form_structure->DetermineHeuristicTypes(); EXPECT_TRUE(form_structure->IsAutofillable(true)); @@ -822,36 +714,27 @@ TEST(FormStructureTest, ThreeAddressLines) { TEST(FormStructureTest, BillingAndShippingAddresses) { scoped_ptr<FormStructure> form_structure; FormData form; - form.method = ASCIIToUTF16("post"); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Address Line1"), - ASCIIToUTF16("shipping.address.addressLine1"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Address Line2"), - ASCIIToUTF16("shipping.address.addressLine2"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Address Line1"), - ASCIIToUTF16("billing.address.addressLine1"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Address Line2"), - ASCIIToUTF16("billing.address.addressLine2"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Address Line1"); + field.name = ASCIIToUTF16("shipping.address.addressLine1"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Address Line2"); + field.name = ASCIIToUTF16("shipping.address.addressLine2"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Address Line1"); + field.name = ASCIIToUTF16("billing.address.addressLine1"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Address Line2"); + field.name = ASCIIToUTF16("billing.address.addressLine2"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); form_structure->DetermineHeuristicTypes(); EXPECT_TRUE(form_structure->IsAutofillable(true)); @@ -877,36 +760,27 @@ TEST(FormStructureTest, BillingAndShippingAddresses) { TEST(FormStructureTest, ThreeAddressLinesExpedia) { scoped_ptr<FormStructure> form_structure; FormData form; - form.method = ASCIIToUTF16("post"); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Street:"), - ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_ads1"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Suite or Apt:"), - ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_adap"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Street address second line"), - ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_ads2"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("City:"), - ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_adct"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Street:"); + field.name = ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_ads1"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Suite or Apt:"); + field.name = ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_adap"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Street address second line"); + field.name = ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_ads2"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("City:"); + field.name = ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_adct"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); form_structure->DetermineHeuristicTypes(); EXPECT_TRUE(form_structure->IsAutofillable(true)); @@ -929,29 +803,23 @@ TEST(FormStructureTest, ThreeAddressLinesExpedia) { TEST(FormStructureTest, TwoAddressLinesEbay) { scoped_ptr<FormStructure> form_structure; FormData form; - form.method = ASCIIToUTF16("post"); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Address Line1"), - ASCIIToUTF16("address1"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Floor number, suite number, etc"), - ASCIIToUTF16("address2"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("City"), - ASCIIToUTF16("city"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Address Line1"); + field.name = ASCIIToUTF16("address1"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Floor number, suite number, etc"); + field.name = ASCIIToUTF16("address2"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("City:"); + field.name = ASCIIToUTF16("city"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); form_structure->DetermineHeuristicTypes(); EXPECT_TRUE(form_structure->IsAutofillable(true)); @@ -969,29 +837,23 @@ TEST(FormStructureTest, TwoAddressLinesEbay) { TEST(FormStructureTest, HeuristicsStateWithProvince) { scoped_ptr<FormStructure> form_structure; FormData form; - form.method = ASCIIToUTF16("post"); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Address Line1"), - ASCIIToUTF16("Address"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Address Line2"), - ASCIIToUTF16("Address"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("State/Province/Region"), - ASCIIToUTF16("State"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Address Line1"); + field.name = ASCIIToUTF16("Address"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Address Line2"); + field.name = ASCIIToUTF16("Address"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("State/Province/Region"); + field.name = ASCIIToUTF16("State"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); form_structure->DetermineHeuristicTypes(); EXPECT_TRUE(form_structure->IsAutofillable(true)); @@ -1010,85 +872,55 @@ TEST(FormStructureTest, HeuristicsStateWithProvince) { TEST(FormStructureTest, HeuristicsWithBilling) { scoped_ptr<FormStructure> form_structure; FormData form; - form.method = ASCIIToUTF16("post"); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("First Name*:"), - ASCIIToUTF16("editBillingAddress$firstNameBox"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Last Name*:"), - ASCIIToUTF16("editBillingAddress$lastNameBox"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Company Name:"), - ASCIIToUTF16("editBillingAddress$companyBox"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Address*:"), - ASCIIToUTF16("editBillingAddress$addressLine1Box"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Apt/Suite :"), - ASCIIToUTF16("editBillingAddress$addressLine2Box"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("City*:"), - ASCIIToUTF16("editBillingAddress$cityBox"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("State/Province*:"), - ASCIIToUTF16("editBillingAddress$stateDropDown"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Country*:"), - ASCIIToUTF16("editBillingAddress$countryDropDown"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Postal Code*:"), - ASCIIToUTF16("editBillingAddress$zipCodeBox"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Phone*:"), - ASCIIToUTF16("editBillingAddress$phoneBox"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Email Address*:"), - ASCIIToUTF16("email$emailBox"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("First Name*:"); + field.name = ASCIIToUTF16("editBillingAddress$firstNameBox"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Last Name*:"); + field.name = ASCIIToUTF16("editBillingAddress$lastNameBox"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Company Name:"); + field.name = ASCIIToUTF16("editBillingAddress$companyBox"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Address*:"); + field.name = ASCIIToUTF16("editBillingAddress$addressLine1Box"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Apt/Suite :"); + field.name = ASCIIToUTF16("editBillingAddress$addressLine2Box"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("City*:"); + field.name = ASCIIToUTF16("editBillingAddress$cityBox"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("State/Province*:"); + field.name = ASCIIToUTF16("editBillingAddress$stateDropDown"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Country*:"); + field.name = ASCIIToUTF16("editBillingAddress$countryDropDown"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Postal Code*:"); + field.name = ASCIIToUTF16("editBillingAddress$zipCodeBox"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Phone*:"); + field.name = ASCIIToUTF16("editBillingAddress$phoneBox"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Email Address*:"); + field.name = ASCIIToUTF16("email$emailBox"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); form_structure->DetermineHeuristicTypes(); EXPECT_TRUE(form_structure->IsAutofillable(true)); @@ -1113,38 +945,33 @@ TEST(FormStructureTest, HeuristicsWithBilling) { TEST(FormStructureTest, ThreePartPhoneNumber) { scoped_ptr<FormStructure> form_structure; FormData form; - form.method = ASCIIToUTF16("post"); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Phone:"), - ASCIIToUTF16("dayphone1"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("-"), - ASCIIToUTF16("dayphone2"), - string16(), - ASCIIToUTF16("text"), - 3, // Size of prefix is 3. - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("-"), - ASCIIToUTF16("dayphone3"), - string16(), - ASCIIToUTF16("text"), - 4, // Size of suffix is 4. If unlimited size is - // passed, phone will be parsed as - // <country code> - <area code> - <phone>. - false)); - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("ext.:"), - ASCIIToUTF16("dayphone4"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Phone:"); + field.name = ASCIIToUTF16("dayphone1"); + field.max_length = 0; + form.fields.push_back(field); + + field.label = ASCIIToUTF16("-"); + field.name = ASCIIToUTF16("dayphone2"); + field.max_length = 3; // Size of prefix is 3. + form.fields.push_back(field); + + field.label = ASCIIToUTF16("-"); + field.name = ASCIIToUTF16("dayphone3"); + field.max_length = 4; // Size of suffix is 4. If unlimited size is + // passed, phone will be parsed as + // <country code> - <area code> - <phone>. + form.fields.push_back(field); + + field.label = ASCIIToUTF16("ext.:"); + field.name = ASCIIToUTF16("dayphone4"); + field.max_length = 0; + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); form_structure->DetermineHeuristicTypes(); EXPECT_TRUE(form_structure->IsAutofillable(true)); @@ -1167,36 +994,30 @@ TEST(FormStructureTest, HeuristicsInfernoCC) { scoped_ptr<FormStructure> form_structure; FormData form; form.method = ASCIIToUTF16("post"); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Name on Card"), - ASCIIToUTF16("name_on_card"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"), - ASCIIToUTF16("billing_address"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Card Number"), - ASCIIToUTF16("card_number"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Expiration Date"), - ASCIIToUTF16("expiration_month"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Expiration Year"), - ASCIIToUTF16("expiration_year"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Name on Card"); + field.name = ASCIIToUTF16("name_on_card"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Address"); + field.name = ASCIIToUTF16("billing_address"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Card Number"); + field.name = ASCIIToUTF16("card_number"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Expiration Date"); + field.name = ASCIIToUTF16("expiration_month"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Expiration Year"); + field.name = ASCIIToUTF16("expiration_year"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); form_structure->DetermineHeuristicTypes(); EXPECT_TRUE(form_structure->IsAutofillable(true)); @@ -1222,42 +1043,34 @@ TEST(FormStructureTest, CVCCodeClash) { scoped_ptr<FormStructure> form_structure; FormData form; form.method = ASCIIToUTF16("post"); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Card number"), - ASCIIToUTF16("ccnumber"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First name"), - ASCIIToUTF16("first_name"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last name"), - ASCIIToUTF16("last_name"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Expiration date"), - ASCIIToUTF16("ccexpiresmonth"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16(""), - ASCIIToUTF16("ccexpiresyear"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("cvc number"), - ASCIIToUTF16("csc"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Card number"); + field.name = ASCIIToUTF16("ccnumber"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("First name"); + field.name = ASCIIToUTF16("first_name"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Last name"); + field.name = ASCIIToUTF16("last_name"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Expiration date"); + field.name = ASCIIToUTF16("ccexpiresmonth"); + form.fields.push_back(field); + + field.label = string16(); + field.name = ASCIIToUTF16("ccexpiresyear"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("cvc number"); + field.name = ASCIIToUTF16("csc"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); form_structure->DetermineHeuristicTypes(); EXPECT_TRUE(form_structure->IsAutofillable(true)); @@ -1284,36 +1097,30 @@ TEST(FormStructureTest, CVCCodeClash) { TEST(FormStructureTest, EncodeQueryRequest) { FormData form; form.method = ASCIIToUTF16("post"); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Name on Card"), - ASCIIToUTF16("name_on_card"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"), - ASCIIToUTF16("billing_address"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Card Number"), - ASCIIToUTF16("card_number"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Expiration Date"), - ASCIIToUTF16("expiration_month"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Expiration Year"), - ASCIIToUTF16("expiration_year"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Name on Card"); + field.name = ASCIIToUTF16("name_on_card"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Address"); + field.name = ASCIIToUTF16("billing_address"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Card Number"); + field.name = ASCIIToUTF16("card_number"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Expiration Date"); + field.name = ASCIIToUTF16("expiration_month"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Expiration Year"); + field.name = ASCIIToUTF16("expiration_year"); + form.fields.push_back(field); + ScopedVector<FormStructure> forms; forms.push_back(new FormStructure(form)); std::vector<std::string> encoded_signatures; @@ -1342,13 +1149,9 @@ TEST(FormStructureTest, EncodeQueryRequest) { EXPECT_EQ(kResponse1, encoded_xml); // Add 5 address fields - this should be still a valid form. for (size_t i = 0; i < 5; ++i) { - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Address"), - ASCIIToUTF16("address"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + field.label = ASCIIToUTF16("Address"); + field.name = ASCIIToUTF16("address"); + form.fields.push_back(field); } forms.push_back(new FormStructure(form)); @@ -1375,13 +1178,9 @@ TEST(FormStructureTest, EncodeQueryRequest) { // Add 50 address fields - the form is not valid anymore, but previous ones // are. The result should be the same as in previous test. for (size_t i = 0; i < 50; ++i) { - form.fields.push_back( - webkit_glue::FormField(ASCIIToUTF16("Address"), - ASCIIToUTF16("address"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + field.label = ASCIIToUTF16("Address"); + field.name = ASCIIToUTF16("address"); + form.fields.push_back(field); } forms.push_back(new FormStructure(form)); @@ -1408,52 +1207,47 @@ TEST(FormStructureTest, EncodeUploadRequest) { form.method = ASCIIToUTF16("post"); form_structure.reset(new FormStructure(form)); form_structure->DetermineHeuristicTypes(); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), - ASCIIToUTF16("firstname"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("First Name"); + field.name = ASCIIToUTF16("firstname"); + form.fields.push_back(field); possible_field_types.push_back(FieldTypeSet()); possible_field_types.back().insert(NAME_FIRST); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"), - ASCIIToUTF16("lastname"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + field.label = ASCIIToUTF16("Last Name"); + field.name = ASCIIToUTF16("lastname"); + form.fields.push_back(field); possible_field_types.push_back(FieldTypeSet()); possible_field_types.back().insert(NAME_LAST); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"), - ASCIIToUTF16("email"), - string16(), - ASCIIToUTF16("email"), - 0, - false)); + + field.label = ASCIIToUTF16("Email"); + field.name = ASCIIToUTF16("email"); + field.form_control_type = ASCIIToUTF16("email"); + form.fields.push_back(field); possible_field_types.push_back(FieldTypeSet()); possible_field_types.back().insert(EMAIL_ADDRESS); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"), - ASCIIToUTF16("phone"), - string16(), - ASCIIToUTF16("number"), - 0, - false)); + + field.label = ASCIIToUTF16("Phone"); + field.name = ASCIIToUTF16("phone"); + field.form_control_type = ASCIIToUTF16("number"); + form.fields.push_back(field); possible_field_types.push_back(FieldTypeSet()); possible_field_types.back().insert(PHONE_HOME_WHOLE_NUMBER); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Country"), - ASCIIToUTF16("country"), - string16(), - ASCIIToUTF16("select-one"), - 0, - false)); + + field.label = ASCIIToUTF16("Country"); + field.name = ASCIIToUTF16("country"); + field.form_control_type = ASCIIToUTF16("select-one"); + form.fields.push_back(field); possible_field_types.push_back(FieldTypeSet()); possible_field_types.back().insert(ADDRESS_HOME_COUNTRY); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"), - ASCIIToUTF16("fax"), - string16(), - ASCIIToUTF16("tel"), - 0, - false)); + + field.label = ASCIIToUTF16("Fax"); + field.name = ASCIIToUTF16("fax"); + field.form_control_type = ASCIIToUTF16("tel"); + form.fields.push_back(field); possible_field_types.push_back(FieldTypeSet()); possible_field_types.back().insert(PHONE_FAX_WHOLE_NUMBER); form_structure.reset(new FormStructure(form)); @@ -1506,12 +1300,10 @@ TEST(FormStructureTest, EncodeUploadRequest) { // Add 2 address fields - this should be still a valid form. for (size_t i = 0; i < 2; ++i) { - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"), - ASCIIToUTF16("address"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + field.label = ASCIIToUTF16("Address"); + field.name = ASCIIToUTF16("address"); + field.form_control_type = ASCIIToUTF16("text"); + form.fields.push_back(field); possible_field_types.push_back(FieldTypeSet()); possible_field_types.back().insert(ADDRESS_HOME_LINE1); possible_field_types.back().insert(ADDRESS_HOME_LINE2); @@ -1549,12 +1341,10 @@ TEST(FormStructureTest, EncodeUploadRequest) { // Add 50 address fields - now the form is invalid, as it has too many fields. for (size_t i = 0; i < 50; ++i) { - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"), - ASCIIToUTF16("address"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + field.label = ASCIIToUTF16("Address"); + field.name = ASCIIToUTF16("address"); + field.form_control_type = ASCIIToUTF16("text"); + form.fields.push_back(field); possible_field_types.push_back(FieldTypeSet()); possible_field_types.back().insert(ADDRESS_HOME_LINE1); possible_field_types.back().insert(ADDRESS_HOME_LINE2); @@ -1574,24 +1364,21 @@ TEST(FormStructureTest, EncodeUploadRequest) { TEST(FormStructureTest, CheckDataPresence) { FormData form; form.method = ASCIIToUTF16("post"); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), - ASCIIToUTF16("first"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"), - ASCIIToUTF16("last"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("email"), - ASCIIToUTF16("email"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("First Name"); + field.name = ASCIIToUTF16("first"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Last Name"); + field.name = ASCIIToUTF16("last"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("Email"); + field.name = ASCIIToUTF16("email"); + form.fields.push_back(field); FormStructure form_structure(form); @@ -1851,38 +1638,34 @@ TEST(FormStructureTest, CheckMultipleTypes) { std::vector<FieldTypeSet> possible_field_types; FormData form; form.method = ASCIIToUTF16("post"); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("email"), - ASCIIToUTF16("email"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("email"); + field.name = ASCIIToUTF16("email"); + form.fields.push_back(field); possible_field_types.push_back(FieldTypeSet()); possible_field_types.back().insert(EMAIL_ADDRESS); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), - ASCIIToUTF16("first"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + field.label = ASCIIToUTF16("First Name"); + field.name = ASCIIToUTF16("first"); + form.fields.push_back(field); possible_field_types.push_back(FieldTypeSet()); possible_field_types.back().insert(NAME_FIRST); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"), - ASCIIToUTF16("last"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + field.label = ASCIIToUTF16("Last Name"); + field.name = ASCIIToUTF16("last"); + form.fields.push_back(field); possible_field_types.push_back(FieldTypeSet()); possible_field_types.back().insert(NAME_LAST); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"), - ASCIIToUTF16("address"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + field.label = ASCIIToUTF16("Address"); + field.name = ASCIIToUTF16("address"); + form.fields.push_back(field); possible_field_types.push_back(FieldTypeSet()); possible_field_types.back().insert(ADDRESS_HOME_LINE1); + form_structure.reset(new FormStructure(form)); for (size_t i = 0; i < form_structure->field_count(); ++i) @@ -1963,18 +1746,18 @@ TEST(FormStructureTest, CheckFormSignature) { scoped_ptr<FormStructure> form_structure; FormData form; form.method = ASCIIToUTF16("post"); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("email"), - ASCIIToUTF16("email"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); - form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), - ASCIIToUTF16("first"), - string16(), - ASCIIToUTF16("text"), - 0, - false)); + + FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("email"); + field.name = ASCIIToUTF16("email"); + form.fields.push_back(field); + + field.label = ASCIIToUTF16("First Name"); + field.name = ASCIIToUTF16("first"); + form.fields.push_back(field); + form_structure.reset(new FormStructure(form)); EXPECT_EQ(FormStructureTest::Hash64Bit( diff --git a/chrome/browser/autofill/name_field_unittest.cc b/chrome/browser/autofill/name_field_unittest.cc index 8edb07f..f89d9de 100644 --- a/chrome/browser/autofill/name_field_unittest.cc +++ b/chrome/browser/autofill/name_field_unittest.cc @@ -30,30 +30,21 @@ class NameFieldTest : public testing::Test { }; TEST_F(NameFieldTest, FirstMiddleLast) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("First Name"), - ASCIIToUTF16("First"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Middle Name"), - ASCIIToUTF16("Middle"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name2"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Last Name"), - ASCIIToUTF16("Last"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name3"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("First Name"); + field.name = ASCIIToUTF16("First"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name1"))); + + field.label = ASCIIToUTF16("Middle Name"); + field.name = ASCIIToUTF16("Middle"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name2"))); + + field.label = ASCIIToUTF16("Last Name"); + field.name = ASCIIToUTF16("Last"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name3"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<NameField*>(NULL), field_.get()); @@ -70,30 +61,21 @@ TEST_F(NameFieldTest, FirstMiddleLast) { } TEST_F(NameFieldTest, FirstMiddleLast2) { - list_.push_back( - new AutofillField(webkit_glue::FormField(string16(), - ASCIIToUTF16("firstName"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(string16(), - ASCIIToUTF16("middleName"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name2"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(string16(), - ASCIIToUTF16("lastName"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name3"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = string16(); + field.name = ASCIIToUTF16("firstName"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name1"))); + + field.label = string16(); + field.name = ASCIIToUTF16("middleName"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name2"))); + + field.label = string16(); + field.name = ASCIIToUTF16("lastName"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name3"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<NameField*>(NULL), field_.get()); @@ -110,22 +92,17 @@ TEST_F(NameFieldTest, FirstMiddleLast2) { } TEST_F(NameFieldTest, FirstLast) { - list_.push_back( - new AutofillField(webkit_glue::FormField(string16(), - ASCIIToUTF16("first_name"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(string16(), - ASCIIToUTF16("last_name"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name2"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = string16(); + field.name = ASCIIToUTF16("first_name"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name1"))); + + field.label = string16(); + field.name = ASCIIToUTF16("last_name"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name2"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<NameField*>(NULL), field_.get()); @@ -139,22 +116,17 @@ TEST_F(NameFieldTest, FirstLast) { } TEST_F(NameFieldTest, FirstLast2) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Name"), - ASCIIToUTF16("first_name"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Name"), - ASCIIToUTF16("last_name"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name2"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Name"); + field.name = ASCIIToUTF16("first_name"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name1"))); + + field.label = ASCIIToUTF16("Name"); + field.name = ASCIIToUTF16("last_name"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name2"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<NameField*>(NULL), field_.get()); @@ -168,30 +140,21 @@ TEST_F(NameFieldTest, FirstLast2) { } TEST_F(NameFieldTest, FirstLastMiddleWithSpaces) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("First Name"), - ASCIIToUTF16("first name"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Middle Name"), - ASCIIToUTF16("middle name"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name2"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Last Name"), - ASCIIToUTF16("last name"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name3"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("First Name"); + field.name = ASCIIToUTF16("first_name"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name1"))); + + field.label = ASCIIToUTF16("Middle Name"); + field.name = ASCIIToUTF16("middle_name"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name2"))); + + field.label = ASCIIToUTF16("Last Name"); + field.name = ASCIIToUTF16("last_name"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name3"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<NameField*>(NULL), field_.get()); @@ -208,22 +171,17 @@ TEST_F(NameFieldTest, FirstLastMiddleWithSpaces) { } TEST_F(NameFieldTest, FirstLastEmpty) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Name"), - ASCIIToUTF16("first_name"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(string16(), - ASCIIToUTF16("last_name"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name2"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Name"); + field.name = ASCIIToUTF16("first_name"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name1"))); + + field.label = string16(); + field.name = ASCIIToUTF16("last_name"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name2"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<NameField*>(NULL), field_.get()); @@ -237,30 +195,21 @@ TEST_F(NameFieldTest, FirstLastEmpty) { } TEST_F(NameFieldTest, FirstMiddleLastEmpty) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Name"), - ASCIIToUTF16("first_name"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(string16(), - ASCIIToUTF16("middle_name"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name2"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(string16(), - ASCIIToUTF16("last_name"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name3"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Name"); + field.name = ASCIIToUTF16("first_name"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name1"))); + + field.label = string16(); + field.name = ASCIIToUTF16("middle_name"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name2"))); + + field.label = string16(); + field.name = ASCIIToUTF16("last_name"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name3"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<NameField*>(NULL), field_.get()); @@ -277,30 +226,21 @@ TEST_F(NameFieldTest, FirstMiddleLastEmpty) { } TEST_F(NameFieldTest, MiddleInitial) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("First Name"), - ASCIIToUTF16("first_name"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("MI"), - ASCIIToUTF16("middle_name"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name2"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Last Name"), - ASCIIToUTF16("last_name"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name3"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("First Name"); + field.name = ASCIIToUTF16("first_name"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name1"))); + + field.label = ASCIIToUTF16("MI"); + field.name = ASCIIToUTF16("middle_name"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name2"))); + + field.label = ASCIIToUTF16("Last Name"); + field.name = ASCIIToUTF16("last_name"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name3"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<NameField*>(NULL), field_.get()); @@ -317,22 +257,17 @@ TEST_F(NameFieldTest, MiddleInitial) { } TEST_F(NameFieldTest, MiddleInitialNoLastName) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("First Name"), - ASCIIToUTF16("first_name"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("MI"), - ASCIIToUTF16("middle_name"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name2"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("First Name"); + field.name = ASCIIToUTF16("first_name"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name1"))); + + field.label = ASCIIToUTF16("MI"); + field.name = ASCIIToUTF16("middle_name"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name2"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_EQ(static_cast<NameField*>(NULL), field_.get()); @@ -341,30 +276,21 @@ TEST_F(NameFieldTest, MiddleInitialNoLastName) { // This case is from the dell.com checkout page. The middle initial "mi" string // came at the end following other descriptive text. http://crbug.com/45123. TEST_F(NameFieldTest, MiddleInitialAtEnd) { - list_.push_back( - new AutofillField(webkit_glue::FormField(string16(), - ASCIIToUTF16("XXXnameXXXfirst"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(string16(), - ASCIIToUTF16("XXXnameXXXmi"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name2"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(string16(), - ASCIIToUTF16("XXXnameXXXlast"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("name3"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = string16(); + field.name = ASCIIToUTF16("XXXnameXXXfirst"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name1"))); + + field.label = string16(); + field.name = ASCIIToUTF16("XXXnameXXXmi"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name2"))); + + field.label = string16(); + field.name = ASCIIToUTF16("XXXnameXXXlast"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("name3"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<NameField*>(NULL), field_.get()); diff --git a/chrome/browser/autofill/phone_field_unittest.cc b/chrome/browser/autofill/phone_field_unittest.cc index 0b2628c..9835567 100644 --- a/chrome/browser/autofill/phone_field_unittest.cc +++ b/chrome/browser/autofill/phone_field_unittest.cc @@ -43,14 +43,13 @@ TEST_F(PhoneFieldTest, NonParse) { } TEST_F(PhoneFieldTest, ParseOneLinePhone) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Phone"), - ASCIIToUTF16("phone"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("phone1"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Phone"); + field.name = ASCIIToUTF16("phone"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("phone1"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get()); @@ -61,22 +60,17 @@ TEST_F(PhoneFieldTest, ParseOneLinePhone) { } TEST_F(PhoneFieldTest, ParseTwoLinePhone) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Area Code"), - ASCIIToUTF16("area code"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("areacode1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Phone"), - ASCIIToUTF16("phone"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("phone1"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Area Code"); + field.name = ASCIIToUTF16("area code"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("areacode1"))); + + field.label = ASCIIToUTF16("Phone"); + field.name = ASCIIToUTF16("phone"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("phone2"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get()); @@ -85,8 +79,8 @@ TEST_F(PhoneFieldTest, ParseTwoLinePhone) { field_type_map_.find(ASCIIToUTF16("areacode1")) != field_type_map_.end()); EXPECT_EQ(PHONE_HOME_CITY_CODE, field_type_map_[ASCIIToUTF16("areacode1")]); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("phone1")) != field_type_map_.end()); - EXPECT_EQ(PHONE_HOME_NUMBER, field_type_map_[ASCIIToUTF16("phone1")]); + field_type_map_.find(ASCIIToUTF16("phone2")) != field_type_map_.end()); + EXPECT_EQ(PHONE_HOME_NUMBER, field_type_map_[ASCIIToUTF16("phone2")]); } TEST_F(PhoneFieldTest, ThreePartPhoneNumber) { @@ -95,38 +89,29 @@ TEST_F(PhoneFieldTest, ThreePartPhoneNumber) { // <country code> - <area code> - <phone>. The only distinguishing feature is // size: <prefix> is no bigger than 3 characters, and <suffix> is no bigger // than 4. - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Phone:"), - ASCIIToUTF16("dayphone1"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("areacode1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("-"), - ASCIIToUTF16("dayphone2"), - string16(), - ASCIIToUTF16("text"), - 3, - false), - ASCIIToUTF16("prefix1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("-"), - ASCIIToUTF16("dayphone3"), - string16(), - ASCIIToUTF16("text"), - 4, - false), - ASCIIToUTF16("suffix1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("ext.:"), - ASCIIToUTF16("dayphone4"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("ext1"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Phone:"); + field.name = ASCIIToUTF16("dayphone1"); + field.max_length = 0; + list_.push_back(new AutofillField(field, ASCIIToUTF16("areacode1"))); + + field.label = ASCIIToUTF16("-"); + field.name = ASCIIToUTF16("dayphone2"); + field.max_length = 3; + list_.push_back(new AutofillField(field, ASCIIToUTF16("prefix2"))); + + field.label = ASCIIToUTF16("-"); + field.name = ASCIIToUTF16("dayphone3"); + field.max_length = 4; + list_.push_back(new AutofillField(field, ASCIIToUTF16("suffix3"))); + + field.label = ASCIIToUTF16("ext.:"); + field.name = ASCIIToUTF16("dayphone4"); + field.max_length = 0; + list_.push_back(new AutofillField(field, ASCIIToUTF16("ext4"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get()); @@ -135,41 +120,34 @@ TEST_F(PhoneFieldTest, ThreePartPhoneNumber) { field_type_map_.find(ASCIIToUTF16("areacode1")) != field_type_map_.end()); EXPECT_EQ(PHONE_HOME_CITY_CODE, field_type_map_[ASCIIToUTF16("areacode1")]); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("prefix1")) != field_type_map_.end()); - EXPECT_EQ(PHONE_HOME_NUMBER, field_type_map_[ASCIIToUTF16("prefix1")]); + field_type_map_.find(ASCIIToUTF16("prefix2")) != field_type_map_.end()); + EXPECT_EQ(PHONE_HOME_NUMBER, field_type_map_[ASCIIToUTF16("prefix2")]); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("suffix1")) != field_type_map_.end()); - EXPECT_EQ(PHONE_HOME_NUMBER, field_type_map_[ASCIIToUTF16("suffix1")]); + field_type_map_.find(ASCIIToUTF16("suffix3")) != field_type_map_.end()); + EXPECT_EQ(PHONE_HOME_NUMBER, field_type_map_[ASCIIToUTF16("suffix3")]); + EXPECT_TRUE( + field_type_map_.find(ASCIIToUTF16("ext4")) == field_type_map_.end()); } // This scenario of explicitly labeled "prefix" and "suffix" phone numbers // encountered in http://crbug.com/40694 with page // https://www.wrapables.com/jsp/Signup.jsp. TEST_F(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Phone:"), - ASCIIToUTF16("area"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("areacode1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(string16(), - ASCIIToUTF16("prefix"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("prefix1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(string16(), - ASCIIToUTF16("suffix"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("suffix1"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Phone:"); + field.name = ASCIIToUTF16("area"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("areacode1"))); + + field.label = string16(); + field.name = ASCIIToUTF16("prefix"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("prefix2"))); + + field.label = string16(); + field.name = ASCIIToUTF16("suffix"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("suffix3"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get()); @@ -178,38 +156,32 @@ TEST_F(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix) { field_type_map_.find(ASCIIToUTF16("areacode1")) != field_type_map_.end()); EXPECT_EQ(PHONE_HOME_CITY_CODE, field_type_map_[ASCIIToUTF16("areacode1")]); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("prefix1")) != field_type_map_.end()); - EXPECT_EQ(PHONE_HOME_NUMBER, field_type_map_[ASCIIToUTF16("prefix1")]); + field_type_map_.find(ASCIIToUTF16("prefix2")) != field_type_map_.end()); + EXPECT_EQ(PHONE_HOME_NUMBER, field_type_map_[ASCIIToUTF16("prefix2")]); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("suffix1")) != field_type_map_.end()); - EXPECT_EQ(PHONE_HOME_NUMBER, field_type_map_[ASCIIToUTF16("suffix1")]); + field_type_map_.find(ASCIIToUTF16("suffix3")) != field_type_map_.end()); + EXPECT_EQ(PHONE_HOME_NUMBER, field_type_map_[ASCIIToUTF16("suffix3")]); } TEST_F(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix2) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("("), - ASCIIToUTF16("phone1"), - string16(), - ASCIIToUTF16("text"), - 3, - false), - ASCIIToUTF16("phone1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16(")"), - ASCIIToUTF16("phone2"), - string16(), - ASCIIToUTF16("text"), - 3, - false), - ASCIIToUTF16("phone2"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(string16(), - ASCIIToUTF16("phone3"), - string16(), - ASCIIToUTF16("text"), - 4, - false), - ASCIIToUTF16("phone3"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("("); + field.name = ASCIIToUTF16("phone1"); + field.max_length = 3; + list_.push_back(new AutofillField(field, ASCIIToUTF16("phone1"))); + + field.label = ASCIIToUTF16(")"); + field.name = ASCIIToUTF16("phone2"); + field.max_length = 3; + list_.push_back(new AutofillField(field, ASCIIToUTF16("phone2"))); + + field.label = string16(); + field.name = ASCIIToUTF16("phone3"); + field.max_length = 4; + list_.push_back(new AutofillField(field, ASCIIToUTF16("phone3"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get()); @@ -226,14 +198,13 @@ TEST_F(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix2) { } TEST_F(PhoneFieldTest, ParseOneLineFax) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Fax"), - ASCIIToUTF16("fax"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("fax1"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Fax"); + field.name = ASCIIToUTF16("fax"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("fax1"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get()); @@ -244,22 +215,17 @@ TEST_F(PhoneFieldTest, ParseOneLineFax) { } TEST_F(PhoneFieldTest, ParseTwoLineFax) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Area Code"), - ASCIIToUTF16("area code"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("areacode1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Fax"), - ASCIIToUTF16("fax"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("fax1"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Area Code"); + field.name = ASCIIToUTF16("area code"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("areacode1"))); + + field.label = ASCIIToUTF16("Fax"); + field.name = ASCIIToUTF16("fax"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("fax2"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get()); @@ -269,35 +235,26 @@ TEST_F(PhoneFieldTest, ParseTwoLineFax) { // It should be FAX, based on the other phone in the group. EXPECT_EQ(PHONE_FAX_CITY_CODE, field_type_map_[ASCIIToUTF16("areacode1")]); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("fax1")) != field_type_map_.end()); - EXPECT_EQ(PHONE_FAX_NUMBER, field_type_map_[ASCIIToUTF16("fax1")]); + field_type_map_.find(ASCIIToUTF16("fax2")) != field_type_map_.end()); + EXPECT_EQ(PHONE_FAX_NUMBER, field_type_map_[ASCIIToUTF16("fax2")]); } TEST_F(PhoneFieldTest, ThreePartFaxNumberPrefixSuffix) { - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Fax:"), - ASCIIToUTF16("area"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("areacode1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(string16(), - ASCIIToUTF16("prefix"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("prefix1"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(string16(), - ASCIIToUTF16("suffix"), - string16(), - ASCIIToUTF16("text"), - 0, - false), - ASCIIToUTF16("suffix1"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Fax:"); + field.name = ASCIIToUTF16("area"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("areacode1"))); + + field.label = string16(); + field.name = ASCIIToUTF16("prefix"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("prefix2"))); + + field.label = string16(); + field.name = ASCIIToUTF16("suffix"); + list_.push_back(new AutofillField(field, ASCIIToUTF16("suffix3"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get()); @@ -306,32 +263,29 @@ TEST_F(PhoneFieldTest, ThreePartFaxNumberPrefixSuffix) { field_type_map_.find(ASCIIToUTF16("areacode1")) != field_type_map_.end()); EXPECT_EQ(PHONE_FAX_CITY_CODE, field_type_map_[ASCIIToUTF16("areacode1")]); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("prefix1")) != field_type_map_.end()); - EXPECT_EQ(PHONE_FAX_NUMBER, field_type_map_[ASCIIToUTF16("prefix1")]); + field_type_map_.find(ASCIIToUTF16("prefix2")) != field_type_map_.end()); + EXPECT_EQ(PHONE_FAX_NUMBER, field_type_map_[ASCIIToUTF16("prefix2")]); ASSERT_TRUE( - field_type_map_.find(ASCIIToUTF16("suffix1")) != field_type_map_.end()); - EXPECT_EQ(PHONE_FAX_NUMBER, field_type_map_[ASCIIToUTF16("suffix1")]); + field_type_map_.find(ASCIIToUTF16("suffix3")) != field_type_map_.end()); + EXPECT_EQ(PHONE_FAX_NUMBER, field_type_map_[ASCIIToUTF16("suffix3")]); } TEST_F(PhoneFieldTest, CountryAndCityAndPhoneNumber) { // Phone in format <country code>:3 - <city and number>:10 // The |maxlength| is considered, otherwise it's too broad. - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Phone Number"), - ASCIIToUTF16("CountryCode"), - string16(), - ASCIIToUTF16("text"), - 3, - false), - ASCIIToUTF16("country"))); - list_.push_back( - new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Phone Number"), - ASCIIToUTF16("PhoneNumber"), - string16(), - ASCIIToUTF16("text"), - 10, - false), - ASCIIToUTF16("phone"))); + webkit_glue::FormField field; + field.form_control_type = ASCIIToUTF16("text"); + + field.label = ASCIIToUTF16("Phone Number"); + field.name = ASCIIToUTF16("CountryCode"); + field.max_length = 3; + list_.push_back(new AutofillField(field, ASCIIToUTF16("country"))); + + field.label = ASCIIToUTF16("Phone Number"); + field.name = ASCIIToUTF16("PhoneNumber"); + field.max_length = 10; + list_.push_back(new AutofillField(field, ASCIIToUTF16("phone"))); + AutofillScanner scanner(list_.get()); field_.reset(Parse(&scanner)); ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get()); |