OLD | NEW |
---|---|
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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 ~TestingSyncSetupHandler() override { set_web_ui(NULL); } | 156 ~TestingSyncSetupHandler() override { set_web_ui(NULL); } |
157 | 157 |
158 void FocusUI() override {} | 158 void FocusUI() override {} |
159 | 159 |
160 Profile* GetProfile() const override { return profile_; } | 160 Profile* GetProfile() const override { return profile_; } |
161 | 161 |
162 using SyncSetupHandler::is_configuring_sync; | 162 using SyncSetupHandler::is_configuring_sync; |
163 | 163 |
164 private: | 164 private: |
165 #if !defined(OS_CHROMEOS) | 165 #if !defined(OS_CHROMEOS) |
166 void DisplayGaiaLoginInNewTabOrWindow() override {} | 166 void DisplayGaiaLoginInNewTabOrWindow( |
167 signin_metrics::AccessPoint access_point) override {} | |
167 #endif | 168 #endif |
168 | 169 |
169 // Weak pointer to parent profile. | 170 // Weak pointer to parent profile. |
170 Profile* profile_; | 171 Profile* profile_; |
171 DISALLOW_COPY_AND_ASSIGN(TestingSyncSetupHandler); | 172 DISALLOW_COPY_AND_ASSIGN(TestingSyncSetupHandler); |
172 }; | 173 }; |
173 | 174 |
174 // The boolean parameter indicates whether the test is run with ClientOAuth | 175 // The boolean parameter indicates whether the test is run with ClientOAuth |
175 // or not. The test parameter is a bool: whether or not to test with/ | 176 // or not. The test parameter is a bool: whether or not to test with/ |
176 // /ClientLogin enabled or not. | 177 // /ClientLogin enabled or not. |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); | 387 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
387 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) | 388 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
388 .WillRepeatedly(Return(true)); | 389 .WillRepeatedly(Return(true)); |
389 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 390 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
390 .WillRepeatedly(Return(false)); | 391 .WillRepeatedly(Return(false)); |
391 error_ = GoogleServiceAuthError::AuthErrorNone(); | 392 error_ = GoogleServiceAuthError::AuthErrorNone(); |
392 // Sync backend is stopped initially, and will start up. | 393 // Sync backend is stopped initially, and will start up. |
393 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); | 394 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); |
394 SetDefaultExpectationsForConfigPage(); | 395 SetDefaultExpectationsForConfigPage(); |
395 | 396 |
396 handler_->OpenSyncSetup(); | 397 handler_->OpenSyncSetup(NULL); |
Bernhard Bauer
2015/12/04 11:06:24
Use nullptr instead of null.
gogerald1
2015/12/04 20:49:09
Done.
| |
397 | 398 |
398 // We expect a call to SyncSetupOverlay.showSyncSetupPage. | 399 // We expect a call to SyncSetupOverlay.showSyncSetupPage. |
399 EXPECT_EQ(1U, web_ui_.call_data().size()); | 400 EXPECT_EQ(1U, web_ui_.call_data().size()); |
400 | 401 |
401 const content::TestWebUI::CallData& data0 = *web_ui_.call_data()[0]; | 402 const content::TestWebUI::CallData& data0 = *web_ui_.call_data()[0]; |
402 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data0.function_name()); | 403 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data0.function_name()); |
403 std::string page; | 404 std::string page; |
404 ASSERT_TRUE(data0.arg1()->GetAsString(&page)); | 405 ASSERT_TRUE(data0.arg1()->GetAsString(&page)); |
405 EXPECT_EQ(page, "spinner"); | 406 EXPECT_EQ(page, "spinner"); |
406 | 407 |
(...skipping 30 matching lines...) Expand all Loading... | |
437 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); | 438 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
438 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) | 439 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
439 .WillRepeatedly(Return(true)); | 440 .WillRepeatedly(Return(true)); |
440 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 441 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
441 .WillRepeatedly(Return(false)); | 442 .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(); | 448 handler_->OpenSyncSetup(NULL); |
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_.get())->current_login_ui()); | 459 profile_.get())->current_login_ui()); |
459 } | 460 } |
460 | 461 |
461 TEST_F(SyncSetupHandlerTest, | 462 TEST_F(SyncSetupHandlerTest, |
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_, IsOAuthRefreshTokenAvailable()) | 465 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
465 .WillRepeatedly(Return(true)); | 466 .WillRepeatedly(Return(true)); |
466 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 467 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
467 .WillRepeatedly(Return(false)); | 468 .WillRepeatedly(Return(false)); |
468 error_ = GoogleServiceAuthError::AuthErrorNone(); | 469 error_ = GoogleServiceAuthError::AuthErrorNone(); |
469 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); | 470 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); |
470 | 471 |
471 handler_->OpenSyncSetup(); | 472 handler_->OpenSyncSetup(NULL); |
472 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 473 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
473 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name()); | 474 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name()); |
474 std::string page; | 475 std::string page; |
475 ASSERT_TRUE(data.arg1()->GetAsString(&page)); | 476 ASSERT_TRUE(data.arg1()->GetAsString(&page)); |
476 EXPECT_EQ(page, "spinner"); | 477 EXPECT_EQ(page, "spinner"); |
477 Mock::VerifyAndClearExpectations(mock_pss_); | 478 Mock::VerifyAndClearExpectations(mock_pss_); |
478 error_ = GoogleServiceAuthError( | 479 error_ = GoogleServiceAuthError( |
479 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 480 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
480 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 481 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
481 NotifySyncListeners(); | 482 NotifySyncListeners(); |
(...skipping 13 matching lines...) Expand all Loading... | |
495 | 496 |
496 TEST_F(SyncSetupHandlerNonCrosTest, HandleGaiaAuthFailure) { | 497 TEST_F(SyncSetupHandlerNonCrosTest, HandleGaiaAuthFailure) { |
497 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); | 498 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
498 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) | 499 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
499 .WillRepeatedly(Return(false)); | 500 .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(); | 506 handler_->OpenSyncSetup(NULL); |
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(SyncSetupHandlerNonCrosTest, UnrecoverableErrorInitializingSync) { | 512 TEST_F(SyncSetupHandlerNonCrosTest, UnrecoverableErrorInitializingSync) { |
512 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); | 513 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
513 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) | 514 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
514 .WillRepeatedly(Return(false)); | 515 .WillRepeatedly(Return(false)); |
515 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 516 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
516 .WillRepeatedly(Return(false)); | 517 .WillRepeatedly(Return(false)); |
517 // Open the web UI. | 518 // Open the web UI. |
518 handler_->OpenSyncSetup(); | 519 handler_->OpenSyncSetup(NULL); |
519 | 520 |
520 ASSERT_FALSE(handler_->is_configuring_sync()); | 521 ASSERT_FALSE(handler_->is_configuring_sync()); |
521 } | 522 } |
522 | 523 |
523 TEST_F(SyncSetupHandlerNonCrosTest, GaiaErrorInitializingSync) { | 524 TEST_F(SyncSetupHandlerNonCrosTest, GaiaErrorInitializingSync) { |
524 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); | 525 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
525 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) | 526 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
526 .WillRepeatedly(Return(false)); | 527 .WillRepeatedly(Return(false)); |
527 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 528 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
528 .WillRepeatedly(Return(false)); | 529 .WillRepeatedly(Return(false)); |
529 // Open the web UI. | 530 // Open the web UI. |
530 handler_->OpenSyncSetup(); | 531 handler_->OpenSyncSetup(NULL); |
531 | 532 |
532 ASSERT_FALSE(handler_->is_configuring_sync()); | 533 ASSERT_FALSE(handler_->is_configuring_sync()); |
533 } | 534 } |
534 | 535 |
535 #endif // #if !defined(OS_CHROMEOS) | 536 #endif // #if !defined(OS_CHROMEOS) |
536 | 537 |
537 TEST_F(SyncSetupHandlerTest, TestSyncEverything) { | 538 TEST_F(SyncSetupHandlerTest, TestSyncEverything) { |
538 std::string args = GetConfiguration( | 539 std::string args = GetConfiguration( |
539 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); | 540 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); |
540 base::ListValue list_args; | 541 base::ListValue list_args; |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
749 } | 750 } |
750 | 751 |
751 TEST_F(SyncSetupHandlerTest, ShowSyncSetup) { | 752 TEST_F(SyncSetupHandlerTest, ShowSyncSetup) { |
752 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 753 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
753 .WillRepeatedly(Return(false)); | 754 .WillRepeatedly(Return(false)); |
754 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 755 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
755 .WillRepeatedly(Return(false)); | 756 .WillRepeatedly(Return(false)); |
756 SetupInitializedProfileSyncService(); | 757 SetupInitializedProfileSyncService(); |
757 // This should display the sync setup dialog (not login). | 758 // This should display the sync setup dialog (not login). |
758 SetDefaultExpectationsForConfigPage(); | 759 SetDefaultExpectationsForConfigPage(); |
759 handler_->OpenSyncSetup(); | 760 handler_->OpenSyncSetup(NULL); |
760 | 761 |
761 ExpectConfig(); | 762 ExpectConfig(); |
762 } | 763 } |
763 | 764 |
764 // We do not display signin on chromeos in the case of auth error. | 765 // We do not display signin on chromeos in the case of auth error. |
765 TEST_F(SyncSetupHandlerTest, ShowSigninOnAuthError) { | 766 TEST_F(SyncSetupHandlerTest, ShowSigninOnAuthError) { |
766 // Initialize the system to a signed in state, but with an auth error. | 767 // Initialize the system to a signed in state, but with an auth error. |
767 error_ = GoogleServiceAuthError( | 768 error_ = GoogleServiceAuthError( |
768 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 769 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
769 | 770 |
(...skipping 16 matching lines...) Expand all Loading... | |
786 // sync backend (which will fail due to the auth error). This should only | 787 // sync backend (which will fail due to the auth error). This should only |
787 // happen if the user manually navigates to chrome://settings/syncSetup - | 788 // happen if the user manually navigates to chrome://settings/syncSetup - |
788 // clicking on the button in the UI will sign the user out rather than | 789 // clicking on the button in the UI will sign the user out rather than |
789 // displaying a spinner. Should be no visible UI on ChromeOS in this case. | 790 // displaying a spinner. Should be no visible UI on ChromeOS in this case. |
790 EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile( | 791 EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile( |
791 profile_.get())->current_login_ui()); | 792 profile_.get())->current_login_ui()); |
792 #else | 793 #else |
793 | 794 |
794 // On ChromeOS, this should display the spinner while we try to startup the | 795 // On ChromeOS, this should display the spinner while we try to startup the |
795 // sync backend, and on desktop this displays the login dialog. | 796 // sync backend, and on desktop this displays the login dialog. |
796 handler_->OpenSyncSetup(); | 797 handler_->OpenSyncSetup(NULL); |
797 | 798 |
798 // Sync setup is closed when re-auth is in progress. | 799 // Sync setup is closed when re-auth is in progress. |
799 EXPECT_EQ(NULL, | 800 EXPECT_EQ(NULL, |
800 LoginUIServiceFactory::GetForProfile( | 801 LoginUIServiceFactory::GetForProfile( |
801 profile_.get())->current_login_ui()); | 802 profile_.get())->current_login_ui()); |
802 | 803 |
803 ASSERT_FALSE(handler_->is_configuring_sync()); | 804 ASSERT_FALSE(handler_->is_configuring_sync()); |
804 #endif | 805 #endif |
805 } | 806 } |
806 | 807 |
807 TEST_F(SyncSetupHandlerTest, ShowSetupSyncEverything) { | 808 TEST_F(SyncSetupHandlerTest, ShowSetupSyncEverything) { |
808 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 809 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
809 .WillRepeatedly(Return(false)); | 810 .WillRepeatedly(Return(false)); |
810 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 811 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
811 .WillRepeatedly(Return(false)); | 812 .WillRepeatedly(Return(false)); |
812 SetupInitializedProfileSyncService(); | 813 SetupInitializedProfileSyncService(); |
813 SetDefaultExpectationsForConfigPage(); | 814 SetDefaultExpectationsForConfigPage(); |
814 // This should display the sync setup dialog (not login). | 815 // This should display the sync setup dialog (not login). |
815 handler_->OpenSyncSetup(); | 816 handler_->OpenSyncSetup(NULL); |
816 | 817 |
817 ExpectConfig(); | 818 ExpectConfig(); |
818 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 819 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
819 const base::DictionaryValue* dictionary = nullptr; | 820 const base::DictionaryValue* dictionary = nullptr; |
820 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 821 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
821 CheckBool(dictionary, "syncAllDataTypes", true); | 822 CheckBool(dictionary, "syncAllDataTypes", true); |
822 CheckBool(dictionary, "appsRegistered", true); | 823 CheckBool(dictionary, "appsRegistered", true); |
823 CheckBool(dictionary, "autofillRegistered", true); | 824 CheckBool(dictionary, "autofillRegistered", true); |
824 CheckBool(dictionary, "bookmarksRegistered", true); | 825 CheckBool(dictionary, "bookmarksRegistered", true); |
825 CheckBool(dictionary, "extensionsRegistered", true); | 826 CheckBool(dictionary, "extensionsRegistered", true); |
(...skipping 13 matching lines...) Expand all Loading... | |
839 TEST_F(SyncSetupHandlerTest, ShowSetupManuallySyncAll) { | 840 TEST_F(SyncSetupHandlerTest, ShowSetupManuallySyncAll) { |
840 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 841 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
841 .WillRepeatedly(Return(false)); | 842 .WillRepeatedly(Return(false)); |
842 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 843 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
843 .WillRepeatedly(Return(false)); | 844 .WillRepeatedly(Return(false)); |
844 SetupInitializedProfileSyncService(); | 845 SetupInitializedProfileSyncService(); |
845 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); | 846 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); |
846 sync_prefs.SetKeepEverythingSynced(false); | 847 sync_prefs.SetKeepEverythingSynced(false); |
847 SetDefaultExpectationsForConfigPage(); | 848 SetDefaultExpectationsForConfigPage(); |
848 // This should display the sync setup dialog (not login). | 849 // This should display the sync setup dialog (not login). |
849 handler_->OpenSyncSetup(); | 850 handler_->OpenSyncSetup(NULL); |
850 | 851 |
851 ExpectConfig(); | 852 ExpectConfig(); |
852 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 853 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
853 const base::DictionaryValue* dictionary = nullptr; | 854 const base::DictionaryValue* dictionary = nullptr; |
854 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 855 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
855 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes()); | 856 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes()); |
856 } | 857 } |
857 | 858 |
858 TEST_F(SyncSetupHandlerTest, ShowSetupSyncForAllTypesIndividually) { | 859 TEST_F(SyncSetupHandlerTest, ShowSetupSyncForAllTypesIndividually) { |
859 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); | 860 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); |
860 syncer::ModelTypeSet::Iterator it; | 861 syncer::ModelTypeSet::Iterator it; |
861 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { | 862 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { |
862 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 863 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
863 .WillRepeatedly(Return(false)); | 864 .WillRepeatedly(Return(false)); |
864 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 865 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
865 .WillRepeatedly(Return(false)); | 866 .WillRepeatedly(Return(false)); |
866 SetupInitializedProfileSyncService(); | 867 SetupInitializedProfileSyncService(); |
867 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); | 868 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); |
868 sync_prefs.SetKeepEverythingSynced(false); | 869 sync_prefs.SetKeepEverythingSynced(false); |
869 SetDefaultExpectationsForConfigPage(); | 870 SetDefaultExpectationsForConfigPage(); |
870 syncer::ModelTypeSet types; | 871 syncer::ModelTypeSet types; |
871 types.Put(it.Get()); | 872 types.Put(it.Get()); |
872 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()). | 873 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()). |
873 WillRepeatedly(Return(types)); | 874 WillRepeatedly(Return(types)); |
874 | 875 |
875 // This should display the sync setup dialog (not login). | 876 // This should display the sync setup dialog (not login). |
876 handler_->OpenSyncSetup(); | 877 handler_->OpenSyncSetup(NULL); |
877 | 878 |
878 ExpectConfig(); | 879 ExpectConfig(); |
879 // Close the config overlay. | 880 // Close the config overlay. |
880 LoginUIServiceFactory::GetForProfile(profile_.get())->LoginUIClosed( | 881 LoginUIServiceFactory::GetForProfile(profile_.get())->LoginUIClosed( |
881 handler_.get()); | 882 handler_.get()); |
882 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 883 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
883 const base::DictionaryValue* dictionary = nullptr; | 884 const base::DictionaryValue* dictionary = nullptr; |
884 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 885 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
885 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types); | 886 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types); |
886 Mock::VerifyAndClearExpectations(mock_pss_); | 887 Mock::VerifyAndClearExpectations(mock_pss_); |
887 // Clean up so we can loop back to display the dialog again. | 888 // Clean up so we can loop back to display the dialog again. |
888 web_ui_.ClearTrackedCalls(); | 889 web_ui_.ClearTrackedCalls(); |
889 } | 890 } |
890 } | 891 } |
891 | 892 |
892 TEST_F(SyncSetupHandlerTest, ShowSetupGaiaPassphraseRequired) { | 893 TEST_F(SyncSetupHandlerTest, ShowSetupGaiaPassphraseRequired) { |
893 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 894 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
894 .WillRepeatedly(Return(true)); | 895 .WillRepeatedly(Return(true)); |
895 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 896 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
896 .WillRepeatedly(Return(false)); | 897 .WillRepeatedly(Return(false)); |
897 SetupInitializedProfileSyncService(); | 898 SetupInitializedProfileSyncService(); |
898 SetDefaultExpectationsForConfigPage(); | 899 SetDefaultExpectationsForConfigPage(); |
899 | 900 |
900 // This should display the sync setup dialog (not login). | 901 // This should display the sync setup dialog (not login). |
901 handler_->OpenSyncSetup(); | 902 handler_->OpenSyncSetup(NULL); |
902 | 903 |
903 ExpectConfig(); | 904 ExpectConfig(); |
904 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 905 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
905 const base::DictionaryValue* dictionary = nullptr; | 906 const base::DictionaryValue* dictionary = nullptr; |
906 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 907 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
907 CheckBool(dictionary, "showPassphrase", true); | 908 CheckBool(dictionary, "showPassphrase", true); |
908 CheckBool(dictionary, "usePassphrase", false); | 909 CheckBool(dictionary, "usePassphrase", false); |
909 CheckBool(dictionary, "passphraseFailed", false); | 910 CheckBool(dictionary, "passphraseFailed", false); |
910 } | 911 } |
911 | 912 |
912 TEST_F(SyncSetupHandlerTest, ShowSetupCustomPassphraseRequired) { | 913 TEST_F(SyncSetupHandlerTest, ShowSetupCustomPassphraseRequired) { |
913 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 914 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
914 .WillRepeatedly(Return(true)); | 915 .WillRepeatedly(Return(true)); |
915 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 916 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
916 .WillRepeatedly(Return(true)); | 917 .WillRepeatedly(Return(true)); |
917 EXPECT_CALL(*mock_pss_, GetPassphraseType()) | 918 EXPECT_CALL(*mock_pss_, GetPassphraseType()) |
918 .WillRepeatedly(Return(syncer::CUSTOM_PASSPHRASE)); | 919 .WillRepeatedly(Return(syncer::CUSTOM_PASSPHRASE)); |
919 SetupInitializedProfileSyncService(); | 920 SetupInitializedProfileSyncService(); |
920 SetDefaultExpectationsForConfigPage(); | 921 SetDefaultExpectationsForConfigPage(); |
921 | 922 |
922 // This should display the sync setup dialog (not login). | 923 // This should display the sync setup dialog (not login). |
923 handler_->OpenSyncSetup(); | 924 handler_->OpenSyncSetup(NULL); |
924 | 925 |
925 ExpectConfig(); | 926 ExpectConfig(); |
926 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 927 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
927 const base::DictionaryValue* dictionary = nullptr; | 928 const base::DictionaryValue* dictionary = nullptr; |
928 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 929 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
929 CheckBool(dictionary, "showPassphrase", true); | 930 CheckBool(dictionary, "showPassphrase", true); |
930 CheckBool(dictionary, "usePassphrase", true); | 931 CheckBool(dictionary, "usePassphrase", true); |
931 CheckBool(dictionary, "passphraseFailed", false); | 932 CheckBool(dictionary, "passphraseFailed", false); |
932 } | 933 } |
933 | 934 |
934 TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAll) { | 935 TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAll) { |
935 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 936 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
936 .WillRepeatedly(Return(false)); | 937 .WillRepeatedly(Return(false)); |
937 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 938 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
938 .WillRepeatedly(Return(false)); | 939 .WillRepeatedly(Return(false)); |
939 SetupInitializedProfileSyncService(); | 940 SetupInitializedProfileSyncService(); |
940 SetDefaultExpectationsForConfigPage(); | 941 SetDefaultExpectationsForConfigPage(); |
941 EXPECT_CALL(*mock_pss_, IsEncryptEverythingEnabled()) | 942 EXPECT_CALL(*mock_pss_, IsEncryptEverythingEnabled()) |
942 .WillRepeatedly(Return(true)); | 943 .WillRepeatedly(Return(true)); |
943 | 944 |
944 // This should display the sync setup dialog (not login). | 945 // This should display the sync setup dialog (not login). |
945 handler_->OpenSyncSetup(); | 946 handler_->OpenSyncSetup(NULL); |
946 | 947 |
947 ExpectConfig(); | 948 ExpectConfig(); |
948 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 949 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
949 const base::DictionaryValue* dictionary = nullptr; | 950 const base::DictionaryValue* dictionary = nullptr; |
950 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 951 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
951 CheckBool(dictionary, "encryptAllData", true); | 952 CheckBool(dictionary, "encryptAllData", true); |
952 } | 953 } |
953 | 954 |
954 TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAllDisallowed) { | 955 TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAllDisallowed) { |
955 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 956 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
956 .WillRepeatedly(Return(false)); | 957 .WillRepeatedly(Return(false)); |
957 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 958 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
958 .WillRepeatedly(Return(false)); | 959 .WillRepeatedly(Return(false)); |
959 SetupInitializedProfileSyncService(); | 960 SetupInitializedProfileSyncService(); |
960 SetDefaultExpectationsForConfigPage(); | 961 SetDefaultExpectationsForConfigPage(); |
961 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) | 962 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) |
962 .WillRepeatedly(Return(false)); | 963 .WillRepeatedly(Return(false)); |
963 | 964 |
964 // This should display the sync setup dialog (not login). | 965 // This should display the sync setup dialog (not login). |
965 handler_->OpenSyncSetup(); | 966 handler_->OpenSyncSetup(NULL); |
966 | 967 |
967 ExpectConfig(); | 968 ExpectConfig(); |
968 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 969 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
969 const base::DictionaryValue* dictionary = nullptr; | 970 const base::DictionaryValue* dictionary = nullptr; |
970 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 971 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
971 CheckBool(dictionary, "encryptAllData", false); | 972 CheckBool(dictionary, "encryptAllData", false); |
972 CheckBool(dictionary, "encryptAllDataAllowed", false); | 973 CheckBool(dictionary, "encryptAllDataAllowed", false); |
973 } | 974 } |
974 | 975 |
975 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAllDisallowed) { | 976 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAllDisallowed) { |
(...skipping 10 matching lines...) Expand all Loading... | |
986 .WillRepeatedly(Return(false)); | 987 .WillRepeatedly(Return(false)); |
987 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0); | 988 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0); |
988 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); | 989 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); |
989 handler_->HandleConfigure(&list_args); | 990 handler_->HandleConfigure(&list_args); |
990 | 991 |
991 // Ensure that we navigated to the "done" state since we don't need a | 992 // Ensure that we navigated to the "done" state since we don't need a |
992 // passphrase. | 993 // passphrase. |
993 ExpectDone(); | 994 ExpectDone(); |
994 } | 995 } |
995 | 996 |
OLD | NEW |