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

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

Issue 969103003: Don't save duplicates of wallet addresses to local Autofill. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make test work Created 5 years, 10 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/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 5955670e45af1c6ffef1dc67ab177441a787f97a..ae899cc87956fe833a9cfc8903ff845593efef4f 100644
--- a/components/autofill/core/browser/personal_data_manager_unittest.cc
+++ b/components/autofill/core/browser/personal_data_manager_unittest.cc
@@ -185,6 +185,45 @@ TEST_F(PersonalDataManagerTest, AddProfile) {
ExpectSameElements(profiles, personal_data_->GetProfiles());
}
+TEST_F(PersonalDataManagerTest, DontDuplicateServerProfile) {
+ EnableWalletCardImport();
+
+ std::vector<AutofillProfile> server_profiles;
+ server_profiles.push_back(
+ AutofillProfile(AutofillProfile::SERVER_PROFILE, "a123"));
+ test::SetProfileInfo(&server_profiles.back(), "John", "", "Doe", "",
+ "ACME Corp", "500 Oak View", "Apt 8", "Houston", "TX",
+ "77401", "US", "");
+ // Wallet only provides a full name, so the above first and last names
+ // will be ignored when the profile is written to the DB.
+ server_profiles.back().SetRawInfo(NAME_FULL, ASCIIToUTF16("John Doe"));
+ autofill_table_->SetServerProfiles(server_profiles);
+ personal_data_->Refresh();
+ EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
+ .WillOnce(QuitMainMessageLoop());
+ base::MessageLoop::current()->Run();
+ EXPECT_EQ(1U, personal_data_->GetProfiles().size());
+
+ // Add profile with identical values. Duplicates should not get saved.
+ AutofillProfile scraped_profile(base::GenerateGUID(),
+ "https://www.example.com");
+ test::SetProfileInfo(&scraped_profile, "John", "", "Doe", "", "ACME Corp",
+ "500 Oak View", "Apt 8", "Houston", "TX", "77401", "US",
+ "");
+ EXPECT_TRUE(scraped_profile.IsSubsetOf(server_profiles.back(), "en-US"));
+ std::string saved_guid = personal_data_->SaveImportedProfile(scraped_profile);
+ EXPECT_NE(scraped_profile.guid(), saved_guid);
+
+ personal_data_->Refresh();
+ EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
+ .WillOnce(QuitMainMessageLoop());
+ base::MessageLoop::current()->Run();
+
+ // Verify the non-addition.
+ EXPECT_EQ(1U, personal_data_->GetProfiles().size());
+ EXPECT_EQ(0U, personal_data_->web_profiles().size());
+}
+
TEST_F(PersonalDataManagerTest, AddUpdateRemoveProfiles) {
AutofillProfile profile0(base::GenerateGUID(), "https://www.example.com");
test::SetProfileInfo(&profile0,
« no previous file with comments | « components/autofill/core/browser/personal_data_manager.cc ('k') | components/autofill/core/browser/webdata/autofill_table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698