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

Side by Side Diff: chrome/browser/webdata/web_data_service_unittest.cc

Issue 11360055: [Autofill] Rename GetInfo and SetInfo to GetRawInfo and SetRawInfo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase harder Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 // Check that it was removed. 393 // Check that it was removed.
394 AutofillWebDataServiceConsumer<std::vector<AutofillProfile*> > consumer2; 394 AutofillWebDataServiceConsumer<std::vector<AutofillProfile*> > consumer2;
395 WebDataService::Handle handle2 = wds_->GetAutofillProfiles(&consumer2); 395 WebDataService::Handle handle2 = wds_->GetAutofillProfiles(&consumer2);
396 MessageLoop::current()->Run(); 396 MessageLoop::current()->Run();
397 EXPECT_EQ(handle2, consumer2.handle()); 397 EXPECT_EQ(handle2, consumer2.handle());
398 ASSERT_EQ(0U, consumer2.result().size()); 398 ASSERT_EQ(0U, consumer2.result().size());
399 } 399 }
400 400
401 TEST_F(WebDataServiceAutofillTest, ProfileUpdate) { 401 TEST_F(WebDataServiceAutofillTest, ProfileUpdate) {
402 AutofillProfile profile1; 402 AutofillProfile profile1;
403 profile1.SetInfo(NAME_FIRST, ASCIIToUTF16("Abe")); 403 profile1.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Abe"));
404 AutofillProfile profile2; 404 AutofillProfile profile2;
405 profile2.SetInfo(NAME_FIRST, ASCIIToUTF16("Alice")); 405 profile2.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Alice"));
406 406
407 EXPECT_CALL(*observer_helper_->observer(), Observe(_, _, _)). 407 EXPECT_CALL(*observer_helper_->observer(), Observe(_, _, _)).
408 WillOnce(DoDefault()). 408 WillOnce(DoDefault()).
409 WillOnce(SignalEvent(&done_event_)); 409 WillOnce(SignalEvent(&done_event_));
410 wds_->AddAutofillProfile(profile1); 410 wds_->AddAutofillProfile(profile1);
411 wds_->AddAutofillProfile(profile2); 411 wds_->AddAutofillProfile(profile2);
412 done_event_.TimedWait(test_timeout_); 412 done_event_.TimedWait(test_timeout_);
413 413
414 // Check that they were added. 414 // Check that they were added.
415 AutofillWebDataServiceConsumer<std::vector<AutofillProfile*> > consumer; 415 AutofillWebDataServiceConsumer<std::vector<AutofillProfile*> > consumer;
416 WebDataService::Handle handle = wds_->GetAutofillProfiles(&consumer); 416 WebDataService::Handle handle = wds_->GetAutofillProfiles(&consumer);
417 MessageLoop::current()->Run(); 417 MessageLoop::current()->Run();
418 EXPECT_EQ(handle, consumer.handle()); 418 EXPECT_EQ(handle, consumer.handle());
419 ASSERT_EQ(2U, consumer.result().size()); 419 ASSERT_EQ(2U, consumer.result().size());
420 EXPECT_EQ(profile1, *consumer.result()[0]); 420 EXPECT_EQ(profile1, *consumer.result()[0]);
421 EXPECT_EQ(profile2, *consumer.result()[1]); 421 EXPECT_EQ(profile2, *consumer.result()[1]);
422 STLDeleteElements(&consumer.result()); 422 STLDeleteElements(&consumer.result());
423 423
424 AutofillProfile profile1_changed(profile1); 424 AutofillProfile profile1_changed(profile1);
425 profile1_changed.SetInfo(NAME_FIRST, ASCIIToUTF16("Bill")); 425 profile1_changed.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Bill"));
426 const AutofillProfileChange expected_change( 426 const AutofillProfileChange expected_change(
427 AutofillProfileChange::UPDATE, profile1.guid(), &profile1_changed); 427 AutofillProfileChange::UPDATE, profile1.guid(), &profile1_changed);
428 428
429 EXPECT_CALL( 429 EXPECT_CALL(
430 *observer_helper_->observer(), 430 *observer_helper_->observer(),
431 Observe(int(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED), 431 Observe(int(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED),
432 content::Source<WebDataService>(wds_.get()), 432 content::Source<WebDataService>(wds_.get()),
433 Property(&content::Details<const AutofillProfileChange>::ptr, 433 Property(&content::Details<const AutofillProfileChange>::ptr,
434 Pointee(expected_change)))). 434 Pointee(expected_change)))).
435 WillOnce(SignalEvent(&done_event_)); 435 WillOnce(SignalEvent(&done_event_));
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 // Check that it was removed. 512 // Check that it was removed.
513 AutofillWebDataServiceConsumer<std::vector<CreditCard*> > consumer2; 513 AutofillWebDataServiceConsumer<std::vector<CreditCard*> > consumer2;
514 WebDataService::Handle handle2 = wds_->GetCreditCards(&consumer2); 514 WebDataService::Handle handle2 = wds_->GetCreditCards(&consumer2);
515 MessageLoop::current()->Run(); 515 MessageLoop::current()->Run();
516 EXPECT_EQ(handle2, consumer2.handle()); 516 EXPECT_EQ(handle2, consumer2.handle());
517 ASSERT_EQ(0U, consumer2.result().size()); 517 ASSERT_EQ(0U, consumer2.result().size());
518 } 518 }
519 519
520 TEST_F(WebDataServiceAutofillTest, CreditUpdate) { 520 TEST_F(WebDataServiceAutofillTest, CreditUpdate) {
521 CreditCard card1; 521 CreditCard card1;
522 card1.SetInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Abe")); 522 card1.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Abe"));
523 CreditCard card2; 523 CreditCard card2;
524 card2.SetInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Alice")); 524 card2.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Alice"));
525 525
526 EXPECT_CALL(*observer_helper_->observer(), Observe(_, _, _)). 526 EXPECT_CALL(*observer_helper_->observer(), Observe(_, _, _)).
527 Times(2). 527 Times(2).
528 WillOnce(DoDefault()). 528 WillOnce(DoDefault()).
529 WillOnce(SignalEvent(&done_event_)); 529 WillOnce(SignalEvent(&done_event_));
530 wds_->AddCreditCard(card1); 530 wds_->AddCreditCard(card1);
531 wds_->AddCreditCard(card2); 531 wds_->AddCreditCard(card2);
532 done_event_.TimedWait(test_timeout_); 532 done_event_.TimedWait(test_timeout_);
533 533
534 // Check that they got added. 534 // Check that they got added.
535 AutofillWebDataServiceConsumer<std::vector<CreditCard*> > consumer; 535 AutofillWebDataServiceConsumer<std::vector<CreditCard*> > consumer;
536 WebDataService::Handle handle = wds_->GetCreditCards(&consumer); 536 WebDataService::Handle handle = wds_->GetCreditCards(&consumer);
537 MessageLoop::current()->Run(); 537 MessageLoop::current()->Run();
538 EXPECT_EQ(handle, consumer.handle()); 538 EXPECT_EQ(handle, consumer.handle());
539 ASSERT_EQ(2U, consumer.result().size()); 539 ASSERT_EQ(2U, consumer.result().size());
540 EXPECT_EQ(card1, *consumer.result()[0]); 540 EXPECT_EQ(card1, *consumer.result()[0]);
541 EXPECT_EQ(card2, *consumer.result()[1]); 541 EXPECT_EQ(card2, *consumer.result()[1]);
542 STLDeleteElements(&consumer.result()); 542 STLDeleteElements(&consumer.result());
543 543
544 CreditCard card1_changed(card1); 544 CreditCard card1_changed(card1);
545 card1_changed.SetInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Bill")); 545 card1_changed.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Bill"));
546 const AutofillCreditCardChange expected_change( 546 const AutofillCreditCardChange expected_change(
547 AutofillCreditCardChange::UPDATE, card1.guid(), &card1_changed); 547 AutofillCreditCardChange::UPDATE, card1.guid(), &card1_changed);
548 548
549 EXPECT_CALL( 549 EXPECT_CALL(
550 *observer_helper_->observer(), 550 *observer_helper_->observer(),
551 Observe( 551 Observe(
552 int(chrome::NOTIFICATION_AUTOFILL_CREDIT_CARD_CHANGED), 552 int(chrome::NOTIFICATION_AUTOFILL_CREDIT_CARD_CHANGED),
553 content::Source<WebDataService>(wds_.get()), 553 content::Source<WebDataService>(wds_.get()),
554 Property(&content::Details<const AutofillCreditCardChange>::ptr, 554 Property(&content::Details<const AutofillCreditCardChange>::ptr,
555 Pointee(expected_change)))). 555 Pointee(expected_change)))).
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 } 828 }
829 829
830 TEST_F(WebDataServiceTest, DidDefaultSearchProviderChangeOnNewProfile) { 830 TEST_F(WebDataServiceTest, DidDefaultSearchProviderChangeOnNewProfile) {
831 KeywordsConsumer consumer; 831 KeywordsConsumer consumer;
832 wds_->GetKeywords(&consumer); 832 wds_->GetKeywords(&consumer);
833 WaitUntilCalled(); 833 WaitUntilCalled();
834 ASSERT_TRUE(consumer.load_succeeded); 834 ASSERT_TRUE(consumer.load_succeeded);
835 EXPECT_FALSE(consumer.keywords_result.did_default_search_provider_change); 835 EXPECT_FALSE(consumer.keywords_result.did_default_search_provider_change);
836 EXPECT_FALSE(consumer.keywords_result.backup_valid); 836 EXPECT_FALSE(consumer.keywords_result.backup_valid);
837 } 837 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/autofill_table_unittest.cc ('k') | chrome/browser/webdata/web_database_migration_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698