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