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

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

Issue 2110563002: Use AutofillProfileComparator in place of ad-hoc merge logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@merge
Patch Set: Initial CL for review 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 11ec5f8be9f529fd0bd6af7f1d21f619d2019b13..4156c5c6df7890effe5f7a49e54c32f18e076e5b 100644
--- a/components/autofill/core/browser/autofill_profile_comparator_unittest.cc
+++ b/components/autofill/core/browser/autofill_profile_comparator_unittest.cc
@@ -289,6 +289,28 @@ TEST_F(AutofillProfileComparatorTest, NormalizeForComparison) {
EXPECT_EQ(UTF8ToUTF16("timothe noel etienne perier"),
comparator_.NormalizeForComparison(
UTF8ToUTF16("Timothé-Noël Étienne Périer")));
+ // NOP.
+ EXPECT_EQ(base::string16(),
+ comparator_.NormalizeForComparison(base::string16()));
+
+ // Simple punctuation removed.
+ EXPECT_EQ(UTF8ToUTF16("1600 amphitheatre pkwy"),
+ comparator_.NormalizeForComparison(
+ UTF8ToUTF16("1600 Amphitheatre, Pkwy.")));
+
+ // Unicode punctuation (hyphen and space), multiple spaces collapsed.
+ EXPECT_EQ(UTF8ToUTF16("mid island plaza"),
+ comparator_.NormalizeForComparison(
+ base::WideToUTF16(L"Mid\x2013Island\x2003 Plaza")));
+
+ // Newline character removed.
+ EXPECT_EQ(UTF8ToUTF16("1600 amphitheatre pkwy app 2"),
+ comparator_.NormalizeForComparison(
+ UTF8ToUTF16("1600 amphitheatre pkwy \n App. 2")));
+
+ // Diacritics removed.
+ EXPECT_EQ(UTF8ToUTF16("まeoa정"),
+ comparator_.NormalizeForComparison(UTF8ToUTF16("まéÖä정")));
}
TEST_F(AutofillProfileComparatorTest, GetNamePartVariants) {
@@ -511,7 +533,7 @@ TEST_F(AutofillProfileComparatorTest, HaveMergeableAddresses) {
EXPECT_FALSE(comparator_.HaveMergeableAddresses(p1, differentAddress));
}
-TEST_F(AutofillProfileComparatorTest, IsMergeable) {
+TEST_F(AutofillProfileComparatorTest, AreMergeable) {
AutofillProfile p1 = autofill::test::GetFullProfile();
AutofillProfile p1_mergeable = CopyAndModify(
p1, {{NAME_MIDDLE, "Herbert"}, // Originally "H."
@@ -524,6 +546,20 @@ TEST_F(AutofillProfileComparatorTest, IsMergeable) {
EXPECT_TRUE(comparator_.AreMergeable(p1, p1_mergeable));
EXPECT_FALSE(comparator_.AreMergeable(p1, p1_not_mergeable));
EXPECT_FALSE(comparator_.AreMergeable(p1, p2));
+
+ // Tests that two similar profiles with different punctuation and case are
+ // mergeable.
+ AutofillProfile profile1(base::GenerateGUID(), "https://www.example.com/");
sebsg 2016/06/29 08:57:03 This seems different that the previous test cases
Roger McFarlane (Chromium) 2016/06/29 18:21:37 Yeah, I moved this test case from AutofillProfileT
+ autofill::test::SetProfileInfo(&profile1, "Marion", "Mitchell", "Morrison",
+ "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5",
+ "Hollywood", "CA", "91601", "US", "+1 (234) 567-8910");
+
+ AutofillProfile profile2(base::GenerateGUID(), "https://www.example.com/");
+ autofill::test::SetProfileInfo(&profile2, "marion", "mitchell", "morrison",
+ "marion@me.xyz", "Fox", "123, Zoo St", "unit 5",
+ "hollywood", "CA", "91601-446", "US", "5678910 ext. 77");
+
+ EXPECT_TRUE(comparator_.AreMergeable(profile1, profile2));
}
TEST_F(AutofillProfileComparatorTest, MergeNames) {

Powered by Google App Engine
This is Rietveld 408576698