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

Side by Side Diff: chrome/browser/ui/webui/settings/people_handler_unittest.cc

Issue 2603283003: [MD Settings][People] Force sign out only in the case of unrecoverable error (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « chrome/browser/ui/webui/settings/people_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/settings/people_handler.h" 5 #include "chrome/browser/ui/webui/settings/people_handler.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 // to showing a configuration page when sync setup completes successfully. 397 // to showing a configuration page when sync setup completes successfully.
398 TEST_F(PeopleHandlerTest, 398 TEST_F(PeopleHandlerTest,
399 DisplayConfigureWithBackendDisabledAndSyncStartupCompleted) { 399 DisplayConfigureWithBackendDisabledAndSyncStartupCompleted) {
400 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); 400 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true));
401 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); 401 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
402 error_ = GoogleServiceAuthError::AuthErrorNone(); 402 error_ = GoogleServiceAuthError::AuthErrorNone();
403 // Sync backend is stopped initially, and will start up. 403 // Sync backend is stopped initially, and will start up.
404 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); 404 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false));
405 SetDefaultExpectationsForConfigPage(); 405 SetDefaultExpectationsForConfigPage();
406 406
407 handler_->OpenSyncSetup(false /* creating_supervised_user */); 407 handler_->OpenSyncSetup();
408 408
409 EXPECT_EQ(1U, web_ui_.call_data().size()); 409 EXPECT_EQ(1U, web_ui_.call_data().size());
410 ExpectPageStatusChanged(PeopleHandler::kSpinnerPageStatus); 410 ExpectPageStatusChanged(PeopleHandler::kSpinnerPageStatus);
411 411
412 Mock::VerifyAndClearExpectations(mock_pss_); 412 Mock::VerifyAndClearExpectations(mock_pss_);
413 // Now, act as if the ProfileSyncService has started up. 413 // Now, act as if the ProfileSyncService has started up.
414 SetDefaultExpectationsForConfigPage(); 414 SetDefaultExpectationsForConfigPage();
415 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(true)); 415 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(true));
416 error_ = GoogleServiceAuthError::AuthErrorNone(); 416 error_ = GoogleServiceAuthError::AuthErrorNone();
417 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); 417 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
(...skipping 15 matching lines...) Expand all
433 // before the user has continued on. 433 // before the user has continued on.
434 TEST_F(PeopleHandlerTest, 434 TEST_F(PeopleHandlerTest,
435 DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) { 435 DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) {
436 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); 436 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true));
437 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); 437 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
438 error_ = GoogleServiceAuthError::AuthErrorNone(); 438 error_ = GoogleServiceAuthError::AuthErrorNone();
439 EXPECT_CALL(*mock_pss_, IsBackendInitialized()) 439 EXPECT_CALL(*mock_pss_, IsBackendInitialized())
440 .WillOnce(Return(false)) 440 .WillOnce(Return(false))
441 .WillRepeatedly(Return(true)); 441 .WillRepeatedly(Return(true));
442 SetDefaultExpectationsForConfigPage(); 442 SetDefaultExpectationsForConfigPage();
443 handler_->OpenSyncSetup(false /* creating_supervised_user */); 443 handler_->OpenSyncSetup();
444 444
445 // It's important to tell sync the user cancelled the setup flow before we 445 // It's important to tell sync the user cancelled the setup flow before we
446 // tell it we're through with the setup progress. 446 // tell it we're through with the setup progress.
447 testing::InSequence seq; 447 testing::InSequence seq;
448 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA)); 448 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA));
449 EXPECT_CALL(*mock_pss_, OnSetupInProgressHandleDestroyed()); 449 EXPECT_CALL(*mock_pss_, OnSetupInProgressHandleDestroyed());
450 450
451 handler_->CloseSyncSetup(); 451 handler_->CloseSyncSetup();
452 EXPECT_EQ(NULL, 452 EXPECT_EQ(NULL,
453 LoginUIServiceFactory::GetForProfile( 453 LoginUIServiceFactory::GetForProfile(
454 profile_)->current_login_ui()); 454 profile_)->current_login_ui());
455 } 455 }
456 456
457 TEST_F(PeopleHandlerTest, 457 TEST_F(PeopleHandlerTest,
458 DisplayConfigureWithBackendDisabledAndSigninFailed) { 458 DisplayConfigureWithBackendDisabledAndSigninFailed) {
459 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); 459 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true));
460 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); 460 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
461 error_ = GoogleServiceAuthError::AuthErrorNone(); 461 error_ = GoogleServiceAuthError::AuthErrorNone();
462 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); 462 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false));
463 463
464 handler_->OpenSyncSetup(false /* creating_supervised_user */); 464 handler_->OpenSyncSetup();
465 ExpectPageStatusChanged(PeopleHandler::kSpinnerPageStatus); 465 ExpectPageStatusChanged(PeopleHandler::kSpinnerPageStatus);
466 Mock::VerifyAndClearExpectations(mock_pss_); 466 Mock::VerifyAndClearExpectations(mock_pss_);
467 error_ = GoogleServiceAuthError( 467 error_ = GoogleServiceAuthError(
468 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); 468 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
469 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); 469 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
470 NotifySyncListeners(); 470 NotifySyncListeners();
471 471
472 // On failure, the dialog will be closed. 472 // On failure, the dialog will be closed.
473 EXPECT_EQ(NULL, 473 EXPECT_EQ(NULL,
474 LoginUIServiceFactory::GetForProfile( 474 LoginUIServiceFactory::GetForProfile(
475 profile_)->current_login_ui()); 475 profile_)->current_login_ui());
476 } 476 }
477 477
478 #if !defined(OS_CHROMEOS) 478 #if !defined(OS_CHROMEOS)
479 479
480 class PeopleHandlerNonCrosTest : public PeopleHandlerTest { 480 class PeopleHandlerNonCrosTest : public PeopleHandlerTest {
481 public: 481 public:
482 PeopleHandlerNonCrosTest() {} 482 PeopleHandlerNonCrosTest() {}
483 }; 483 };
484 484
485 TEST_F(PeopleHandlerNonCrosTest, HandleGaiaAuthFailure) { 485 TEST_F(PeopleHandlerNonCrosTest, HandleGaiaAuthFailure) {
486 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); 486 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false));
487 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) 487 EXPECT_CALL(*mock_pss_, HasUnrecoverableError())
488 .WillRepeatedly(Return(false)); 488 .WillRepeatedly(Return(false));
489 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); 489 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
490 // Open the web UI. 490 // Open the web UI.
491 handler_->OpenSyncSetup(false /* creating_supervised_user */); 491 handler_->OpenSyncSetup();
492 492
493 ASSERT_FALSE(handler_->is_configuring_sync()); 493 ASSERT_FALSE(handler_->is_configuring_sync());
494 } 494 }
495 495
496 // TODO(kochi): We need equivalent tests for ChromeOS. 496 // TODO(kochi): We need equivalent tests for ChromeOS.
497 TEST_F(PeopleHandlerNonCrosTest, UnrecoverableErrorInitializingSync) { 497 TEST_F(PeopleHandlerNonCrosTest, UnrecoverableErrorInitializingSync) {
498 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); 498 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false));
499 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); 499 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
500 // Open the web UI. 500 // Open the web UI.
501 handler_->OpenSyncSetup(false /* creating_supervised_user */); 501 handler_->OpenSyncSetup();
502 502
503 ASSERT_FALSE(handler_->is_configuring_sync()); 503 ASSERT_FALSE(handler_->is_configuring_sync());
504 } 504 }
505 505
506 TEST_F(PeopleHandlerNonCrosTest, GaiaErrorInitializingSync) { 506 TEST_F(PeopleHandlerNonCrosTest, GaiaErrorInitializingSync) {
507 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); 507 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false));
508 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); 508 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
509 // Open the web UI. 509 // Open the web UI.
510 handler_->OpenSyncSetup(false /* creating_supervised_user */); 510 handler_->OpenSyncSetup();
511 511
512 ASSERT_FALSE(handler_->is_configuring_sync()); 512 ASSERT_FALSE(handler_->is_configuring_sync());
513 } 513 }
514 514
515 #endif // #if !defined(OS_CHROMEOS) 515 #endif // #if !defined(OS_CHROMEOS)
516 516
517 TEST_F(PeopleHandlerTest, TestSyncEverything) { 517 TEST_F(PeopleHandlerTest, TestSyncEverything) {
518 std::string args = GetConfiguration( 518 std::string args = GetConfiguration(
519 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); 519 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS);
520 base::ListValue list_args; 520 base::ListValue list_args;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 } 700 }
701 701
702 TEST_F(PeopleHandlerTest, ShowSyncSetup) { 702 TEST_F(PeopleHandlerTest, ShowSyncSetup) {
703 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 703 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
704 .WillRepeatedly(Return(false)); 704 .WillRepeatedly(Return(false));
705 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 705 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
706 .WillRepeatedly(Return(false)); 706 .WillRepeatedly(Return(false));
707 SetupInitializedProfileSyncService(); 707 SetupInitializedProfileSyncService();
708 // This should display the sync setup dialog (not login). 708 // This should display the sync setup dialog (not login).
709 SetDefaultExpectationsForConfigPage(); 709 SetDefaultExpectationsForConfigPage();
710 handler_->OpenSyncSetup(false /* creating_supervised_user */); 710 handler_->OpenSyncSetup();
711 711
712 ExpectSyncPrefsChanged(); 712 ExpectSyncPrefsChanged();
713 } 713 }
714 714
715 // We do not display signin on chromeos in the case of auth error. 715 // We do not display signin on chromeos in the case of auth error.
716 TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) { 716 TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) {
717 // Initialize the system to a signed in state, but with an auth error. 717 // Initialize the system to a signed in state, but with an auth error.
718 error_ = GoogleServiceAuthError( 718 error_ = GoogleServiceAuthError(
719 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); 719 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
720 720
(...skipping 14 matching lines...) Expand all
735 // sync backend (which will fail due to the auth error). This should only 735 // sync backend (which will fail due to the auth error). This should only
736 // happen if the user manually navigates to chrome://settings/syncSetup - 736 // happen if the user manually navigates to chrome://settings/syncSetup -
737 // clicking on the button in the UI will sign the user out rather than 737 // clicking on the button in the UI will sign the user out rather than
738 // displaying a spinner. Should be no visible UI on ChromeOS in this case. 738 // displaying a spinner. Should be no visible UI on ChromeOS in this case.
739 EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile( 739 EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile(
740 profile_)->current_login_ui()); 740 profile_)->current_login_ui());
741 #else 741 #else
742 742
743 // On ChromeOS, this should display the spinner while we try to startup the 743 // On ChromeOS, this should display the spinner while we try to startup the
744 // sync backend, and on desktop this displays the login dialog. 744 // sync backend, and on desktop this displays the login dialog.
745 handler_->OpenSyncSetup(false /* creating_supervised_user */); 745 handler_->OpenSyncSetup();
746 746
747 // Sync setup is closed when re-auth is in progress. 747 // Sync setup is closed when re-auth is in progress.
748 EXPECT_EQ(NULL, 748 EXPECT_EQ(NULL,
749 LoginUIServiceFactory::GetForProfile( 749 LoginUIServiceFactory::GetForProfile(
750 profile_)->current_login_ui()); 750 profile_)->current_login_ui());
751 751
752 ASSERT_FALSE(handler_->is_configuring_sync()); 752 ASSERT_FALSE(handler_->is_configuring_sync());
753 #endif 753 #endif
754 } 754 }
755 755
756 TEST_F(PeopleHandlerTest, ShowSetupSyncEverything) { 756 TEST_F(PeopleHandlerTest, ShowSetupSyncEverything) {
757 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 757 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
758 .WillRepeatedly(Return(false)); 758 .WillRepeatedly(Return(false));
759 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 759 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
760 .WillRepeatedly(Return(false)); 760 .WillRepeatedly(Return(false));
761 SetupInitializedProfileSyncService(); 761 SetupInitializedProfileSyncService();
762 SetDefaultExpectationsForConfigPage(); 762 SetDefaultExpectationsForConfigPage();
763 // This should display the sync setup dialog (not login). 763 // This should display the sync setup dialog (not login).
764 handler_->OpenSyncSetup(false /* creating_supervised_user */); 764 handler_->OpenSyncSetup();
765 765
766 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); 766 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged();
767 CheckBool(dictionary, "syncAllDataTypes", true); 767 CheckBool(dictionary, "syncAllDataTypes", true);
768 CheckBool(dictionary, "appsRegistered", true); 768 CheckBool(dictionary, "appsRegistered", true);
769 CheckBool(dictionary, "autofillRegistered", true); 769 CheckBool(dictionary, "autofillRegistered", true);
770 CheckBool(dictionary, "bookmarksRegistered", true); 770 CheckBool(dictionary, "bookmarksRegistered", true);
771 CheckBool(dictionary, "extensionsRegistered", true); 771 CheckBool(dictionary, "extensionsRegistered", true);
772 CheckBool(dictionary, "passwordsRegistered", true); 772 CheckBool(dictionary, "passwordsRegistered", true);
773 CheckBool(dictionary, "preferencesRegistered", true); 773 CheckBool(dictionary, "preferencesRegistered", true);
774 CheckBool(dictionary, "tabsRegistered", true); 774 CheckBool(dictionary, "tabsRegistered", true);
775 CheckBool(dictionary, "themesRegistered", true); 775 CheckBool(dictionary, "themesRegistered", true);
776 CheckBool(dictionary, "typedUrlsRegistered", true); 776 CheckBool(dictionary, "typedUrlsRegistered", true);
777 CheckBool(dictionary, "paymentsIntegrationEnabled", true); 777 CheckBool(dictionary, "paymentsIntegrationEnabled", true);
778 CheckBool(dictionary, "passphraseRequired", false); 778 CheckBool(dictionary, "passphraseRequired", false);
779 CheckBool(dictionary, "passphraseTypeIsCustom", false); 779 CheckBool(dictionary, "passphraseTypeIsCustom", false);
780 CheckBool(dictionary, "encryptAllData", false); 780 CheckBool(dictionary, "encryptAllData", false);
781 CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes()); 781 CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes());
782 } 782 }
783 783
784 TEST_F(PeopleHandlerTest, ShowSetupManuallySyncAll) { 784 TEST_F(PeopleHandlerTest, ShowSetupManuallySyncAll) {
785 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 785 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
786 .WillRepeatedly(Return(false)); 786 .WillRepeatedly(Return(false));
787 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 787 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
788 .WillRepeatedly(Return(false)); 788 .WillRepeatedly(Return(false));
789 SetupInitializedProfileSyncService(); 789 SetupInitializedProfileSyncService();
790 syncer::SyncPrefs sync_prefs(profile_->GetPrefs()); 790 syncer::SyncPrefs sync_prefs(profile_->GetPrefs());
791 sync_prefs.SetKeepEverythingSynced(false); 791 sync_prefs.SetKeepEverythingSynced(false);
792 SetDefaultExpectationsForConfigPage(); 792 SetDefaultExpectationsForConfigPage();
793 // This should display the sync setup dialog (not login). 793 // This should display the sync setup dialog (not login).
794 handler_->OpenSyncSetup(false /* creating_supervised_user */); 794 handler_->OpenSyncSetup();
795 795
796 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); 796 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged();
797 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes()); 797 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes());
798 } 798 }
799 799
800 TEST_F(PeopleHandlerTest, ShowSetupSyncForAllTypesIndividually) { 800 TEST_F(PeopleHandlerTest, ShowSetupSyncForAllTypesIndividually) {
801 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); 801 syncer::ModelTypeSet user_selectable_types = GetAllTypes();
802 syncer::ModelTypeSet::Iterator it; 802 syncer::ModelTypeSet::Iterator it;
803 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { 803 for (it = user_selectable_types.First(); it.Good(); it.Inc()) {
804 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 804 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
805 .WillRepeatedly(Return(false)); 805 .WillRepeatedly(Return(false));
806 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 806 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
807 .WillRepeatedly(Return(false)); 807 .WillRepeatedly(Return(false));
808 SetupInitializedProfileSyncService(); 808 SetupInitializedProfileSyncService();
809 syncer::SyncPrefs sync_prefs(profile_->GetPrefs()); 809 syncer::SyncPrefs sync_prefs(profile_->GetPrefs());
810 sync_prefs.SetKeepEverythingSynced(false); 810 sync_prefs.SetKeepEverythingSynced(false);
811 SetDefaultExpectationsForConfigPage(); 811 SetDefaultExpectationsForConfigPage();
812 syncer::ModelTypeSet types; 812 syncer::ModelTypeSet types;
813 types.Put(it.Get()); 813 types.Put(it.Get());
814 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()). 814 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()).
815 WillRepeatedly(Return(types)); 815 WillRepeatedly(Return(types));
816 816
817 // This should display the sync setup dialog (not login). 817 // This should display the sync setup dialog (not login).
818 handler_->OpenSyncSetup(false /* creating_supervised_user */); 818 handler_->OpenSyncSetup();
819 819
820 // Close the config overlay. 820 // Close the config overlay.
821 LoginUIServiceFactory::GetForProfile(profile_)->LoginUIClosed( 821 LoginUIServiceFactory::GetForProfile(profile_)->LoginUIClosed(
822 handler_.get()); 822 handler_.get());
823 823
824 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); 824 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged();
825 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types); 825 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types);
826 Mock::VerifyAndClearExpectations(mock_pss_); 826 Mock::VerifyAndClearExpectations(mock_pss_);
827 // Clean up so we can loop back to display the dialog again. 827 // Clean up so we can loop back to display the dialog again.
828 web_ui_.ClearTrackedCalls(); 828 web_ui_.ClearTrackedCalls();
829 } 829 }
830 } 830 }
831 831
832 TEST_F(PeopleHandlerTest, ShowSetupOldGaiaPassphraseRequired) { 832 TEST_F(PeopleHandlerTest, ShowSetupOldGaiaPassphraseRequired) {
833 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 833 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
834 .WillRepeatedly(Return(true)); 834 .WillRepeatedly(Return(true));
835 EXPECT_CALL(*mock_pss_, GetPassphraseType()) 835 EXPECT_CALL(*mock_pss_, GetPassphraseType())
836 .WillRepeatedly( 836 .WillRepeatedly(
837 Return(syncer::PassphraseType::FROZEN_IMPLICIT_PASSPHRASE)); 837 Return(syncer::PassphraseType::FROZEN_IMPLICIT_PASSPHRASE));
838 SetupInitializedProfileSyncService(); 838 SetupInitializedProfileSyncService();
839 SetDefaultExpectationsForConfigPage(); 839 SetDefaultExpectationsForConfigPage();
840 840
841 // This should display the sync setup dialog (not login). 841 // This should display the sync setup dialog (not login).
842 handler_->OpenSyncSetup(false /* creating_supervised_user */); 842 handler_->OpenSyncSetup();
843 843
844 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); 844 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged();
845 CheckBool(dictionary, "passphraseRequired", true); 845 CheckBool(dictionary, "passphraseRequired", true);
846 CheckBool(dictionary, "passphraseTypeIsCustom", false); 846 CheckBool(dictionary, "passphraseTypeIsCustom", false);
847 } 847 }
848 848
849 TEST_F(PeopleHandlerTest, ShowSetupCustomPassphraseRequired) { 849 TEST_F(PeopleHandlerTest, ShowSetupCustomPassphraseRequired) {
850 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 850 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
851 .WillRepeatedly(Return(true)); 851 .WillRepeatedly(Return(true));
852 EXPECT_CALL(*mock_pss_, GetPassphraseType()) 852 EXPECT_CALL(*mock_pss_, GetPassphraseType())
853 .WillRepeatedly(Return(syncer::PassphraseType::CUSTOM_PASSPHRASE)); 853 .WillRepeatedly(Return(syncer::PassphraseType::CUSTOM_PASSPHRASE));
854 SetupInitializedProfileSyncService(); 854 SetupInitializedProfileSyncService();
855 SetDefaultExpectationsForConfigPage(); 855 SetDefaultExpectationsForConfigPage();
856 856
857 // This should display the sync setup dialog (not login). 857 // This should display the sync setup dialog (not login).
858 handler_->OpenSyncSetup(false /* creating_supervised_user */); 858 handler_->OpenSyncSetup();
859 859
860 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); 860 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged();
861 CheckBool(dictionary, "passphraseRequired", true); 861 CheckBool(dictionary, "passphraseRequired", true);
862 CheckBool(dictionary, "passphraseTypeIsCustom", true); 862 CheckBool(dictionary, "passphraseTypeIsCustom", true);
863 } 863 }
864 864
865 TEST_F(PeopleHandlerTest, ShowSetupEncryptAll) { 865 TEST_F(PeopleHandlerTest, ShowSetupEncryptAll) {
866 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 866 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
867 .WillRepeatedly(Return(false)); 867 .WillRepeatedly(Return(false));
868 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 868 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
869 .WillRepeatedly(Return(false)); 869 .WillRepeatedly(Return(false));
870 SetupInitializedProfileSyncService(); 870 SetupInitializedProfileSyncService();
871 SetDefaultExpectationsForConfigPage(); 871 SetDefaultExpectationsForConfigPage();
872 EXPECT_CALL(*mock_pss_, IsEncryptEverythingEnabled()) 872 EXPECT_CALL(*mock_pss_, IsEncryptEverythingEnabled())
873 .WillRepeatedly(Return(true)); 873 .WillRepeatedly(Return(true));
874 874
875 // This should display the sync setup dialog (not login). 875 // This should display the sync setup dialog (not login).
876 handler_->OpenSyncSetup(false /* creating_supervised_user */); 876 handler_->OpenSyncSetup();
877 877
878 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); 878 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged();
879 CheckBool(dictionary, "encryptAllData", true); 879 CheckBool(dictionary, "encryptAllData", true);
880 } 880 }
881 881
882 TEST_F(PeopleHandlerTest, ShowSetupEncryptAllDisallowed) { 882 TEST_F(PeopleHandlerTest, ShowSetupEncryptAllDisallowed) {
883 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 883 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
884 .WillRepeatedly(Return(false)); 884 .WillRepeatedly(Return(false));
885 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 885 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
886 .WillRepeatedly(Return(false)); 886 .WillRepeatedly(Return(false));
887 SetupInitializedProfileSyncService(); 887 SetupInitializedProfileSyncService();
888 SetDefaultExpectationsForConfigPage(); 888 SetDefaultExpectationsForConfigPage();
889 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) 889 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed())
890 .WillRepeatedly(Return(false)); 890 .WillRepeatedly(Return(false));
891 891
892 // This should display the sync setup dialog (not login). 892 // This should display the sync setup dialog (not login).
893 handler_->OpenSyncSetup(false /* creating_supervised_user */); 893 handler_->OpenSyncSetup();
894 894
895 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); 895 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged();
896 CheckBool(dictionary, "encryptAllData", false); 896 CheckBool(dictionary, "encryptAllData", false);
897 CheckBool(dictionary, "encryptAllDataAllowed", false); 897 CheckBool(dictionary, "encryptAllDataAllowed", false);
898 } 898 }
899 899
900 TEST_F(PeopleHandlerTest, TurnOnEncryptAllDisallowed) { 900 TEST_F(PeopleHandlerTest, TurnOnEncryptAllDisallowed) {
901 std::string args = GetConfiguration( 901 std::string args = GetConfiguration(
902 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA); 902 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA);
903 base::ListValue list_args; 903 base::ListValue list_args;
904 list_args.AppendString(kTestCallbackId); 904 list_args.AppendString(kTestCallbackId);
905 list_args.AppendString(args); 905 list_args.AppendString(args);
906 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 906 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
907 .WillRepeatedly(Return(false)); 907 .WillRepeatedly(Return(false));
908 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 908 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
909 .WillRepeatedly(Return(false)); 909 .WillRepeatedly(Return(false));
910 SetupInitializedProfileSyncService(); 910 SetupInitializedProfileSyncService();
911 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) 911 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed())
912 .WillRepeatedly(Return(false)); 912 .WillRepeatedly(Return(false));
913 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0); 913 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0);
914 handler_->HandleSetEncryption(&list_args); 914 handler_->HandleSetEncryption(&list_args);
915 915
916 ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus); 916 ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus);
917 } 917 }
918 918
919 } // namespace settings 919 } // namespace settings
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/people_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698