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