| 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 <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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 TEST_F(PeopleHandlerTest, | 392 TEST_F(PeopleHandlerTest, |
| 393 DisplayConfigureWithBackendDisabledAndSyncStartupCompleted) { | 393 DisplayConfigureWithBackendDisabledAndSyncStartupCompleted) { |
| 394 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); | 394 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
| 395 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 395 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 396 .WillRepeatedly(Return(false)); | 396 .WillRepeatedly(Return(false)); |
| 397 error_ = GoogleServiceAuthError::AuthErrorNone(); | 397 error_ = GoogleServiceAuthError::AuthErrorNone(); |
| 398 // Sync backend is stopped initially, and will start up. | 398 // Sync backend is stopped initially, and will start up. |
| 399 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); | 399 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); |
| 400 SetDefaultExpectationsForConfigPage(); | 400 SetDefaultExpectationsForConfigPage(); |
| 401 | 401 |
| 402 handler_->OpenSyncSetup(nullptr); | 402 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 403 | 403 |
| 404 // We expect a call to settings.SyncPrivateApi.showSyncSetupPage. | 404 // We expect a call to settings.SyncPrivateApi.showSyncSetupPage. |
| 405 EXPECT_EQ(1U, web_ui_.call_data().size()); | 405 EXPECT_EQ(1U, web_ui_.call_data().size()); |
| 406 | 406 |
| 407 const content::TestWebUI::CallData& data0 = *web_ui_.call_data()[0]; | 407 const content::TestWebUI::CallData& data0 = *web_ui_.call_data()[0]; |
| 408 EXPECT_EQ("settings.SyncPrivateApi.showSyncSetupPage", data0.function_name()); | 408 EXPECT_EQ("settings.SyncPrivateApi.showSyncSetupPage", data0.function_name()); |
| 409 std::string page; | 409 std::string page; |
| 410 ASSERT_TRUE(data0.arg1()->GetAsString(&page)); | 410 ASSERT_TRUE(data0.arg1()->GetAsString(&page)); |
| 411 EXPECT_EQ(page, "spinner"); | 411 EXPECT_EQ(page, "spinner"); |
| 412 | 412 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 441 TEST_F(PeopleHandlerTest, | 441 TEST_F(PeopleHandlerTest, |
| 442 DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) { | 442 DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) { |
| 443 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); | 443 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
| 444 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 444 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 445 .WillRepeatedly(Return(false)); | 445 .WillRepeatedly(Return(false)); |
| 446 error_ = GoogleServiceAuthError::AuthErrorNone(); | 446 error_ = GoogleServiceAuthError::AuthErrorNone(); |
| 447 EXPECT_CALL(*mock_pss_, IsBackendInitialized()) | 447 EXPECT_CALL(*mock_pss_, IsBackendInitialized()) |
| 448 .WillOnce(Return(false)) | 448 .WillOnce(Return(false)) |
| 449 .WillRepeatedly(Return(true)); | 449 .WillRepeatedly(Return(true)); |
| 450 SetDefaultExpectationsForConfigPage(); | 450 SetDefaultExpectationsForConfigPage(); |
| 451 handler_->OpenSyncSetup(nullptr); | 451 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 452 | 452 |
| 453 // It's important to tell sync the user cancelled the setup flow before we | 453 // It's important to tell sync the user cancelled the setup flow before we |
| 454 // tell it we're through with the setup progress. | 454 // tell it we're through with the setup progress. |
| 455 testing::InSequence seq; | 455 testing::InSequence seq; |
| 456 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA)); | 456 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA)); |
| 457 EXPECT_CALL(*mock_pss_, SetSetupInProgress(false)); | 457 EXPECT_CALL(*mock_pss_, SetSetupInProgress(false)); |
| 458 | 458 |
| 459 handler_->CloseSyncSetup(); | 459 handler_->CloseSyncSetup(); |
| 460 EXPECT_EQ(NULL, | 460 EXPECT_EQ(NULL, |
| 461 LoginUIServiceFactory::GetForProfile( | 461 LoginUIServiceFactory::GetForProfile( |
| 462 profile_)->current_login_ui()); | 462 profile_)->current_login_ui()); |
| 463 } | 463 } |
| 464 | 464 |
| 465 TEST_F(PeopleHandlerTest, | 465 TEST_F(PeopleHandlerTest, |
| 466 DisplayConfigureWithBackendDisabledAndSigninFailed) { | 466 DisplayConfigureWithBackendDisabledAndSigninFailed) { |
| 467 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); | 467 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
| 468 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 468 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 469 .WillRepeatedly(Return(false)); | 469 .WillRepeatedly(Return(false)); |
| 470 error_ = GoogleServiceAuthError::AuthErrorNone(); | 470 error_ = GoogleServiceAuthError::AuthErrorNone(); |
| 471 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); | 471 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); |
| 472 | 472 |
| 473 handler_->OpenSyncSetup(nullptr); | 473 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 474 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 474 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
| 475 EXPECT_EQ("settings.SyncPrivateApi.showSyncSetupPage", data.function_name()); | 475 EXPECT_EQ("settings.SyncPrivateApi.showSyncSetupPage", data.function_name()); |
| 476 std::string page; | 476 std::string page; |
| 477 ASSERT_TRUE(data.arg1()->GetAsString(&page)); | 477 ASSERT_TRUE(data.arg1()->GetAsString(&page)); |
| 478 EXPECT_EQ(page, "spinner"); | 478 EXPECT_EQ(page, "spinner"); |
| 479 Mock::VerifyAndClearExpectations(mock_pss_); | 479 Mock::VerifyAndClearExpectations(mock_pss_); |
| 480 error_ = GoogleServiceAuthError( | 480 error_ = GoogleServiceAuthError( |
| 481 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 481 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| 482 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 482 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
| 483 NotifySyncListeners(); | 483 NotifySyncListeners(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 495 PeopleHandlerNonCrosTest() {} | 495 PeopleHandlerNonCrosTest() {} |
| 496 }; | 496 }; |
| 497 | 497 |
| 498 TEST_F(PeopleHandlerNonCrosTest, HandleGaiaAuthFailure) { | 498 TEST_F(PeopleHandlerNonCrosTest, HandleGaiaAuthFailure) { |
| 499 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); | 499 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
| 500 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) | 500 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) |
| 501 .WillRepeatedly(Return(false)); | 501 .WillRepeatedly(Return(false)); |
| 502 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 502 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 503 .WillRepeatedly(Return(false)); | 503 .WillRepeatedly(Return(false)); |
| 504 // Open the web UI. | 504 // Open the web UI. |
| 505 handler_->OpenSyncSetup(nullptr); | 505 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 506 | 506 |
| 507 ASSERT_FALSE(handler_->is_configuring_sync()); | 507 ASSERT_FALSE(handler_->is_configuring_sync()); |
| 508 } | 508 } |
| 509 | 509 |
| 510 // TODO(kochi): We need equivalent tests for ChromeOS. | 510 // TODO(kochi): We need equivalent tests for ChromeOS. |
| 511 TEST_F(PeopleHandlerNonCrosTest, UnrecoverableErrorInitializingSync) { | 511 TEST_F(PeopleHandlerNonCrosTest, UnrecoverableErrorInitializingSync) { |
| 512 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); | 512 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
| 513 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 513 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 514 .WillRepeatedly(Return(false)); | 514 .WillRepeatedly(Return(false)); |
| 515 // Open the web UI. | 515 // Open the web UI. |
| 516 handler_->OpenSyncSetup(nullptr); | 516 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 517 | 517 |
| 518 ASSERT_FALSE(handler_->is_configuring_sync()); | 518 ASSERT_FALSE(handler_->is_configuring_sync()); |
| 519 } | 519 } |
| 520 | 520 |
| 521 TEST_F(PeopleHandlerNonCrosTest, GaiaErrorInitializingSync) { | 521 TEST_F(PeopleHandlerNonCrosTest, GaiaErrorInitializingSync) { |
| 522 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); | 522 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
| 523 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 523 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 524 .WillRepeatedly(Return(false)); | 524 .WillRepeatedly(Return(false)); |
| 525 // Open the web UI. | 525 // Open the web UI. |
| 526 handler_->OpenSyncSetup(nullptr); | 526 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 527 | 527 |
| 528 ASSERT_FALSE(handler_->is_configuring_sync()); | 528 ASSERT_FALSE(handler_->is_configuring_sync()); |
| 529 } | 529 } |
| 530 | 530 |
| 531 #endif // #if !defined(OS_CHROMEOS) | 531 #endif // #if !defined(OS_CHROMEOS) |
| 532 | 532 |
| 533 TEST_F(PeopleHandlerTest, TestSyncEverything) { | 533 TEST_F(PeopleHandlerTest, TestSyncEverything) { |
| 534 std::string args = GetConfiguration( | 534 std::string args = GetConfiguration( |
| 535 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); | 535 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); |
| 536 base::ListValue list_args; | 536 base::ListValue list_args; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 } | 745 } |
| 746 | 746 |
| 747 TEST_F(PeopleHandlerTest, ShowSyncSetup) { | 747 TEST_F(PeopleHandlerTest, ShowSyncSetup) { |
| 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 // This should display the sync setup dialog (not login). | 753 // This should display the sync setup dialog (not login). |
| 754 SetDefaultExpectationsForConfigPage(); | 754 SetDefaultExpectationsForConfigPage(); |
| 755 handler_->OpenSyncSetup(nullptr); | 755 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 756 | 756 |
| 757 ExpectConfig(); | 757 ExpectConfig(); |
| 758 } | 758 } |
| 759 | 759 |
| 760 // We do not display signin on chromeos in the case of auth error. | 760 // We do not display signin on chromeos in the case of auth error. |
| 761 TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) { | 761 TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) { |
| 762 // Initialize the system to a signed in state, but with an auth error. | 762 // Initialize the system to a signed in state, but with an auth error. |
| 763 error_ = GoogleServiceAuthError( | 763 error_ = GoogleServiceAuthError( |
| 764 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 764 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| 765 | 765 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 780 // sync backend (which will fail due to the auth error). This should only | 780 // sync backend (which will fail due to the auth error). This should only |
| 781 // happen if the user manually navigates to chrome://settings/syncSetup - | 781 // happen if the user manually navigates to chrome://settings/syncSetup - |
| 782 // clicking on the button in the UI will sign the user out rather than | 782 // clicking on the button in the UI will sign the user out rather than |
| 783 // displaying a spinner. Should be no visible UI on ChromeOS in this case. | 783 // displaying a spinner. Should be no visible UI on ChromeOS in this case. |
| 784 EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile( | 784 EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile( |
| 785 profile_)->current_login_ui()); | 785 profile_)->current_login_ui()); |
| 786 #else | 786 #else |
| 787 | 787 |
| 788 // On ChromeOS, this should display the spinner while we try to startup the | 788 // On ChromeOS, this should display the spinner while we try to startup the |
| 789 // sync backend, and on desktop this displays the login dialog. | 789 // sync backend, and on desktop this displays the login dialog. |
| 790 handler_->OpenSyncSetup(nullptr); | 790 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 791 | 791 |
| 792 // Sync setup is closed when re-auth is in progress. | 792 // Sync setup is closed when re-auth is in progress. |
| 793 EXPECT_EQ(NULL, | 793 EXPECT_EQ(NULL, |
| 794 LoginUIServiceFactory::GetForProfile( | 794 LoginUIServiceFactory::GetForProfile( |
| 795 profile_)->current_login_ui()); | 795 profile_)->current_login_ui()); |
| 796 | 796 |
| 797 ASSERT_FALSE(handler_->is_configuring_sync()); | 797 ASSERT_FALSE(handler_->is_configuring_sync()); |
| 798 #endif | 798 #endif |
| 799 } | 799 } |
| 800 | 800 |
| 801 TEST_F(PeopleHandlerTest, ShowSetupSyncEverything) { | 801 TEST_F(PeopleHandlerTest, ShowSetupSyncEverything) { |
| 802 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 802 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 803 .WillRepeatedly(Return(false)); | 803 .WillRepeatedly(Return(false)); |
| 804 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 804 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 805 .WillRepeatedly(Return(false)); | 805 .WillRepeatedly(Return(false)); |
| 806 SetupInitializedProfileSyncService(); | 806 SetupInitializedProfileSyncService(); |
| 807 SetDefaultExpectationsForConfigPage(); | 807 SetDefaultExpectationsForConfigPage(); |
| 808 // This should display the sync setup dialog (not login). | 808 // This should display the sync setup dialog (not login). |
| 809 handler_->OpenSyncSetup(nullptr); | 809 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 810 | 810 |
| 811 ExpectConfig(); | 811 ExpectConfig(); |
| 812 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 812 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
| 813 const base::DictionaryValue* dictionary = nullptr; | 813 const base::DictionaryValue* dictionary = nullptr; |
| 814 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 814 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
| 815 CheckBool(dictionary, "syncAllDataTypes", true); | 815 CheckBool(dictionary, "syncAllDataTypes", true); |
| 816 CheckBool(dictionary, "appsRegistered", true); | 816 CheckBool(dictionary, "appsRegistered", true); |
| 817 CheckBool(dictionary, "autofillRegistered", true); | 817 CheckBool(dictionary, "autofillRegistered", true); |
| 818 CheckBool(dictionary, "bookmarksRegistered", true); | 818 CheckBool(dictionary, "bookmarksRegistered", true); |
| 819 CheckBool(dictionary, "extensionsRegistered", true); | 819 CheckBool(dictionary, "extensionsRegistered", true); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 833 TEST_F(PeopleHandlerTest, ShowSetupManuallySyncAll) { | 833 TEST_F(PeopleHandlerTest, ShowSetupManuallySyncAll) { |
| 834 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 834 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 835 .WillRepeatedly(Return(false)); | 835 .WillRepeatedly(Return(false)); |
| 836 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 836 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 837 .WillRepeatedly(Return(false)); | 837 .WillRepeatedly(Return(false)); |
| 838 SetupInitializedProfileSyncService(); | 838 SetupInitializedProfileSyncService(); |
| 839 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); | 839 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); |
| 840 sync_prefs.SetKeepEverythingSynced(false); | 840 sync_prefs.SetKeepEverythingSynced(false); |
| 841 SetDefaultExpectationsForConfigPage(); | 841 SetDefaultExpectationsForConfigPage(); |
| 842 // This should display the sync setup dialog (not login). | 842 // This should display the sync setup dialog (not login). |
| 843 handler_->OpenSyncSetup(nullptr); | 843 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 844 | 844 |
| 845 ExpectConfig(); | 845 ExpectConfig(); |
| 846 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 846 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
| 847 const base::DictionaryValue* dictionary = nullptr; | 847 const base::DictionaryValue* dictionary = nullptr; |
| 848 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 848 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
| 849 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes()); | 849 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes()); |
| 850 } | 850 } |
| 851 | 851 |
| 852 TEST_F(PeopleHandlerTest, ShowSetupSyncForAllTypesIndividually) { | 852 TEST_F(PeopleHandlerTest, ShowSetupSyncForAllTypesIndividually) { |
| 853 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); | 853 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); |
| 854 syncer::ModelTypeSet::Iterator it; | 854 syncer::ModelTypeSet::Iterator it; |
| 855 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { | 855 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { |
| 856 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 856 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 857 .WillRepeatedly(Return(false)); | 857 .WillRepeatedly(Return(false)); |
| 858 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 858 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 859 .WillRepeatedly(Return(false)); | 859 .WillRepeatedly(Return(false)); |
| 860 SetupInitializedProfileSyncService(); | 860 SetupInitializedProfileSyncService(); |
| 861 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); | 861 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); |
| 862 sync_prefs.SetKeepEverythingSynced(false); | 862 sync_prefs.SetKeepEverythingSynced(false); |
| 863 SetDefaultExpectationsForConfigPage(); | 863 SetDefaultExpectationsForConfigPage(); |
| 864 syncer::ModelTypeSet types; | 864 syncer::ModelTypeSet types; |
| 865 types.Put(it.Get()); | 865 types.Put(it.Get()); |
| 866 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()). | 866 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()). |
| 867 WillRepeatedly(Return(types)); | 867 WillRepeatedly(Return(types)); |
| 868 | 868 |
| 869 // This should display the sync setup dialog (not login). | 869 // This should display the sync setup dialog (not login). |
| 870 handler_->OpenSyncSetup(nullptr); | 870 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 871 | 871 |
| 872 ExpectConfig(); | 872 ExpectConfig(); |
| 873 // Close the config overlay. | 873 // Close the config overlay. |
| 874 LoginUIServiceFactory::GetForProfile(profile_)->LoginUIClosed( | 874 LoginUIServiceFactory::GetForProfile(profile_)->LoginUIClosed( |
| 875 handler_.get()); | 875 handler_.get()); |
| 876 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 876 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
| 877 const base::DictionaryValue* dictionary = nullptr; | 877 const base::DictionaryValue* dictionary = nullptr; |
| 878 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 878 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
| 879 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types); | 879 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types); |
| 880 Mock::VerifyAndClearExpectations(mock_pss_); | 880 Mock::VerifyAndClearExpectations(mock_pss_); |
| 881 // Clean up so we can loop back to display the dialog again. | 881 // Clean up so we can loop back to display the dialog again. |
| 882 web_ui_.ClearTrackedCalls(); | 882 web_ui_.ClearTrackedCalls(); |
| 883 } | 883 } |
| 884 } | 884 } |
| 885 | 885 |
| 886 TEST_F(PeopleHandlerTest, ShowSetupGaiaPassphraseRequired) { | 886 TEST_F(PeopleHandlerTest, ShowSetupGaiaPassphraseRequired) { |
| 887 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 887 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 888 .WillRepeatedly(Return(true)); | 888 .WillRepeatedly(Return(true)); |
| 889 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 889 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 890 .WillRepeatedly(Return(false)); | 890 .WillRepeatedly(Return(false)); |
| 891 SetupInitializedProfileSyncService(); | 891 SetupInitializedProfileSyncService(); |
| 892 SetDefaultExpectationsForConfigPage(); | 892 SetDefaultExpectationsForConfigPage(); |
| 893 | 893 |
| 894 // This should display the sync setup dialog (not login). | 894 // This should display the sync setup dialog (not login). |
| 895 handler_->OpenSyncSetup(nullptr); | 895 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 896 | 896 |
| 897 ExpectConfig(); | 897 ExpectConfig(); |
| 898 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 898 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
| 899 const base::DictionaryValue* dictionary = nullptr; | 899 const base::DictionaryValue* dictionary = nullptr; |
| 900 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 900 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
| 901 CheckBool(dictionary, "showPassphrase", true); | 901 CheckBool(dictionary, "showPassphrase", true); |
| 902 CheckBool(dictionary, "usePassphrase", false); | 902 CheckBool(dictionary, "usePassphrase", false); |
| 903 CheckBool(dictionary, "passphraseFailed", false); | 903 CheckBool(dictionary, "passphraseFailed", false); |
| 904 } | 904 } |
| 905 | 905 |
| 906 TEST_F(PeopleHandlerTest, ShowSetupCustomPassphraseRequired) { | 906 TEST_F(PeopleHandlerTest, ShowSetupCustomPassphraseRequired) { |
| 907 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 907 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 908 .WillRepeatedly(Return(true)); | 908 .WillRepeatedly(Return(true)); |
| 909 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 909 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 910 .WillRepeatedly(Return(true)); | 910 .WillRepeatedly(Return(true)); |
| 911 EXPECT_CALL(*mock_pss_, GetPassphraseType()) | 911 EXPECT_CALL(*mock_pss_, GetPassphraseType()) |
| 912 .WillRepeatedly(Return(syncer::CUSTOM_PASSPHRASE)); | 912 .WillRepeatedly(Return(syncer::CUSTOM_PASSPHRASE)); |
| 913 SetupInitializedProfileSyncService(); | 913 SetupInitializedProfileSyncService(); |
| 914 SetDefaultExpectationsForConfigPage(); | 914 SetDefaultExpectationsForConfigPage(); |
| 915 | 915 |
| 916 // This should display the sync setup dialog (not login). | 916 // This should display the sync setup dialog (not login). |
| 917 handler_->OpenSyncSetup(nullptr); | 917 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 918 | 918 |
| 919 ExpectConfig(); | 919 ExpectConfig(); |
| 920 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 920 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
| 921 const base::DictionaryValue* dictionary = nullptr; | 921 const base::DictionaryValue* dictionary = nullptr; |
| 922 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 922 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
| 923 CheckBool(dictionary, "showPassphrase", true); | 923 CheckBool(dictionary, "showPassphrase", true); |
| 924 CheckBool(dictionary, "usePassphrase", true); | 924 CheckBool(dictionary, "usePassphrase", true); |
| 925 CheckBool(dictionary, "passphraseFailed", false); | 925 CheckBool(dictionary, "passphraseFailed", false); |
| 926 } | 926 } |
| 927 | 927 |
| 928 TEST_F(PeopleHandlerTest, ShowSetupEncryptAll) { | 928 TEST_F(PeopleHandlerTest, ShowSetupEncryptAll) { |
| 929 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 929 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 930 .WillRepeatedly(Return(false)); | 930 .WillRepeatedly(Return(false)); |
| 931 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 931 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 932 .WillRepeatedly(Return(false)); | 932 .WillRepeatedly(Return(false)); |
| 933 SetupInitializedProfileSyncService(); | 933 SetupInitializedProfileSyncService(); |
| 934 SetDefaultExpectationsForConfigPage(); | 934 SetDefaultExpectationsForConfigPage(); |
| 935 EXPECT_CALL(*mock_pss_, IsEncryptEverythingEnabled()) | 935 EXPECT_CALL(*mock_pss_, IsEncryptEverythingEnabled()) |
| 936 .WillRepeatedly(Return(true)); | 936 .WillRepeatedly(Return(true)); |
| 937 | 937 |
| 938 // This should display the sync setup dialog (not login). | 938 // This should display the sync setup dialog (not login). |
| 939 handler_->OpenSyncSetup(nullptr); | 939 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 940 | 940 |
| 941 ExpectConfig(); | 941 ExpectConfig(); |
| 942 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 942 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
| 943 const base::DictionaryValue* dictionary = nullptr; | 943 const base::DictionaryValue* dictionary = nullptr; |
| 944 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 944 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
| 945 CheckBool(dictionary, "encryptAllData", true); | 945 CheckBool(dictionary, "encryptAllData", true); |
| 946 } | 946 } |
| 947 | 947 |
| 948 TEST_F(PeopleHandlerTest, ShowSetupEncryptAllDisallowed) { | 948 TEST_F(PeopleHandlerTest, ShowSetupEncryptAllDisallowed) { |
| 949 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 949 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 950 .WillRepeatedly(Return(false)); | 950 .WillRepeatedly(Return(false)); |
| 951 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 951 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 952 .WillRepeatedly(Return(false)); | 952 .WillRepeatedly(Return(false)); |
| 953 SetupInitializedProfileSyncService(); | 953 SetupInitializedProfileSyncService(); |
| 954 SetDefaultExpectationsForConfigPage(); | 954 SetDefaultExpectationsForConfigPage(); |
| 955 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) | 955 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) |
| 956 .WillRepeatedly(Return(false)); | 956 .WillRepeatedly(Return(false)); |
| 957 | 957 |
| 958 // This should display the sync setup dialog (not login). | 958 // This should display the sync setup dialog (not login). |
| 959 handler_->OpenSyncSetup(nullptr); | 959 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
| 960 | 960 |
| 961 ExpectConfig(); | 961 ExpectConfig(); |
| 962 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 962 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
| 963 const base::DictionaryValue* dictionary = nullptr; | 963 const base::DictionaryValue* dictionary = nullptr; |
| 964 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 964 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
| 965 CheckBool(dictionary, "encryptAllData", false); | 965 CheckBool(dictionary, "encryptAllData", false); |
| 966 CheckBool(dictionary, "encryptAllDataAllowed", false); | 966 CheckBool(dictionary, "encryptAllDataAllowed", false); |
| 967 } | 967 } |
| 968 | 968 |
| 969 TEST_F(PeopleHandlerTest, TurnOnEncryptAllDisallowed) { | 969 TEST_F(PeopleHandlerTest, TurnOnEncryptAllDisallowed) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 981 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0); | 981 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0); |
| 982 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); | 982 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); |
| 983 handler_->HandleConfigure(&list_args); | 983 handler_->HandleConfigure(&list_args); |
| 984 | 984 |
| 985 // Ensure that we navigated to the "done" state since we don't need a | 985 // Ensure that we navigated to the "done" state since we don't need a |
| 986 // passphrase. | 986 // passphrase. |
| 987 ExpectDone(); | 987 ExpectDone(); |
| 988 } | 988 } |
| 989 | 989 |
| 990 } // namespace settings | 990 } // namespace settings |
| OLD | NEW |