OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 *observer_helper_->observer(), | 217 *observer_helper_->observer(), |
218 Observe(NotificationType(NotificationType::AUTOFILL_ENTRIES_CHANGED), | 218 Observe(NotificationType(NotificationType::AUTOFILL_ENTRIES_CHANGED), |
219 NotificationService::AllSources(), | 219 NotificationService::AllSources(), |
220 Property(&Details<const AutofillChangeList>::ptr, | 220 Property(&Details<const AutofillChangeList>::ptr, |
221 Pointee(ElementsAreArray(expected_changes))))). | 221 Pointee(ElementsAreArray(expected_changes))))). |
222 WillOnce(SignalEvent(&done_event_)); | 222 WillOnce(SignalEvent(&done_event_)); |
223 | 223 |
224 std::vector<webkit_glue::FormField> form_fields; | 224 std::vector<webkit_glue::FormField> form_fields; |
225 AppendFormField(name1_, value1_, &form_fields); | 225 AppendFormField(name1_, value1_, &form_fields); |
226 AppendFormField(name2_, value2_, &form_fields); | 226 AppendFormField(name2_, value2_, &form_fields); |
227 wds_->AddFormFieldValues(form_fields); | 227 wds_->AddFormFields(form_fields); |
228 | 228 |
229 // The event will be signaled when the mock observer is notified. | 229 // The event will be signaled when the mock observer is notified. |
230 done_event_.TimedWait(test_timeout_); | 230 done_event_.TimedWait(test_timeout_); |
231 | 231 |
232 AutofillWebDataServiceConsumer consumer; | 232 AutofillWebDataServiceConsumer consumer; |
233 WebDataService::Handle handle; | 233 WebDataService::Handle handle; |
234 static const int limit = 10; | 234 static const int limit = 10; |
235 handle = wds_->GetFormValuesForElementName( | 235 handle = wds_->GetFormValuesForElementName( |
236 name1_, string16(), limit, &consumer); | 236 name1_, string16(), limit, &consumer); |
237 | 237 |
238 // The message loop will exit when the consumer is called. | 238 // The message loop will exit when the consumer is called. |
239 MessageLoop::current()->Run(); | 239 MessageLoop::current()->Run(); |
240 | 240 |
241 EXPECT_EQ(handle, consumer.handle()); | 241 EXPECT_EQ(handle, consumer.handle()); |
242 ASSERT_EQ(1U, consumer.values().size()); | 242 ASSERT_EQ(1U, consumer.values().size()); |
243 EXPECT_EQ(value1_, consumer.values()[0]); | 243 EXPECT_EQ(value1_, consumer.values()[0]); |
244 } | 244 } |
245 | 245 |
246 TEST_F(WebDataServiceAutofillTest, FormFillRemoveOne) { | 246 TEST_F(WebDataServiceAutofillTest, FormFillRemoveOne) { |
247 // First add some values to autofill. | 247 // First add some values to autofill. |
248 EXPECT_CALL(*observer_helper_->observer(), Observe(_, _, _)). | 248 EXPECT_CALL(*observer_helper_->observer(), Observe(_, _, _)). |
249 WillOnce(SignalEvent(&done_event_)); | 249 WillOnce(SignalEvent(&done_event_)); |
250 std::vector<webkit_glue::FormField> form_fields; | 250 std::vector<webkit_glue::FormField> form_fields; |
251 AppendFormField(name1_, value1_, &form_fields); | 251 AppendFormField(name1_, value1_, &form_fields); |
252 wds_->AddFormFieldValues(form_fields); | 252 wds_->AddFormFields(form_fields); |
253 | 253 |
254 // The event will be signaled when the mock observer is notified. | 254 // The event will be signaled when the mock observer is notified. |
255 done_event_.TimedWait(test_timeout_); | 255 done_event_.TimedWait(test_timeout_); |
256 | 256 |
257 // This will verify that the correct notification is triggered, | 257 // This will verify that the correct notification is triggered, |
258 // passing the correct list of autofill keys in the details. | 258 // passing the correct list of autofill keys in the details. |
259 const AutofillChange expected_changes[] = { | 259 const AutofillChange expected_changes[] = { |
260 AutofillChange(AutofillChange::REMOVE, AutofillKey(name1_, value1_)) | 260 AutofillChange(AutofillChange::REMOVE, AutofillKey(name1_, value1_)) |
261 }; | 261 }; |
262 EXPECT_CALL( | 262 EXPECT_CALL( |
(...skipping 11 matching lines...) Expand all Loading... |
274 | 274 |
275 TEST_F(WebDataServiceAutofillTest,FormFillRemoveMany) { | 275 TEST_F(WebDataServiceAutofillTest,FormFillRemoveMany) { |
276 TimeDelta one_day(TimeDelta::FromDays(1)); | 276 TimeDelta one_day(TimeDelta::FromDays(1)); |
277 Time t = Time::Now(); | 277 Time t = Time::Now(); |
278 | 278 |
279 EXPECT_CALL(*observer_helper_->observer(), Observe(_, _, _)). | 279 EXPECT_CALL(*observer_helper_->observer(), Observe(_, _, _)). |
280 WillOnce(SignalEvent(&done_event_)); | 280 WillOnce(SignalEvent(&done_event_)); |
281 std::vector<webkit_glue::FormField> form_fields; | 281 std::vector<webkit_glue::FormField> form_fields; |
282 AppendFormField(name1_, value1_, &form_fields); | 282 AppendFormField(name1_, value1_, &form_fields); |
283 AppendFormField(name2_, value2_, &form_fields); | 283 AppendFormField(name2_, value2_, &form_fields); |
284 wds_->AddFormFieldValues(form_fields); | 284 wds_->AddFormFields(form_fields); |
285 | 285 |
286 // The event will be signaled when the mock observer is notified. | 286 // The event will be signaled when the mock observer is notified. |
287 done_event_.TimedWait(test_timeout_); | 287 done_event_.TimedWait(test_timeout_); |
288 | 288 |
289 // This will verify that the correct notification is triggered, | 289 // This will verify that the correct notification is triggered, |
290 // passing the correct list of autofill keys in the details. | 290 // passing the correct list of autofill keys in the details. |
291 const AutofillChange expected_changes[] = { | 291 const AutofillChange expected_changes[] = { |
292 AutofillChange(AutofillChange::REMOVE, AutofillKey(name1_, value1_)), | 292 AutofillChange(AutofillChange::REMOVE, AutofillKey(name1_, value1_)), |
293 AutofillChange(AutofillChange::REMOVE, AutofillKey(name2_, value2_)) | 293 AutofillChange(AutofillChange::REMOVE, AutofillKey(name2_, value2_)) |
294 }; | 294 }; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 Observe(NotificationType(NotificationType::AUTOFILL_CREDIT_CARD_CHANGED), | 436 Observe(NotificationType(NotificationType::AUTOFILL_CREDIT_CARD_CHANGED), |
437 NotificationService::AllSources(), | 437 NotificationService::AllSources(), |
438 Property(&Details<const AutofillCreditCardChange>::ptr, | 438 Property(&Details<const AutofillCreditCardChange>::ptr, |
439 Pointee(expected_change)))). | 439 Pointee(expected_change)))). |
440 WillOnce(SignalEvent(&done_event_)); | 440 WillOnce(SignalEvent(&done_event_)); |
441 | 441 |
442 wds_->UpdateCreditCard(card1_delta); | 442 wds_->UpdateCreditCard(card1_delta); |
443 done_event_.TimedWait(test_timeout_); | 443 done_event_.TimedWait(test_timeout_); |
444 } | 444 } |
445 | 445 |
OLD | NEW |