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" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chrome/browser/signin/fake_auth_status_provider.h" | 16 #include "chrome/browser/signin/fake_auth_status_provider.h" |
17 #include "chrome/browser/signin/fake_signin_manager.h" | 17 #include "chrome/browser/signin/fake_signin_manager.h" |
18 #include "chrome/browser/signin/signin_manager.h" | 18 #include "chrome/browser/signin/signin_manager.h" |
19 #include "chrome/browser/signin/signin_manager_factory.h" | 19 #include "chrome/browser/signin/signin_manager_factory.h" |
20 #include "chrome/browser/sync/profile_sync_service_factory.h" | 20 #include "chrome/browser/sync/profile_sync_service_factory.h" |
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/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
26 #include "chrome/test/base/testing_profile.h" | 26 #include "chrome/test/base/testing_profile.h" |
27 #include "chrome/test/base/testing_browser_process.h" | 27 #include "chrome/test/base/testing_browser_process.h" |
28 #include "chrome/test/base/scoped_testing_local_state.h" | 28 #include "chrome/test/base/scoped_testing_local_state.h" |
29 #include "content/public/browser/web_ui.h" | 29 #include "content/public/browser/web_ui.h" |
| 30 #include "content/public/test/test_browser_thread.h" |
30 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
31 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
32 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
33 #include "ui/base/layout.h" | 34 #include "ui/base/layout.h" |
34 | 35 |
35 using ::testing::_; | 36 using ::testing::_; |
36 using ::testing::Mock; | 37 using ::testing::Mock; |
37 using ::testing::Return; | 38 using ::testing::Return; |
38 using ::testing::ReturnRef; | 39 using ::testing::ReturnRef; |
39 using ::testing::Values; | 40 using ::testing::Values; |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 void SetupInitializedProfileSyncService() { | 374 void SetupInitializedProfileSyncService() { |
374 // An initialized ProfileSyncService will have already completed sync setup | 375 // An initialized ProfileSyncService will have already completed sync setup |
375 // and will have an initialized sync backend. | 376 // and will have an initialized sync backend. |
376 if (!mock_signin_->IsInitialized()) { | 377 if (!mock_signin_->IsInitialized()) { |
377 profile_->GetPrefs()->SetString( | 378 profile_->GetPrefs()->SetString( |
378 prefs::kGoogleServicesUsername, kTestUser); | 379 prefs::kGoogleServicesUsername, kTestUser); |
379 mock_signin_->Initialize(profile_.get(), NULL); | 380 mock_signin_->Initialize(profile_.get(), NULL); |
380 } | 381 } |
381 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 382 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
382 .WillRepeatedly(Return(true)); | 383 .WillRepeatedly(Return(true)); |
383 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 384 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
384 .WillRepeatedly(Return(true)); | 385 .WillRepeatedly(Return(true)); |
385 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 386 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
386 .WillRepeatedly(Return(true)); | 387 .WillRepeatedly(Return(true)); |
387 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 388 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
388 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(true)); | 389 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(true)); |
389 } | 390 } |
390 | 391 |
391 void ExpectConfig() { | 392 void ExpectConfig() { |
392 ASSERT_EQ(1U, web_ui_.call_data().size()); | 393 ASSERT_EQ(1U, web_ui_.call_data().size()); |
393 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 394 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 scoped_ptr<TestingSyncSetupHandler> handler_; | 435 scoped_ptr<TestingSyncSetupHandler> handler_; |
435 }; | 436 }; |
436 | 437 |
437 TEST_F(SyncSetupHandlerTest, Basic) { | 438 TEST_F(SyncSetupHandlerTest, Basic) { |
438 } | 439 } |
439 | 440 |
440 #if !defined(OS_CHROMEOS) | 441 #if !defined(OS_CHROMEOS) |
441 TEST_F(SyncSetupHandlerTest, DisplayBasicLogin) { | 442 TEST_F(SyncSetupHandlerTest, DisplayBasicLogin) { |
442 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 443 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
443 .WillRepeatedly(Return(false)); | 444 .WillRepeatedly(Return(false)); |
444 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 445 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
445 .WillRepeatedly(Return(false)); | 446 .WillRepeatedly(Return(false)); |
446 const GoogleServiceAuthError error(GoogleServiceAuthError::NONE); | 447 const GoogleServiceAuthError error(GoogleServiceAuthError::NONE); |
447 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error)); | 448 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error)); |
448 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 449 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
449 .WillRepeatedly(Return(false)); | 450 .WillRepeatedly(Return(false)); |
450 handler_->HandleStartSignin(NULL); | 451 handler_->HandleStartSignin(NULL); |
451 EXPECT_EQ(handler_.get(), | 452 EXPECT_EQ(handler_.get(), |
452 LoginUIServiceFactory::GetForProfile( | 453 LoginUIServiceFactory::GetForProfile( |
453 profile_.get())->current_login_ui()); | 454 profile_.get())->current_login_ui()); |
454 | 455 |
455 ASSERT_FALSE(handler_->is_configuring_sync()); | 456 ASSERT_FALSE(handler_->is_configuring_sync()); |
456 ASSERT_TRUE(handler_->have_signin_tracker()); | 457 ASSERT_TRUE(handler_->have_signin_tracker()); |
457 | 458 |
458 handler_->CloseSyncSetup(); | 459 handler_->CloseSyncSetup(); |
459 EXPECT_EQ(NULL, | 460 EXPECT_EQ(NULL, |
460 LoginUIServiceFactory::GetForProfile( | 461 LoginUIServiceFactory::GetForProfile( |
461 profile_.get())->current_login_ui()); | 462 profile_.get())->current_login_ui()); |
462 } | 463 } |
463 | 464 |
464 TEST_F(SyncSetupHandlerTest, ShowSyncSetupWhenNotSignedIn) { | 465 TEST_F(SyncSetupHandlerTest, ShowSyncSetupWhenNotSignedIn) { |
465 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 466 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
466 .WillRepeatedly(Return(false)); | 467 .WillRepeatedly(Return(false)); |
467 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 468 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
468 .WillRepeatedly(Return(false)); | 469 .WillRepeatedly(Return(false)); |
469 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 470 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
470 .WillRepeatedly(Return(false)); | 471 .WillRepeatedly(Return(false)); |
471 handler_->HandleShowSetupUI(NULL); | 472 handler_->HandleShowSetupUI(NULL); |
472 | 473 |
473 ASSERT_EQ(1U, web_ui_.call_data().size()); | 474 ASSERT_EQ(1U, web_ui_.call_data().size()); |
474 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 475 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
475 EXPECT_EQ("OptionsPage.closeOverlay", data.function_name); | 476 EXPECT_EQ("OptionsPage.closeOverlay", data.function_name); |
476 ASSERT_FALSE(handler_->is_configuring_sync()); | 477 ASSERT_FALSE(handler_->is_configuring_sync()); |
477 EXPECT_EQ(NULL, | 478 EXPECT_EQ(NULL, |
478 LoginUIServiceFactory::GetForProfile( | 479 LoginUIServiceFactory::GetForProfile( |
479 profile_.get())->current_login_ui()); | 480 profile_.get())->current_login_ui()); |
480 } | 481 } |
481 #endif | 482 #endif |
482 | 483 |
483 // Verifies that the handler correctly handles a cancellation when | 484 // Verifies that the handler correctly handles a cancellation when |
484 // it is displaying the spinner to the user. | 485 // it is displaying the spinner to the user. |
485 TEST_F(SyncSetupHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) { | 486 TEST_F(SyncSetupHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) { |
486 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 487 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
487 .WillRepeatedly(Return(true)); | 488 .WillRepeatedly(Return(true)); |
488 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser); | 489 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser); |
489 mock_signin_->Initialize(profile_.get(), NULL); | 490 mock_signin_->Initialize(profile_.get(), NULL); |
490 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 491 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
491 .WillRepeatedly(Return(true)); | 492 .WillRepeatedly(Return(true)); |
492 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 493 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
493 .WillRepeatedly(Return(false)); | 494 .WillRepeatedly(Return(false)); |
494 error_ = GoogleServiceAuthError::AuthErrorNone(); | 495 error_ = GoogleServiceAuthError::AuthErrorNone(); |
495 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 496 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
496 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); | 497 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); |
497 | 498 |
498 // We're simulating a user setting up sync, which would cause the backend to | 499 // We're simulating a user setting up sync, which would cause the backend to |
499 // kick off initialization, but not download user data types. The sync | 500 // kick off initialization, but not download user data types. The sync |
500 // backend will try to download control data types (e.g encryption info), but | 501 // backend will try to download control data types (e.g encryption info), but |
501 // that won't finish for this test as we're simulating cancelling while the | 502 // that won't finish for this test as we're simulating cancelling while the |
502 // spinner is showing. | 503 // spinner is showing. |
503 handler_->HandleShowSetupUI(NULL); | 504 handler_->HandleShowSetupUI(NULL); |
504 | 505 |
505 EXPECT_EQ(handler_.get(), | 506 EXPECT_EQ(handler_.get(), |
506 LoginUIServiceFactory::GetForProfile( | 507 LoginUIServiceFactory::GetForProfile( |
507 profile_.get())->current_login_ui()); | 508 profile_.get())->current_login_ui()); |
508 | 509 |
509 ExpectSpinnerAndClose(); | 510 ExpectSpinnerAndClose(); |
510 } | 511 } |
511 | 512 |
512 // Verifies that the handler correctly transitions from showing the spinner | 513 // Verifies that the handler correctly transitions from showing the spinner |
513 // to showing a configuration page when signin completes successfully. | 514 // to showing a configuration page when signin completes successfully. |
514 TEST_F(SyncSetupHandlerTest, | 515 TEST_F(SyncSetupHandlerTest, |
515 DisplayConfigureWithBackendDisabledAndSigninSuccess) { | 516 DisplayConfigureWithBackendDisabledAndSigninSuccess) { |
516 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 517 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
517 .WillRepeatedly(Return(true)); | 518 .WillRepeatedly(Return(true)); |
518 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser); | 519 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser); |
519 mock_signin_->Initialize(profile_.get(), NULL); | 520 mock_signin_->Initialize(profile_.get(), NULL); |
520 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 521 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
521 .WillRepeatedly(Return(true)); | 522 .WillRepeatedly(Return(true)); |
522 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 523 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
523 .WillRepeatedly(Return(false)); | 524 .WillRepeatedly(Return(false)); |
524 error_ = GoogleServiceAuthError::AuthErrorNone(); | 525 error_ = GoogleServiceAuthError::AuthErrorNone(); |
525 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 526 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
526 // Sync backend is stopped initially, and will start up. | 527 // Sync backend is stopped initially, and will start up. |
527 EXPECT_CALL(*mock_pss_, sync_initialized()) | 528 EXPECT_CALL(*mock_pss_, sync_initialized()) |
528 .WillRepeatedly(Return(false)); | 529 .WillRepeatedly(Return(false)); |
529 SetDefaultExpectationsForConfigPage(); | 530 SetDefaultExpectationsForConfigPage(); |
530 | 531 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 // initialized (meaning it already transitioned from the spinner to a proper | 569 // initialized (meaning it already transitioned from the spinner to a proper |
569 // configuration page, tested by | 570 // configuration page, tested by |
570 // DisplayConfigureWithBackendDisabledAndSigninSuccess), but before the user | 571 // DisplayConfigureWithBackendDisabledAndSigninSuccess), but before the user |
571 // before the user has continued on. | 572 // before the user has continued on. |
572 TEST_F(SyncSetupHandlerTest, | 573 TEST_F(SyncSetupHandlerTest, |
573 DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) { | 574 DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) { |
574 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 575 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
575 .WillRepeatedly(Return(true)); | 576 .WillRepeatedly(Return(true)); |
576 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser); | 577 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser); |
577 mock_signin_->Initialize(profile_.get(), NULL); | 578 mock_signin_->Initialize(profile_.get(), NULL); |
578 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 579 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
579 .WillRepeatedly(Return(true)); | 580 .WillRepeatedly(Return(true)); |
580 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 581 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
581 .WillRepeatedly(Return(false)); | 582 .WillRepeatedly(Return(false)); |
582 error_ = GoogleServiceAuthError::AuthErrorNone(); | 583 error_ = GoogleServiceAuthError::AuthErrorNone(); |
583 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 584 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
584 EXPECT_CALL(*mock_pss_, sync_initialized()) | 585 EXPECT_CALL(*mock_pss_, sync_initialized()) |
585 .WillOnce(Return(false)) | 586 .WillOnce(Return(false)) |
586 .WillRepeatedly(Return(true)); | 587 .WillRepeatedly(Return(true)); |
587 SetDefaultExpectationsForConfigPage(); | 588 SetDefaultExpectationsForConfigPage(); |
588 handler_->OpenSyncSetup(); | 589 handler_->OpenSyncSetup(); |
(...skipping 10 matching lines...) Expand all Loading... |
599 LoginUIServiceFactory::GetForProfile( | 600 LoginUIServiceFactory::GetForProfile( |
600 profile_.get())->current_login_ui()); | 601 profile_.get())->current_login_ui()); |
601 } | 602 } |
602 | 603 |
603 TEST_F(SyncSetupHandlerTest, | 604 TEST_F(SyncSetupHandlerTest, |
604 DisplayConfigureWithBackendDisabledAndSigninFalied) { | 605 DisplayConfigureWithBackendDisabledAndSigninFalied) { |
605 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 606 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
606 .WillRepeatedly(Return(true)); | 607 .WillRepeatedly(Return(true)); |
607 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser); | 608 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser); |
608 mock_signin_->Initialize(profile_.get(), NULL); | 609 mock_signin_->Initialize(profile_.get(), NULL); |
609 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 610 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
610 .WillRepeatedly(Return(true)); | 611 .WillRepeatedly(Return(true)); |
611 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 612 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
612 .WillRepeatedly(Return(false)); | 613 .WillRepeatedly(Return(false)); |
613 error_ = GoogleServiceAuthError::AuthErrorNone(); | 614 error_ = GoogleServiceAuthError::AuthErrorNone(); |
614 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 615 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
615 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); | 616 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); |
616 | 617 |
617 handler_->OpenSyncSetup(); | 618 handler_->OpenSyncSetup(); |
618 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 619 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
619 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 620 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); |
(...skipping 18 matching lines...) Expand all Loading... |
638 SyncSetupHandlerTest::SetUp(); | 639 SyncSetupHandlerTest::SetUp(); |
639 mock_signin_ = static_cast<SigninManagerBase*>( | 640 mock_signin_ = static_cast<SigninManagerBase*>( |
640 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( | 641 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( |
641 profile_.get(), FakeSigninManager::Build)); | 642 profile_.get(), FakeSigninManager::Build)); |
642 } | 643 } |
643 }; | 644 }; |
644 | 645 |
645 TEST_F(SyncSetupHandlerNonCrosTest, HandleGaiaAuthFailure) { | 646 TEST_F(SyncSetupHandlerNonCrosTest, HandleGaiaAuthFailure) { |
646 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 647 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
647 .WillRepeatedly(Return(false)); | 648 .WillRepeatedly(Return(false)); |
648 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 649 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
649 .WillRepeatedly(Return(false)); | 650 .WillRepeatedly(Return(false)); |
650 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) | 651 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) |
651 .WillRepeatedly(Return(false)); | 652 .WillRepeatedly(Return(false)); |
652 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 653 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
653 .WillRepeatedly(Return(false)); | 654 .WillRepeatedly(Return(false)); |
654 // Open the web UI. | 655 // Open the web UI. |
655 handler_->OpenSyncSetup(); | 656 handler_->OpenSyncSetup(); |
656 | 657 |
657 ASSERT_FALSE(handler_->is_configuring_sync()); | 658 ASSERT_FALSE(handler_->is_configuring_sync()); |
658 ASSERT_TRUE(handler_->have_signin_tracker()); | 659 ASSERT_TRUE(handler_->have_signin_tracker()); |
659 } | 660 } |
660 | 661 |
661 // TODO(kochi): We need equivalent tests for ChromeOS. | 662 // TODO(kochi): We need equivalent tests for ChromeOS. |
662 TEST_F(SyncSetupHandlerNonCrosTest, UnrecoverableErrorInitializingSync) { | 663 TEST_F(SyncSetupHandlerNonCrosTest, UnrecoverableErrorInitializingSync) { |
663 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 664 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
664 .WillRepeatedly(Return(false)); | 665 .WillRepeatedly(Return(false)); |
665 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 666 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
666 .WillRepeatedly(Return(false)); | 667 .WillRepeatedly(Return(false)); |
667 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 668 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
668 .WillRepeatedly(Return(false)); | 669 .WillRepeatedly(Return(false)); |
669 // Open the web UI. | 670 // Open the web UI. |
670 handler_->OpenSyncSetup(); | 671 handler_->OpenSyncSetup(); |
671 | 672 |
672 ASSERT_FALSE(handler_->is_configuring_sync()); | 673 ASSERT_FALSE(handler_->is_configuring_sync()); |
673 ASSERT_TRUE(handler_->have_signin_tracker()); | 674 ASSERT_TRUE(handler_->have_signin_tracker()); |
674 } | 675 } |
675 | 676 |
676 TEST_F(SyncSetupHandlerNonCrosTest, GaiaErrorInitializingSync) { | 677 TEST_F(SyncSetupHandlerNonCrosTest, GaiaErrorInitializingSync) { |
677 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 678 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
678 .WillRepeatedly(Return(false)); | 679 .WillRepeatedly(Return(false)); |
679 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 680 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
680 .WillRepeatedly(Return(false)); | 681 .WillRepeatedly(Return(false)); |
681 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 682 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
682 .WillRepeatedly(Return(false)); | 683 .WillRepeatedly(Return(false)); |
683 // Open the web UI. | 684 // Open the web UI. |
684 handler_->OpenSyncSetup(); | 685 handler_->OpenSyncSetup(); |
685 | 686 |
686 ASSERT_FALSE(handler_->is_configuring_sync()); | 687 ASSERT_FALSE(handler_->is_configuring_sync()); |
687 ASSERT_TRUE(handler_->have_signin_tracker()); | 688 ASSERT_TRUE(handler_->have_signin_tracker()); |
688 } | 689 } |
689 | 690 |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 // Initialize the system to a signed in state, but with an auth error. | 919 // Initialize the system to a signed in state, but with an auth error. |
919 error_ = GoogleServiceAuthError( | 920 error_ = GoogleServiceAuthError( |
920 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 921 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
921 | 922 |
922 SetupInitializedProfileSyncService(); | 923 SetupInitializedProfileSyncService(); |
923 mock_signin_->SetAuthenticatedUsername(kTestUser); | 924 mock_signin_->SetAuthenticatedUsername(kTestUser); |
924 FakeAuthStatusProvider provider(mock_signin_->signin_global_error()); | 925 FakeAuthStatusProvider provider(mock_signin_->signin_global_error()); |
925 provider.SetAuthError(error_); | 926 provider.SetAuthError(error_); |
926 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 927 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
927 .WillRepeatedly(Return(true)); | 928 .WillRepeatedly(Return(true)); |
928 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 929 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
929 .WillRepeatedly(Return(true)); | 930 .WillRepeatedly(Return(true)); |
930 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 931 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
931 .WillRepeatedly(Return(false)); | 932 .WillRepeatedly(Return(false)); |
932 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 933 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
933 .WillRepeatedly(Return(false)); | 934 .WillRepeatedly(Return(false)); |
934 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 935 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
935 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); | 936 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); |
936 | 937 |
937 #if defined(CHROME_OS) | 938 #if defined(CHROME_OS) |
938 // On ChromeOS, auth errors are ignored - instead we just try to start the | 939 // On ChromeOS, auth errors are ignored - instead we just try to start the |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 | 1096 |
1096 // This should display the sync setup dialog (not login). | 1097 // This should display the sync setup dialog (not login). |
1097 handler_->OpenSyncSetup(); | 1098 handler_->OpenSyncSetup(); |
1098 | 1099 |
1099 ExpectConfig(); | 1100 ExpectConfig(); |
1100 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 1101 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
1101 DictionaryValue* dictionary; | 1102 DictionaryValue* dictionary; |
1102 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 1103 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
1103 CheckBool(dictionary, "encryptAllData", true); | 1104 CheckBool(dictionary, "encryptAllData", true); |
1104 } | 1105 } |
OLD | NEW |