Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(493)

Unified Diff: components/autofill/core/browser/autofill_profile_comparator_unittest.cc

Issue 2493253002: [autofill] Add address comparison/merge logic for dependent locality and sorting codes (Closed)
Patch Set: fix try bots (redux) Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/autofill_profile_comparator_unittest.cc
diff --git a/components/autofill/core/browser/autofill_profile_comparator_unittest.cc b/components/autofill/core/browser/autofill_profile_comparator_unittest.cc
index bcd0274eb66126433f1e7381ea82becddfb389a8..36da4fdf765a50ecade966ae5ed874443eca27e3 100644
--- a/components/autofill/core/browser/autofill_profile_comparator_unittest.cc
+++ b/components/autofill/core/browser/autofill_profile_comparator_unittest.cc
@@ -16,9 +16,11 @@
// Field Type Constants
using autofill::ADDRESS_HOME_CITY;
using autofill::ADDRESS_HOME_COUNTRY;
+using autofill::ADDRESS_HOME_DEPENDENT_LOCALITY;
using autofill::ADDRESS_HOME_LINE1;
using autofill::ADDRESS_HOME_LINE2;
using autofill::ADDRESS_HOME_LINE3;
+using autofill::ADDRESS_HOME_SORTING_CODE;
using autofill::ADDRESS_HOME_STATE;
using autofill::ADDRESS_HOME_STREET_ADDRESS;
using autofill::ADDRESS_HOME_ZIP;
@@ -239,6 +241,13 @@ class AutofillProfileComparatorTest : public ::testing::Test {
EXPECT_EQ(
expected.GetInfo(AutofillType(ADDRESS_HOME_STREET_ADDRESS), kLocale),
actual.GetInfo(AutofillType(ADDRESS_HOME_STREET_ADDRESS), kLocale));
+ EXPECT_EQ(
+ expected.GetInfo(AutofillType(ADDRESS_HOME_DEPENDENT_LOCALITY),
+ kLocale),
+ actual.GetInfo(AutofillType(ADDRESS_HOME_DEPENDENT_LOCALITY), kLocale));
+ EXPECT_EQ(
+ expected.GetInfo(AutofillType(ADDRESS_HOME_SORTING_CODE), kLocale),
+ actual.GetInfo(AutofillType(ADDRESS_HOME_SORTING_CODE), kLocale));
EXPECT_EQ(expected.GetInfo(AutofillType(ADDRESS_HOME_CITY), kLocale),
actual.GetInfo(AutofillType(ADDRESS_HOME_CITY), kLocale));
EXPECT_EQ(expected.GetInfo(AutofillType(ADDRESS_HOME_STATE), kLocale),
@@ -518,10 +527,14 @@ TEST_F(AutofillProfileComparatorTest, HaveMergeableAddresses) {
AutofillProfile empty = CreateProfileWithAddress("", "", "", "", "", "");
AutofillProfile p1 = CreateProfileWithAddress(
"1 Some Street", "Unit 3", "Carver", "CA - California", "90210", "US");
+ p1.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, UTF8ToUTF16("Some String"));
+ p1.SetRawInfo(ADDRESS_HOME_SORTING_CODE, UTF8ToUTF16("64205 Biarritz CEDEX"));
+
AutofillProfile p2 = CreateProfileWithAddress(
"Unit 3", "1 Some Street", "Suburb", "california", "90 210-3214", "");
AutofillProfile p3 = CreateProfileWithAddress("1 Some Street #3", "",
"Carver City", "ca", "", "us");
+
AutofillProfile differentCountry =
CopyAndModify(p1, {{ADDRESS_HOME_COUNTRY, "CA"}});
AutofillProfile differentZip =
@@ -533,6 +546,10 @@ TEST_F(AutofillProfileComparatorTest, HaveMergeableAddresses) {
AutofillProfile differentAddress =
CopyAndModify(p1, {{ADDRESS_HOME_LINE1, "17 Park Lane"},
{ADDRESS_HOME_LINE2, "Suite 150"}});
+ AutofillProfile differentLocality =
+ CopyAndModify(p1, {{ADDRESS_HOME_DEPENDENT_LOCALITY, "Funky Chicken"}});
+ AutofillProfile differentSortingCode =
+ CopyAndModify(p1, {{ADDRESS_HOME_SORTING_CODE, "98000 Monaco"}});
EXPECT_TRUE(comparator_.HaveMergeableAddresses(p1, empty));
EXPECT_TRUE(comparator_.HaveMergeableAddresses(empty, p2));
@@ -553,6 +570,8 @@ TEST_F(AutofillProfileComparatorTest, HaveMergeableAddresses) {
EXPECT_FALSE(comparator_.HaveMergeableAddresses(p1, differentState));
EXPECT_FALSE(comparator_.HaveMergeableAddresses(p1, differentCity));
EXPECT_FALSE(comparator_.HaveMergeableAddresses(p1, differentAddress));
+ EXPECT_FALSE(comparator_.HaveMergeableAddresses(p1, differentLocality));
+ EXPECT_FALSE(comparator_.HaveMergeableAddresses(p1, differentSortingCode));
}
TEST_F(AutofillProfileComparatorTest, AreMergeable) {
@@ -902,7 +921,6 @@ TEST_F(AutofillProfileComparatorTest, MergePhoneNumbers_Intl) {
}
TEST_F(AutofillProfileComparatorTest, MergeAddresses) {
- AutofillProfile empty;
AutofillProfile p1 = CreateProfileWithAddress(
"1 Some Street", "Unit 3", "Carver", "CA - California", "90210", "US");
AutofillProfile p2 = CreateProfileWithAddress(
@@ -919,8 +937,25 @@ TEST_F(AutofillProfileComparatorTest, MergeAddresses) {
MergeAddressesAndExpect(p1, p2, expected);
}
+TEST_F(AutofillProfileComparatorTest, MergeAddressesMostUniqueTokens) {
Roger McFarlane (Chromium) 2016/11/21 18:39:51 Added this test to validate the bug fix for the ad
sebsg 2016/11/21 18:48:45 Acknowledged.
+ AutofillProfile p1 = CreateProfileWithAddress(
+ "1 Some Street", "Unit 3", "Carver", "CA - California", "90210", "US");
+ AutofillProfile p2 = CreateProfileWithAddress(
+ "1 Some Other Street", "Unit 3", "Carver City", "ca", "90210-1234", "us");
+
+ Address expected;
+ expected.SetRawInfo(ADDRESS_HOME_LINE1, UTF8ToUTF16("1 Some Other Street"));
+ expected.SetRawInfo(ADDRESS_HOME_LINE2, UTF8ToUTF16("Unit 3"));
+ expected.SetRawInfo(ADDRESS_HOME_CITY, UTF8ToUTF16("Carver City"));
+ expected.SetRawInfo(ADDRESS_HOME_STATE, UTF8ToUTF16("ca"));
+ expected.SetRawInfo(ADDRESS_HOME_ZIP, UTF8ToUTF16("90210-1234"));
+ expected.SetRawInfo(ADDRESS_HOME_COUNTRY, UTF8ToUTF16("US"));
+
+ MergeAddressesAndExpect(p1, p2, expected);
+ MergeAddressesAndExpect(p2, p1, expected);
+}
+
TEST_F(AutofillProfileComparatorTest, MergeAddressesWithRewrite) {
- AutofillProfile empty;
AutofillProfile p1 = CreateProfileWithAddress(
"6543 CH BACON", "APP 3", "MONTRÉAL", "QUÉBEC", "HHH999", "ca");
AutofillProfile p2 = CreateProfileWithAddress(
@@ -936,4 +971,34 @@ TEST_F(AutofillProfileComparatorTest, MergeAddressesWithRewrite) {
expected.SetRawInfo(ADDRESS_HOME_COUNTRY, UTF8ToUTF16("CA"));
MergeAddressesAndExpect(p1, p2, expected);
+ MergeAddressesAndExpect(p2, p1, expected);
+}
+
+TEST_F(AutofillProfileComparatorTest,
+ MergeAddressesDependendLocalityAndSortingCode) {
+ AutofillProfile p1 = CreateProfileWithAddress(
+ "6543 CH BACON", "APP 3", "MONTRÉAL", "QUÉBEC", "HHH999", "ca");
+ p1.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, UTF8ToUTF16("Some String"));
+ p1.SetRawInfo(ADDRESS_HOME_SORTING_CODE, UTF8ToUTF16("64205 Biarritz CEDEX"));
+ AutofillProfile p2 = CreateProfileWithAddress(
+ "6543, Bacon Rd", "", "Montreal", "QC", "hhh 999", "CA");
+ p2.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY,
+ UTF8ToUTF16("Some Other String"));
+ p2.SetRawInfo(ADDRESS_HOME_SORTING_CODE, UTF8ToUTF16("64205 Biarritz"));
+ p2.set_use_date(p1.use_date() + base::TimeDelta::FromMinutes(1));
+
+ Address expected;
+ expected.SetRawInfo(ADDRESS_HOME_LINE1, UTF8ToUTF16("6543 CH BACON"));
+ expected.SetRawInfo(ADDRESS_HOME_LINE2, UTF8ToUTF16("APP 3"));
+ expected.SetRawInfo(ADDRESS_HOME_CITY, UTF8ToUTF16("Montreal"));
+ expected.SetRawInfo(ADDRESS_HOME_STATE, UTF8ToUTF16("QC"));
+ expected.SetRawInfo(ADDRESS_HOME_ZIP, UTF8ToUTF16("hhh 999"));
+ expected.SetRawInfo(ADDRESS_HOME_COUNTRY, UTF8ToUTF16("CA"));
+ expected.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY,
+ UTF8ToUTF16("Some Other String"));
+ expected.SetRawInfo(ADDRESS_HOME_SORTING_CODE,
+ UTF8ToUTF16("64205 Biarritz")); // Preferred by use date.
+
+ MergeAddressesAndExpect(p1, p2, expected);
+ MergeAddressesAndExpect(p2, p1, expected);
}

Powered by Google App Engine
This is Rietveld 408576698