Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: chrome/browser/ui/webui/options/sync_setup_handler_unittest.cc

Issue 1608103002: Settings Rewrite: Fix Opening Sync User login (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 306 }
307 307
308 #if !defined(OS_CHROMEOS) 308 #if !defined(OS_CHROMEOS)
309 TEST_F(SyncSetupHandlerFirstSigninTest, DisplayBasicLogin) { 309 TEST_F(SyncSetupHandlerFirstSigninTest, DisplayBasicLogin) {
310 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); 310 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false));
311 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); 311 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
312 // Ensure that the user is not signed in before calling |HandleStartSignin()|. 312 // Ensure that the user is not signed in before calling |HandleStartSignin()|.
313 SigninManager* manager = static_cast<SigninManager*>(mock_signin_); 313 SigninManager* manager = static_cast<SigninManager*>(mock_signin_);
314 manager->SignOut(signin_metrics::SIGNOUT_TEST, 314 manager->SignOut(signin_metrics::SIGNOUT_TEST,
315 signin_metrics::SignoutDelete::IGNORE_METRIC); 315 signin_metrics::SignoutDelete::IGNORE_METRIC);
316 handler_->HandleStartSignin(NULL); 316 base::ListValue list_args;
317 handler_->HandleStartSignin(&list_args);
317 318
318 // Sync setup hands off control to the gaia login tab. 319 // Sync setup hands off control to the gaia login tab.
319 EXPECT_EQ(NULL, 320 EXPECT_EQ(NULL,
320 LoginUIServiceFactory::GetForProfile( 321 LoginUIServiceFactory::GetForProfile(
321 profile_.get())->current_login_ui()); 322 profile_.get())->current_login_ui());
322 323
323 ASSERT_FALSE(handler_->is_configuring_sync()); 324 ASSERT_FALSE(handler_->is_configuring_sync());
324 325
325 handler_->CloseSyncSetup(); 326 handler_->CloseSyncSetup();
326 EXPECT_EQ(NULL, 327 EXPECT_EQ(NULL,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 // to showing a configuration page when sync setup completes successfully. 385 // to showing a configuration page when sync setup completes successfully.
385 TEST_F(SyncSetupHandlerTest, 386 TEST_F(SyncSetupHandlerTest,
386 DisplayConfigureWithBackendDisabledAndSyncStartupCompleted) { 387 DisplayConfigureWithBackendDisabledAndSyncStartupCompleted) {
387 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); 388 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true));
388 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); 389 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
389 error_ = GoogleServiceAuthError::AuthErrorNone(); 390 error_ = GoogleServiceAuthError::AuthErrorNone();
390 // Sync backend is stopped initially, and will start up. 391 // Sync backend is stopped initially, and will start up.
391 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); 392 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false));
392 SetDefaultExpectationsForConfigPage(); 393 SetDefaultExpectationsForConfigPage();
393 394
394 handler_->OpenSyncSetup(nullptr); 395 handler_->OpenSyncSetup(false /* creating_supervised_user */);
395 396
396 // We expect a call to SyncSetupOverlay.showSyncSetupPage. 397 // We expect a call to SyncSetupOverlay.showSyncSetupPage.
397 EXPECT_EQ(1U, web_ui_.call_data().size()); 398 EXPECT_EQ(1U, web_ui_.call_data().size());
398 399
399 const content::TestWebUI::CallData& data0 = *web_ui_.call_data()[0]; 400 const content::TestWebUI::CallData& data0 = *web_ui_.call_data()[0];
400 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data0.function_name()); 401 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data0.function_name());
401 std::string page; 402 std::string page;
402 ASSERT_TRUE(data0.arg1()->GetAsString(&page)); 403 ASSERT_TRUE(data0.arg1()->GetAsString(&page));
403 EXPECT_EQ(page, "spinner"); 404 EXPECT_EQ(page, "spinner");
404 405
(...skipping 27 matching lines...) Expand all
432 // before the user has continued on. 433 // before the user has continued on.
433 TEST_F(SyncSetupHandlerTest, 434 TEST_F(SyncSetupHandlerTest,
434 DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) { 435 DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) {
435 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); 436 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true));
436 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); 437 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
437 error_ = GoogleServiceAuthError::AuthErrorNone(); 438 error_ = GoogleServiceAuthError::AuthErrorNone();
438 EXPECT_CALL(*mock_pss_, IsBackendInitialized()) 439 EXPECT_CALL(*mock_pss_, IsBackendInitialized())
439 .WillOnce(Return(false)) 440 .WillOnce(Return(false))
440 .WillRepeatedly(Return(true)); 441 .WillRepeatedly(Return(true));
441 SetDefaultExpectationsForConfigPage(); 442 SetDefaultExpectationsForConfigPage();
442 handler_->OpenSyncSetup(nullptr); 443 handler_->OpenSyncSetup(false /* creating_supervised_user */);
443 444
444 // It's important to tell sync the user cancelled the setup flow before we 445 // It's important to tell sync the user cancelled the setup flow before we
445 // tell it we're through with the setup progress. 446 // tell it we're through with the setup progress.
446 testing::InSequence seq; 447 testing::InSequence seq;
447 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA)); 448 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA));
448 EXPECT_CALL(*mock_pss_, SetSetupInProgress(false)); 449 EXPECT_CALL(*mock_pss_, SetSetupInProgress(false));
449 450
450 handler_->CloseSyncSetup(); 451 handler_->CloseSyncSetup();
451 EXPECT_EQ(NULL, 452 EXPECT_EQ(NULL,
452 LoginUIServiceFactory::GetForProfile( 453 LoginUIServiceFactory::GetForProfile(
453 profile_.get())->current_login_ui()); 454 profile_.get())->current_login_ui());
454 } 455 }
455 456
456 TEST_F(SyncSetupHandlerTest, 457 TEST_F(SyncSetupHandlerTest,
457 DisplayConfigureWithBackendDisabledAndSigninFailed) { 458 DisplayConfigureWithBackendDisabledAndSigninFailed) {
458 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); 459 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true));
459 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); 460 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
460 error_ = GoogleServiceAuthError::AuthErrorNone(); 461 error_ = GoogleServiceAuthError::AuthErrorNone();
461 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); 462 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false));
462 463
463 handler_->OpenSyncSetup(nullptr); 464 handler_->OpenSyncSetup(false /* creating_supervised_user */);
464 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; 465 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
465 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name()); 466 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name());
466 std::string page; 467 std::string page;
467 ASSERT_TRUE(data.arg1()->GetAsString(&page)); 468 ASSERT_TRUE(data.arg1()->GetAsString(&page));
468 EXPECT_EQ(page, "spinner"); 469 EXPECT_EQ(page, "spinner");
469 Mock::VerifyAndClearExpectations(mock_pss_); 470 Mock::VerifyAndClearExpectations(mock_pss_);
470 error_ = GoogleServiceAuthError( 471 error_ = GoogleServiceAuthError(
471 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); 472 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
472 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); 473 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
473 NotifySyncListeners(); 474 NotifySyncListeners();
(...skipping 10 matching lines...) Expand all
484 public: 485 public:
485 SyncSetupHandlerNonCrosTest() {} 486 SyncSetupHandlerNonCrosTest() {}
486 }; 487 };
487 488
488 TEST_F(SyncSetupHandlerNonCrosTest, HandleGaiaAuthFailure) { 489 TEST_F(SyncSetupHandlerNonCrosTest, HandleGaiaAuthFailure) {
489 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); 490 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false));
490 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) 491 EXPECT_CALL(*mock_pss_, HasUnrecoverableError())
491 .WillRepeatedly(Return(false)); 492 .WillRepeatedly(Return(false));
492 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); 493 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
493 // Open the web UI. 494 // Open the web UI.
494 handler_->OpenSyncSetup(nullptr); 495 handler_->OpenSyncSetup(false /* creating_supervised_user */);
495 496
496 ASSERT_FALSE(handler_->is_configuring_sync()); 497 ASSERT_FALSE(handler_->is_configuring_sync());
497 } 498 }
498 499
499 // TODO(kochi): We need equivalent tests for ChromeOS. 500 // TODO(kochi): We need equivalent tests for ChromeOS.
500 TEST_F(SyncSetupHandlerNonCrosTest, UnrecoverableErrorInitializingSync) { 501 TEST_F(SyncSetupHandlerNonCrosTest, UnrecoverableErrorInitializingSync) {
501 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); 502 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false));
502 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); 503 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
503 // Open the web UI. 504 // Open the web UI.
504 handler_->OpenSyncSetup(nullptr); 505 handler_->OpenSyncSetup(false /* creating_supervised_user */);
505 506
506 ASSERT_FALSE(handler_->is_configuring_sync()); 507 ASSERT_FALSE(handler_->is_configuring_sync());
507 } 508 }
508 509
509 TEST_F(SyncSetupHandlerNonCrosTest, GaiaErrorInitializingSync) { 510 TEST_F(SyncSetupHandlerNonCrosTest, GaiaErrorInitializingSync) {
510 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); 511 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false));
511 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false)); 512 EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
512 // Open the web UI. 513 // Open the web UI.
513 handler_->OpenSyncSetup(nullptr); 514 handler_->OpenSyncSetup(false /* creating_supervised_user */);
514 515
515 ASSERT_FALSE(handler_->is_configuring_sync()); 516 ASSERT_FALSE(handler_->is_configuring_sync());
516 } 517 }
517 518
518 #endif // #if !defined(OS_CHROMEOS) 519 #endif // #if !defined(OS_CHROMEOS)
519 520
520 TEST_F(SyncSetupHandlerTest, TestSyncEverything) { 521 TEST_F(SyncSetupHandlerTest, TestSyncEverything) {
521 std::string args = 522 std::string args =
522 GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), 523 GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(),
523 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); 524 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED);
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 } 727 }
727 728
728 TEST_F(SyncSetupHandlerTest, ShowSyncSetup) { 729 TEST_F(SyncSetupHandlerTest, ShowSyncSetup) {
729 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 730 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
730 .WillRepeatedly(Return(false)); 731 .WillRepeatedly(Return(false));
731 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 732 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
732 .WillRepeatedly(Return(false)); 733 .WillRepeatedly(Return(false));
733 SetupInitializedProfileSyncService(); 734 SetupInitializedProfileSyncService();
734 // This should display the sync setup dialog (not login). 735 // This should display the sync setup dialog (not login).
735 SetDefaultExpectationsForConfigPage(); 736 SetDefaultExpectationsForConfigPage();
736 handler_->OpenSyncSetup(nullptr); 737 handler_->OpenSyncSetup(false /* creating_supervised_user */);
737 738
738 ExpectConfig(); 739 ExpectConfig();
739 } 740 }
740 741
741 // We do not display signin on chromeos in the case of auth error. 742 // We do not display signin on chromeos in the case of auth error.
742 TEST_F(SyncSetupHandlerTest, ShowSigninOnAuthError) { 743 TEST_F(SyncSetupHandlerTest, ShowSigninOnAuthError) {
743 // Initialize the system to a signed in state, but with an auth error. 744 // Initialize the system to a signed in state, but with an auth error.
744 error_ = GoogleServiceAuthError( 745 error_ = GoogleServiceAuthError(
745 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); 746 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
746 747
(...skipping 14 matching lines...) Expand all
761 // sync backend (which will fail due to the auth error). This should only 762 // sync backend (which will fail due to the auth error). This should only
762 // happen if the user manually navigates to chrome://settings/syncSetup - 763 // happen if the user manually navigates to chrome://settings/syncSetup -
763 // clicking on the button in the UI will sign the user out rather than 764 // clicking on the button in the UI will sign the user out rather than
764 // displaying a spinner. Should be no visible UI on ChromeOS in this case. 765 // displaying a spinner. Should be no visible UI on ChromeOS in this case.
765 EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile( 766 EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile(
766 profile_.get())->current_login_ui()); 767 profile_.get())->current_login_ui());
767 #else 768 #else
768 769
769 // On ChromeOS, this should display the spinner while we try to startup the 770 // On ChromeOS, this should display the spinner while we try to startup the
770 // sync backend, and on desktop this displays the login dialog. 771 // sync backend, and on desktop this displays the login dialog.
771 handler_->OpenSyncSetup(nullptr); 772 handler_->OpenSyncSetup(false /* creating_supervised_user */);
772 773
773 // Sync setup is closed when re-auth is in progress. 774 // Sync setup is closed when re-auth is in progress.
774 EXPECT_EQ(NULL, 775 EXPECT_EQ(NULL,
775 LoginUIServiceFactory::GetForProfile( 776 LoginUIServiceFactory::GetForProfile(
776 profile_.get())->current_login_ui()); 777 profile_.get())->current_login_ui());
777 778
778 ASSERT_FALSE(handler_->is_configuring_sync()); 779 ASSERT_FALSE(handler_->is_configuring_sync());
779 #endif 780 #endif
780 } 781 }
781 782
782 TEST_F(SyncSetupHandlerTest, ShowSetupSyncEverything) { 783 TEST_F(SyncSetupHandlerTest, ShowSetupSyncEverything) {
783 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 784 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
784 .WillRepeatedly(Return(false)); 785 .WillRepeatedly(Return(false));
785 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 786 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
786 .WillRepeatedly(Return(false)); 787 .WillRepeatedly(Return(false));
787 SetupInitializedProfileSyncService(); 788 SetupInitializedProfileSyncService();
788 SetDefaultExpectationsForConfigPage(); 789 SetDefaultExpectationsForConfigPage();
789 // This should display the sync setup dialog (not login). 790 // This should display the sync setup dialog (not login).
790 handler_->OpenSyncSetup(nullptr); 791 handler_->OpenSyncSetup(false /* creating_supervised_user */);
791 792
792 ExpectConfig(); 793 ExpectConfig();
793 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; 794 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
794 const base::DictionaryValue* dictionary = nullptr; 795 const base::DictionaryValue* dictionary = nullptr;
795 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); 796 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary));
796 CheckBool(dictionary, "syncAllDataTypes", true); 797 CheckBool(dictionary, "syncAllDataTypes", true);
797 CheckBool(dictionary, "appsRegistered", true); 798 CheckBool(dictionary, "appsRegistered", true);
798 CheckBool(dictionary, "autofillRegistered", true); 799 CheckBool(dictionary, "autofillRegistered", true);
799 CheckBool(dictionary, "bookmarksRegistered", true); 800 CheckBool(dictionary, "bookmarksRegistered", true);
800 CheckBool(dictionary, "extensionsRegistered", true); 801 CheckBool(dictionary, "extensionsRegistered", true);
(...skipping 14 matching lines...) Expand all
815 TEST_F(SyncSetupHandlerTest, ShowSetupManuallySyncAll) { 816 TEST_F(SyncSetupHandlerTest, ShowSetupManuallySyncAll) {
816 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 817 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
817 .WillRepeatedly(Return(false)); 818 .WillRepeatedly(Return(false));
818 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 819 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
819 .WillRepeatedly(Return(false)); 820 .WillRepeatedly(Return(false));
820 SetupInitializedProfileSyncService(); 821 SetupInitializedProfileSyncService();
821 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); 822 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs());
822 sync_prefs.SetKeepEverythingSynced(false); 823 sync_prefs.SetKeepEverythingSynced(false);
823 SetDefaultExpectationsForConfigPage(); 824 SetDefaultExpectationsForConfigPage();
824 // This should display the sync setup dialog (not login). 825 // This should display the sync setup dialog (not login).
825 handler_->OpenSyncSetup(nullptr); 826 handler_->OpenSyncSetup(false /* creating_supervised_user */);
826 827
827 ExpectConfig(); 828 ExpectConfig();
828 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; 829 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
829 const base::DictionaryValue* dictionary = nullptr; 830 const base::DictionaryValue* dictionary = nullptr;
830 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); 831 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary));
831 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes()); 832 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes());
832 } 833 }
833 834
834 TEST_F(SyncSetupHandlerTest, ShowSetupSyncForAllTypesIndividually) { 835 TEST_F(SyncSetupHandlerTest, ShowSetupSyncForAllTypesIndividually) {
835 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); 836 syncer::ModelTypeSet user_selectable_types = GetAllTypes();
836 syncer::ModelTypeSet::Iterator it; 837 syncer::ModelTypeSet::Iterator it;
837 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { 838 for (it = user_selectable_types.First(); it.Good(); it.Inc()) {
838 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 839 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
839 .WillRepeatedly(Return(false)); 840 .WillRepeatedly(Return(false));
840 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 841 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
841 .WillRepeatedly(Return(false)); 842 .WillRepeatedly(Return(false));
842 SetupInitializedProfileSyncService(); 843 SetupInitializedProfileSyncService();
843 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); 844 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs());
844 sync_prefs.SetKeepEverythingSynced(false); 845 sync_prefs.SetKeepEverythingSynced(false);
845 SetDefaultExpectationsForConfigPage(); 846 SetDefaultExpectationsForConfigPage();
846 syncer::ModelTypeSet types; 847 syncer::ModelTypeSet types;
847 types.Put(it.Get()); 848 types.Put(it.Get());
848 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()). 849 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()).
849 WillRepeatedly(Return(types)); 850 WillRepeatedly(Return(types));
850 851
851 // This should display the sync setup dialog (not login). 852 // This should display the sync setup dialog (not login).
852 handler_->OpenSyncSetup(nullptr); 853 handler_->OpenSyncSetup(false /* creating_supervised_user */);
853 854
854 ExpectConfig(); 855 ExpectConfig();
855 // Close the config overlay. 856 // Close the config overlay.
856 LoginUIServiceFactory::GetForProfile(profile_.get())->LoginUIClosed( 857 LoginUIServiceFactory::GetForProfile(profile_.get())->LoginUIClosed(
857 handler_.get()); 858 handler_.get());
858 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; 859 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
859 const base::DictionaryValue* dictionary = nullptr; 860 const base::DictionaryValue* dictionary = nullptr;
860 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); 861 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary));
861 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types); 862 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types);
862 Mock::VerifyAndClearExpectations(mock_pss_); 863 Mock::VerifyAndClearExpectations(mock_pss_);
863 // Clean up so we can loop back to display the dialog again. 864 // Clean up so we can loop back to display the dialog again.
864 web_ui_.ClearTrackedCalls(); 865 web_ui_.ClearTrackedCalls();
865 } 866 }
866 } 867 }
867 868
868 TEST_F(SyncSetupHandlerTest, ShowSetupGaiaPassphraseRequired) { 869 TEST_F(SyncSetupHandlerTest, ShowSetupGaiaPassphraseRequired) {
869 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 870 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
870 .WillRepeatedly(Return(true)); 871 .WillRepeatedly(Return(true));
871 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 872 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
872 .WillRepeatedly(Return(false)); 873 .WillRepeatedly(Return(false));
873 SetupInitializedProfileSyncService(); 874 SetupInitializedProfileSyncService();
874 SetDefaultExpectationsForConfigPage(); 875 SetDefaultExpectationsForConfigPage();
875 876
876 // This should display the sync setup dialog (not login). 877 // This should display the sync setup dialog (not login).
877 handler_->OpenSyncSetup(nullptr); 878 handler_->OpenSyncSetup(false /* creating_supervised_user */);
878 879
879 ExpectConfig(); 880 ExpectConfig();
880 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; 881 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
881 const base::DictionaryValue* dictionary = nullptr; 882 const base::DictionaryValue* dictionary = nullptr;
882 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); 883 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary));
883 CheckBool(dictionary, "showPassphrase", true); 884 CheckBool(dictionary, "showPassphrase", true);
884 CheckBool(dictionary, "usePassphrase", false); 885 CheckBool(dictionary, "usePassphrase", false);
885 CheckBool(dictionary, "passphraseFailed", false); 886 CheckBool(dictionary, "passphraseFailed", false);
886 } 887 }
887 888
888 TEST_F(SyncSetupHandlerTest, ShowSetupCustomPassphraseRequired) { 889 TEST_F(SyncSetupHandlerTest, ShowSetupCustomPassphraseRequired) {
889 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 890 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
890 .WillRepeatedly(Return(true)); 891 .WillRepeatedly(Return(true));
891 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 892 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
892 .WillRepeatedly(Return(true)); 893 .WillRepeatedly(Return(true));
893 EXPECT_CALL(*mock_pss_, GetPassphraseType()) 894 EXPECT_CALL(*mock_pss_, GetPassphraseType())
894 .WillRepeatedly(Return(syncer::CUSTOM_PASSPHRASE)); 895 .WillRepeatedly(Return(syncer::CUSTOM_PASSPHRASE));
895 SetupInitializedProfileSyncService(); 896 SetupInitializedProfileSyncService();
896 SetDefaultExpectationsForConfigPage(); 897 SetDefaultExpectationsForConfigPage();
897 898
898 // This should display the sync setup dialog (not login). 899 // This should display the sync setup dialog (not login).
899 handler_->OpenSyncSetup(nullptr); 900 handler_->OpenSyncSetup(false /* creating_supervised_user */);
900 901
901 ExpectConfig(); 902 ExpectConfig();
902 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; 903 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
903 const base::DictionaryValue* dictionary = nullptr; 904 const base::DictionaryValue* dictionary = nullptr;
904 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); 905 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary));
905 CheckBool(dictionary, "showPassphrase", true); 906 CheckBool(dictionary, "showPassphrase", true);
906 CheckBool(dictionary, "usePassphrase", true); 907 CheckBool(dictionary, "usePassphrase", true);
907 CheckBool(dictionary, "passphraseFailed", false); 908 CheckBool(dictionary, "passphraseFailed", false);
908 } 909 }
909 910
910 TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAll) { 911 TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAll) {
911 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 912 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
912 .WillRepeatedly(Return(false)); 913 .WillRepeatedly(Return(false));
913 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 914 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
914 .WillRepeatedly(Return(false)); 915 .WillRepeatedly(Return(false));
915 SetupInitializedProfileSyncService(); 916 SetupInitializedProfileSyncService();
916 SetDefaultExpectationsForConfigPage(); 917 SetDefaultExpectationsForConfigPage();
917 EXPECT_CALL(*mock_pss_, IsEncryptEverythingEnabled()) 918 EXPECT_CALL(*mock_pss_, IsEncryptEverythingEnabled())
918 .WillRepeatedly(Return(true)); 919 .WillRepeatedly(Return(true));
919 920
920 // This should display the sync setup dialog (not login). 921 // This should display the sync setup dialog (not login).
921 handler_->OpenSyncSetup(nullptr); 922 handler_->OpenSyncSetup(false /* creating_supervised_user */);
922 923
923 ExpectConfig(); 924 ExpectConfig();
924 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; 925 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
925 const base::DictionaryValue* dictionary = nullptr; 926 const base::DictionaryValue* dictionary = nullptr;
926 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); 927 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary));
927 CheckBool(dictionary, "encryptAllData", true); 928 CheckBool(dictionary, "encryptAllData", true);
928 } 929 }
929 930
930 TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAllDisallowed) { 931 TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAllDisallowed) {
931 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 932 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
932 .WillRepeatedly(Return(false)); 933 .WillRepeatedly(Return(false));
933 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 934 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
934 .WillRepeatedly(Return(false)); 935 .WillRepeatedly(Return(false));
935 SetupInitializedProfileSyncService(); 936 SetupInitializedProfileSyncService();
936 SetDefaultExpectationsForConfigPage(); 937 SetDefaultExpectationsForConfigPage();
937 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) 938 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed())
938 .WillRepeatedly(Return(false)); 939 .WillRepeatedly(Return(false));
939 940
940 // This should display the sync setup dialog (not login). 941 // This should display the sync setup dialog (not login).
941 handler_->OpenSyncSetup(nullptr); 942 handler_->OpenSyncSetup(false /* creating_supervised_user */);
942 943
943 ExpectConfig(); 944 ExpectConfig();
944 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; 945 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
945 const base::DictionaryValue* dictionary = nullptr; 946 const base::DictionaryValue* dictionary = nullptr;
946 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); 947 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary));
947 CheckBool(dictionary, "encryptAllData", false); 948 CheckBool(dictionary, "encryptAllData", false);
948 CheckBool(dictionary, "encryptAllDataAllowed", false); 949 CheckBool(dictionary, "encryptAllDataAllowed", false);
949 } 950 }
950 951
951 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAllDisallowed) { 952 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAllDisallowed) {
(...skipping 10 matching lines...) Expand all
962 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) 963 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed())
963 .WillRepeatedly(Return(false)); 964 .WillRepeatedly(Return(false));
964 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0); 965 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0);
965 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); 966 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _));
966 handler_->HandleConfigure(&list_args); 967 handler_->HandleConfigure(&list_args);
967 968
968 // Ensure that we navigated to the "done" state since we don't need a 969 // Ensure that we navigated to the "done" state since we don't need a
969 // passphrase. 970 // passphrase.
970 ExpectDone(); 971 ExpectDone();
971 } 972 }
972
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/sync_setup_handler.cc ('k') | chrome/browser/ui/webui/settings/people_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698