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

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

Issue 2842067: Fixes bug where PersonalDataManager wasn't setting unique_ids_ on (Closed)
Patch Set: Created 10 years, 5 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 7f61789fb6e65c995a459390b1094756f4aca040..8afb9e90fc905351aa753e4d3e25bf686a76c38b 100644
--- a/chrome/browser/autofill/personal_data_manager_unittest.cc
+++ b/chrome/browser/autofill/personal_data_manager_unittest.cc
@@ -334,6 +334,55 @@ TEST_F(PersonalDataManagerTest, SetProfilesAndCreditCards) {
EXPECT_EQ(4U, ids.size());
}
+// Test care for 50047. Makes sure that unique_ids_ is populated correctly on
+// load.
+TEST_F(PersonalDataManagerTest, PopulateUniqueIDsOnLoad) {
+ AutoFillProfile profile0(string16(), 0);
+ autofill_unittest::SetProfileInfo(&profile0,
+ "", "y", "", "", "", "", "", "", "", "", "", "", "", "");
+
+ // This will verify that the web database has been loaded and the notification
+ // sent out.
+ EXPECT_CALL(personal_data_observer_,
+ OnPersonalDataLoaded()).WillRepeatedly(QuitUIMessageLoop());
+
+ // The message loop will exit when the mock observer is notified.
+ MessageLoop::current()->Run();
+
+ // Add the profile0 to the db.
+ std::vector<AutoFillProfile> update;
+ update.push_back(profile0);
+ personal_data_->SetProfiles(&update);
+
+ // Reset the PersonalDataManager. This recreates PersonalDataManager, which
+ // should populate unique_ids_.
+ ResetPersonalDataManager();
+
+ // The message loop will exit when the PersonalDataLoadedObserver is notified.
+ MessageLoop::current()->Run();
+
+ // Verify that we've loaded the profiles from the web database.
+ const std::vector<AutoFillProfile*>& results2 = personal_data_->profiles();
+ ASSERT_EQ(1U, results2.size());
+
+ // Add a new profile.
+ AutoFillProfile profile1(string16(), 0);
+ autofill_unittest::SetProfileInfo(&profile1,
+ "", "y", "", "", "", "", "", "", "", "", "", "", "", "");
+ update.clear();
+ update.push_back(*results2[0]);
+ update.push_back(profile1);
+ personal_data_->SetProfiles(&update);
+
+ // Make sure the two profiles have different ids (and neither equal to 0,
+ // which is an invalid id).
+ const std::vector<AutoFillProfile*>& results3 = personal_data_->profiles();
+ ASSERT_EQ(2U, results3.size());
+ EXPECT_NE(results3[0]->unique_id(), results3[1]->unique_id());
+ EXPECT_NE(0, results3[0]->unique_id());
+ EXPECT_NE(0, results3[1]->unique_id());
+}
+
TEST_F(PersonalDataManagerTest, SetEmptyProfile) {
AutoFillProfile profile0(string16(), 0);
autofill_unittest::SetProfileInfo(&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