Index: chrome/browser/autofill/personal_data_manager_unittest.cc |
=================================================================== |
--- chrome/browser/autofill/personal_data_manager_unittest.cc (revision 71100) |
+++ chrome/browser/autofill/personal_data_manager_unittest.cc (working copy) |
@@ -280,6 +280,9 @@ |
EXPECT_EQ(creditcard0, *results2.at(0)); |
EXPECT_EQ(creditcard1, *results2.at(1)); |
+ // The message loop will exit when the mock observer is notified. |
+ MessageLoop::current()->Run(); |
+ |
// Determine uniqueness by inserting all of the GUIDs into a set and verifying |
// the size of the set matches the number of GUIDs. |
std::set<std::string> guids; |
@@ -323,13 +326,17 @@ |
// Add a new profile. |
AutoFillProfile profile1; |
+ // Need to be different from results2[0] by contents or it will be dropped. |
autofill_test::SetProfileInfo(&profile1, |
- "", "y", "", "", "", "", "", "", "", "", "", "", "", ""); |
+ "", "y", "1", "", "", "", "", "", "", "", "", "", "", ""); |
update.clear(); |
update.push_back(*results2[0]); |
update.push_back(profile1); |
personal_data_->SetProfiles(&update); |
+ // The message loop will exit when the PersonalDataLoadedObserver is notified. |
+ MessageLoop::current()->Run(); |
+ |
// 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(); |
@@ -1388,3 +1395,72 @@ |
ASSERT_EQ(1U, results2.size()); |
EXPECT_EQ(0, expected2.Compare(*results2[0])); |
} |
+ |
+TEST_F(PersonalDataManagerTest, CheckPresentData) { |
+ AutoFillProfile profile0; |
+ autofill_test::SetProfileInfo(&profile0, |
+ "Billing", "Marion", "Mitchell", "Morrison", |
+ "johnwayne@me.xyz", "", "123 Zoo St.", "unit 5", "Hollywood", "CA", |
+ "91601", "US", "12345678910", NULL); |
+ |
+ AutoFillProfile profile1; |
+ autofill_test::SetProfileInfo(&profile1, |
+ "Home", "Josephine", "Alicia", "Saenz", |
+ "joewayne@me.xyz", "Fox", "903 Apple Ct.", NULL, "Orlando", "FL", "32801", |
+ "US", "19482937549", NULL); |
+ |
+ AutoFillProfile profile2; |
+ autofill_test::SetProfileInfo(&profile2, |
+ "Home", "Jouhn", NULL, "Doe", |
+ "johm@me.xyz", NULL, NULL, NULL, NULL, NULL, NULL, |
+ "US", NULL, "13502849239"); |
+ |
+ CreditCard creditcard0; |
+ autofill_test::SetCreditCardInfo(&creditcard0, "Corporate", |
+ "John Dillinger", "423456789012" /* Visa */, "01", "2010"); |
+ |
+ CreditCard creditcard1; |
+ autofill_test::SetCreditCardInfo(&creditcard1, "Personal", |
+ "Bonnie Parker", "518765432109" /* Mastercard */, "12", "2012"); |
+ |
+ // This will verify that the web database has been loaded and the notification |
+ // sent out. |
+ EXPECT_CALL( |
+ personal_data_observer_, |
+ OnPersonalDataLoaded()).WillRepeatedly(QuitUIMessageLoop()); |
+ |
+ std::vector<AutoFillProfile> update; |
+ update.push_back(profile0); |
+ update.push_back(profile1); |
+ update.push_back(profile2); |
+ personal_data_->SetProfiles(&update); |
+ |
+ std::vector<CreditCard> update_cc; |
+ update_cc.push_back(creditcard0); |
+ update_cc.push_back(creditcard1); |
+ personal_data_->SetCreditCards(&update_cc); |
+ |
+ // The message loop will exit when the mock observer is notified. |
+ MessageLoop::current()->Run(); |
+ |
+ EXPECT_EQ("", personal_data_->PresentData(std::string(), std::string())); |
+ EXPECT_EQ("1f7e00037ef0", |
+ personal_data_->PresentData(profile0.guid(), std::string())); |
+ EXPECT_EQ("1f7e00027cf00008", |
+ personal_data_->PresentData(profile1.guid(), std::string())); |
+ EXPECT_EQ("15400f800810", |
+ personal_data_->PresentData(profile2.guid(), std::string())); |
+ EXPECT_EQ("0000000000001fc0", |
+ personal_data_->PresentData(std::string(), creditcard0.guid())); |
+ EXPECT_EQ("0000000000001fc0", |
+ personal_data_->PresentData(std::string(), creditcard1.guid())); |
+ EXPECT_EQ("1f7e00037ef01fc0", |
+ personal_data_->PresentData(profile0.guid(), creditcard0.guid())); |
+ EXPECT_EQ("1f7e00027cf01fc8", |
+ personal_data_->PresentData(profile1.guid(), creditcard0.guid())); |
+ EXPECT_EQ("15400f8008101fc0", |
+ personal_data_->PresentData(profile2.guid(), creditcard0.guid())); |
+ EXPECT_EQ("1f7e00037ef01fc0", |
+ personal_data_->PresentData(profile0.guid(), creditcard1.guid())); |
+} |
+ |