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

Side by Side Diff: chrome/browser/ui/webui/sync_setup_handler_unittest.cc

Issue 15421011: Use OAuth2 token for sync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android build Created 7 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 (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 "chrome/browser/ui/webui/sync_setup_handler.h" 5 #include "chrome/browser/ui/webui/sync_setup_handler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/sync/profile_sync_service_mock.h" 21 #include "chrome/browser/sync/profile_sync_service_mock.h"
22 #include "chrome/browser/ui/webui/signin/login_ui_service.h" 22 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
23 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 23 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
24 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" 24 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "chrome/test/base/testing_profile.h" 27 #include "chrome/test/base/testing_profile.h"
28 #include "chrome/test/base/testing_browser_process.h" 28 #include "chrome/test/base/testing_browser_process.h"
29 #include "chrome/test/base/scoped_testing_local_state.h" 29 #include "chrome/test/base/scoped_testing_local_state.h"
30 #include "content/public/browser/web_ui.h" 30 #include "content/public/browser/web_ui.h"
31 #include "content/public/test/test_browser_thread.h"
31 #include "grit/generated_resources.h" 32 #include "grit/generated_resources.h"
32 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
33 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
34 #include "ui/base/layout.h" 35 #include "ui/base/layout.h"
35 36
36 using ::testing::_; 37 using ::testing::_;
37 using ::testing::Mock; 38 using ::testing::Mock;
38 using ::testing::Return; 39 using ::testing::Return;
39 using ::testing::ReturnRef; 40 using ::testing::ReturnRef;
40 using ::testing::Values; 41 using ::testing::Values;
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 void SetupInitializedProfileSyncService() { 387 void SetupInitializedProfileSyncService() {
387 // An initialized ProfileSyncService will have already completed sync setup 388 // An initialized ProfileSyncService will have already completed sync setup
388 // and will have an initialized sync backend. 389 // and will have an initialized sync backend.
389 if (!mock_signin_->IsInitialized()) { 390 if (!mock_signin_->IsInitialized()) {
390 profile_->GetPrefs()->SetString( 391 profile_->GetPrefs()->SetString(
391 prefs::kGoogleServicesUsername, kTestUser); 392 prefs::kGoogleServicesUsername, kTestUser);
392 mock_signin_->Initialize(profile_.get(), NULL); 393 mock_signin_->Initialize(profile_.get(), NULL);
393 } 394 }
394 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) 395 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
395 .WillRepeatedly(Return(true)); 396 .WillRepeatedly(Return(true));
396 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) 397 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
397 .WillRepeatedly(Return(true)); 398 .WillRepeatedly(Return(true));
398 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) 399 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
399 .WillRepeatedly(Return(true)); 400 .WillRepeatedly(Return(true));
400 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); 401 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
401 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(true)); 402 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(true));
402 } 403 }
403 404
404 void ExpectConfig() { 405 void ExpectConfig() {
405 ASSERT_EQ(1U, web_ui_.call_data().size()); 406 ASSERT_EQ(1U, web_ui_.call_data().size());
406 const TestWebUI::CallData& data = web_ui_.call_data()[0]; 407 const TestWebUI::CallData& data = web_ui_.call_data()[0];
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 scoped_ptr<TestingSyncSetupHandler> handler_; 448 scoped_ptr<TestingSyncSetupHandler> handler_;
448 }; 449 };
449 450
450 TEST_P(SyncSetupHandlerTest, Basic) { 451 TEST_P(SyncSetupHandlerTest, Basic) {
451 } 452 }
452 453
453 #if !defined(OS_CHROMEOS) 454 #if !defined(OS_CHROMEOS)
454 TEST_P(SyncSetupHandlerTest, DisplayBasicLogin) { 455 TEST_P(SyncSetupHandlerTest, DisplayBasicLogin) {
455 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) 456 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
456 .WillRepeatedly(Return(false)); 457 .WillRepeatedly(Return(false));
457 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) 458 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
458 .WillRepeatedly(Return(false)); 459 .WillRepeatedly(Return(false));
459 const GoogleServiceAuthError error(GoogleServiceAuthError::NONE); 460 const GoogleServiceAuthError error(GoogleServiceAuthError::NONE);
460 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error)); 461 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error));
461 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) 462 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
462 .WillRepeatedly(Return(false)); 463 .WillRepeatedly(Return(false));
463 handler_->HandleStartSignin(NULL); 464 handler_->HandleStartSignin(NULL);
464 EXPECT_EQ(handler_.get(), 465 EXPECT_EQ(handler_.get(),
465 LoginUIServiceFactory::GetForProfile( 466 LoginUIServiceFactory::GetForProfile(
466 profile_.get())->current_login_ui()); 467 profile_.get())->current_login_ui());
467 468
(...skipping 21 matching lines...) Expand all
489 490
490 handler_->CloseSyncSetup(); 491 handler_->CloseSyncSetup();
491 EXPECT_EQ(NULL, 492 EXPECT_EQ(NULL,
492 LoginUIServiceFactory::GetForProfile( 493 LoginUIServiceFactory::GetForProfile(
493 profile_.get())->current_login_ui()); 494 profile_.get())->current_login_ui());
494 } 495 }
495 496
496 TEST_P(SyncSetupHandlerTest, ShowSyncSetupWhenNotSignedIn) { 497 TEST_P(SyncSetupHandlerTest, ShowSyncSetupWhenNotSignedIn) {
497 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) 498 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
498 .WillRepeatedly(Return(false)); 499 .WillRepeatedly(Return(false));
499 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) 500 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
500 .WillRepeatedly(Return(false)); 501 .WillRepeatedly(Return(false));
501 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) 502 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
502 .WillRepeatedly(Return(false)); 503 .WillRepeatedly(Return(false));
503 handler_->HandleShowSetupUI(NULL); 504 handler_->HandleShowSetupUI(NULL);
504 505
505 ASSERT_EQ(1U, web_ui_.call_data().size()); 506 ASSERT_EQ(1U, web_ui_.call_data().size());
506 if (SyncPromoUI::UseWebBasedSigninFlow()) { 507 if (SyncPromoUI::UseWebBasedSigninFlow()) {
507 const TestWebUI::CallData& data = web_ui_.call_data()[0]; 508 const TestWebUI::CallData& data = web_ui_.call_data()[0];
508 EXPECT_EQ("OptionsPage.closeOverlay", data.function_name); 509 EXPECT_EQ("OptionsPage.closeOverlay", data.function_name);
509 ASSERT_FALSE(handler_->is_configuring_sync()); 510 ASSERT_FALSE(handler_->is_configuring_sync());
(...skipping 10 matching lines...) Expand all
520 } 521 }
521 #endif 522 #endif
522 523
523 // Verifies that the handler correctly handles a cancellation when 524 // Verifies that the handler correctly handles a cancellation when
524 // it is displaying the spinner to the user. 525 // it is displaying the spinner to the user.
525 TEST_P(SyncSetupHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) { 526 TEST_P(SyncSetupHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) {
526 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) 527 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
527 .WillRepeatedly(Return(true)); 528 .WillRepeatedly(Return(true));
528 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser); 529 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser);
529 mock_signin_->Initialize(profile_.get(), NULL); 530 mock_signin_->Initialize(profile_.get(), NULL);
530 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) 531 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
531 .WillRepeatedly(Return(true)); 532 .WillRepeatedly(Return(true));
532 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) 533 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
533 .WillRepeatedly(Return(false)); 534 .WillRepeatedly(Return(false));
534 error_ = GoogleServiceAuthError::AuthErrorNone(); 535 error_ = GoogleServiceAuthError::AuthErrorNone();
535 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); 536 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
536 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); 537 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false));
537 538
538 // We're simulating a user setting up sync, which would cause the backend to 539 // We're simulating a user setting up sync, which would cause the backend to
539 // kick off initialization, but not download user data types. The sync 540 // kick off initialization, but not download user data types. The sync
540 // backend will try to download control data types (e.g encryption info), but 541 // backend will try to download control data types (e.g encryption info), but
541 // that won't finish for this test as we're simulating cancelling while the 542 // that won't finish for this test as we're simulating cancelling while the
542 // spinner is showing. 543 // spinner is showing.
543 handler_->HandleShowSetupUI(NULL); 544 handler_->HandleShowSetupUI(NULL);
544 545
545 EXPECT_EQ(handler_.get(), 546 EXPECT_EQ(handler_.get(),
546 LoginUIServiceFactory::GetForProfile( 547 LoginUIServiceFactory::GetForProfile(
547 profile_.get())->current_login_ui()); 548 profile_.get())->current_login_ui());
548 549
549 ExpectSpinnerAndClose(); 550 ExpectSpinnerAndClose();
550 } 551 }
551 552
552 // Verifies that the handler correctly transitions from showing the spinner 553 // Verifies that the handler correctly transitions from showing the spinner
553 // to showing a configuration page when signin completes successfully. 554 // to showing a configuration page when signin completes successfully.
554 TEST_P(SyncSetupHandlerTest, 555 TEST_P(SyncSetupHandlerTest,
555 DisplayConfigureWithBackendDisabledAndSigninSuccess) { 556 DisplayConfigureWithBackendDisabledAndSigninSuccess) {
556 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) 557 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
557 .WillRepeatedly(Return(true)); 558 .WillRepeatedly(Return(true));
558 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser); 559 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser);
559 mock_signin_->Initialize(profile_.get(), NULL); 560 mock_signin_->Initialize(profile_.get(), NULL);
560 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) 561 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
561 .WillRepeatedly(Return(true)); 562 .WillRepeatedly(Return(true));
562 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) 563 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
563 .WillRepeatedly(Return(false)); 564 .WillRepeatedly(Return(false));
564 error_ = GoogleServiceAuthError::AuthErrorNone(); 565 error_ = GoogleServiceAuthError::AuthErrorNone();
565 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); 566 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
566 // Sync backend is stopped initially, and will start up. 567 // Sync backend is stopped initially, and will start up.
567 EXPECT_CALL(*mock_pss_, sync_initialized()) 568 EXPECT_CALL(*mock_pss_, sync_initialized())
568 .WillRepeatedly(Return(false)); 569 .WillRepeatedly(Return(false));
569 SetDefaultExpectationsForConfigPage(); 570 SetDefaultExpectationsForConfigPage();
570 571
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 // initialized (meaning it already transitioned from the spinner to a proper 609 // initialized (meaning it already transitioned from the spinner to a proper
609 // configuration page, tested by 610 // configuration page, tested by
610 // DisplayConfigureWithBackendDisabledAndSigninSuccess), but before the user 611 // DisplayConfigureWithBackendDisabledAndSigninSuccess), but before the user
611 // before the user has continued on. 612 // before the user has continued on.
612 TEST_P(SyncSetupHandlerTest, 613 TEST_P(SyncSetupHandlerTest,
613 DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) { 614 DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) {
614 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) 615 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
615 .WillRepeatedly(Return(true)); 616 .WillRepeatedly(Return(true));
616 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser); 617 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser);
617 mock_signin_->Initialize(profile_.get(), NULL); 618 mock_signin_->Initialize(profile_.get(), NULL);
618 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) 619 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
619 .WillRepeatedly(Return(true)); 620 .WillRepeatedly(Return(true));
620 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) 621 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
621 .WillRepeatedly(Return(false)); 622 .WillRepeatedly(Return(false));
622 error_ = GoogleServiceAuthError::AuthErrorNone(); 623 error_ = GoogleServiceAuthError::AuthErrorNone();
623 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); 624 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
624 EXPECT_CALL(*mock_pss_, sync_initialized()) 625 EXPECT_CALL(*mock_pss_, sync_initialized())
625 .WillOnce(Return(false)) 626 .WillOnce(Return(false))
626 .WillRepeatedly(Return(true)); 627 .WillRepeatedly(Return(true));
627 SetDefaultExpectationsForConfigPage(); 628 SetDefaultExpectationsForConfigPage();
628 handler_->OpenSyncSetup(); 629 handler_->OpenSyncSetup();
(...skipping 10 matching lines...) Expand all
639 LoginUIServiceFactory::GetForProfile( 640 LoginUIServiceFactory::GetForProfile(
640 profile_.get())->current_login_ui()); 641 profile_.get())->current_login_ui());
641 } 642 }
642 643
643 TEST_P(SyncSetupHandlerTest, 644 TEST_P(SyncSetupHandlerTest,
644 DisplayConfigureWithBackendDisabledAndSigninFalied) { 645 DisplayConfigureWithBackendDisabledAndSigninFalied) {
645 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) 646 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
646 .WillRepeatedly(Return(true)); 647 .WillRepeatedly(Return(true));
647 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser); 648 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser);
648 mock_signin_->Initialize(profile_.get(), NULL); 649 mock_signin_->Initialize(profile_.get(), NULL);
649 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) 650 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
650 .WillRepeatedly(Return(true)); 651 .WillRepeatedly(Return(true));
651 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) 652 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
652 .WillRepeatedly(Return(false)); 653 .WillRepeatedly(Return(false));
653 error_ = GoogleServiceAuthError::AuthErrorNone(); 654 error_ = GoogleServiceAuthError::AuthErrorNone();
654 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); 655 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
655 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); 656 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false));
656 657
657 handler_->OpenSyncSetup(); 658 handler_->OpenSyncSetup();
658 const TestWebUI::CallData& data = web_ui_.call_data()[0]; 659 const TestWebUI::CallData& data = web_ui_.call_data()[0];
659 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); 660 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name);
(...skipping 18 matching lines...) Expand all
678 SyncSetupHandlerTest::SetUp(); 679 SyncSetupHandlerTest::SetUp();
679 mock_signin_ = static_cast<SigninManagerBase*>( 680 mock_signin_ = static_cast<SigninManagerBase*>(
680 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( 681 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse(
681 profile_.get(), FakeSigninManager::Build)); 682 profile_.get(), FakeSigninManager::Build));
682 } 683 }
683 }; 684 };
684 685
685 TEST_P(SyncSetupHandlerNonCrosTest, HandleGaiaAuthFailure) { 686 TEST_P(SyncSetupHandlerNonCrosTest, HandleGaiaAuthFailure) {
686 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) 687 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
687 .WillRepeatedly(Return(false)); 688 .WillRepeatedly(Return(false));
688 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) 689 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
689 .WillRepeatedly(Return(false)); 690 .WillRepeatedly(Return(false));
690 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) 691 EXPECT_CALL(*mock_pss_, HasUnrecoverableError())
691 .WillRepeatedly(Return(false)); 692 .WillRepeatedly(Return(false));
692 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) 693 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
693 .WillRepeatedly(Return(false)); 694 .WillRepeatedly(Return(false));
694 // Open the web UI. 695 // Open the web UI.
695 handler_->OpenSyncSetup(); 696 handler_->OpenSyncSetup();
696 697
697 if (!SyncPromoUI::UseWebBasedSigninFlow()) { 698 if (!SyncPromoUI::UseWebBasedSigninFlow()) {
698 // Fake a failed signin attempt. 699 // Fake a failed signin attempt.
(...skipping 22 matching lines...) Expand all
721 std::string()); 722 std::string());
722 } else { 723 } else {
723 ASSERT_FALSE(handler_->is_configuring_sync()); 724 ASSERT_FALSE(handler_->is_configuring_sync());
724 ASSERT_TRUE(handler_->have_signin_tracker()); 725 ASSERT_TRUE(handler_->have_signin_tracker());
725 } 726 }
726 } 727 }
727 728
728 TEST_P(SyncSetupHandlerNonCrosTest, HandleCaptcha) { 729 TEST_P(SyncSetupHandlerNonCrosTest, HandleCaptcha) {
729 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) 730 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
730 .WillRepeatedly(Return(false)); 731 .WillRepeatedly(Return(false));
731 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) 732 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
732 .WillRepeatedly(Return(false)); 733 .WillRepeatedly(Return(false));
733 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) 734 EXPECT_CALL(*mock_pss_, HasUnrecoverableError())
734 .WillRepeatedly(Return(false)); 735 .WillRepeatedly(Return(false));
735 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) 736 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
736 .WillRepeatedly(Return(false)); 737 .WillRepeatedly(Return(false));
737 // Open the web UI. 738 // Open the web UI.
738 handler_->OpenSyncSetup(); 739 handler_->OpenSyncSetup();
739 740
740 if (!SyncPromoUI::UseWebBasedSigninFlow()) { 741 if (!SyncPromoUI::UseWebBasedSigninFlow()) {
741 // Fake a failed signin attempt that requires a captcha. 742 // Fake a failed signin attempt that requires a captcha.
(...skipping 23 matching lines...) Expand all
765 } else { 766 } else {
766 ASSERT_FALSE(handler_->is_configuring_sync()); 767 ASSERT_FALSE(handler_->is_configuring_sync());
767 ASSERT_TRUE(handler_->have_signin_tracker()); 768 ASSERT_TRUE(handler_->have_signin_tracker());
768 } 769 }
769 } 770 }
770 771
771 // TODO(kochi): We need equivalent tests for ChromeOS. 772 // TODO(kochi): We need equivalent tests for ChromeOS.
772 TEST_P(SyncSetupHandlerNonCrosTest, UnrecoverableErrorInitializingSync) { 773 TEST_P(SyncSetupHandlerNonCrosTest, UnrecoverableErrorInitializingSync) {
773 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) 774 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
774 .WillRepeatedly(Return(false)); 775 .WillRepeatedly(Return(false));
775 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) 776 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
776 .WillRepeatedly(Return(false)); 777 .WillRepeatedly(Return(false));
777 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) 778 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
778 .WillRepeatedly(Return(false)); 779 .WillRepeatedly(Return(false));
779 // Open the web UI. 780 // Open the web UI.
780 handler_->OpenSyncSetup(); 781 handler_->OpenSyncSetup();
781 782
782 if (!SyncPromoUI::UseWebBasedSigninFlow()) { 783 if (!SyncPromoUI::UseWebBasedSigninFlow()) {
783 ASSERT_EQ(1U, web_ui_.call_data().size()); 784 ASSERT_EQ(1U, web_ui_.call_data().size());
784 // Fake a successful GAIA request (gaia credentials valid, but signin not 785 // Fake a successful GAIA request (gaia credentials valid, but signin not
785 // complete yet). 786 // complete yet).
(...skipping 29 matching lines...) Expand all
815 std::string()); 816 std::string());
816 } else { 817 } else {
817 ASSERT_FALSE(handler_->is_configuring_sync()); 818 ASSERT_FALSE(handler_->is_configuring_sync());
818 ASSERT_TRUE(handler_->have_signin_tracker()); 819 ASSERT_TRUE(handler_->have_signin_tracker());
819 } 820 }
820 } 821 }
821 822
822 TEST_P(SyncSetupHandlerNonCrosTest, GaiaErrorInitializingSync) { 823 TEST_P(SyncSetupHandlerNonCrosTest, GaiaErrorInitializingSync) {
823 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) 824 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
824 .WillRepeatedly(Return(false)); 825 .WillRepeatedly(Return(false));
825 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) 826 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
826 .WillRepeatedly(Return(false)); 827 .WillRepeatedly(Return(false));
827 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) 828 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
828 .WillRepeatedly(Return(false)); 829 .WillRepeatedly(Return(false));
829 // Open the web UI. 830 // Open the web UI.
830 handler_->OpenSyncSetup(); 831 handler_->OpenSyncSetup();
831 832
832 if (!SyncPromoUI::UseWebBasedSigninFlow()) { 833 if (!SyncPromoUI::UseWebBasedSigninFlow()) {
833 ASSERT_EQ(1U, web_ui_.call_data().size()); 834 ASSERT_EQ(1U, web_ui_.call_data().size());
834 // Fake a successful GAIA request (gaia credentials valid, but signin not 835 // Fake a successful GAIA request (gaia credentials valid, but signin not
835 // complete yet). 836 // complete yet).
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 // Initialize the system to a signed in state, but with an auth error. 1151 // Initialize the system to a signed in state, but with an auth error.
1151 error_ = GoogleServiceAuthError( 1152 error_ = GoogleServiceAuthError(
1152 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); 1153 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
1153 1154
1154 SetupInitializedProfileSyncService(); 1155 SetupInitializedProfileSyncService();
1155 mock_signin_->SetAuthenticatedUsername(kTestUser); 1156 mock_signin_->SetAuthenticatedUsername(kTestUser);
1156 FakeAuthStatusProvider provider(mock_signin_->signin_global_error()); 1157 FakeAuthStatusProvider provider(mock_signin_->signin_global_error());
1157 provider.SetAuthError(error_); 1158 provider.SetAuthError(error_);
1158 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) 1159 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
1159 .WillRepeatedly(Return(true)); 1160 .WillRepeatedly(Return(true));
1160 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) 1161 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
1161 .WillRepeatedly(Return(true)); 1162 .WillRepeatedly(Return(true));
1162 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 1163 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
1163 .WillRepeatedly(Return(false)); 1164 .WillRepeatedly(Return(false));
1164 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 1165 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
1165 .WillRepeatedly(Return(false)); 1166 .WillRepeatedly(Return(false));
1166 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); 1167 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
1167 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); 1168 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false));
1168 1169
1169 #if defined(CHROME_OS) 1170 #if defined(CHROME_OS)
1170 // On ChromeOS, auth errors are ignored - instead we just try to start the 1171 // On ChromeOS, auth errors are ignored - instead we just try to start the
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 ExpectConfig(); 1352 ExpectConfig();
1352 const TestWebUI::CallData& data = web_ui_.call_data()[0]; 1353 const TestWebUI::CallData& data = web_ui_.call_data()[0];
1353 DictionaryValue* dictionary; 1354 DictionaryValue* dictionary;
1354 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); 1355 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary));
1355 CheckBool(dictionary, "encryptAllData", true); 1356 CheckBool(dictionary, "encryptAllData", true);
1356 } 1357 }
1357 1358
1358 INSTANTIATE_TEST_CASE_P(SyncSetupHandlerTestWithParam, 1359 INSTANTIATE_TEST_CASE_P(SyncSetupHandlerTestWithParam,
1359 SyncSetupHandlerTest, 1360 SyncSetupHandlerTest,
1360 Values(true, false)); 1361 Values(true, false));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698