summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/autofill/personal_data_manager.cc2
-rw-r--r--chrome/browser/autofill/personal_data_manager_unittest.cc49
2 files changed, 51 insertions, 0 deletions
diff --git a/chrome/browser/autofill/personal_data_manager.cc b/chrome/browser/autofill/personal_data_manager.cc
index 61b47b7b..981c20b 100644
--- a/chrome/browser/autofill/personal_data_manager.cc
+++ b/chrome/browser/autofill/personal_data_manager.cc
@@ -523,6 +523,7 @@ void PersonalDataManager::ReceiveLoadedProfiles(WebDataService::Handle h,
for (std::vector<AutoFillProfile*>::iterator iter = profiles.begin();
iter != profiles.end(); ++iter) {
unique_profile_ids_.insert((*iter)->unique_id());
+ unique_ids_.insert((*iter)->unique_id());
web_profiles_.push_back(*iter);
}
}
@@ -543,6 +544,7 @@ void PersonalDataManager::ReceiveLoadedCreditCards(
for (std::vector<CreditCard*>::iterator iter = credit_cards.begin();
iter != credit_cards.end(); ++iter) {
unique_creditcard_ids_.insert((*iter)->unique_id());
+ unique_ids_.insert((*iter)->unique_id());
credit_cards_.push_back(*iter);
}
}
diff --git a/chrome/browser/autofill/personal_data_manager_unittest.cc b/chrome/browser/autofill/personal_data_manager_unittest.cc
index 7f61789..8afb9e9 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,