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

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

Issue 1943853003: [Autofill] Sort existing profiles by frecency before trying to merge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « components/autofill/core/browser/personal_data_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/personal_data_manager_unittest.cc
diff --git a/components/autofill/core/browser/personal_data_manager_unittest.cc b/components/autofill/core/browser/personal_data_manager_unittest.cc
index f229534bf99248920e8747c0f625a4830b490302..5b6028604de0f69420507d9d0ac62c69c20f9c0d 100644
--- a/components/autofill/core/browser/personal_data_manager_unittest.cc
+++ b/components/autofill/core/browser/personal_data_manager_unittest.cc
@@ -4161,4 +4161,41 @@ TEST_F(PersonalDataManagerTest, SaveImportedProfile) {
}
}
+// Tests that MergeProfile tries to merge the imported profile into the
+// existing profile in decreasing order of frecency.
+TEST_F(PersonalDataManagerTest, MergeProfile_Frecency) {
+ // Create two very similar profiles except with different company names.
+ AutofillProfile profile1(base::GenerateGUID(), "https://www.example.com");
+ test::SetProfileInfo(&profile1, "Homer", "Jay", "Simpson",
+ "homer.simpson@abc.com", "SNP", "742 Evergreen Terrace",
+ "", "Springfield", "IL", "91601", "US", "12345678910");
+ AutofillProfile profile2(base::GenerateGUID(), "https://www.example.com");
+ test::SetProfileInfo(&profile2, "Homer", "Jay", "Simpson",
+ "homer.simpson@abc.com", "Fox", "742 Evergreen Terrace",
+ "", "Springfield", "IL", "91601", "US", "12345678910");
+
+ // Give the "Fox" profile a bigger frecency score.
+ profile2.set_use_count(15);
+
+ // Create the |existing_profiles| vector.
+ std::vector<AutofillProfile*> existing_profiles;
+ existing_profiles.push_back(&profile1);
+ existing_profiles.push_back(&profile2);
+
+ // Create a new imported profile with no company name.
+ AutofillProfile imported_profile(base::GenerateGUID(),
+ "https://www.example.com");
+ test::SetProfileInfo(&imported_profile, "Homer", "Jay", "Simpson",
+ "homer.simpson@abc.com", "", "742 Evergreen Terrace", "",
+ "Springfield", "IL", "91601", "US", "12345678910");
+
+ // Merge the imported profile into the existing profiles.
+ std::vector<AutofillProfile> profiles;
+ std::string guid = personal_data_->MergeProfile(
+ imported_profile, existing_profiles, "US-EN", &profiles);
+
+ // The new profile should be merged into the "fox" profile.
+ EXPECT_EQ(profile2.guid(), guid);
+}
+
} // namespace autofill
« no previous file with comments | « components/autofill/core/browser/personal_data_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698