summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill
diff options
context:
space:
mode:
authorisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-28 15:16:13 +0000
committerisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-28 15:16:13 +0000
commit5c0208c074a66e9dd43b9e4aca16ed7132f1da6c (patch)
treef4307e48700e93579506613aff3f6eb0d9efdf4f /chrome/browser/autofill
parent64253c04e20b156bd0d337c41527f167057ebbb8 (diff)
downloadchromium_src-5c0208c074a66e9dd43b9e4aca16ed7132f1da6c.zip
chromium_src-5c0208c074a66e9dd43b9e4aca16ed7132f1da6c.tar.gz
chromium_src-5c0208c074a66e9dd43b9e4aca16ed7132f1da6c.tar.bz2
[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
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r--chrome/browser/autofill/autofill_profile.cc2
-rw-r--r--chrome/browser/autofill/autofill_profile_unittest.cc9
-rw-r--r--chrome/browser/autofill/personal_data_manager_unittest.cc20
3 files changed, 20 insertions, 11 deletions
diff --git a/chrome/browser/autofill/autofill_profile.cc b/chrome/browser/autofill/autofill_profile.cc
index ff7356c..5783760 100644
--- a/chrome/browser/autofill/autofill_profile.cc
+++ b/chrome/browser/autofill/autofill_profile.cc
@@ -426,7 +426,7 @@ int AutofillProfile::Compare(const AutofillProfile& profile) const {
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..0fc822e 100644
--- a/chrome/browser/autofill/autofill_profile_unittest.cc
+++ b/chrome/browser/autofill/autofill_profile_unittest.cc
@@ -578,6 +578,15 @@ TEST(AutofillProfileTest, Compare) {
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 3a7e8b0..6f64256 100644
--- a/chrome/browser/autofill/personal_data_manager_unittest.cc
+++ b/chrome/browser/autofill/personal_data_manager_unittest.cc
@@ -647,7 +647,7 @@ TEST_F(PersonalDataManagerTest, ImportPhoneNumberSplitAcrossMultipleFields) {
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 @@ TEST_F(PersonalDataManagerTest, AggregateSameProfileWithConflict) {
autofill_test::CreateTestFormField(
"Email:", "email", "theprez@gmail.com", "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 @@ TEST_F(PersonalDataManagerTest, AggregateSameProfileWithConflict) {
MessageLoop::current()->Run();
AutofillProfile expected;
- autofill_test::SetProfileInfo(&expected, "George", NULL,
- "Washington", "theprez@gmail.com", NULL, "1600 Pennsylvania Avenue",
- "Suite A", "San Francisco", "California", "94102", NULL, "4085556666");
+ autofill_test::SetProfileInfo(
+ &expected, "George", NULL, "Washington", "theprez@gmail.com", 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 @@ TEST_F(PersonalDataManagerTest, AggregateSameProfileWithConflict) {
// 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 @@ TEST_F(PersonalDataManagerTest, CaseInsensitiveMultiValueAggregation) {
AutofillProfile expected;
autofill_test::SetProfileInfo(&expected, "George", NULL,
"Washington", "theprez@gmail.com", 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 @@ TEST_F(PersonalDataManagerTest, CaseInsensitiveMultiValueAggregation) {
// 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]));