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