summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill/form_structure_unittest.cc
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-14 19:21:18 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-14 19:21:18 +0000
commitee0e2d945e34a794f5268137f71fc9e7d1cdc82b (patch)
treeceac50e53dc7d55b85e9ca2d0ab359fa9a236deb /chrome/browser/autofill/form_structure_unittest.cc
parent1b2b9e175adf3b51215ca88f75ea66605f74ef33 (diff)
downloadchromium_src-ee0e2d945e34a794f5268137f71fc9e7d1cdc82b.zip
chromium_src-ee0e2d945e34a794f5268137f71fc9e7d1cdc82b.tar.gz
chromium_src-ee0e2d945e34a794f5268137f71fc9e7d1cdc82b.tar.bz2
Form AutoFill Phone number should be displayed as xxx-xxx-xxxx
Modifies the AutoFill label inferencing logic to skip over <img> tags when deriving labels. It is common to use small images as spacers between elements. Also, extends the phone number heuristics to recognize numbers that are split into three fields of the form [xxx]-[yyy]-[zzzz] where xxx is the area code, yyy is the phone number prefix and zzz is the phone number suffix. Note: This change has a dependency on WebKit change: https://bugs.webkit.org/show_bug.cgi?id=38825. Will need to wait for that to land before committing this change. BUG=38218 TEST=FormManagerTest.LabelsInferredWithImageTags:FormStructureTest.ThreePartPhoneNumber:PhoneFieldTest.ThreePartPhoneNumber Review URL: http://codereview.chromium.org/1979008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47297 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/form_structure_unittest.cc')
-rw-r--r--chrome/browser/autofill/form_structure_unittest.cc289
1 files changed, 208 insertions, 81 deletions
diff --git a/chrome/browser/autofill/form_structure_unittest.cc b/chrome/browser/autofill/form_structure_unittest.cc
index 1286f9a..f8f8f87 100644
--- a/chrome/browser/autofill/form_structure_unittest.cc
+++ b/chrome/browser/autofill/form_structure_unittest.cc
@@ -43,15 +43,18 @@ TEST(FormStructureTest, FieldCount) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"),
ASCIIToUTF16("username"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"),
ASCIIToUTF16("password"),
string16(),
- ASCIIToUTF16("password")));
+ ASCIIToUTF16("password"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
FormStructure form_structure(form);
// All fields are counted.
@@ -64,19 +67,23 @@ TEST(FormStructureTest, AutoFillCount) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"),
ASCIIToUTF16("username"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"),
ASCIIToUTF16("password"),
string16(),
- ASCIIToUTF16("password")));
+ ASCIIToUTF16("password"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("state"),
ASCIIToUTF16("state"),
string16(),
- ASCIIToUTF16("select-one")));
+ ASCIIToUTF16("select-one"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
FormStructure form_structure(form);
// Only text and select fields that are heuristically matched are counted.
@@ -89,19 +96,23 @@ TEST(FormStructureTest, ConvertToFormData) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"),
ASCIIToUTF16("username"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"),
ASCIIToUTF16("password"),
string16(),
- ASCIIToUTF16("password")));
+ ASCIIToUTF16("password"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("state"),
ASCIIToUTF16("state"),
string16(),
- ASCIIToUTF16("select")));
+ ASCIIToUTF16("select"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
FormStructure form_structure(form);
FormData converted = form_structure.ConvertToFormData();
@@ -117,11 +128,13 @@ TEST(FormStructureTest, HasAutoFillableValues) {
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit1"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit2"),
ASCIIToUTF16("dummy value"),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_FALSE(form_structure->HasAutoFillableValues());
@@ -129,11 +142,13 @@ TEST(FormStructureTest, HasAutoFillableValues) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Email"),
ASCIIToUTF16("email"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("state"),
ASCIIToUTF16("state"),
string16(),
- ASCIIToUTF16("select-one")));
+ ASCIIToUTF16("select-one"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_FALSE(form_structure->HasAutoFillableValues());
@@ -141,11 +156,13 @@ TEST(FormStructureTest, HasAutoFillableValues) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"),
ASCIIToUTF16("firstname"),
ASCIIToUTF16("John"),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
ASCIIToUTF16("lastname"),
ASCIIToUTF16("Dear"),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->HasAutoFillableValues());
@@ -155,11 +172,13 @@ TEST(FormStructureTest, HasAutoFillableValues) {
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Field1"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Field2"),
ASCIIToUTF16("dummy value"),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_FALSE(form_structure->HasAutoFillableValues());
@@ -168,7 +187,8 @@ TEST(FormStructureTest, HasAutoFillableValues) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Full Name"),
ASCIIToUTF16("fullname"),
ASCIIToUTF16("John Dear"),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->HasAutoFillableValues());
}
@@ -182,15 +202,18 @@ TEST(FormStructureTest, IsAutoFillable) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"),
ASCIIToUTF16("username"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"),
ASCIIToUTF16("password"),
string16(),
- ASCIIToUTF16("password")));
+ ASCIIToUTF16("password"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_FALSE(form_structure->IsAutoFillable());
@@ -198,11 +221,13 @@ TEST(FormStructureTest, IsAutoFillable) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"),
ASCIIToUTF16("firstname"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
ASCIIToUTF16("lastname"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_FALSE(form_structure->IsAutoFillable());
@@ -210,7 +235,8 @@ TEST(FormStructureTest, IsAutoFillable) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Email"),
ASCIIToUTF16("email"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
@@ -239,39 +265,48 @@ TEST(FormStructureTest, HeuristicsContactInfo) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"),
ASCIIToUTF16("firstname"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
ASCIIToUTF16("lastname"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"),
ASCIIToUTF16("email"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"),
ASCIIToUTF16("phone"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"),
ASCIIToUTF16("fax"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
ASCIIToUTF16("address"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("City"),
ASCIIToUTF16("city"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Zip code"),
ASCIIToUTF16("zipcode"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
@@ -309,52 +344,62 @@ TEST(FormStructureTest, HeuristicsSample8) {
webkit_glue::FormField(ASCIIToUTF16("Your First Name:"),
ASCIIToUTF16("bill.first"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Your Last Name:"),
ASCIIToUTF16("bill.last"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Street Address Line 1:"),
ASCIIToUTF16("bill.street1"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Street Address Line 2:"),
ASCIIToUTF16("bill.street2"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("City:"),
ASCIIToUTF16("bill.city"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("State (U.S.):"),
ASCIIToUTF16("bill.state"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Zip/Postal Code:"),
ASCIIToUTF16("BillTo.PostalCode"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Country:"),
ASCIIToUTF16("bill.country"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Phone Number:"),
ASCIIToUTF16("BillTo.Phone"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
ASSERT_EQ(10U, form_structure->field_count());
@@ -392,39 +437,46 @@ TEST(FormStructureTest, HeuristicsSample6) {
webkit_glue::FormField(ASCIIToUTF16("E-mail address"),
ASCIIToUTF16("email"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Full name"),
ASCIIToUTF16("name"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Company"),
ASCIIToUTF16("company"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Address"),
ASCIIToUTF16("address"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("City"),
ASCIIToUTF16("city"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
// TODO(jhawkins): Add state select control.
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Zip Code"),
ASCIIToUTF16("Home.PostalCode"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
// TODO(jhawkins): Phone number.
form.fields.push_back(
webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
ASCIIToUTF16("continue"),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
ASSERT_EQ(7U, form_structure->field_count());
@@ -457,39 +509,48 @@ TEST(FormStructureTest, HeuristicsLabelsOnly) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"),
string16(),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
string16(),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"),
string16(),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"),
string16(),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"),
string16(),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
string16(),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
string16(),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Zip code"),
string16(),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
ASSERT_EQ(9U, form_structure->field_count());
@@ -524,27 +585,33 @@ TEST(FormStructureTest, HeuristicsCreditCardInfo) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Name on Card"),
ASCIIToUTF16("name on card"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
ASCIIToUTF16("card_number"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Month"),
ASCIIToUTF16("ccmonth"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Year"),
ASCIIToUTF16("ccyear"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Verification"),
ASCIIToUTF16("verification"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
ASSERT_EQ(6U, form_structure->field_count());
@@ -574,33 +641,40 @@ TEST(FormStructureTest, HeuristicsCreditCardInfoWithUnknownCardField) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Name on Card"),
ASCIIToUTF16("name on card"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
// 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")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
ASCIIToUTF16("card_number"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Month"),
ASCIIToUTF16("ccmonth"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Year"),
ASCIIToUTF16("ccyear"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Verification"),
ASCIIToUTF16("verification"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
ASSERT_EQ(7U, form_structure->field_count());
@@ -633,22 +707,26 @@ TEST(FormStructureTest, ThreeAddressLines) {
webkit_glue::FormField(ASCIIToUTF16("Address Line1"),
ASCIIToUTF16("Address"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Address Line2"),
ASCIIToUTF16("Address"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Address Line3"),
ASCIIToUTF16("Address"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("City"),
ASCIIToUTF16("city"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
ASSERT_EQ(4U, form_structure->field_count());
@@ -673,17 +751,20 @@ TEST(FormStructureTest, HeuristicsStateWithProvince) {
webkit_glue::FormField(ASCIIToUTF16("Address Line1"),
ASCIIToUTF16("Address"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Address Line2"),
ASCIIToUTF16("Address"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("State/Province/Region"),
ASCIIToUTF16("State"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
ASSERT_EQ(3U, form_structure->field_count());
@@ -697,4 +778,50 @@ TEST(FormStructureTest, HeuristicsStateWithProvince) {
EXPECT_EQ(ADDRESS_HOME_STATE, form_structure->field(2)->heuristic_type());
}
+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));
+ form.fields.push_back(
+ webkit_glue::FormField(ASCIIToUTF16("-"),
+ ASCIIToUTF16("dayphone2"),
+ string16(),
+ ASCIIToUTF16("text"),
+ 0));
+ form.fields.push_back(
+ webkit_glue::FormField(ASCIIToUTF16("-"),
+ ASCIIToUTF16("dayphone3"),
+ string16(),
+ ASCIIToUTF16("text"),
+ 0));
+ form.fields.push_back(
+ webkit_glue::FormField(ASCIIToUTF16("ext.:"),
+ ASCIIToUTF16("dayphone4"),
+ string16(),
+ ASCIIToUTF16("text"),
+ 0));
+ form_structure.reset(new FormStructure(form));
+ EXPECT_TRUE(form_structure->IsAutoFillable());
+ ASSERT_EQ(4U, form_structure->field_count());
+ ASSERT_EQ(3U, form_structure->autofill_count());
+
+ // Area code.
+ EXPECT_EQ(PHONE_HOME_CITY_CODE, form_structure->field(0)->heuristic_type());
+ // Phone number suffix.
+ EXPECT_EQ(PHONE_HOME_NUMBER,
+ form_structure->field(1)->heuristic_type());
+ // Phone number suffix.
+ EXPECT_EQ(PHONE_HOME_NUMBER,
+ form_structure->field(2)->heuristic_type());
+ // Unknown.
+ EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(3)->heuristic_type());
+}
+
} // namespace