| OLD | NEW |
| 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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 // to showing a configuration page when sync setup completes successfully. | 389 // to showing a configuration page when sync setup completes successfully. |
| 390 TEST_F(PeopleHandlerTest, | 390 TEST_F(PeopleHandlerTest, |
| 391 DisplayConfigureWithEngineDisabledAndSyncStartupCompleted) { | 391 DisplayConfigureWithEngineDisabledAndSyncStartupCompleted) { |
| 392 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); | 392 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
| 393 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); | 393 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); |
| 394 error_ = GoogleServiceAuthError::AuthErrorNone(); | 394 error_ = GoogleServiceAuthError::AuthErrorNone(); |
| 395 // Sync engine is stopped initially, and will start up. | 395 // Sync engine is stopped initially, and will start up. |
| 396 EXPECT_CALL(*mock_pss_, IsEngineInitialized()).WillRepeatedly(Return(false)); | 396 EXPECT_CALL(*mock_pss_, IsEngineInitialized()).WillRepeatedly(Return(false)); |
| 397 SetDefaultExpectationsForConfigPage(); | 397 SetDefaultExpectationsForConfigPage(); |
| 398 | 398 |
| 399 handler_->OpenSyncSetup(false /* creating_supervised_user */); | 399 handler_->OpenSyncSetup(); |
| 400 | 400 |
| 401 EXPECT_EQ(1U, web_ui_.call_data().size()); | 401 EXPECT_EQ(1U, web_ui_.call_data().size()); |
| 402 ExpectPageStatusChanged(PeopleHandler::kSpinnerPageStatus); | 402 ExpectPageStatusChanged(PeopleHandler::kSpinnerPageStatus); |
| 403 | 403 |
| 404 Mock::VerifyAndClearExpectations(mock_pss_); | 404 Mock::VerifyAndClearExpectations(mock_pss_); |
| 405 // Now, act as if the ProfileSyncService has started up. | 405 // Now, act as if the ProfileSyncService has started up. |
| 406 SetDefaultExpectationsForConfigPage(); | 406 SetDefaultExpectationsForConfigPage(); |
| 407 EXPECT_CALL(*mock_pss_, IsEngineInitialized()).WillRepeatedly(Return(true)); | 407 EXPECT_CALL(*mock_pss_, IsEngineInitialized()).WillRepeatedly(Return(true)); |
| 408 error_ = GoogleServiceAuthError::AuthErrorNone(); | 408 error_ = GoogleServiceAuthError::AuthErrorNone(); |
| 409 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 409 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 425 // user has continued on. | 425 // user has continued on. |
| 426 TEST_F(PeopleHandlerTest, | 426 TEST_F(PeopleHandlerTest, |
| 427 DisplayConfigureWithEngineDisabledAndCancelAfterSigninSuccess) { | 427 DisplayConfigureWithEngineDisabledAndCancelAfterSigninSuccess) { |
| 428 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); | 428 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
| 429 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); | 429 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); |
| 430 error_ = GoogleServiceAuthError::AuthErrorNone(); | 430 error_ = GoogleServiceAuthError::AuthErrorNone(); |
| 431 EXPECT_CALL(*mock_pss_, IsEngineInitialized()) | 431 EXPECT_CALL(*mock_pss_, IsEngineInitialized()) |
| 432 .WillOnce(Return(false)) | 432 .WillOnce(Return(false)) |
| 433 .WillRepeatedly(Return(true)); | 433 .WillRepeatedly(Return(true)); |
| 434 SetDefaultExpectationsForConfigPage(); | 434 SetDefaultExpectationsForConfigPage(); |
| 435 handler_->OpenSyncSetup(false /* creating_supervised_user */); | 435 handler_->OpenSyncSetup(); |
| 436 | 436 |
| 437 // It's important to tell sync the user cancelled the setup flow before we | 437 // It's important to tell sync the user cancelled the setup flow before we |
| 438 // tell it we're through with the setup progress. | 438 // tell it we're through with the setup progress. |
| 439 testing::InSequence seq; | 439 testing::InSequence seq; |
| 440 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA)); | 440 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA)); |
| 441 EXPECT_CALL(*mock_pss_, OnSetupInProgressHandleDestroyed()); | 441 EXPECT_CALL(*mock_pss_, OnSetupInProgressHandleDestroyed()); |
| 442 | 442 |
| 443 handler_->CloseSyncSetup(); | 443 handler_->CloseSyncSetup(); |
| 444 EXPECT_EQ(NULL, | 444 EXPECT_EQ(NULL, |
| 445 LoginUIServiceFactory::GetForProfile( | 445 LoginUIServiceFactory::GetForProfile( |
| 446 profile_)->current_login_ui()); | 446 profile_)->current_login_ui()); |
| 447 } | 447 } |
| 448 | 448 |
| 449 TEST_F(PeopleHandlerTest, DisplayConfigureWithEngineDisabledAndSigninFailed) { | 449 TEST_F(PeopleHandlerTest, DisplayConfigureWithEngineDisabledAndSigninFailed) { |
| 450 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); | 450 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
| 451 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); | 451 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); |
| 452 error_ = GoogleServiceAuthError::AuthErrorNone(); | 452 error_ = GoogleServiceAuthError::AuthErrorNone(); |
| 453 EXPECT_CALL(*mock_pss_, IsEngineInitialized()).WillRepeatedly(Return(false)); | 453 EXPECT_CALL(*mock_pss_, IsEngineInitialized()).WillRepeatedly(Return(false)); |
| 454 | 454 |
| 455 handler_->OpenSyncSetup(false /* creating_supervised_user */); | 455 handler_->OpenSyncSetup(); |
| 456 ExpectPageStatusChanged(PeopleHandler::kSpinnerPageStatus); | 456 ExpectPageStatusChanged(PeopleHandler::kSpinnerPageStatus); |
| 457 Mock::VerifyAndClearExpectations(mock_pss_); | 457 Mock::VerifyAndClearExpectations(mock_pss_); |
| 458 error_ = GoogleServiceAuthError( | 458 error_ = GoogleServiceAuthError( |
| 459 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 459 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| 460 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 460 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
| 461 NotifySyncListeners(); | 461 NotifySyncListeners(); |
| 462 | 462 |
| 463 // On failure, the dialog will be closed. | 463 // On failure, the dialog will be closed. |
| 464 EXPECT_EQ(NULL, | 464 EXPECT_EQ(NULL, |
| 465 LoginUIServiceFactory::GetForProfile( | 465 LoginUIServiceFactory::GetForProfile( |
| 466 profile_)->current_login_ui()); | 466 profile_)->current_login_ui()); |
| 467 } | 467 } |
| 468 | 468 |
| 469 #if !defined(OS_CHROMEOS) | 469 #if !defined(OS_CHROMEOS) |
| 470 | 470 |
| 471 class PeopleHandlerNonCrosTest : public PeopleHandlerTest { | 471 class PeopleHandlerNonCrosTest : public PeopleHandlerTest { |
| 472 public: | 472 public: |
| 473 PeopleHandlerNonCrosTest() {} | 473 PeopleHandlerNonCrosTest() {} |
| 474 }; | 474 }; |
| 475 | 475 |
| 476 TEST_F(PeopleHandlerNonCrosTest, HandleGaiaAuthFailure) { | 476 TEST_F(PeopleHandlerNonCrosTest, HandleGaiaAuthFailure) { |
| 477 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); | 477 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
| 478 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) | 478 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) |
| 479 .WillRepeatedly(Return(false)); | 479 .WillRepeatedly(Return(false)); |
| 480 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); | 480 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); |
| 481 // Open the web UI. | 481 // Open the web UI. |
| 482 handler_->OpenSyncSetup(false /* creating_supervised_user */); | 482 handler_->OpenSyncSetup(); |
| 483 | 483 |
| 484 ASSERT_FALSE(handler_->is_configuring_sync()); | 484 ASSERT_FALSE(handler_->is_configuring_sync()); |
| 485 } | 485 } |
| 486 | 486 |
| 487 // TODO(kochi): We need equivalent tests for ChromeOS. | 487 // TODO(kochi): We need equivalent tests for ChromeOS. |
| 488 TEST_F(PeopleHandlerNonCrosTest, UnrecoverableErrorInitializingSync) { | 488 TEST_F(PeopleHandlerNonCrosTest, UnrecoverableErrorInitializingSync) { |
| 489 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); | 489 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
| 490 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); | 490 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); |
| 491 // Open the web UI. | 491 // Open the web UI. |
| 492 handler_->OpenSyncSetup(false /* creating_supervised_user */); | 492 handler_->OpenSyncSetup(); |
| 493 | 493 |
| 494 ASSERT_FALSE(handler_->is_configuring_sync()); | 494 ASSERT_FALSE(handler_->is_configuring_sync()); |
| 495 } | 495 } |
| 496 | 496 |
| 497 TEST_F(PeopleHandlerNonCrosTest, GaiaErrorInitializingSync) { | 497 TEST_F(PeopleHandlerNonCrosTest, GaiaErrorInitializingSync) { |
| 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 #endif // #if !defined(OS_CHROMEOS) | 506 #endif // #if !defined(OS_CHROMEOS) |
| 507 | 507 |
| 508 TEST_F(PeopleHandlerTest, TestSyncEverything) { | 508 TEST_F(PeopleHandlerTest, TestSyncEverything) { |
| 509 std::string args = GetConfiguration( | 509 std::string args = GetConfiguration( |
| 510 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); | 510 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); |
| 511 base::ListValue list_args; | 511 base::ListValue list_args; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 } | 691 } |
| 692 | 692 |
| 693 TEST_F(PeopleHandlerTest, ShowSyncSetup) { | 693 TEST_F(PeopleHandlerTest, ShowSyncSetup) { |
| 694 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 694 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 695 .WillRepeatedly(Return(false)); | 695 .WillRepeatedly(Return(false)); |
| 696 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 696 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 697 .WillRepeatedly(Return(false)); | 697 .WillRepeatedly(Return(false)); |
| 698 SetupInitializedProfileSyncService(); | 698 SetupInitializedProfileSyncService(); |
| 699 // This should display the sync setup dialog (not login). | 699 // This should display the sync setup dialog (not login). |
| 700 SetDefaultExpectationsForConfigPage(); | 700 SetDefaultExpectationsForConfigPage(); |
| 701 handler_->OpenSyncSetup(false /* creating_supervised_user */); | 701 handler_->OpenSyncSetup(); |
| 702 | 702 |
| 703 ExpectSyncPrefsChanged(); | 703 ExpectSyncPrefsChanged(); |
| 704 } | 704 } |
| 705 | 705 |
| 706 // We do not display signin on chromeos in the case of auth error. | 706 // We do not display signin on chromeos in the case of auth error. |
| 707 TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) { | 707 TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) { |
| 708 // Initialize the system to a signed in state, but with an auth error. | 708 // Initialize the system to a signed in state, but with an auth error. |
| 709 error_ = GoogleServiceAuthError( | 709 error_ = GoogleServiceAuthError( |
| 710 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 710 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| 711 | 711 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 726 // sync engine (which will fail due to the auth error). This should only | 726 // sync engine (which will fail due to the auth error). This should only |
| 727 // happen if the user manually navigates to chrome://settings/syncSetup - | 727 // happen if the user manually navigates to chrome://settings/syncSetup - |
| 728 // clicking on the button in the UI will sign the user out rather than | 728 // clicking on the button in the UI will sign the user out rather than |
| 729 // displaying a spinner. Should be no visible UI on ChromeOS in this case. | 729 // displaying a spinner. Should be no visible UI on ChromeOS in this case. |
| 730 EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile( | 730 EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile( |
| 731 profile_)->current_login_ui()); | 731 profile_)->current_login_ui()); |
| 732 #else | 732 #else |
| 733 | 733 |
| 734 // On ChromeOS, this should display the spinner while we try to startup the | 734 // On ChromeOS, this should display the spinner while we try to startup the |
| 735 // sync engine, and on desktop this displays the login dialog. | 735 // sync engine, and on desktop this displays the login dialog. |
| 736 handler_->OpenSyncSetup(false /* creating_supervised_user */); | 736 handler_->OpenSyncSetup(); |
| 737 | 737 |
| 738 // Sync setup is closed when re-auth is in progress. | 738 // Sync setup is closed when re-auth is in progress. |
| 739 EXPECT_EQ(NULL, | 739 EXPECT_EQ(NULL, |
| 740 LoginUIServiceFactory::GetForProfile( | 740 LoginUIServiceFactory::GetForProfile( |
| 741 profile_)->current_login_ui()); | 741 profile_)->current_login_ui()); |
| 742 | 742 |
| 743 ASSERT_FALSE(handler_->is_configuring_sync()); | 743 ASSERT_FALSE(handler_->is_configuring_sync()); |
| 744 #endif | 744 #endif |
| 745 } | 745 } |
| 746 | 746 |
| 747 TEST_F(PeopleHandlerTest, ShowSetupSyncEverything) { | 747 TEST_F(PeopleHandlerTest, ShowSetupSyncEverything) { |
| 748 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 748 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 749 .WillRepeatedly(Return(false)); | 749 .WillRepeatedly(Return(false)); |
| 750 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 750 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 751 .WillRepeatedly(Return(false)); | 751 .WillRepeatedly(Return(false)); |
| 752 SetupInitializedProfileSyncService(); | 752 SetupInitializedProfileSyncService(); |
| 753 SetDefaultExpectationsForConfigPage(); | 753 SetDefaultExpectationsForConfigPage(); |
| 754 // This should display the sync setup dialog (not login). | 754 // This should display the sync setup dialog (not login). |
| 755 handler_->OpenSyncSetup(false /* creating_supervised_user */); | 755 handler_->OpenSyncSetup(); |
| 756 | 756 |
| 757 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); | 757 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); |
| 758 CheckBool(dictionary, "syncAllDataTypes", true); | 758 CheckBool(dictionary, "syncAllDataTypes", true); |
| 759 CheckBool(dictionary, "appsRegistered", true); | 759 CheckBool(dictionary, "appsRegistered", true); |
| 760 CheckBool(dictionary, "autofillRegistered", true); | 760 CheckBool(dictionary, "autofillRegistered", true); |
| 761 CheckBool(dictionary, "bookmarksRegistered", true); | 761 CheckBool(dictionary, "bookmarksRegistered", true); |
| 762 CheckBool(dictionary, "extensionsRegistered", true); | 762 CheckBool(dictionary, "extensionsRegistered", true); |
| 763 CheckBool(dictionary, "passwordsRegistered", true); | 763 CheckBool(dictionary, "passwordsRegistered", true); |
| 764 CheckBool(dictionary, "preferencesRegistered", true); | 764 CheckBool(dictionary, "preferencesRegistered", true); |
| 765 CheckBool(dictionary, "tabsRegistered", true); | 765 CheckBool(dictionary, "tabsRegistered", true); |
| 766 CheckBool(dictionary, "themesRegistered", true); | 766 CheckBool(dictionary, "themesRegistered", true); |
| 767 CheckBool(dictionary, "typedUrlsRegistered", true); | 767 CheckBool(dictionary, "typedUrlsRegistered", true); |
| 768 CheckBool(dictionary, "paymentsIntegrationEnabled", true); | 768 CheckBool(dictionary, "paymentsIntegrationEnabled", true); |
| 769 CheckBool(dictionary, "passphraseRequired", false); | 769 CheckBool(dictionary, "passphraseRequired", false); |
| 770 CheckBool(dictionary, "passphraseTypeIsCustom", false); | 770 CheckBool(dictionary, "passphraseTypeIsCustom", false); |
| 771 CheckBool(dictionary, "encryptAllData", false); | 771 CheckBool(dictionary, "encryptAllData", false); |
| 772 CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes()); | 772 CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes()); |
| 773 } | 773 } |
| 774 | 774 |
| 775 TEST_F(PeopleHandlerTest, ShowSetupManuallySyncAll) { | 775 TEST_F(PeopleHandlerTest, ShowSetupManuallySyncAll) { |
| 776 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 776 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 777 .WillRepeatedly(Return(false)); | 777 .WillRepeatedly(Return(false)); |
| 778 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 778 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 779 .WillRepeatedly(Return(false)); | 779 .WillRepeatedly(Return(false)); |
| 780 SetupInitializedProfileSyncService(); | 780 SetupInitializedProfileSyncService(); |
| 781 syncer::SyncPrefs sync_prefs(profile_->GetPrefs()); | 781 syncer::SyncPrefs sync_prefs(profile_->GetPrefs()); |
| 782 sync_prefs.SetKeepEverythingSynced(false); | 782 sync_prefs.SetKeepEverythingSynced(false); |
| 783 SetDefaultExpectationsForConfigPage(); | 783 SetDefaultExpectationsForConfigPage(); |
| 784 // This should display the sync setup dialog (not login). | 784 // This should display the sync setup dialog (not login). |
| 785 handler_->OpenSyncSetup(false /* creating_supervised_user */); | 785 handler_->OpenSyncSetup(); |
| 786 | 786 |
| 787 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); | 787 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); |
| 788 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes()); | 788 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes()); |
| 789 } | 789 } |
| 790 | 790 |
| 791 TEST_F(PeopleHandlerTest, ShowSetupSyncForAllTypesIndividually) { | 791 TEST_F(PeopleHandlerTest, ShowSetupSyncForAllTypesIndividually) { |
| 792 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); | 792 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); |
| 793 syncer::ModelTypeSet::Iterator it; | 793 syncer::ModelTypeSet::Iterator it; |
| 794 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { | 794 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { |
| 795 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 795 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 796 .WillRepeatedly(Return(false)); | 796 .WillRepeatedly(Return(false)); |
| 797 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 797 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 798 .WillRepeatedly(Return(false)); | 798 .WillRepeatedly(Return(false)); |
| 799 SetupInitializedProfileSyncService(); | 799 SetupInitializedProfileSyncService(); |
| 800 syncer::SyncPrefs sync_prefs(profile_->GetPrefs()); | 800 syncer::SyncPrefs sync_prefs(profile_->GetPrefs()); |
| 801 sync_prefs.SetKeepEverythingSynced(false); | 801 sync_prefs.SetKeepEverythingSynced(false); |
| 802 SetDefaultExpectationsForConfigPage(); | 802 SetDefaultExpectationsForConfigPage(); |
| 803 syncer::ModelTypeSet types; | 803 syncer::ModelTypeSet types; |
| 804 types.Put(it.Get()); | 804 types.Put(it.Get()); |
| 805 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()). | 805 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()). |
| 806 WillRepeatedly(Return(types)); | 806 WillRepeatedly(Return(types)); |
| 807 | 807 |
| 808 // This should display the sync setup dialog (not login). | 808 // This should display the sync setup dialog (not login). |
| 809 handler_->OpenSyncSetup(false /* creating_supervised_user */); | 809 handler_->OpenSyncSetup(); |
| 810 | 810 |
| 811 // Close the config overlay. | 811 // Close the config overlay. |
| 812 LoginUIServiceFactory::GetForProfile(profile_)->LoginUIClosed( | 812 LoginUIServiceFactory::GetForProfile(profile_)->LoginUIClosed( |
| 813 handler_.get()); | 813 handler_.get()); |
| 814 | 814 |
| 815 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); | 815 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); |
| 816 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types); | 816 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types); |
| 817 Mock::VerifyAndClearExpectations(mock_pss_); | 817 Mock::VerifyAndClearExpectations(mock_pss_); |
| 818 // Clean up so we can loop back to display the dialog again. | 818 // Clean up so we can loop back to display the dialog again. |
| 819 web_ui_.ClearTrackedCalls(); | 819 web_ui_.ClearTrackedCalls(); |
| 820 } | 820 } |
| 821 } | 821 } |
| 822 | 822 |
| 823 TEST_F(PeopleHandlerTest, ShowSetupOldGaiaPassphraseRequired) { | 823 TEST_F(PeopleHandlerTest, ShowSetupOldGaiaPassphraseRequired) { |
| 824 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 824 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 825 .WillRepeatedly(Return(true)); | 825 .WillRepeatedly(Return(true)); |
| 826 EXPECT_CALL(*mock_pss_, GetPassphraseType()) | 826 EXPECT_CALL(*mock_pss_, GetPassphraseType()) |
| 827 .WillRepeatedly( | 827 .WillRepeatedly( |
| 828 Return(syncer::PassphraseType::FROZEN_IMPLICIT_PASSPHRASE)); | 828 Return(syncer::PassphraseType::FROZEN_IMPLICIT_PASSPHRASE)); |
| 829 SetupInitializedProfileSyncService(); | 829 SetupInitializedProfileSyncService(); |
| 830 SetDefaultExpectationsForConfigPage(); | 830 SetDefaultExpectationsForConfigPage(); |
| 831 | 831 |
| 832 // This should display the sync setup dialog (not login). | 832 // This should display the sync setup dialog (not login). |
| 833 handler_->OpenSyncSetup(false /* creating_supervised_user */); | 833 handler_->OpenSyncSetup(); |
| 834 | 834 |
| 835 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); | 835 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); |
| 836 CheckBool(dictionary, "passphraseRequired", true); | 836 CheckBool(dictionary, "passphraseRequired", true); |
| 837 CheckBool(dictionary, "passphraseTypeIsCustom", false); | 837 CheckBool(dictionary, "passphraseTypeIsCustom", false); |
| 838 } | 838 } |
| 839 | 839 |
| 840 TEST_F(PeopleHandlerTest, ShowSetupCustomPassphraseRequired) { | 840 TEST_F(PeopleHandlerTest, ShowSetupCustomPassphraseRequired) { |
| 841 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 841 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 842 .WillRepeatedly(Return(true)); | 842 .WillRepeatedly(Return(true)); |
| 843 EXPECT_CALL(*mock_pss_, GetPassphraseType()) | 843 EXPECT_CALL(*mock_pss_, GetPassphraseType()) |
| 844 .WillRepeatedly(Return(syncer::PassphraseType::CUSTOM_PASSPHRASE)); | 844 .WillRepeatedly(Return(syncer::PassphraseType::CUSTOM_PASSPHRASE)); |
| 845 SetupInitializedProfileSyncService(); | 845 SetupInitializedProfileSyncService(); |
| 846 SetDefaultExpectationsForConfigPage(); | 846 SetDefaultExpectationsForConfigPage(); |
| 847 | 847 |
| 848 // This should display the sync setup dialog (not login). | 848 // This should display the sync setup dialog (not login). |
| 849 handler_->OpenSyncSetup(false /* creating_supervised_user */); | 849 handler_->OpenSyncSetup(); |
| 850 | 850 |
| 851 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); | 851 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); |
| 852 CheckBool(dictionary, "passphraseRequired", true); | 852 CheckBool(dictionary, "passphraseRequired", true); |
| 853 CheckBool(dictionary, "passphraseTypeIsCustom", true); | 853 CheckBool(dictionary, "passphraseTypeIsCustom", true); |
| 854 } | 854 } |
| 855 | 855 |
| 856 TEST_F(PeopleHandlerTest, ShowSetupEncryptAll) { | 856 TEST_F(PeopleHandlerTest, ShowSetupEncryptAll) { |
| 857 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 857 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 858 .WillRepeatedly(Return(false)); | 858 .WillRepeatedly(Return(false)); |
| 859 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 859 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 860 .WillRepeatedly(Return(false)); | 860 .WillRepeatedly(Return(false)); |
| 861 SetupInitializedProfileSyncService(); | 861 SetupInitializedProfileSyncService(); |
| 862 SetDefaultExpectationsForConfigPage(); | 862 SetDefaultExpectationsForConfigPage(); |
| 863 EXPECT_CALL(*mock_pss_, IsEncryptEverythingEnabled()) | 863 EXPECT_CALL(*mock_pss_, IsEncryptEverythingEnabled()) |
| 864 .WillRepeatedly(Return(true)); | 864 .WillRepeatedly(Return(true)); |
| 865 | 865 |
| 866 // This should display the sync setup dialog (not login). | 866 // This should display the sync setup dialog (not login). |
| 867 handler_->OpenSyncSetup(false /* creating_supervised_user */); | 867 handler_->OpenSyncSetup(); |
| 868 | 868 |
| 869 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); | 869 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); |
| 870 CheckBool(dictionary, "encryptAllData", true); | 870 CheckBool(dictionary, "encryptAllData", true); |
| 871 } | 871 } |
| 872 | 872 |
| 873 TEST_F(PeopleHandlerTest, ShowSetupEncryptAllDisallowed) { | 873 TEST_F(PeopleHandlerTest, ShowSetupEncryptAllDisallowed) { |
| 874 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 874 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 875 .WillRepeatedly(Return(false)); | 875 .WillRepeatedly(Return(false)); |
| 876 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 876 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 877 .WillRepeatedly(Return(false)); | 877 .WillRepeatedly(Return(false)); |
| 878 SetupInitializedProfileSyncService(); | 878 SetupInitializedProfileSyncService(); |
| 879 SetDefaultExpectationsForConfigPage(); | 879 SetDefaultExpectationsForConfigPage(); |
| 880 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) | 880 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) |
| 881 .WillRepeatedly(Return(false)); | 881 .WillRepeatedly(Return(false)); |
| 882 | 882 |
| 883 // This should display the sync setup dialog (not login). | 883 // This should display the sync setup dialog (not login). |
| 884 handler_->OpenSyncSetup(false /* creating_supervised_user */); | 884 handler_->OpenSyncSetup(); |
| 885 | 885 |
| 886 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); | 886 const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged(); |
| 887 CheckBool(dictionary, "encryptAllData", false); | 887 CheckBool(dictionary, "encryptAllData", false); |
| 888 CheckBool(dictionary, "encryptAllDataAllowed", false); | 888 CheckBool(dictionary, "encryptAllDataAllowed", false); |
| 889 } | 889 } |
| 890 | 890 |
| 891 TEST_F(PeopleHandlerTest, TurnOnEncryptAllDisallowed) { | 891 TEST_F(PeopleHandlerTest, TurnOnEncryptAllDisallowed) { |
| 892 std::string args = GetConfiguration( | 892 std::string args = GetConfiguration( |
| 893 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA); | 893 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA); |
| 894 base::ListValue list_args; | 894 base::ListValue list_args; |
| 895 list_args.AppendString(kTestCallbackId); | 895 list_args.AppendString(kTestCallbackId); |
| 896 list_args.AppendString(args); | 896 list_args.AppendString(args); |
| 897 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 897 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
| 898 .WillRepeatedly(Return(false)); | 898 .WillRepeatedly(Return(false)); |
| 899 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 899 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 900 .WillRepeatedly(Return(false)); | 900 .WillRepeatedly(Return(false)); |
| 901 SetupInitializedProfileSyncService(); | 901 SetupInitializedProfileSyncService(); |
| 902 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) | 902 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) |
| 903 .WillRepeatedly(Return(false)); | 903 .WillRepeatedly(Return(false)); |
| 904 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0); | 904 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0); |
| 905 handler_->HandleSetEncryption(&list_args); | 905 handler_->HandleSetEncryption(&list_args); |
| 906 | 906 |
| 907 ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus); | 907 ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus); |
| 908 } | 908 } |
| 909 | 909 |
| 910 } // namespace settings | 910 } // namespace settings |
| OLD | NEW |