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

Side by Side Diff: chrome/browser/signin/account_reconcilor_unittest.cc

Issue 1166373006: Prefer to use the AccountID to the Email from ListAccounts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 5 years, 6 months 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/test/histogram_tester.h" 9 #include "base/test/histogram_tester.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 AccountReconcilor* reconcilor = 309 AccountReconcilor* reconcilor =
310 AccountReconcilorFactory::GetForProfile(profile()); 310 AccountReconcilorFactory::GetForProfile(profile());
311 ASSERT_TRUE(reconcilor); 311 ASSERT_TRUE(reconcilor);
312 ASSERT_TRUE(reconcilor->IsRegisteredWithTokenService()); 312 ASSERT_TRUE(reconcilor->IsRegisteredWithTokenService());
313 } 313 }
314 314
315 TEST_F(AccountReconcilorTest, GetAccountsFromCookieSuccess) { 315 TEST_F(AccountReconcilorTest, GetAccountsFromCookieSuccess) {
316 const std::string account_id = 316 const std::string account_id =
317 ConnectProfileToAccount("12345", "user@gmail.com"); 317 ConnectProfileToAccount("12345", "user@gmail.com");
318 cookie_manager_service()->SetListAccountsResponseOneAccountWithExpiry( 318 cookie_manager_service()->SetListAccountsResponseOneAccountWithExpiry(
319 "user@gmail.com", true); 319 "user@gmail.com", "12345", true);
320 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id)); 320 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id));
321 321
322 AccountReconcilor* reconcilor = 322 AccountReconcilor* reconcilor =
323 AccountReconcilorFactory::GetForProfile(profile()); 323 AccountReconcilorFactory::GetForProfile(profile());
324 ASSERT_TRUE(reconcilor); 324 ASSERT_TRUE(reconcilor);
325 325
326 ASSERT_EQ(signin_metrics::ACCOUNT_RECONCILOR_OK, reconcilor->GetState()); 326 ASSERT_EQ(signin_metrics::ACCOUNT_RECONCILOR_OK, reconcilor->GetState());
327 reconcilor->StartReconcile(); 327 reconcilor->StartReconcile();
328 ASSERT_EQ(signin_metrics::ACCOUNT_RECONCILOR_RUNNING, 328 ASSERT_EQ(signin_metrics::ACCOUNT_RECONCILOR_RUNNING,
329 reconcilor->GetState()); 329 reconcilor->GetState());
330 base::RunLoop().RunUntilIdle(); 330 base::RunLoop().RunUntilIdle();
331 ASSERT_EQ(signin_metrics::ACCOUNT_RECONCILOR_RUNNING, reconcilor->GetState()); 331 ASSERT_EQ(signin_metrics::ACCOUNT_RECONCILOR_RUNNING, reconcilor->GetState());
332 332
333 std::vector<gaia::ListedAccount> accounts; 333 std::vector<gaia::ListedAccount> accounts;
334 ASSERT_TRUE(cookie_manager_service()->ListAccounts(&accounts)); 334 ASSERT_TRUE(cookie_manager_service()->ListAccounts(&accounts));
335 ASSERT_EQ(1u, accounts.size()); 335 ASSERT_EQ(1u, accounts.size());
336 ASSERT_EQ(account_id, accounts[0].email); 336 ASSERT_EQ(account_id, accounts[0].id);
337 } 337 }
338 338
339 TEST_F(AccountReconcilorTest, GetAccountsFromCookieFailure) { 339 TEST_F(AccountReconcilorTest, GetAccountsFromCookieFailure) {
340 ConnectProfileToAccount("12345", "user@gmail.com"); 340 ConnectProfileToAccount("12345", "user@gmail.com");
341 cookie_manager_service()->SetListAccountsResponseWebLoginRequired(); 341 cookie_manager_service()->SetListAccountsResponseWebLoginRequired();
342 342
343 AccountReconcilor* reconcilor = 343 AccountReconcilor* reconcilor =
344 AccountReconcilorFactory::GetForProfile(profile()); 344 AccountReconcilorFactory::GetForProfile(profile());
345 ASSERT_TRUE(reconcilor); 345 ASSERT_TRUE(reconcilor);
346 346
(...skipping 13 matching lines...) Expand all
360 } 360 }
361 361
362 TEST_P(AccountReconcilorTest, StartReconcileNoop) { 362 TEST_P(AccountReconcilorTest, StartReconcileNoop) {
363 const std::string account_id = 363 const std::string account_id =
364 ConnectProfileToAccount("12345", "user@gmail.com"); 364 ConnectProfileToAccount("12345", "user@gmail.com");
365 365
366 AccountReconcilor* reconcilor = 366 AccountReconcilor* reconcilor =
367 AccountReconcilorFactory::GetForProfile(profile()); 367 AccountReconcilorFactory::GetForProfile(profile());
368 ASSERT_TRUE(reconcilor); 368 ASSERT_TRUE(reconcilor);
369 369
370 cookie_manager_service()->SetListAccountsResponseOneAccount("user@gmail.com"); 370 cookie_manager_service()->SetListAccountsResponseOneAccount(
371 "user@gmail.com", "12345");
371 372
372 reconcilor->StartReconcile(); 373 reconcilor->StartReconcile();
373 ASSERT_TRUE(reconcilor->is_reconcile_started_); 374 ASSERT_TRUE(reconcilor->is_reconcile_started_);
374 375
375 base::RunLoop().RunUntilIdle(); 376 base::RunLoop().RunUntilIdle();
376 ASSERT_FALSE(reconcilor->is_reconcile_started_); 377 ASSERT_FALSE(reconcilor->is_reconcile_started_);
377 378
378 histogram_tester()->ExpectTotalCount( 379 histogram_tester()->ExpectTotalCount(
379 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 1); 380 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 1);
380 histogram_tester()->ExpectUniqueSample( 381 histogram_tester()->ExpectUniqueSample(
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 // by gaia::ParseListAccountsData(). 481 // by gaia::ParseListAccountsData().
481 TEST_P(AccountReconcilorTest, StartReconcileNoopWithDots) { 482 TEST_P(AccountReconcilorTest, StartReconcileNoopWithDots) {
482 if (account_tracker()->GetMigrationState() != 483 if (account_tracker()->GetMigrationState() !=
483 AccountTrackerService::MIGRATION_NOT_STARTED) { 484 AccountTrackerService::MIGRATION_NOT_STARTED) {
484 return; 485 return;
485 } 486 }
486 487
487 const std::string account_id = 488 const std::string account_id =
488 ConnectProfileToAccount("12345", "Dot.S@gmail.com"); 489 ConnectProfileToAccount("12345", "Dot.S@gmail.com");
489 cookie_manager_service()->SetListAccountsResponseOneAccount( 490 cookie_manager_service()->SetListAccountsResponseOneAccount(
490 "dot.s@gmail.com"); 491 "dot.s@gmail.com", "12345");
491 AccountReconcilor* reconcilor = 492 AccountReconcilor* reconcilor =
492 AccountReconcilorFactory::GetForProfile(profile()); 493 AccountReconcilorFactory::GetForProfile(profile());
493 ASSERT_TRUE(reconcilor); 494 ASSERT_TRUE(reconcilor);
494 495
495 reconcilor->StartReconcile(); 496 reconcilor->StartReconcile();
496 base::RunLoop().RunUntilIdle(); 497 base::RunLoop().RunUntilIdle();
497 ASSERT_FALSE(reconcilor->is_reconcile_started_); 498 ASSERT_FALSE(reconcilor->is_reconcile_started_);
498 499
499 histogram_tester()->ExpectUniqueSample( 500 histogram_tester()->ExpectUniqueSample(
500 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 501 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun",
501 signin_metrics::ACCOUNTS_SAME, 502 signin_metrics::ACCOUNTS_SAME,
502 1); 503 1);
503 } 504 }
504 505
505 TEST_P(AccountReconcilorTest, StartReconcileNoopMultiple) { 506 TEST_P(AccountReconcilorTest, StartReconcileNoopMultiple) {
506 const std::string account_id = 507 const std::string account_id =
507 ConnectProfileToAccount("12345", "user@gmail.com"); 508 ConnectProfileToAccount("12345", "user@gmail.com");
508 const std::string account_id2 = 509 const std::string account_id2 =
509 PickAccountIdForAccount("67890", "other@gmail.com"); 510 PickAccountIdForAccount("67890", "other@gmail.com");
510 cookie_manager_service()->SetListAccountsResponseTwoAccounts( 511 cookie_manager_service()->SetListAccountsResponseTwoAccounts(
511 "user@gmail.com", "other@gmail.com"); 512 "user@gmail.com", "12345", "other@gmail.com", "67890");
512 token_service()->UpdateCredentials(account_id2, "refresh_token"); 513 token_service()->UpdateCredentials(account_id2, "refresh_token");
513 514
514 AccountReconcilor* reconcilor = 515 AccountReconcilor* reconcilor =
515 AccountReconcilorFactory::GetForProfile(profile()); 516 AccountReconcilorFactory::GetForProfile(profile());
516 ASSERT_TRUE(reconcilor); 517 ASSERT_TRUE(reconcilor);
517 518
518 reconcilor->StartReconcile(); 519 reconcilor->StartReconcile();
519 base::RunLoop().RunUntilIdle(); 520 base::RunLoop().RunUntilIdle();
520 ASSERT_FALSE(reconcilor->is_reconcile_started_); 521 ASSERT_FALSE(reconcilor->is_reconcile_started_);
521 522
522 histogram_tester()->ExpectTotalCount( 523 histogram_tester()->ExpectTotalCount(
523 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 1); 524 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 1);
524 histogram_tester()->ExpectUniqueSample( 525 histogram_tester()->ExpectUniqueSample(
525 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 526 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun",
526 signin_metrics::ACCOUNTS_SAME, 527 signin_metrics::ACCOUNTS_SAME,
527 1); 528 1);
528 } 529 }
529 530
530 TEST_P(AccountReconcilorTest, StartReconcileAddToCookie) { 531 TEST_P(AccountReconcilorTest, StartReconcileAddToCookie) {
531 const std::string account_id = 532 const std::string account_id =
532 ConnectProfileToAccount("12345", "user@gmail.com"); 533 ConnectProfileToAccount("12345", "user@gmail.com");
533 token_service()->UpdateCredentials(account_id, "refresh_token"); 534 token_service()->UpdateCredentials(account_id, "refresh_token");
534 cookie_manager_service()->SetListAccountsResponseOneAccount( 535 cookie_manager_service()->SetListAccountsResponseOneAccount(
535 "user@gmail.com"); 536 "user@gmail.com", "12345");
536 537
537 const std::string account_id2 = 538 const std::string account_id2 =
538 PickAccountIdForAccount("67890", "other@gmail.com"); 539 PickAccountIdForAccount("67890", "other@gmail.com");
539 token_service()->UpdateCredentials(account_id2, "refresh_token"); 540 token_service()->UpdateCredentials(account_id2, "refresh_token");
540 541
541 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id2)); 542 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id2));
542 543
543 AccountReconcilor* reconcilor = GetMockReconcilor(); 544 AccountReconcilor* reconcilor = GetMockReconcilor();
544 reconcilor->StartReconcile(); 545 reconcilor->StartReconcile();
545 546
(...skipping 11 matching lines...) Expand all
557 "Signin.Reconciler.AddedToCookieJar.FirstRun", 1, 1); 558 "Signin.Reconciler.AddedToCookieJar.FirstRun", 1, 1);
558 histogram_tester()->ExpectUniqueSample( 559 histogram_tester()->ExpectUniqueSample(
559 "Signin.Reconciler.RemovedFromCookieJar.FirstRun", 0, 1); 560 "Signin.Reconciler.RemovedFromCookieJar.FirstRun", 0, 1);
560 } 561 }
561 562
562 TEST_P(AccountReconcilorTest, StartReconcileRemoveFromCookie) { 563 TEST_P(AccountReconcilorTest, StartReconcileRemoveFromCookie) {
563 const std::string account_id = 564 const std::string account_id =
564 ConnectProfileToAccount("12345", "user@gmail.com"); 565 ConnectProfileToAccount("12345", "user@gmail.com");
565 token_service()->UpdateCredentials(account_id, "refresh_token"); 566 token_service()->UpdateCredentials(account_id, "refresh_token");
566 cookie_manager_service()->SetListAccountsResponseTwoAccounts( 567 cookie_manager_service()->SetListAccountsResponseTwoAccounts(
567 "user@gmail.com", "other@gmail.com"); 568 "user@gmail.com", "12345", "other@gmail.com", "67890");
568 569
569 EXPECT_CALL(*GetMockReconcilor(), PerformLogoutAllAccountsAction()); 570 EXPECT_CALL(*GetMockReconcilor(), PerformLogoutAllAccountsAction());
570 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id)); 571 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id));
571 572
572 AccountReconcilor* reconcilor = GetMockReconcilor(); 573 AccountReconcilor* reconcilor = GetMockReconcilor();
573 reconcilor->StartReconcile(); 574 reconcilor->StartReconcile();
574 ASSERT_TRUE(reconcilor->is_reconcile_started_); 575 ASSERT_TRUE(reconcilor->is_reconcile_started_);
575 576
576 base::RunLoop().RunUntilIdle(); 577 base::RunLoop().RunUntilIdle();
577 SimulateAddAccountToCookieCompleted(reconcilor, "user@gmail.com", 578 SimulateAddAccountToCookieCompleted(reconcilor, "user@gmail.com",
(...skipping 12 matching lines...) Expand all
590 591
591 TEST_P(AccountReconcilorTest, StartReconcileAddToCookieTwice) { 592 TEST_P(AccountReconcilorTest, StartReconcileAddToCookieTwice) {
592 const std::string account_id = 593 const std::string account_id =
593 ConnectProfileToAccount("12345", "user@gmail.com"); 594 ConnectProfileToAccount("12345", "user@gmail.com");
594 const std::string account_id2 = 595 const std::string account_id2 =
595 PickAccountIdForAccount("67890", "other@gmail.com"); 596 PickAccountIdForAccount("67890", "other@gmail.com");
596 const std::string account_id3 = 597 const std::string account_id3 =
597 PickAccountIdForAccount("34567", "third@gmail.com"); 598 PickAccountIdForAccount("34567", "third@gmail.com");
598 599
599 cookie_manager_service()->SetListAccountsResponseOneAccount( 600 cookie_manager_service()->SetListAccountsResponseOneAccount(
600 "user@gmail.com"); 601 "user@gmail.com", "12345");
601 token_service()->UpdateCredentials(account_id2, "refresh_token"); 602 token_service()->UpdateCredentials(account_id2, "refresh_token");
602 603
603 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id2)); 604 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id2));
604 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id3)); 605 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id3));
605 606
606 AccountReconcilor* reconcilor = GetMockReconcilor(); 607 AccountReconcilor* reconcilor = GetMockReconcilor();
607 reconcilor->StartReconcile(); 608 reconcilor->StartReconcile();
608 609
609 base::RunLoop().RunUntilIdle(); 610 base::RunLoop().RunUntilIdle();
610 ASSERT_TRUE(reconcilor->is_reconcile_started_); 611 ASSERT_TRUE(reconcilor->is_reconcile_started_);
611 SimulateAddAccountToCookieCompleted( 612 SimulateAddAccountToCookieCompleted(
612 reconcilor, account_id2, GoogleServiceAuthError::AuthErrorNone()); 613 reconcilor, account_id2, GoogleServiceAuthError::AuthErrorNone());
613 ASSERT_FALSE(reconcilor->is_reconcile_started_); 614 ASSERT_FALSE(reconcilor->is_reconcile_started_);
614 615
615 histogram_tester()->ExpectUniqueSample( 616 histogram_tester()->ExpectUniqueSample(
616 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 617 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun",
617 signin_metrics::ACCOUNTS_SAME, 618 signin_metrics::ACCOUNTS_SAME,
618 1); 619 1);
619 histogram_tester()->ExpectUniqueSample( 620 histogram_tester()->ExpectUniqueSample(
620 "Signin.Reconciler.AddedToCookieJar.FirstRun", 1, 1); 621 "Signin.Reconciler.AddedToCookieJar.FirstRun", 1, 1);
621 histogram_tester()->ExpectUniqueSample( 622 histogram_tester()->ExpectUniqueSample(
622 "Signin.Reconciler.RemovedFromCookieJar.FirstRun", 0, 1); 623 "Signin.Reconciler.RemovedFromCookieJar.FirstRun", 0, 1);
623 624
624 // Do another pass after I've added a third account to the token service 625 // Do another pass after I've added a third account to the token service
625 cookie_manager_service()->SetListAccountsResponseTwoAccounts( 626 cookie_manager_service()->SetListAccountsResponseTwoAccounts(
626 "user@gmail.com", "other@gmail.com"); 627 "user@gmail.com", "12345", "other@gmail.com", "67890");
627 cookie_manager_service()->set_list_accounts_fetched_once_for_testing(false); 628 cookie_manager_service()->set_list_accounts_fetched_once_for_testing(false);
628 629
629 // This will cause the reconcilor to fire. 630 // This will cause the reconcilor to fire.
630 token_service()->UpdateCredentials(account_id3, "refresh_token"); 631 token_service()->UpdateCredentials(account_id3, "refresh_token");
631 base::RunLoop().RunUntilIdle(); 632 base::RunLoop().RunUntilIdle();
632 633
633 ASSERT_TRUE(reconcilor->is_reconcile_started_); 634 ASSERT_TRUE(reconcilor->is_reconcile_started_);
634 SimulateAddAccountToCookieCompleted( 635 SimulateAddAccountToCookieCompleted(
635 reconcilor, account_id3, GoogleServiceAuthError::AuthErrorNone()); 636 reconcilor, account_id3, GoogleServiceAuthError::AuthErrorNone());
636 ASSERT_FALSE(reconcilor->is_reconcile_started_); 637 ASSERT_FALSE(reconcilor->is_reconcile_started_);
(...skipping 17 matching lines...) Expand all
654 } 655 }
655 656
656 TEST_P(AccountReconcilorTest, StartReconcileBadPrimary) { 657 TEST_P(AccountReconcilorTest, StartReconcileBadPrimary) {
657 const std::string account_id = 658 const std::string account_id =
658 ConnectProfileToAccount("12345", "user@gmail.com"); 659 ConnectProfileToAccount("12345", "user@gmail.com");
659 const std::string account_id2 = 660 const std::string account_id2 =
660 PickAccountIdForAccount("67890", "other@gmail.com"); 661 PickAccountIdForAccount("67890", "other@gmail.com");
661 662
662 token_service()->UpdateCredentials(account_id2, "refresh_token"); 663 token_service()->UpdateCredentials(account_id2, "refresh_token");
663 cookie_manager_service()->SetListAccountsResponseTwoAccounts( 664 cookie_manager_service()->SetListAccountsResponseTwoAccounts(
664 "other@gmail.com", "user@gmail.com"); 665 "other@gmail.com", "12345", "user@gmail.com", "67890");
665 666
666 EXPECT_CALL(*GetMockReconcilor(), PerformLogoutAllAccountsAction()); 667 EXPECT_CALL(*GetMockReconcilor(), PerformLogoutAllAccountsAction());
667 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id)); 668 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id));
668 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id2)); 669 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id2));
669 670
670 AccountReconcilor* reconcilor = GetMockReconcilor(); 671 AccountReconcilor* reconcilor = GetMockReconcilor();
671 reconcilor->StartReconcile(); 672 reconcilor->StartReconcile();
672 673
673 base::RunLoop().RunUntilIdle(); 674 base::RunLoop().RunUntilIdle();
674 ASSERT_TRUE(reconcilor->is_reconcile_started_); 675 ASSERT_TRUE(reconcilor->is_reconcile_started_);
(...skipping 11 matching lines...) Expand all
686 histogram_tester()->ExpectUniqueSample( 687 histogram_tester()->ExpectUniqueSample(
687 "Signin.Reconciler.AddedToCookieJar.FirstRun", 0, 1); 688 "Signin.Reconciler.AddedToCookieJar.FirstRun", 0, 1);
688 histogram_tester()->ExpectUniqueSample( 689 histogram_tester()->ExpectUniqueSample(
689 "Signin.Reconciler.RemovedFromCookieJar.FirstRun", 0, 1); 690 "Signin.Reconciler.RemovedFromCookieJar.FirstRun", 0, 1);
690 } 691 }
691 692
692 TEST_P(AccountReconcilorTest, StartReconcileOnlyOnce) { 693 TEST_P(AccountReconcilorTest, StartReconcileOnlyOnce) {
693 const std::string account_id = 694 const std::string account_id =
694 ConnectProfileToAccount("12345", "user@gmail.com"); 695 ConnectProfileToAccount("12345", "user@gmail.com");
695 cookie_manager_service()->SetListAccountsResponseOneAccount( 696 cookie_manager_service()->SetListAccountsResponseOneAccount(
696 "user@gmail.com"); 697 "user@gmail.com", "12345");
697 698
698 AccountReconcilor* reconcilor = 699 AccountReconcilor* reconcilor =
699 AccountReconcilorFactory::GetForProfile(profile()); 700 AccountReconcilorFactory::GetForProfile(profile());
700 ASSERT_TRUE(reconcilor); 701 ASSERT_TRUE(reconcilor);
701 702
702 ASSERT_FALSE(reconcilor->is_reconcile_started_); 703 ASSERT_FALSE(reconcilor->is_reconcile_started_);
703 reconcilor->StartReconcile(); 704 reconcilor->StartReconcile();
704 ASSERT_TRUE(reconcilor->is_reconcile_started_); 705 ASSERT_TRUE(reconcilor->is_reconcile_started_);
705 706
706 base::RunLoop().RunUntilIdle(); 707 base::RunLoop().RunUntilIdle();
(...skipping 22 matching lines...) Expand all
729 base::RunLoop().RunUntilIdle(); 730 base::RunLoop().RunUntilIdle();
730 SimulateAddAccountToCookieCompleted(reconcilor, account_id, 731 SimulateAddAccountToCookieCompleted(reconcilor, account_id,
731 GoogleServiceAuthError::AuthErrorNone()); 732 GoogleServiceAuthError::AuthErrorNone());
732 ASSERT_FALSE(reconcilor->is_reconcile_started_); 733 ASSERT_FALSE(reconcilor->is_reconcile_started_);
733 } 734 }
734 735
735 TEST_F(AccountReconcilorTest, AddAccountToCookieCompletedWithBogusAccount) { 736 TEST_F(AccountReconcilorTest, AddAccountToCookieCompletedWithBogusAccount) {
736 const std::string account_id = 737 const std::string account_id =
737 ConnectProfileToAccount("12345", "user@gmail.com"); 738 ConnectProfileToAccount("12345", "user@gmail.com");
738 cookie_manager_service()->SetListAccountsResponseOneAccountWithExpiry( 739 cookie_manager_service()->SetListAccountsResponseOneAccountWithExpiry(
739 "user@gmail.com", true); 740 "user@gmail.com", "12345", true);
740 741
741 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id)); 742 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id));
742 743
743 AccountReconcilor* reconcilor = 744 AccountReconcilor* reconcilor =
744 AccountReconcilorFactory::GetForProfile(profile()); 745 AccountReconcilorFactory::GetForProfile(profile());
745 ASSERT_TRUE(reconcilor); 746 ASSERT_TRUE(reconcilor);
746 747
747 ASSERT_FALSE(reconcilor->is_reconcile_started_); 748 ASSERT_FALSE(reconcilor->is_reconcile_started_);
748 reconcilor->StartReconcile(); 749 reconcilor->StartReconcile();
749 ASSERT_TRUE(reconcilor->is_reconcile_started_); 750 ASSERT_TRUE(reconcilor->is_reconcile_started_);
750 751
751 base::RunLoop().RunUntilIdle(); 752 base::RunLoop().RunUntilIdle();
752 753
753 // If an unknown account id is sent, it should not upset the state. 754 // If an unknown account id is sent, it should not upset the state.
754 SimulateAddAccountToCookieCompleted(reconcilor, "bogus_account_id", 755 SimulateAddAccountToCookieCompleted(reconcilor, "bogus_account_id",
755 GoogleServiceAuthError::AuthErrorNone()); 756 GoogleServiceAuthError::AuthErrorNone());
756 ASSERT_TRUE(reconcilor->is_reconcile_started_); 757 ASSERT_TRUE(reconcilor->is_reconcile_started_);
757 758
758 SimulateAddAccountToCookieCompleted(reconcilor, account_id, 759 SimulateAddAccountToCookieCompleted(reconcilor, account_id,
759 GoogleServiceAuthError::AuthErrorNone()); 760 GoogleServiceAuthError::AuthErrorNone());
760 ASSERT_FALSE(reconcilor->is_reconcile_started_); 761 ASSERT_FALSE(reconcilor->is_reconcile_started_);
761 } 762 }
762 763
763 INSTANTIATE_TEST_CASE_P(AccountReconcilorMaybeEnabled, 764 INSTANTIATE_TEST_CASE_P(AccountReconcilorMaybeEnabled,
764 AccountReconcilorTest, 765 AccountReconcilorTest,
765 testing::Bool()); 766 testing::Bool());
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/signin/cross_device_promo_unittest.cc » ('j') | google_apis/gaia/gaia_auth_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698