| 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/options/sync_setup_handler.h" | 5 #include "chrome/browser/ui/webui/options/sync_setup_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 TEST_F(SyncSetupHandlerTest, | 387 TEST_F(SyncSetupHandlerTest, |
| 388 DisplayConfigureWithBackendDisabledAndSyncStartupCompleted) { | 388 DisplayConfigureWithBackendDisabledAndSyncStartupCompleted) { |
| 389 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); | 389 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
| 390 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 390 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 391 .WillRepeatedly(Return(false)); | 391 .WillRepeatedly(Return(false)); |
| 392 error_ = GoogleServiceAuthError::AuthErrorNone(); | 392 error_ = GoogleServiceAuthError::AuthErrorNone(); |
| 393 // Sync backend is stopped initially, and will start up. | 393 // Sync backend is stopped initially, and will start up. |
| 394 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); | 394 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); |
| 395 SetDefaultExpectationsForConfigPage(); | 395 SetDefaultExpectationsForConfigPage(); |
| 396 | 396 |
| 397 handler_->OpenSyncSetup(nullptr); | 397 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 398 | 398 |
| 399 // We expect a call to SyncSetupOverlay.showSyncSetupPage. | 399 // We expect a call to SyncSetupOverlay.showSyncSetupPage. |
| 400 EXPECT_EQ(1U, web_ui_.call_data().size()); | 400 EXPECT_EQ(1U, web_ui_.call_data().size()); |
| 401 | 401 |
| 402 const content::TestWebUI::CallData& data0 = *web_ui_.call_data()[0]; | 402 const content::TestWebUI::CallData& data0 = *web_ui_.call_data()[0]; |
| 403 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data0.function_name()); | 403 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data0.function_name()); |
| 404 std::string page; | 404 std::string page; |
| 405 ASSERT_TRUE(data0.arg1()->GetAsString(&page)); | 405 ASSERT_TRUE(data0.arg1()->GetAsString(&page)); |
| 406 EXPECT_EQ(page, "spinner"); | 406 EXPECT_EQ(page, "spinner"); |
| 407 | 407 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 436 TEST_F(SyncSetupHandlerTest, | 436 TEST_F(SyncSetupHandlerTest, |
| 437 DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) { | 437 DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) { |
| 438 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); | 438 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
| 439 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 439 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 440 .WillRepeatedly(Return(false)); | 440 .WillRepeatedly(Return(false)); |
| 441 error_ = GoogleServiceAuthError::AuthErrorNone(); | 441 error_ = GoogleServiceAuthError::AuthErrorNone(); |
| 442 EXPECT_CALL(*mock_pss_, IsBackendInitialized()) | 442 EXPECT_CALL(*mock_pss_, IsBackendInitialized()) |
| 443 .WillOnce(Return(false)) | 443 .WillOnce(Return(false)) |
| 444 .WillRepeatedly(Return(true)); | 444 .WillRepeatedly(Return(true)); |
| 445 SetDefaultExpectationsForConfigPage(); | 445 SetDefaultExpectationsForConfigPage(); |
| 446 handler_->OpenSyncSetup(nullptr); | 446 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 447 | 447 |
| 448 // It's important to tell sync the user cancelled the setup flow before we | 448 // It's important to tell sync the user cancelled the setup flow before we |
| 449 // tell it we're through with the setup progress. | 449 // tell it we're through with the setup progress. |
| 450 testing::InSequence seq; | 450 testing::InSequence seq; |
| 451 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA)); | 451 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA)); |
| 452 EXPECT_CALL(*mock_pss_, SetSetupInProgress(false)); | 452 EXPECT_CALL(*mock_pss_, SetSetupInProgress(false)); |
| 453 | 453 |
| 454 handler_->CloseSyncSetup(); | 454 handler_->CloseSyncSetup(); |
| 455 EXPECT_EQ(NULL, | 455 EXPECT_EQ(NULL, |
| 456 LoginUIServiceFactory::GetForProfile( | 456 LoginUIServiceFactory::GetForProfile( |
| 457 profile_.get())->current_login_ui()); | 457 profile_.get())->current_login_ui()); |
| 458 } | 458 } |
| 459 | 459 |
| 460 TEST_F(SyncSetupHandlerTest, | 460 TEST_F(SyncSetupHandlerTest, |
| 461 DisplayConfigureWithBackendDisabledAndSigninFailed) { | 461 DisplayConfigureWithBackendDisabledAndSigninFailed) { |
| 462 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); | 462 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
| 463 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 463 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 464 .WillRepeatedly(Return(false)); | 464 .WillRepeatedly(Return(false)); |
| 465 error_ = GoogleServiceAuthError::AuthErrorNone(); | 465 error_ = GoogleServiceAuthError::AuthErrorNone(); |
| 466 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); | 466 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); |
| 467 | 467 |
| 468 handler_->OpenSyncSetup(nullptr); | 468 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 469 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 469 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
| 470 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name()); | 470 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name()); |
| 471 std::string page; | 471 std::string page; |
| 472 ASSERT_TRUE(data.arg1()->GetAsString(&page)); | 472 ASSERT_TRUE(data.arg1()->GetAsString(&page)); |
| 473 EXPECT_EQ(page, "spinner"); | 473 EXPECT_EQ(page, "spinner"); |
| 474 Mock::VerifyAndClearExpectations(mock_pss_); | 474 Mock::VerifyAndClearExpectations(mock_pss_); |
| 475 error_ = GoogleServiceAuthError( | 475 error_ = GoogleServiceAuthError( |
| 476 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 476 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| 477 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 477 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
| 478 NotifySyncListeners(); | 478 NotifySyncListeners(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 490 SyncSetupHandlerNonCrosTest() {} | 490 SyncSetupHandlerNonCrosTest() {} |
| 491 }; | 491 }; |
| 492 | 492 |
| 493 TEST_F(SyncSetupHandlerNonCrosTest, HandleGaiaAuthFailure) { | 493 TEST_F(SyncSetupHandlerNonCrosTest, HandleGaiaAuthFailure) { |
| 494 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); | 494 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
| 495 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) | 495 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) |
| 496 .WillRepeatedly(Return(false)); | 496 .WillRepeatedly(Return(false)); |
| 497 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 497 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 498 .WillRepeatedly(Return(false)); | 498 .WillRepeatedly(Return(false)); |
| 499 // Open the web UI. | 499 // Open the web UI. |
| 500 handler_->OpenSyncSetup(nullptr); | 500 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 501 | 501 |
| 502 ASSERT_FALSE(handler_->is_configuring_sync()); | 502 ASSERT_FALSE(handler_->is_configuring_sync()); |
| 503 } | 503 } |
| 504 | 504 |
| 505 // TODO(kochi): We need equivalent tests for ChromeOS. | 505 // TODO(kochi): We need equivalent tests for ChromeOS. |
| 506 TEST_F(SyncSetupHandlerNonCrosTest, UnrecoverableErrorInitializingSync) { | 506 TEST_F(SyncSetupHandlerNonCrosTest, UnrecoverableErrorInitializingSync) { |
| 507 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); | 507 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
| 508 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 508 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 509 .WillRepeatedly(Return(false)); | 509 .WillRepeatedly(Return(false)); |
| 510 // Open the web UI. | 510 // Open the web UI. |
| 511 handler_->OpenSyncSetup(nullptr); | 511 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 512 | 512 |
| 513 ASSERT_FALSE(handler_->is_configuring_sync()); | 513 ASSERT_FALSE(handler_->is_configuring_sync()); |
| 514 } | 514 } |
| 515 | 515 |
| 516 TEST_F(SyncSetupHandlerNonCrosTest, GaiaErrorInitializingSync) { | 516 TEST_F(SyncSetupHandlerNonCrosTest, GaiaErrorInitializingSync) { |
| 517 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); | 517 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
| 518 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 518 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 519 .WillRepeatedly(Return(false)); | 519 .WillRepeatedly(Return(false)); |
| 520 // Open the web UI. | 520 // Open the web UI. |
| 521 handler_->OpenSyncSetup(nullptr); | 521 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 522 | 522 |
| 523 ASSERT_FALSE(handler_->is_configuring_sync()); | 523 ASSERT_FALSE(handler_->is_configuring_sync()); |
| 524 } | 524 } |
| 525 | 525 |
| 526 #endif // #if !defined(OS_CHROMEOS) | 526 #endif // #if !defined(OS_CHROMEOS) |
| 527 | 527 |
| 528 TEST_F(SyncSetupHandlerTest, TestSyncEverything) { | 528 TEST_F(SyncSetupHandlerTest, TestSyncEverything) { |
| 529 std::string args = | 529 std::string args = |
| 530 GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), | 530 GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), |
| 531 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); | 531 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 } | 734 } |
| 735 | 735 |
| 736 TEST_F(SyncSetupHandlerTest, ShowSyncSetup) { | 736 TEST_F(SyncSetupHandlerTest, ShowSyncSetup) { |
| 737 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 737 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 738 .WillRepeatedly(Return(false)); | 738 .WillRepeatedly(Return(false)); |
| 739 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 739 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 740 .WillRepeatedly(Return(false)); | 740 .WillRepeatedly(Return(false)); |
| 741 SetupInitializedProfileSyncService(); | 741 SetupInitializedProfileSyncService(); |
| 742 // This should display the sync setup dialog (not login). | 742 // This should display the sync setup dialog (not login). |
| 743 SetDefaultExpectationsForConfigPage(); | 743 SetDefaultExpectationsForConfigPage(); |
| 744 handler_->OpenSyncSetup(nullptr); | 744 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 745 | 745 |
| 746 ExpectConfig(); | 746 ExpectConfig(); |
| 747 } | 747 } |
| 748 | 748 |
| 749 // We do not display signin on chromeos in the case of auth error. | 749 // We do not display signin on chromeos in the case of auth error. |
| 750 TEST_F(SyncSetupHandlerTest, ShowSigninOnAuthError) { | 750 TEST_F(SyncSetupHandlerTest, ShowSigninOnAuthError) { |
| 751 // Initialize the system to a signed in state, but with an auth error. | 751 // Initialize the system to a signed in state, but with an auth error. |
| 752 error_ = GoogleServiceAuthError( | 752 error_ = GoogleServiceAuthError( |
| 753 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 753 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| 754 | 754 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 769 // sync backend (which will fail due to the auth error). This should only | 769 // sync backend (which will fail due to the auth error). This should only |
| 770 // happen if the user manually navigates to chrome://settings/syncSetup - | 770 // happen if the user manually navigates to chrome://settings/syncSetup - |
| 771 // clicking on the button in the UI will sign the user out rather than | 771 // clicking on the button in the UI will sign the user out rather than |
| 772 // displaying a spinner. Should be no visible UI on ChromeOS in this case. | 772 // displaying a spinner. Should be no visible UI on ChromeOS in this case. |
| 773 EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile( | 773 EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile( |
| 774 profile_.get())->current_login_ui()); | 774 profile_.get())->current_login_ui()); |
| 775 #else | 775 #else |
| 776 | 776 |
| 777 // On ChromeOS, this should display the spinner while we try to startup the | 777 // On ChromeOS, this should display the spinner while we try to startup the |
| 778 // sync backend, and on desktop this displays the login dialog. | 778 // sync backend, and on desktop this displays the login dialog. |
| 779 handler_->OpenSyncSetup(nullptr); | 779 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 780 | 780 |
| 781 // Sync setup is closed when re-auth is in progress. | 781 // Sync setup is closed when re-auth is in progress. |
| 782 EXPECT_EQ(NULL, | 782 EXPECT_EQ(NULL, |
| 783 LoginUIServiceFactory::GetForProfile( | 783 LoginUIServiceFactory::GetForProfile( |
| 784 profile_.get())->current_login_ui()); | 784 profile_.get())->current_login_ui()); |
| 785 | 785 |
| 786 ASSERT_FALSE(handler_->is_configuring_sync()); | 786 ASSERT_FALSE(handler_->is_configuring_sync()); |
| 787 #endif | 787 #endif |
| 788 } | 788 } |
| 789 | 789 |
| 790 TEST_F(SyncSetupHandlerTest, ShowSetupSyncEverything) { | 790 TEST_F(SyncSetupHandlerTest, ShowSetupSyncEverything) { |
| 791 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 791 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 792 .WillRepeatedly(Return(false)); | 792 .WillRepeatedly(Return(false)); |
| 793 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 793 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 794 .WillRepeatedly(Return(false)); | 794 .WillRepeatedly(Return(false)); |
| 795 SetupInitializedProfileSyncService(); | 795 SetupInitializedProfileSyncService(); |
| 796 SetDefaultExpectationsForConfigPage(); | 796 SetDefaultExpectationsForConfigPage(); |
| 797 // This should display the sync setup dialog (not login). | 797 // This should display the sync setup dialog (not login). |
| 798 handler_->OpenSyncSetup(nullptr); | 798 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 799 | 799 |
| 800 ExpectConfig(); | 800 ExpectConfig(); |
| 801 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 801 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
| 802 const base::DictionaryValue* dictionary = nullptr; | 802 const base::DictionaryValue* dictionary = nullptr; |
| 803 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 803 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
| 804 CheckBool(dictionary, "syncAllDataTypes", true); | 804 CheckBool(dictionary, "syncAllDataTypes", true); |
| 805 CheckBool(dictionary, "appsRegistered", true); | 805 CheckBool(dictionary, "appsRegistered", true); |
| 806 CheckBool(dictionary, "autofillRegistered", true); | 806 CheckBool(dictionary, "autofillRegistered", true); |
| 807 CheckBool(dictionary, "bookmarksRegistered", true); | 807 CheckBool(dictionary, "bookmarksRegistered", true); |
| 808 CheckBool(dictionary, "extensionsRegistered", true); | 808 CheckBool(dictionary, "extensionsRegistered", true); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 823 TEST_F(SyncSetupHandlerTest, ShowSetupManuallySyncAll) { | 823 TEST_F(SyncSetupHandlerTest, ShowSetupManuallySyncAll) { |
| 824 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 824 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 825 .WillRepeatedly(Return(false)); | 825 .WillRepeatedly(Return(false)); |
| 826 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 826 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 827 .WillRepeatedly(Return(false)); | 827 .WillRepeatedly(Return(false)); |
| 828 SetupInitializedProfileSyncService(); | 828 SetupInitializedProfileSyncService(); |
| 829 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); | 829 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); |
| 830 sync_prefs.SetKeepEverythingSynced(false); | 830 sync_prefs.SetKeepEverythingSynced(false); |
| 831 SetDefaultExpectationsForConfigPage(); | 831 SetDefaultExpectationsForConfigPage(); |
| 832 // This should display the sync setup dialog (not login). | 832 // This should display the sync setup dialog (not login). |
| 833 handler_->OpenSyncSetup(nullptr); | 833 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 834 | 834 |
| 835 ExpectConfig(); | 835 ExpectConfig(); |
| 836 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 836 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
| 837 const base::DictionaryValue* dictionary = nullptr; | 837 const base::DictionaryValue* dictionary = nullptr; |
| 838 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 838 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
| 839 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes()); | 839 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes()); |
| 840 } | 840 } |
| 841 | 841 |
| 842 TEST_F(SyncSetupHandlerTest, ShowSetupSyncForAllTypesIndividually) { | 842 TEST_F(SyncSetupHandlerTest, ShowSetupSyncForAllTypesIndividually) { |
| 843 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); | 843 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); |
| 844 syncer::ModelTypeSet::Iterator it; | 844 syncer::ModelTypeSet::Iterator it; |
| 845 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { | 845 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { |
| 846 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 846 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 847 .WillRepeatedly(Return(false)); | 847 .WillRepeatedly(Return(false)); |
| 848 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 848 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 849 .WillRepeatedly(Return(false)); | 849 .WillRepeatedly(Return(false)); |
| 850 SetupInitializedProfileSyncService(); | 850 SetupInitializedProfileSyncService(); |
| 851 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); | 851 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); |
| 852 sync_prefs.SetKeepEverythingSynced(false); | 852 sync_prefs.SetKeepEverythingSynced(false); |
| 853 SetDefaultExpectationsForConfigPage(); | 853 SetDefaultExpectationsForConfigPage(); |
| 854 syncer::ModelTypeSet types; | 854 syncer::ModelTypeSet types; |
| 855 types.Put(it.Get()); | 855 types.Put(it.Get()); |
| 856 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()). | 856 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()). |
| 857 WillRepeatedly(Return(types)); | 857 WillRepeatedly(Return(types)); |
| 858 | 858 |
| 859 // This should display the sync setup dialog (not login). | 859 // This should display the sync setup dialog (not login). |
| 860 handler_->OpenSyncSetup(nullptr); | 860 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 861 | 861 |
| 862 ExpectConfig(); | 862 ExpectConfig(); |
| 863 // Close the config overlay. | 863 // Close the config overlay. |
| 864 LoginUIServiceFactory::GetForProfile(profile_.get())->LoginUIClosed( | 864 LoginUIServiceFactory::GetForProfile(profile_.get())->LoginUIClosed( |
| 865 handler_.get()); | 865 handler_.get()); |
| 866 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 866 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
| 867 const base::DictionaryValue* dictionary = nullptr; | 867 const base::DictionaryValue* dictionary = nullptr; |
| 868 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 868 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
| 869 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types); | 869 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types); |
| 870 Mock::VerifyAndClearExpectations(mock_pss_); | 870 Mock::VerifyAndClearExpectations(mock_pss_); |
| 871 // Clean up so we can loop back to display the dialog again. | 871 // Clean up so we can loop back to display the dialog again. |
| 872 web_ui_.ClearTrackedCalls(); | 872 web_ui_.ClearTrackedCalls(); |
| 873 } | 873 } |
| 874 } | 874 } |
| 875 | 875 |
| 876 TEST_F(SyncSetupHandlerTest, ShowSetupGaiaPassphraseRequired) { | 876 TEST_F(SyncSetupHandlerTest, ShowSetupGaiaPassphraseRequired) { |
| 877 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 877 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 878 .WillRepeatedly(Return(true)); | 878 .WillRepeatedly(Return(true)); |
| 879 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 879 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 880 .WillRepeatedly(Return(false)); | 880 .WillRepeatedly(Return(false)); |
| 881 SetupInitializedProfileSyncService(); | 881 SetupInitializedProfileSyncService(); |
| 882 SetDefaultExpectationsForConfigPage(); | 882 SetDefaultExpectationsForConfigPage(); |
| 883 | 883 |
| 884 // This should display the sync setup dialog (not login). | 884 // This should display the sync setup dialog (not login). |
| 885 handler_->OpenSyncSetup(nullptr); | 885 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 886 | 886 |
| 887 ExpectConfig(); | 887 ExpectConfig(); |
| 888 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 888 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
| 889 const base::DictionaryValue* dictionary = nullptr; | 889 const base::DictionaryValue* dictionary = nullptr; |
| 890 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 890 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
| 891 CheckBool(dictionary, "showPassphrase", true); | 891 CheckBool(dictionary, "showPassphrase", true); |
| 892 CheckBool(dictionary, "usePassphrase", false); | 892 CheckBool(dictionary, "usePassphrase", false); |
| 893 CheckBool(dictionary, "passphraseFailed", false); | 893 CheckBool(dictionary, "passphraseFailed", false); |
| 894 } | 894 } |
| 895 | 895 |
| 896 TEST_F(SyncSetupHandlerTest, ShowSetupCustomPassphraseRequired) { | 896 TEST_F(SyncSetupHandlerTest, ShowSetupCustomPassphraseRequired) { |
| 897 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 897 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 898 .WillRepeatedly(Return(true)); | 898 .WillRepeatedly(Return(true)); |
| 899 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 899 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 900 .WillRepeatedly(Return(true)); | 900 .WillRepeatedly(Return(true)); |
| 901 EXPECT_CALL(*mock_pss_, GetPassphraseType()) | 901 EXPECT_CALL(*mock_pss_, GetPassphraseType()) |
| 902 .WillRepeatedly(Return(syncer::CUSTOM_PASSPHRASE)); | 902 .WillRepeatedly(Return(syncer::CUSTOM_PASSPHRASE)); |
| 903 SetupInitializedProfileSyncService(); | 903 SetupInitializedProfileSyncService(); |
| 904 SetDefaultExpectationsForConfigPage(); | 904 SetDefaultExpectationsForConfigPage(); |
| 905 | 905 |
| 906 // This should display the sync setup dialog (not login). | 906 // This should display the sync setup dialog (not login). |
| 907 handler_->OpenSyncSetup(nullptr); | 907 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 908 | 908 |
| 909 ExpectConfig(); | 909 ExpectConfig(); |
| 910 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 910 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
| 911 const base::DictionaryValue* dictionary = nullptr; | 911 const base::DictionaryValue* dictionary = nullptr; |
| 912 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 912 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
| 913 CheckBool(dictionary, "showPassphrase", true); | 913 CheckBool(dictionary, "showPassphrase", true); |
| 914 CheckBool(dictionary, "usePassphrase", true); | 914 CheckBool(dictionary, "usePassphrase", true); |
| 915 CheckBool(dictionary, "passphraseFailed", false); | 915 CheckBool(dictionary, "passphraseFailed", false); |
| 916 } | 916 } |
| 917 | 917 |
| 918 TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAll) { | 918 TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAll) { |
| 919 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 919 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 920 .WillRepeatedly(Return(false)); | 920 .WillRepeatedly(Return(false)); |
| 921 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 921 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 922 .WillRepeatedly(Return(false)); | 922 .WillRepeatedly(Return(false)); |
| 923 SetupInitializedProfileSyncService(); | 923 SetupInitializedProfileSyncService(); |
| 924 SetDefaultExpectationsForConfigPage(); | 924 SetDefaultExpectationsForConfigPage(); |
| 925 EXPECT_CALL(*mock_pss_, IsEncryptEverythingEnabled()) | 925 EXPECT_CALL(*mock_pss_, IsEncryptEverythingEnabled()) |
| 926 .WillRepeatedly(Return(true)); | 926 .WillRepeatedly(Return(true)); |
| 927 | 927 |
| 928 // This should display the sync setup dialog (not login). | 928 // This should display the sync setup dialog (not login). |
| 929 handler_->OpenSyncSetup(nullptr); | 929 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 930 | 930 |
| 931 ExpectConfig(); | 931 ExpectConfig(); |
| 932 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 932 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
| 933 const base::DictionaryValue* dictionary = nullptr; | 933 const base::DictionaryValue* dictionary = nullptr; |
| 934 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 934 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
| 935 CheckBool(dictionary, "encryptAllData", true); | 935 CheckBool(dictionary, "encryptAllData", true); |
| 936 } | 936 } |
| 937 | 937 |
| 938 TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAllDisallowed) { | 938 TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAllDisallowed) { |
| 939 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 939 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 940 .WillRepeatedly(Return(false)); | 940 .WillRepeatedly(Return(false)); |
| 941 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 941 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 942 .WillRepeatedly(Return(false)); | 942 .WillRepeatedly(Return(false)); |
| 943 SetupInitializedProfileSyncService(); | 943 SetupInitializedProfileSyncService(); |
| 944 SetDefaultExpectationsForConfigPage(); | 944 SetDefaultExpectationsForConfigPage(); |
| 945 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) | 945 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) |
| 946 .WillRepeatedly(Return(false)); | 946 .WillRepeatedly(Return(false)); |
| 947 | 947 |
| 948 // This should display the sync setup dialog (not login). | 948 // This should display the sync setup dialog (not login). |
| 949 handler_->OpenSyncSetup(nullptr); | 949 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 950 | 950 |
| 951 ExpectConfig(); | 951 ExpectConfig(); |
| 952 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 952 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
| 953 const base::DictionaryValue* dictionary = nullptr; | 953 const base::DictionaryValue* dictionary = nullptr; |
| 954 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 954 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
| 955 CheckBool(dictionary, "encryptAllData", false); | 955 CheckBool(dictionary, "encryptAllData", false); |
| 956 CheckBool(dictionary, "encryptAllDataAllowed", false); | 956 CheckBool(dictionary, "encryptAllDataAllowed", false); |
| 957 } | 957 } |
| 958 | 958 |
| 959 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAllDisallowed) { | 959 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAllDisallowed) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 970 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) | 970 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) |
| 971 .WillRepeatedly(Return(false)); | 971 .WillRepeatedly(Return(false)); |
| 972 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0); | 972 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0); |
| 973 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); | 973 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); |
| 974 handler_->HandleConfigure(&list_args); | 974 handler_->HandleConfigure(&list_args); |
| 975 | 975 |
| 976 // Ensure that we navigated to the "done" state since we don't need a | 976 // Ensure that we navigated to the "done" state since we don't need a |
| 977 // passphrase. | 977 // passphrase. |
| 978 ExpectDone(); | 978 ExpectDone(); |
| 979 } | 979 } |
| 980 | |
| OLD | NEW |