diff options
author | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-20 19:30:20 +0000 |
---|---|---|
committer | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-20 19:30:20 +0000 |
commit | 452bb48838c784b237c0844aa4708396b0dce35b (patch) | |
tree | cb7cc12ad9a82cad13fbcbeb55087aa305216e92 | |
parent | 90864a884d166bc380fc354e6a448bea1230a087 (diff) | |
download | chromium_src-452bb48838c784b237c0844aa4708396b0dce35b.zip chromium_src-452bb48838c784b237c0844aa4708396b0dce35b.tar.gz chromium_src-452bb48838c784b237c0844aa4708396b0dce35b.tar.bz2 |
AutoFill telephone number prefix and suffix heuristics.
Extends matching of telephone number prefix and suffix fields to include fields explicitly labeled with "prefix" and "suffix" strings.
BUG=40694
TEST=PhoneFieldTest.ThreePartPhoneNumberPrefixSuffix
Review URL: http://codereview.chromium.org/2129016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47829 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/autofill/phone_field.cc | 4 | ||||
-rw-r--r-- | chrome/browser/autofill/phone_field_unittest.cc | 41 |
2 files changed, 43 insertions, 2 deletions
diff --git a/chrome/browser/autofill/phone_field.cc b/chrome/browser/autofill/phone_field.cc index 6092fe4..5b4494d 100644 --- a/chrome/browser/autofill/phone_field.cc +++ b/chrome/browser/autofill/phone_field.cc @@ -46,11 +46,11 @@ PhoneField* PhoneField::Parse(std::vector<AutoFillField*>::const_iterator* iter, // uk/Furniture123-1.html) have several phone numbers in succession and we // don't want those to be parsed as components of a single phone number. if (phone2 == NULL) - ParseText(&q, ASCIIToUTF16("^-$|\\)$"), &phone2); + ParseText(&q, ASCIIToUTF16("^-$|\\)$|prefix"), &phone2); // Look for a third text box. if (phone2) - ParseText(&q, ASCIIToUTF16("^-$"), &phone3); + ParseText(&q, ASCIIToUTF16("^-$|suffix"), &phone3); // Now we have one, two, or three phone number text fields. Package them // up into a PhoneField object. diff --git a/chrome/browser/autofill/phone_field_unittest.cc b/chrome/browser/autofill/phone_field_unittest.cc index bf7d9fb..0a6b0fa 100644 --- a/chrome/browser/autofill/phone_field_unittest.cc +++ b/chrome/browser/autofill/phone_field_unittest.cc @@ -204,4 +204,45 @@ TEST_F(PhoneFieldTest, ThreePartPhoneNumber) { EXPECT_EQ(PHONE_HOME_NUMBER, field_type_map_[ASCIIToUTF16("suffix1")]); } +// 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), + ASCIIToUTF16("areacode1"))); + list_.push_back( + new AutoFillField(webkit_glue::FormField(string16(), + ASCIIToUTF16("prefix"), + string16(), + ASCIIToUTF16("text"), + 0), + ASCIIToUTF16("prefix1"))); + list_.push_back( + new AutoFillField(webkit_glue::FormField(string16(), + ASCIIToUTF16("suffix"), + string16(), + ASCIIToUTF16("text"), + 0), + ASCIIToUTF16("suffix1"))); + list_.push_back(NULL); + iter_ = list_.begin(); + field_.reset(PhoneField::Parse(&iter_, false)); + ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get()); + ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_)); + ASSERT_TRUE( + 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")]); + ASSERT_TRUE( + field_type_map_.find(ASCIIToUTF16("suffix1")) != field_type_map_.end()); + EXPECT_EQ(PHONE_HOME_NUMBER, field_type_map_[ASCIIToUTF16("suffix1")]); +} + } // namespace |