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

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

Issue 2088443002: Expand autofill profile merge logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months 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 6e5ad906afd6e561f365064626a68e26c0b33e1c..9912b26cca96fb9e0df9249a16eff2f4a2c61350 100644
--- a/components/autofill/core/browser/autofill_profile_comparator_unittest.cc
+++ b/components/autofill/core/browser/autofill_profile_comparator_unittest.cc
@@ -37,7 +37,7 @@ class AutofillProfileComparatorTest : public ::testing::Test {
typedef ::autofill::AutofillProfileComparator Super;
using Super::Super;
using Super::UniqueTokens;
- using Super::HaveSameTokens;
+ using Super::CompareTokens;
using Super::GetNamePartVariants;
using Super::IsNameVariantOf;
using Super::HaveMergeableNames;
@@ -45,6 +45,11 @@ class AutofillProfileComparatorTest : public ::testing::Test {
using Super::HaveMergeableCompanyNames;
using Super::HaveMergeablePhoneNumbers;
using Super::HaveMergeableAddresses;
+
+ using Super::DIFFERENT_TOKENS;
+ using Super::SAME_TOKENS;
+ using Super::S1_CONTAINS_S2;
+ using Super::S2_CONTAINS_S1;
};
AutofillProfileComparatorTest() : comparator_("en-US") {}
@@ -116,19 +121,27 @@ TEST_F(AutofillProfileComparatorTest, UniqueTokens) {
comparator_.UniqueTokens(kInput));
}
-TEST_F(AutofillProfileComparatorTest, HaveSameTokens) {
+TEST_F(AutofillProfileComparatorTest, CompareTokens) {
base::string16 kEmptyStr = UTF8ToUTF16("");
base::string16 kHello = UTF8ToUTF16("hello");
base::string16 kHelloThere = UTF8ToUTF16("hello there");
base::string16 kHelloThereAlice = UTF8ToUTF16("hello there alice");
base::string16 kHelloThereBob = UTF8ToUTF16("hello there bob");
- EXPECT_TRUE(comparator_.HaveSameTokens(kEmptyStr, kHello));
- EXPECT_TRUE(comparator_.HaveSameTokens(kHello, kEmptyStr));
- EXPECT_TRUE(comparator_.HaveSameTokens(kHelloThere, kHello));
- EXPECT_TRUE(comparator_.HaveSameTokens(kHello, kHelloThere));
- EXPECT_FALSE(comparator_.HaveSameTokens(kHelloThereAlice, kHelloThereBob));
- EXPECT_FALSE(comparator_.HaveSameTokens(kHelloThereBob, kHelloThereAlice));
+ EXPECT_EQ(AutofillProfileComparator::SAME_TOKENS,
+ comparator_.CompareTokens(kHelloThereBob, kHelloThereBob));
+ EXPECT_EQ(AutofillProfileComparator::S2_CONTAINS_S1,
+ comparator_.CompareTokens(kEmptyStr, kHello));
+ EXPECT_EQ(AutofillProfileComparator::S1_CONTAINS_S2,
+ comparator_.CompareTokens(kHello, kEmptyStr));
+ EXPECT_EQ(AutofillProfileComparator::S1_CONTAINS_S2,
+ comparator_.CompareTokens(kHelloThere, kHello));
+ EXPECT_EQ(AutofillProfileComparator::S2_CONTAINS_S1,
+ comparator_.CompareTokens(kHello, kHelloThere));
+ EXPECT_EQ(AutofillProfileComparator::DIFFERENT_TOKENS,
+ comparator_.CompareTokens(kHelloThereAlice, kHelloThereBob));
+ EXPECT_EQ(AutofillProfileComparator::DIFFERENT_TOKENS,
+ comparator_.CompareTokens(kHelloThereBob, kHelloThereAlice));
}
TEST_F(AutofillProfileComparatorTest, NormalizeForComparison) {
@@ -349,16 +362,17 @@ TEST_F(AutofillProfileComparatorTest, HaveMergeableAddresses) {
EXPECT_TRUE(comparator_.HaveMergeableAddresses(p1, empty));
EXPECT_TRUE(comparator_.HaveMergeableAddresses(empty, p2));
- EXPECT_TRUE(comparator_.HaveMergeableAddresses(p1, p2));
- EXPECT_TRUE(comparator_.HaveMergeableAddresses(p2, p1));
EXPECT_TRUE(comparator_.HaveMergeableAddresses(p1, p3));
EXPECT_TRUE(comparator_.HaveMergeableAddresses(p3, p1));
- // |p2| and |p3| don't match because without a "real" zip match, we can't
- // resolve the mismatched city/suburb names.
+ // |p2| matches neither |p1| nor |p3| because we can't resolve the mismatched
+ // city/suburb names.
+ EXPECT_FALSE(comparator_.HaveMergeableAddresses(p1, p2));
+ EXPECT_FALSE(comparator_.HaveMergeableAddresses(p2, p1));
EXPECT_FALSE(comparator_.HaveMergeableAddresses(p2, p3));
EXPECT_FALSE(comparator_.HaveMergeableAddresses(p3, p2));
+ // Changing things about |p1| causes its copies to stop being mergeable.
EXPECT_FALSE(comparator_.HaveMergeableAddresses(p1, differentCountry));
EXPECT_FALSE(comparator_.HaveMergeableAddresses(p1, differentZip));
EXPECT_FALSE(comparator_.HaveMergeableAddresses(p1, differentState));

Powered by Google App Engine
This is Rietveld 408576698