summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill/phone_field_unittest.cc
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-19 23:42:46 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-19 23:42:46 +0000
commit1a9d0de2824b9805e3fdfcdb859f01c3cebccbd8 (patch)
treec4af67ddbba14721f8e1b7ab645bc7b6078a60a1 /chrome/browser/autofill/phone_field_unittest.cc
parent483cad04e9efc1b42f8b2b5b118a95a5650d3c3e (diff)
downloadchromium_src-1a9d0de2824b9805e3fdfcdb859f01c3cebccbd8.zip
chromium_src-1a9d0de2824b9805e3fdfcdb859f01c3cebccbd8.tar.gz
chromium_src-1a9d0de2824b9805e3fdfcdb859f01c3cebccbd8.tar.bz2
Autofill refactor form_field.h/cc.
1. Moves FormField methods into proper public/protected/private visibility. 2. Eliminates redundant "Parse" methods. 3. Introduces |MatchType| bit field to simplify variant matching. 4. Consolidates |Match| method. 5. Renames |Add| and |GetFieldInfo| to |AddClassification| and |ClassifyField| respectively. 6. Move ECML logic into separate file. BUG=none TEST=Unit tests in autofill/*_field_unittest.cc. Review URL: http://codereview.chromium.org/7043027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86016 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/phone_field_unittest.cc')
-rw-r--r--chrome/browser/autofill/phone_field_unittest.cc25
1 files changed, 11 insertions, 14 deletions
diff --git a/chrome/browser/autofill/phone_field_unittest.cc b/chrome/browser/autofill/phone_field_unittest.cc
index d8cfba7..dac50cf 100644
--- a/chrome/browser/autofill/phone_field_unittest.cc
+++ b/chrome/browser/autofill/phone_field_unittest.cc
@@ -5,14 +5,13 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/utf_string_conversions.h"
+#include "chrome/browser/autofill/autofill_ecml.h"
#include "chrome/browser/autofill/autofill_field.h"
#include "chrome/browser/autofill/autofill_scanner.h"
#include "chrome/browser/autofill/phone_field.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/glue/form_field.h"
-namespace {
-
class PhoneFieldTest : public testing::Test {
public:
PhoneFieldTest() {}
@@ -52,7 +51,7 @@ TEST_F(PhoneFieldTest, ParseOneLinePhone) {
AutofillScanner scanner(list_.get());
field_.reset(PhoneField::Parse(&scanner, false));
ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get());
- ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
+ ASSERT_TRUE(field_->ClassifyField(&field_type_map_));
ASSERT_TRUE(
field_type_map_.find(ASCIIToUTF16("phone1")) != field_type_map_.end());
EXPECT_EQ(PHONE_HOME_WHOLE_NUMBER, field_type_map_[ASCIIToUTF16("phone1")]);
@@ -70,7 +69,7 @@ TEST_F(PhoneFieldTest, ParseOneLinePhoneEcml) {
AutofillScanner scanner(list_.get());
field_.reset(PhoneField::Parse(&scanner, true));
ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get());
- ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
+ ASSERT_TRUE(field_->ClassifyField(&field_type_map_));
ASSERT_TRUE(
field_type_map_.find(ASCIIToUTF16("phone1")) != field_type_map_.end());
EXPECT_EQ(PHONE_HOME_WHOLE_NUMBER, field_type_map_[ASCIIToUTF16("phone1")]);
@@ -96,7 +95,7 @@ TEST_F(PhoneFieldTest, ParseTwoLinePhone) {
AutofillScanner scanner(list_.get());
field_.reset(PhoneField::Parse(&scanner, false));
ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get());
- ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
+ ASSERT_TRUE(field_->ClassifyField(&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")]);
@@ -126,7 +125,7 @@ TEST_F(PhoneFieldTest, ParseTwoLinePhoneEcmlShipTo) {
AutofillScanner scanner(list_.get());
field_.reset(PhoneField::Parse(&scanner, false));
ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get());
- ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
+ ASSERT_TRUE(field_->ClassifyField(&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")]);
@@ -156,7 +155,7 @@ TEST_F(PhoneFieldTest, ParseTwoLinePhoneEcmlBillTo) {
AutofillScanner scanner(list_.get());
field_.reset(PhoneField::Parse(&scanner, false));
ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get());
- ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
+ ASSERT_TRUE(field_->ClassifyField(&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")]);
@@ -206,7 +205,7 @@ TEST_F(PhoneFieldTest, ThreePartPhoneNumber) {
AutofillScanner scanner(list_.get());
field_.reset(PhoneField::Parse(&scanner, false));
ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get());
- ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
+ ASSERT_TRUE(field_->ClassifyField(&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")]);
@@ -249,7 +248,7 @@ TEST_F(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix) {
AutofillScanner scanner(list_.get());
field_.reset(PhoneField::Parse(&scanner, false));
ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get());
- ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
+ ASSERT_TRUE(field_->ClassifyField(&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")]);
@@ -273,7 +272,7 @@ TEST_F(PhoneFieldTest, ParseOneLineFax) {
AutofillScanner scanner(list_.get());
field_.reset(PhoneField::Parse(&scanner, false));
ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get());
- ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
+ ASSERT_TRUE(field_->ClassifyField(&field_type_map_));
ASSERT_TRUE(
field_type_map_.find(ASCIIToUTF16("fax1")) != field_type_map_.end());
EXPECT_EQ(PHONE_FAX_WHOLE_NUMBER, field_type_map_[ASCIIToUTF16("fax1")]);
@@ -299,7 +298,7 @@ TEST_F(PhoneFieldTest, ParseTwoLineFax) {
AutofillScanner scanner(list_.get());
field_.reset(PhoneField::Parse(&scanner, false));
ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get());
- ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
+ ASSERT_TRUE(field_->ClassifyField(&field_type_map_));
ASSERT_TRUE(
field_type_map_.find(ASCIIToUTF16("areacode1")) != field_type_map_.end());
// It should be FAX, based on the other phone in the group.
@@ -337,7 +336,7 @@ TEST_F(PhoneFieldTest, ThreePartFaxNumberPrefixSuffix) {
AutofillScanner scanner(list_.get());
field_.reset(PhoneField::Parse(&scanner, false));
ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get());
- ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
+ ASSERT_TRUE(field_->ClassifyField(&field_type_map_));
ASSERT_TRUE(
field_type_map_.find(ASCIIToUTF16("areacode1")) != field_type_map_.end());
EXPECT_EQ(PHONE_FAX_CITY_CODE, field_type_map_[ASCIIToUTF16("areacode1")]);
@@ -348,5 +347,3 @@ TEST_F(PhoneFieldTest, ThreePartFaxNumberPrefixSuffix) {
field_type_map_.find(ASCIIToUTF16("suffix1")) != field_type_map_.end());
EXPECT_EQ(PHONE_FAX_NUMBER, field_type_map_[ASCIIToUTF16("suffix1")]);
}
-
-} // namespace