summaryrefslogtreecommitdiffstats
path: root/chrome/browser/webdata/web_data_service_unittest.cc
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-13 19:27:34 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-13 19:27:34 +0000
commit7ca1290d1f65a364626d737bfabed3fcd0a83dbb (patch)
tree848f8ebfab65f3696e5fed19565853c32e73c740 /chrome/browser/webdata/web_data_service_unittest.cc
parent995f4838a7642620daf0e2797b5364a7d06dc336 (diff)
downloadchromium_src-7ca1290d1f65a364626d737bfabed3fcd0a83dbb.zip
chromium_src-7ca1290d1f65a364626d737bfabed3fcd0a83dbb.tar.gz
chromium_src-7ca1290d1f65a364626d737bfabed3fcd0a83dbb.tar.bz2
Sync: Delete Autofill profiles through [Clear saved Autofill form data] does not sync
Adds notifications to batch delete of Autofill profiles and credit cards. BUG=79086 TEST=WebDataServiceAutofillTest.*:AutofillTableTest.* Review URL: http://codereview.chromium.org/6839010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81455 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/webdata/web_data_service_unittest.cc')
-rw-r--r--chrome/browser/webdata/web_data_service_unittest.cc82
1 files changed, 82 insertions, 0 deletions
diff --git a/chrome/browser/webdata/web_data_service_unittest.cc b/chrome/browser/webdata/web_data_service_unittest.cc
index 00d9049..da66435 100644
--- a/chrome/browser/webdata/web_data_service_unittest.cc
+++ b/chrome/browser/webdata/web_data_service_unittest.cc
@@ -491,3 +491,85 @@ TEST_F(WebDataServiceAutofillTest, CreditUpdate) {
EXPECT_EQ(card2, *consumer2.result()[1]);
STLDeleteElements(&consumer2.result());
}
+
+TEST_F(WebDataServiceAutofillTest, AutofillRemoveModifiedBetween) {
+ // Add a profile.
+ EXPECT_CALL(*observer_helper_->observer(), Observe(_, _, _)).
+ Times(1).
+ WillOnce(SignalEvent(&done_event_));
+ AutofillProfile profile;
+ wds_->AddAutofillProfile(profile);
+ done_event_.TimedWait(test_timeout_);
+
+ // Check that it was added.
+ AutofillWebDataServiceConsumer<std::vector<AutofillProfile*> >
+ profile_consumer;
+ WebDataService::Handle handle = wds_->GetAutofillProfiles(&profile_consumer);
+ MessageLoop::current()->Run();
+ EXPECT_EQ(handle, profile_consumer.handle());
+ ASSERT_EQ(1U, profile_consumer.result().size());
+ EXPECT_EQ(profile, *profile_consumer.result()[0]);
+ STLDeleteElements(&profile_consumer.result());
+
+ // Add a credit card.
+ EXPECT_CALL(*observer_helper_->observer(), Observe(_, _, _)).
+ WillOnce(SignalEvent(&done_event_));
+ CreditCard credit_card;
+ wds_->AddCreditCard(credit_card);
+ done_event_.TimedWait(test_timeout_);
+
+ // Check that it was added.
+ AutofillWebDataServiceConsumer<std::vector<CreditCard*> >
+ card_consumer;
+ handle = wds_->GetCreditCards(&card_consumer);
+ MessageLoop::current()->Run();
+ EXPECT_EQ(handle, card_consumer.handle());
+ ASSERT_EQ(1U, card_consumer.result().size());
+ EXPECT_EQ(credit_card, *card_consumer.result()[0]);
+ STLDeleteElements(&card_consumer.result());
+
+ // Check that GUID-based notification was sent for the profile.
+ const AutofillProfileChange expected_profile_change(
+ AutofillProfileChange::REMOVE, profile.guid(), NULL);
+ EXPECT_CALL(
+ *observer_helper_->observer(),
+ Observe(NotificationType(NotificationType::AUTOFILL_PROFILE_CHANGED),
+ Source<WebDataService>(wds_.get()),
+ Property(&Details<const AutofillProfileChange>::ptr,
+ Pointee(expected_profile_change)))).
+ WillOnce(SignalEvent(&done_event_));
+
+ // Check that GUID-based notification was sent for the credit card.
+ const AutofillCreditCardChange expected_card_change(
+ AutofillCreditCardChange::REMOVE, credit_card.guid(), NULL);
+ EXPECT_CALL(
+ *observer_helper_->observer(),
+ Observe(
+ NotificationType(NotificationType::AUTOFILL_CREDIT_CARD_CHANGED),
+ Source<WebDataService>(wds_.get()),
+ Property(&Details<const AutofillCreditCardChange>::ptr,
+ Pointee(expected_card_change)))).
+ WillOnce(SignalEvent(&done_event_));
+
+ // Remove the profile using time range of "all time".
+ wds_->RemoveAutofillProfilesAndCreditCardsModifiedBetween(Time(), Time());
+ done_event_.TimedWait(test_timeout_);
+ done_event_.TimedWait(test_timeout_);
+
+ // Check that the profile was removed.
+ AutofillWebDataServiceConsumer<std::vector<AutofillProfile*> >
+ profile_consumer2;
+ WebDataService::Handle handle2 =
+ wds_->GetAutofillProfiles(&profile_consumer2);
+ MessageLoop::current()->Run();
+ EXPECT_EQ(handle2, profile_consumer2.handle());
+ ASSERT_EQ(0U, profile_consumer2.result().size());
+
+ // Check that the credit card was removed.
+ AutofillWebDataServiceConsumer<std::vector<CreditCard*> >
+ card_consumer2;
+ handle2 = wds_->GetCreditCards(&card_consumer2);
+ MessageLoop::current()->Run();
+ EXPECT_EQ(handle2, card_consumer2.handle());
+ ASSERT_EQ(0U, card_consumer2.result().size());
+}