[Autofill] When comparing profiles, compare the full number, not just the local part.

BUG=163024
TEST=unit_tests --gtest_filter=AutofillProfileTest.Compare


Review URL: https://chromiumcodereview.appspot.com/11348264

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169944 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/autofill/autofill_profile.cc b/chrome/browser/autofill/autofill_profile.cc
index ff7356ca..5783760 100644
--- a/chrome/browser/autofill/autofill_profile.cc
+++ b/chrome/browser/autofill/autofill_profile.cc
@@ -426,7 +426,7 @@
                                                   NAME_MIDDLE,
                                                   NAME_LAST,
                                                   EMAIL_ADDRESS,
-                                                  PHONE_HOME_NUMBER };
+                                                  PHONE_HOME_WHOLE_NUMBER };
 
   for (size_t i = 0; i < arraysize(multi_value_types); ++i) {
     std::vector<string16> values_a;
diff --git a/chrome/browser/autofill/autofill_profile_unittest.cc b/chrome/browser/autofill/autofill_profile_unittest.cc
index 26f4de4..0fc822e3 100644
--- a/chrome/browser/autofill/autofill_profile_unittest.cc
+++ b/chrome/browser/autofill/autofill_profile_unittest.cc
@@ -578,6 +578,15 @@
       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
   EXPECT_GT(0, a.Compare(b));
   EXPECT_LT(0, b.Compare(a));
+
+  // Phone numbers are compared by the full number, including the area code.
+  // This is a regression test for http://crbug.com/163024
+  autofill_test::SetProfileInfo(&a, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, "650.555.4321");
+  autofill_test::SetProfileInfo(&b, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, "408.555.4321");
+  EXPECT_GT(0, a.Compare(b));
+  EXPECT_LT(0, b.Compare(a));
 }
 
 TEST(AutofillProfileTest, CountryCode) {
diff --git a/chrome/browser/autofill/personal_data_manager_unittest.cc b/chrome/browser/autofill/personal_data_manager_unittest.cc
index 3a7e8b07..6f64256 100644
--- a/chrome/browser/autofill/personal_data_manager_unittest.cc
+++ b/chrome/browser/autofill/personal_data_manager_unittest.cc
@@ -647,7 +647,7 @@
   AutofillProfile expected;
   autofill_test::SetProfileInfo(&expected, "George", NULL,
       "Washington", NULL, NULL, "21 Laussat St", NULL,
-      "San Francisco", "California", "94102", NULL, "6505550000");
+      "San Francisco", "California", "94102", NULL, "(650) 555-0000");
   const std::vector<AutofillProfile*>& results = personal_data_->profiles();
   ASSERT_EQ(1U, results.size());
   EXPECT_EQ(0, expected.Compare(*results[0]));
@@ -903,7 +903,6 @@
   autofill_test::CreateTestFormField(
       "Email:", "email", "[email protected]", "text", &field);
   form1.fields.push_back(field);
-  // Phone gets updated.
   autofill_test::CreateTestFormField(
       "Phone:", "phone", "6505556666", "text", &field);
   form1.fields.push_back(field);
@@ -921,9 +920,10 @@
   MessageLoop::current()->Run();
 
   AutofillProfile expected;
-  autofill_test::SetProfileInfo(&expected, "George", NULL,
-      "Washington", "[email protected]", NULL, "1600 Pennsylvania Avenue",
-      "Suite A", "San Francisco", "California", "94102", NULL, "4085556666");
+  autofill_test::SetProfileInfo(
+      &expected, "George", NULL, "Washington", "[email protected]", NULL,
+      "1600 Pennsylvania Avenue", "Suite A", "San Francisco", "California",
+      "94102", NULL, "(650) 555-6666");
   const std::vector<AutofillProfile*>& results1 = personal_data_->profiles();
   ASSERT_EQ(1U, results1.size());
   EXPECT_EQ(0, expected.Compare(*results1[0]));
@@ -979,7 +979,7 @@
   // Add multi-valued phone number to expectation.  Also, country gets added.
   std::vector<string16> values;
   expected.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values);
-  values.push_back(ASCIIToUTF16("6502231234"));
+  values.push_back(ASCIIToUTF16("(650) 223-1234"));
   expected.SetMultiInfo(PHONE_HOME_WHOLE_NUMBER, values);
   expected.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("United States"));
   ASSERT_EQ(1U, results2.size());
@@ -1918,7 +1918,7 @@
   AutofillProfile expected;
   autofill_test::SetProfileInfo(&expected, "George", NULL,
       "Washington", "[email protected]", NULL, "21 Laussat St", NULL,
-      "San Francisco", "California", "94102", NULL, "817-555-6789");
+      "San Francisco", "California", "94102", NULL, "(817) 555-6789");
   const std::vector<AutofillProfile*>& results1 = personal_data_->profiles();
   ASSERT_EQ(1U, results1.size());
   EXPECT_EQ(0, expected.Compare(*results1[0]));
@@ -1965,9 +1965,9 @@
 
   // Modify expected to include multi-valued fields.
   std::vector<string16> values;
-  expected.GetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, &values);
-  values.push_back(ASCIIToUTF16("214-555-1234"));
-  expected.SetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, values);
+  expected.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values);
+  values.push_back(ASCIIToUTF16("(214) 555-1234"));
+  expected.SetMultiInfo(PHONE_HOME_WHOLE_NUMBER, values);
 
   ASSERT_EQ(1U, results2.size());
   EXPECT_EQ(0, expected.Compare(*results2[0]));