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

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

Powered by Google App Engine
This is Rietveld 408576698