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

Unified Diff: chrome/browser/autofill/personal_data_manager_unittest.cc

Issue 6903091: Autofill Multi-Value: Additional profiles with same name and address not added to DOM UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address nits. Created 9 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 | « chrome/browser/autofill/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: chrome/browser/autofill/personal_data_manager_unittest.cc
diff --git a/chrome/browser/autofill/personal_data_manager_unittest.cc b/chrome/browser/autofill/personal_data_manager_unittest.cc
index 4c031b6d41ab29885eac16e39eeea34e4c33c444..458f0e5cea4173541ca53e3e49c9309fe2db433b 100644
--- a/chrome/browser/autofill/personal_data_manager_unittest.cc
+++ b/chrome/browser/autofill/personal_data_manager_unittest.cc
@@ -87,6 +87,74 @@ class PersonalDataManagerTest : public testing::Test {
PersonalDataLoadedObserverMock personal_data_observer_;
};
+TEST_F(PersonalDataManagerTest, AddProfile) {
+ // This will verify that the web database has been loaded and the notification
+ // sent out.
+ EXPECT_CALL(personal_data_observer_,
+ OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop());
+
+ // The message loop will exit when the mock observer is notified.
+ MessageLoop::current()->Run();
+
+ AutofillProfile profile0;
+ autofill_test::SetProfileInfo(&profile0,
+ "John", "Mitchell", "Smith",
+ "j@s.com", "Acme Inc.", "1 Main", "Apt A", "San Francisco", "CA",
+ "94102", "USA", "4158889999", "4152223333");
+
+ // Add profile0 to the database.
+ personal_data_->AddProfile(profile0);
+
+ // Reload the database.
+ ResetPersonalDataManager();
+ EXPECT_CALL(personal_data_observer_,
+ OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop());
+ MessageLoop::current()->Run();
+
+ // Verify the addition.
+ const std::vector<AutofillProfile*>& results1 = personal_data_->profiles();
+ ASSERT_EQ(1U, results1.size());
+ EXPECT_EQ(0, profile0.CompareMulti(*results1.at(0)));
+
+ // Add profile with identical values. Duplicates should not get saved.
+ AutofillProfile profile0a = profile0;
+ profile0a.set_guid(guid::GenerateGUID());
+ personal_data_->AddProfile(profile0a);
+
+ // Reload the database.
+ ResetPersonalDataManager();
+ EXPECT_CALL(personal_data_observer_,
+ OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop());
+ MessageLoop::current()->Run();
+
+ // Verify the non-addition.
+ const std::vector<AutofillProfile*>& results2 = personal_data_->profiles();
+ ASSERT_EQ(1U, results2.size());
+ EXPECT_EQ(0, profile0.CompareMulti(*results2.at(0)));
+
+ // New profile with different email.
+ AutofillProfile profile1 = profile0;
+ profile1.set_guid(guid::GenerateGUID());
+ profile1.SetInfo(EMAIL_ADDRESS, ASCIIToUTF16("john@smith.com"));
+
+ // Add the different profile. This should save as a separate profile.
+ // Note that if this same profile was "merged" it would collapse to one
+ // profile with a multi-valued entry for email.
+ personal_data_->AddProfile(profile1);
+
+ // Reload the database.
+ ResetPersonalDataManager();
+ EXPECT_CALL(personal_data_observer_,
+ OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop());
+ MessageLoop::current()->Run();
+
+ // Verify the addition.
+ const std::vector<AutofillProfile*>& results3 = personal_data_->profiles();
+ ASSERT_EQ(2U, results3.size());
+ EXPECT_EQ(0, profile0.CompareMulti(*results3.at(0)));
+ EXPECT_EQ(0, profile1.CompareMulti(*results3.at(1)));
+}
+
// TODO(jhawkins): Test SetProfiles w/out a WebDataService in the profile.
TEST_F(PersonalDataManagerTest, SetProfiles) {
AutofillProfile profile0;
« no previous file with comments | « chrome/browser/autofill/personal_data_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698