Chromium Code Reviews| Index: chrome/browser/ui/webui/settings/people_handler_unittest.cc |
| diff --git a/chrome/browser/ui/webui/settings/sync_handler_unittest.cc b/chrome/browser/ui/webui/settings/people_handler_unittest.cc |
| similarity index 79% |
| rename from chrome/browser/ui/webui/settings/sync_handler_unittest.cc |
| rename to chrome/browser/ui/webui/settings/people_handler_unittest.cc |
| index 80d09aac464fa5212e1f840e67517e9f00df914d..9b834f062a174d2e94616ab8874ffceadff00ff1 100644 |
| --- a/chrome/browser/ui/webui/settings/sync_handler_unittest.cc |
| +++ b/chrome/browser/ui/webui/settings/people_handler_unittest.cc |
| @@ -2,7 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "chrome/browser/ui/webui/settings/sync_handler.h" |
| +#include "chrome/browser/ui/webui/settings/people_handler.h" |
| #include <vector> |
| @@ -44,7 +44,9 @@ typedef GoogleServiceAuthError AuthError; |
| namespace { |
| -MATCHER_P(ModelTypeSetMatches, value, "") { return arg.Equals(value); } |
| +MATCHER_P(ModelTypeSetMatches, value, "") { |
| + return arg.Equals(value); |
| +} |
| const char kTestUser[] = "chrome.p13n.test@gmail.com"; |
| @@ -53,16 +55,9 @@ syncer::ModelTypeSet GetAllTypes() { |
| return syncer::UserSelectableTypes(); |
| } |
| -enum SyncAllDataConfig { |
| - SYNC_ALL_DATA, |
| - CHOOSE_WHAT_TO_SYNC, |
| - SYNC_NOTHING |
| -}; |
| +enum SyncAllDataConfig { SYNC_ALL_DATA, CHOOSE_WHAT_TO_SYNC, SYNC_NOTHING }; |
| -enum EncryptAllConfig { |
| - ENCRYPT_ALL_DATA, |
| - ENCRYPT_PASSWORDS |
| -}; |
| +enum EncryptAllConfig { ENCRYPT_ALL_DATA, ENCRYPT_PASSWORDS }; |
| // Create a json-format string with the key/value pairs appropriate for a call |
| // to HandleConfigure(). If |extra_values| is non-null, then the values from |
| @@ -106,14 +101,13 @@ void CheckBool(const base::DictionaryValue* dictionary, |
| bool expected_value, |
| bool omit_if_false) { |
| if (omit_if_false && !expected_value) { |
| - EXPECT_FALSE(dictionary->HasKey(key)) << |
| - "Did not expect to find value for " << key; |
| + EXPECT_FALSE(dictionary->HasKey(key)) << "Did not expect to find value for " |
| + << key; |
| } else { |
| bool actual_value; |
| - EXPECT_TRUE(dictionary->GetBoolean(key, &actual_value)) << |
| - "No value found for " << key; |
| - EXPECT_EQ(expected_value, actual_value) << |
| - "Mismatch found for " << key; |
| + EXPECT_TRUE(dictionary->GetBoolean(key, &actual_value)) |
| + << "No value found for " << key; |
| + EXPECT_EQ(expected_value, actual_value) << "Mismatch found for " << key; |
| } |
| } |
| @@ -148,21 +142,21 @@ void CheckConfigDataTypeArguments(const base::DictionaryValue* dictionary, |
| namespace settings { |
| -class TestingSyncHandler : public SyncHandler { |
| +class TestingPeopleHandler : public PeopleHandler { |
| public: |
| - TestingSyncHandler(content::WebUI* web_ui, Profile* profile) |
| - : SyncHandler(profile) { |
| + TestingPeopleHandler(content::WebUI* web_ui, Profile* profile) |
| + : PeopleHandler(profile) { |
| set_web_ui(web_ui); |
| } |
| - ~TestingSyncHandler() override { |
| - // TODO(tommycli): SyncHandler needs this call to destruct properly in the |
| - // unit testing context. See the destructor to SyncHandler. This is hacky. |
| + ~TestingPeopleHandler() override { |
| + // TODO(tommycli): PeopleHandler needs this call to destruct properly in the |
| + // unit testing context. See the destructor to PeopleHandler. This is hacky. |
| set_web_ui(nullptr); |
| } |
| void FocusUI() override {} |
| - using SyncHandler::is_configuring_sync; |
| + using PeopleHandler::is_configuring_sync; |
| private: |
| #if !defined(OS_CHROMEOS) |
| @@ -170,15 +164,15 @@ class TestingSyncHandler : public SyncHandler { |
| signin_metrics::AccessPoint access_point) override {} |
| #endif |
| - DISALLOW_COPY_AND_ASSIGN(TestingSyncHandler); |
| + DISALLOW_COPY_AND_ASSIGN(TestingPeopleHandler); |
| }; |
| // The boolean parameter indicates whether the test is run with ClientOAuth |
| // or not. The test parameter is a bool: whether or not to test with/ |
| // /ClientLogin enabled or not. |
| -class SyncHandlerTest : public testing::Test { |
| +class PeopleHandlerTest : public testing::Test { |
| public: |
| - SyncHandlerTest() : error_(GoogleServiceAuthError::NONE) {} |
| + PeopleHandlerTest() : error_(GoogleServiceAuthError::NONE) {} |
| void SetUp() override { |
| error_ = GoogleServiceAuthError::AuthErrorNone(); |
| @@ -199,18 +193,18 @@ class SyncHandlerTest : public testing::Test { |
| profile_.get(), |
| ProfileSyncServiceMock::BuildMockProfileSyncService)); |
| EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
| - ON_CALL(*mock_pss_, GetPassphraseType()).WillByDefault( |
| - Return(syncer::IMPLICIT_PASSPHRASE)); |
| - ON_CALL(*mock_pss_, GetPassphraseTime()).WillByDefault( |
| - Return(base::Time())); |
| - ON_CALL(*mock_pss_, GetExplicitPassphraseTime()).WillByDefault( |
| - Return(base::Time())); |
| + ON_CALL(*mock_pss_, GetPassphraseType()) |
| + .WillByDefault(Return(syncer::IMPLICIT_PASSPHRASE)); |
| + ON_CALL(*mock_pss_, GetPassphraseTime()) |
| + .WillByDefault(Return(base::Time())); |
| + ON_CALL(*mock_pss_, GetExplicitPassphraseTime()) |
| + .WillByDefault(Return(base::Time())); |
| ON_CALL(*mock_pss_, GetRegisteredDataTypes()) |
| .WillByDefault(Return(syncer::ModelTypeSet())); |
| mock_pss_->Initialize(); |
| - handler_.reset(new TestingSyncHandler(&web_ui_, profile_.get())); |
| + handler_.reset(new TestingPeopleHandler(&web_ui_, profile_.get())); |
| } |
| // Setup the expectations for calls made when displaying the config page. |
| @@ -268,9 +262,8 @@ class SyncHandlerTest : public testing::Test { |
| EXPECT_EQ(page, "spinner"); |
| // Cancelling the spinner dialog will cause CloseSyncSetup(). |
| handler_->CloseSyncSetup(); |
| - EXPECT_EQ(NULL, |
| - LoginUIServiceFactory::GetForProfile( |
| - profile_.get())->current_login_ui()); |
| + EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile(profile_.get()) |
| + ->current_login_ui()); |
|
dschuyler
2015/12/10 00:51:48
This is another case where it looks more readable
tommycli
2015/12/10 01:57:02
Done.
|
| } |
| // It's difficult to notify sync listeners when using a ProfileSyncServiceMock |
| @@ -281,9 +274,7 @@ class SyncHandlerTest : public testing::Test { |
| handler_->sync_startup_tracker_->OnStateChanged(); |
| } |
| - virtual std::string GetTestUser() { |
| - return std::string(kTestUser); |
| - } |
| + virtual std::string GetTestUser() { return std::string(kTestUser); } |
| content::TestBrowserThreadBundle thread_bundle_; |
| scoped_ptr<Profile> profile_; |
| @@ -291,18 +282,17 @@ class SyncHandlerTest : public testing::Test { |
| GoogleServiceAuthError error_; |
| SigninManagerBase* mock_signin_; |
| content::TestWebUI web_ui_; |
| - scoped_ptr<TestingSyncHandler> handler_; |
| + scoped_ptr<TestingPeopleHandler> handler_; |
| }; |
| -class SyncHandlerFirstSigninTest : public SyncHandlerTest { |
| +class PeopleHandlerFirstSigninTest : public PeopleHandlerTest { |
| std::string GetTestUser() override { return std::string(); } |
| }; |
| -TEST_F(SyncHandlerTest, Basic) { |
| -} |
| +TEST_F(PeopleHandlerTest, Basic) {} |
| #if !defined(OS_CHROMEOS) |
| -TEST_F(SyncHandlerFirstSigninTest, DisplayBasicLogin) { |
| +TEST_F(PeopleHandlerFirstSigninTest, DisplayBasicLogin) { |
| EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
| EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
| .WillRepeatedly(Return(false)); |
| @@ -314,19 +304,17 @@ TEST_F(SyncHandlerFirstSigninTest, DisplayBasicLogin) { |
| handler_->HandleStartSignin(NULL); |
| // Sync setup hands off control to the gaia login tab. |
| - EXPECT_EQ(NULL, |
| - LoginUIServiceFactory::GetForProfile( |
| - profile_.get())->current_login_ui()); |
| + EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile(profile_.get()) |
| + ->current_login_ui()); |
| ASSERT_FALSE(handler_->is_configuring_sync()); |
| handler_->CloseSyncSetup(); |
| - EXPECT_EQ(NULL, |
| - LoginUIServiceFactory::GetForProfile( |
| - profile_.get())->current_login_ui()); |
| + EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile(profile_.get()) |
| + ->current_login_ui()); |
| } |
| -TEST_F(SyncHandlerTest, ShowSyncSetupWhenNotSignedIn) { |
| +TEST_F(PeopleHandlerTest, ShowSyncSetupWhenNotSignedIn) { |
| EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
| EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
| .WillRepeatedly(Return(false)); |
| @@ -340,28 +328,26 @@ TEST_F(SyncHandlerTest, ShowSyncSetupWhenNotSignedIn) { |
| EXPECT_EQ("settings.SyncPrivateApi.showSyncSetupPage", data.function_name()); |
| ASSERT_FALSE(handler_->is_configuring_sync()); |
| - EXPECT_EQ(NULL, |
| - LoginUIServiceFactory::GetForProfile( |
| - profile_.get())->current_login_ui()); |
| + EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile(profile_.get()) |
| + ->current_login_ui()); |
| } |
| #endif // !defined(OS_CHROMEOS) |
| // Verifies that the sync setup is terminated correctly when the |
| // sync is disabled. |
| -TEST_F(SyncHandlerTest, HandleSetupUIWhenSyncDisabled) { |
| +TEST_F(PeopleHandlerTest, HandleSetupUIWhenSyncDisabled) { |
| EXPECT_CALL(*mock_pss_, IsManaged()).WillRepeatedly(Return(true)); |
| handler_->HandleShowSetupUI(NULL); |
| // Sync setup is closed when sync is disabled. |
| - EXPECT_EQ(NULL, |
| - LoginUIServiceFactory::GetForProfile( |
| - profile_.get())->current_login_ui()); |
| + EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile(profile_.get()) |
| + ->current_login_ui()); |
| ASSERT_FALSE(handler_->is_configuring_sync()); |
| } |
| // Verifies that the handler correctly handles a cancellation when |
| // it is displaying the spinner to the user. |
| -TEST_F(SyncHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) { |
| +TEST_F(PeopleHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) { |
| EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
| EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
| .WillRepeatedly(Return(true)); |
| @@ -377,16 +363,15 @@ TEST_F(SyncHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) { |
| // spinner is showing. |
| handler_->HandleShowSetupUI(NULL); |
| - EXPECT_EQ(handler_.get(), |
| - LoginUIServiceFactory::GetForProfile( |
| - profile_.get())->current_login_ui()); |
| + EXPECT_EQ(handler_.get(), LoginUIServiceFactory::GetForProfile(profile_.get()) |
| + ->current_login_ui()); |
| ExpectSpinnerAndClose(); |
| } |
| // Verifies that the handler correctly transitions from showing the spinner |
| // to showing a configuration page when sync setup completes successfully. |
| -TEST_F(SyncHandlerTest, |
| +TEST_F(PeopleHandlerTest, |
| DisplayConfigureWithBackendDisabledAndSyncStartupCompleted) { |
| EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
| EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
| @@ -437,7 +422,7 @@ TEST_F(SyncHandlerTest, |
| // configuration page, tested by |
| // DisplayConfigureWithBackendDisabledAndSigninSuccess), but before the user |
| // before the user has continued on. |
| -TEST_F(SyncHandlerTest, |
| +TEST_F(PeopleHandlerTest, |
| DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) { |
| EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
| EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
| @@ -458,13 +443,11 @@ TEST_F(SyncHandlerTest, |
| EXPECT_CALL(*mock_pss_, SetSetupInProgress(false)); |
| handler_->CloseSyncSetup(); |
| - EXPECT_EQ(NULL, |
| - LoginUIServiceFactory::GetForProfile( |
| - profile_.get())->current_login_ui()); |
| + EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile(profile_.get()) |
| + ->current_login_ui()); |
| } |
| -TEST_F(SyncHandlerTest, |
| - DisplayConfigureWithBackendDisabledAndSigninFailed) { |
| +TEST_F(PeopleHandlerTest, DisplayConfigureWithBackendDisabledAndSigninFailed) { |
| EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
| EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
| .WillRepeatedly(Return(true)); |
| @@ -480,25 +463,24 @@ TEST_F(SyncHandlerTest, |
| ASSERT_TRUE(data.arg1()->GetAsString(&page)); |
| EXPECT_EQ(page, "spinner"); |
| Mock::VerifyAndClearExpectations(mock_pss_); |
| - error_ = GoogleServiceAuthError( |
| - GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| + error_ = |
| + GoogleServiceAuthError(GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
| NotifySyncListeners(); |
| // On failure, the dialog will be closed. |
| - EXPECT_EQ(NULL, |
| - LoginUIServiceFactory::GetForProfile( |
| - profile_.get())->current_login_ui()); |
| + EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile(profile_.get()) |
| + ->current_login_ui()); |
| } |
| #if !defined(OS_CHROMEOS) |
| -class SyncHandlerNonCrosTest : public SyncHandlerTest { |
| +class PeopleHandlerNonCrosTest : public PeopleHandlerTest { |
| public: |
| - SyncHandlerNonCrosTest() {} |
| + PeopleHandlerNonCrosTest() {} |
| }; |
| -TEST_F(SyncHandlerNonCrosTest, HandleGaiaAuthFailure) { |
| +TEST_F(PeopleHandlerNonCrosTest, HandleGaiaAuthFailure) { |
| EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
| EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
| .WillRepeatedly(Return(false)); |
| @@ -513,7 +495,7 @@ TEST_F(SyncHandlerNonCrosTest, HandleGaiaAuthFailure) { |
| } |
| // TODO(kochi): We need equivalent tests for ChromeOS. |
| -TEST_F(SyncHandlerNonCrosTest, UnrecoverableErrorInitializingSync) { |
| +TEST_F(PeopleHandlerNonCrosTest, UnrecoverableErrorInitializingSync) { |
| EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
| EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
| .WillRepeatedly(Return(false)); |
| @@ -525,7 +507,7 @@ TEST_F(SyncHandlerNonCrosTest, UnrecoverableErrorInitializingSync) { |
| ASSERT_FALSE(handler_->is_configuring_sync()); |
| } |
| -TEST_F(SyncHandlerNonCrosTest, GaiaErrorInitializingSync) { |
| +TEST_F(PeopleHandlerNonCrosTest, GaiaErrorInitializingSync) { |
| EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
| EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
| .WillRepeatedly(Return(false)); |
| @@ -539,15 +521,14 @@ TEST_F(SyncHandlerNonCrosTest, GaiaErrorInitializingSync) { |
| #endif // #if !defined(OS_CHROMEOS) |
| -TEST_F(SyncHandlerTest, TestSyncEverything) { |
| - std::string args = GetConfiguration( |
| - NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); |
| +TEST_F(PeopleHandlerTest, TestSyncEverything) { |
| + std::string args = GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), |
| + std::string(), ENCRYPT_PASSWORDS); |
| base::ListValue list_args; |
| list_args.Append(new base::StringValue(args)); |
| EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
| .WillRepeatedly(Return(false)); |
| - EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| - .WillRepeatedly(Return(false)); |
| + EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillRepeatedly(Return(false)); |
| SetupInitializedProfileSyncService(); |
| EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); |
| handler_->HandleConfigure(&list_args); |
| @@ -557,9 +538,9 @@ TEST_F(SyncHandlerTest, TestSyncEverything) { |
| ExpectDone(); |
| } |
| -TEST_F(SyncHandlerTest, TestSyncNothing) { |
| - std::string args = GetConfiguration( |
| - NULL, SYNC_NOTHING, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); |
| +TEST_F(PeopleHandlerTest, TestSyncNothing) { |
| + std::string args = GetConfiguration(NULL, SYNC_NOTHING, GetAllTypes(), |
| + std::string(), ENCRYPT_PASSWORDS); |
| base::ListValue list_args; |
| list_args.Append(new base::StringValue(args)); |
| EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA)); |
| @@ -572,15 +553,14 @@ TEST_F(SyncHandlerTest, TestSyncNothing) { |
| EXPECT_EQ("settings.SyncPrivateApi.showSyncSetupPage", data.function_name()); |
| } |
| -TEST_F(SyncHandlerTest, TurnOnEncryptAll) { |
| - std::string args = GetConfiguration( |
| - NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA); |
| +TEST_F(PeopleHandlerTest, TurnOnEncryptAll) { |
| + std::string args = GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), |
| + std::string(), ENCRYPT_ALL_DATA); |
| base::ListValue list_args; |
| list_args.Append(new base::StringValue(args)); |
| EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
| .WillRepeatedly(Return(false)); |
| - EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| - .WillRepeatedly(Return(false)); |
| + EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillRepeatedly(Return(false)); |
| EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) |
| .WillRepeatedly(Return(true)); |
| SetupInitializedProfileSyncService(); |
| @@ -593,15 +573,14 @@ TEST_F(SyncHandlerTest, TurnOnEncryptAll) { |
| ExpectDone(); |
| } |
| -TEST_F(SyncHandlerTest, TestPassphraseStillRequired) { |
| - std::string args = GetConfiguration( |
| - NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); |
| +TEST_F(PeopleHandlerTest, TestPassphraseStillRequired) { |
| + std::string args = GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), |
| + std::string(), ENCRYPT_PASSWORDS); |
| base::ListValue list_args; |
| list_args.Append(new base::StringValue(args)); |
| EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
| .WillRepeatedly(Return(true)); |
| - EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| - .WillRepeatedly(Return(true)); |
| + EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillRepeatedly(Return(true)); |
| EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| .WillRepeatedly(Return(false)); |
| SetupInitializedProfileSyncService(); |
| @@ -614,14 +593,11 @@ TEST_F(SyncHandlerTest, TestPassphraseStillRequired) { |
| ExpectConfig(); |
| } |
| -TEST_F(SyncHandlerTest, SuccessfullySetPassphrase) { |
| +TEST_F(PeopleHandlerTest, SuccessfullySetPassphrase) { |
| base::DictionaryValue dict; |
| dict.SetBoolean("isGooglePassphrase", true); |
| - std::string args = GetConfiguration(&dict, |
| - SYNC_ALL_DATA, |
| - GetAllTypes(), |
| - "gaiaPassphrase", |
| - ENCRYPT_PASSWORDS); |
| + std::string args = GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(), |
| + "gaiaPassphrase", ENCRYPT_PASSWORDS); |
| base::ListValue list_args; |
| list_args.Append(new base::StringValue(args)); |
| // Act as if an encryption passphrase is required the first time, then never |
| @@ -633,28 +609,24 @@ TEST_F(SyncHandlerTest, SuccessfullySetPassphrase) { |
| .WillRepeatedly(Return(false)); |
| SetupInitializedProfileSyncService(); |
| EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); |
| - EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("gaiaPassphrase")). |
| - WillOnce(Return(true)); |
| + EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("gaiaPassphrase")) |
| + .WillOnce(Return(true)); |
| handler_->HandleConfigure(&list_args); |
| // We should navigate to "done" page since we finished configuring. |
| ExpectDone(); |
| } |
| -TEST_F(SyncHandlerTest, SelectCustomEncryption) { |
| +TEST_F(PeopleHandlerTest, SelectCustomEncryption) { |
| base::DictionaryValue dict; |
| dict.SetBoolean("isGooglePassphrase", false); |
| - std::string args = GetConfiguration(&dict, |
| - SYNC_ALL_DATA, |
| - GetAllTypes(), |
| - "custom_passphrase", |
| - ENCRYPT_PASSWORDS); |
| + std::string args = GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(), |
| + "custom_passphrase", ENCRYPT_PASSWORDS); |
| base::ListValue list_args; |
| list_args.Append(new base::StringValue(args)); |
| EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
| .WillRepeatedly(Return(false)); |
| - EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| - .WillRepeatedly(Return(false)); |
| + EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillRepeatedly(Return(false)); |
| EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| .WillRepeatedly(Return(false)); |
| SetupInitializedProfileSyncService(); |
| @@ -668,26 +640,22 @@ TEST_F(SyncHandlerTest, SelectCustomEncryption) { |
| ExpectDone(); |
| } |
| -TEST_F(SyncHandlerTest, UnsuccessfullySetPassphrase) { |
| +TEST_F(PeopleHandlerTest, UnsuccessfullySetPassphrase) { |
| base::DictionaryValue dict; |
| dict.SetBoolean("isGooglePassphrase", true); |
| - std::string args = GetConfiguration(&dict, |
| - SYNC_ALL_DATA, |
| - GetAllTypes(), |
| - "invalid_passphrase", |
| - ENCRYPT_PASSWORDS); |
| + std::string args = GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(), |
| + "invalid_passphrase", ENCRYPT_PASSWORDS); |
| base::ListValue list_args; |
| list_args.Append(new base::StringValue(args)); |
| EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
| .WillRepeatedly(Return(true)); |
| - EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| - .WillRepeatedly(Return(true)); |
| + EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillRepeatedly(Return(true)); |
| EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| .WillRepeatedly(Return(false)); |
| SetupInitializedProfileSyncService(); |
| EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); |
| - EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("invalid_passphrase")). |
| - WillOnce(Return(false)); |
| + EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("invalid_passphrase")) |
| + .WillOnce(Return(false)); |
| SetDefaultExpectationsForConfigPage(); |
| // We should navigate back to the configure page since we need a passphrase. |
| @@ -705,17 +673,14 @@ TEST_F(SyncHandlerTest, UnsuccessfullySetPassphrase) { |
| // Walks through each user selectable type, and tries to sync just that single |
| // data type. |
| -TEST_F(SyncHandlerTest, TestSyncIndividualTypes) { |
| +TEST_F(PeopleHandlerTest, TestSyncIndividualTypes) { |
| syncer::ModelTypeSet user_selectable_types = GetAllTypes(); |
| syncer::ModelTypeSet::Iterator it; |
| for (it = user_selectable_types.First(); it.Good(); it.Inc()) { |
| syncer::ModelTypeSet type_to_set; |
| type_to_set.Put(it.Get()); |
| - std::string args = GetConfiguration(NULL, |
| - CHOOSE_WHAT_TO_SYNC, |
| - type_to_set, |
| - std::string(), |
| - ENCRYPT_PASSWORDS); |
| + std::string args = GetConfiguration(NULL, CHOOSE_WHAT_TO_SYNC, type_to_set, |
| + std::string(), ENCRYPT_PASSWORDS); |
| base::ListValue list_args; |
| list_args.Append(new base::StringValue(args)); |
| EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
| @@ -733,18 +698,14 @@ TEST_F(SyncHandlerTest, TestSyncIndividualTypes) { |
| } |
| } |
| -TEST_F(SyncHandlerTest, TestSyncAllManually) { |
| - std::string args = GetConfiguration(NULL, |
| - CHOOSE_WHAT_TO_SYNC, |
| - GetAllTypes(), |
| - std::string(), |
| - ENCRYPT_PASSWORDS); |
| +TEST_F(PeopleHandlerTest, TestSyncAllManually) { |
| + std::string args = GetConfiguration(NULL, CHOOSE_WHAT_TO_SYNC, GetAllTypes(), |
| + std::string(), ENCRYPT_PASSWORDS); |
| base::ListValue list_args; |
| list_args.Append(new base::StringValue(args)); |
| EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
| .WillRepeatedly(Return(false)); |
| - EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| - .WillRepeatedly(Return(false)); |
| + EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillRepeatedly(Return(false)); |
| SetupInitializedProfileSyncService(); |
| EXPECT_CALL(*mock_pss_, |
| OnUserChoseDatatypes(false, ModelTypeSetMatches(GetAllTypes()))); |
| @@ -753,9 +714,8 @@ TEST_F(SyncHandlerTest, TestSyncAllManually) { |
| ExpectDone(); |
| } |
| -TEST_F(SyncHandlerTest, ShowSyncSetup) { |
| - EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| - .WillRepeatedly(Return(false)); |
| +TEST_F(PeopleHandlerTest, ShowSyncSetup) { |
| + EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillRepeatedly(Return(false)); |
| EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| .WillRepeatedly(Return(false)); |
| SetupInitializedProfileSyncService(); |
| @@ -767,10 +727,10 @@ TEST_F(SyncHandlerTest, ShowSyncSetup) { |
| } |
| // We do not display signin on chromeos in the case of auth error. |
| -TEST_F(SyncHandlerTest, ShowSigninOnAuthError) { |
| +TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) { |
| // Initialize the system to a signed in state, but with an auth error. |
| - error_ = GoogleServiceAuthError( |
| - GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| + error_ = |
| + GoogleServiceAuthError(GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| SetupInitializedProfileSyncService(); |
| mock_signin_->SetAuthenticatedAccountInfo(kTestUser, kTestUser); |
| @@ -780,8 +740,7 @@ TEST_F(SyncHandlerTest, ShowSigninOnAuthError) { |
| EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
| EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
| .WillRepeatedly(Return(true)); |
| - EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| - .WillRepeatedly(Return(false)); |
| + EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillRepeatedly(Return(false)); |
| EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| .WillRepeatedly(Return(false)); |
| EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); |
| @@ -792,8 +751,8 @@ TEST_F(SyncHandlerTest, ShowSigninOnAuthError) { |
| // happen if the user manually navigates to chrome://settings/syncSetup - |
| // clicking on the button in the UI will sign the user out rather than |
| // displaying a spinner. Should be no visible UI on ChromeOS in this case. |
| - EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile( |
| - profile_.get())->current_login_ui()); |
| + EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile(profile_.get()) |
| + ->current_login_ui()); |
| #else |
| // On ChromeOS, this should display the spinner while we try to startup the |
| @@ -801,17 +760,15 @@ TEST_F(SyncHandlerTest, ShowSigninOnAuthError) { |
| handler_->OpenSyncSetup(nullptr); |
| // Sync setup is closed when re-auth is in progress. |
| - EXPECT_EQ(NULL, |
| - LoginUIServiceFactory::GetForProfile( |
| - profile_.get())->current_login_ui()); |
| + EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile(profile_.get()) |
| + ->current_login_ui()); |
| ASSERT_FALSE(handler_->is_configuring_sync()); |
| #endif |
| } |
| -TEST_F(SyncHandlerTest, ShowSetupSyncEverything) { |
| - EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| - .WillRepeatedly(Return(false)); |
| +TEST_F(PeopleHandlerTest, ShowSetupSyncEverything) { |
| + EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillRepeatedly(Return(false)); |
| EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| .WillRepeatedly(Return(false)); |
| SetupInitializedProfileSyncService(); |
| @@ -841,9 +798,8 @@ TEST_F(SyncHandlerTest, ShowSetupSyncEverything) { |
| CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes()); |
| } |
| -TEST_F(SyncHandlerTest, ShowSetupManuallySyncAll) { |
| - EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| - .WillRepeatedly(Return(false)); |
| +TEST_F(PeopleHandlerTest, ShowSetupManuallySyncAll) { |
| + EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillRepeatedly(Return(false)); |
| EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| .WillRepeatedly(Return(false)); |
| SetupInitializedProfileSyncService(); |
| @@ -860,7 +816,7 @@ TEST_F(SyncHandlerTest, ShowSetupManuallySyncAll) { |
| CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes()); |
| } |
| -TEST_F(SyncHandlerTest, ShowSetupSyncForAllTypesIndividually) { |
| +TEST_F(PeopleHandlerTest, ShowSetupSyncForAllTypesIndividually) { |
| syncer::ModelTypeSet user_selectable_types = GetAllTypes(); |
| syncer::ModelTypeSet::Iterator it; |
| for (it = user_selectable_types.First(); it.Good(); it.Inc()) { |
| @@ -874,16 +830,16 @@ TEST_F(SyncHandlerTest, ShowSetupSyncForAllTypesIndividually) { |
| SetDefaultExpectationsForConfigPage(); |
| syncer::ModelTypeSet types; |
| types.Put(it.Get()); |
| - EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()). |
| - WillRepeatedly(Return(types)); |
| + EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()) |
| + .WillRepeatedly(Return(types)); |
| // This should display the sync setup dialog (not login). |
| handler_->OpenSyncSetup(nullptr); |
| ExpectConfig(); |
| // Close the config overlay. |
| - LoginUIServiceFactory::GetForProfile(profile_.get())->LoginUIClosed( |
| - handler_.get()); |
| + LoginUIServiceFactory::GetForProfile(profile_.get()) |
| + ->LoginUIClosed(handler_.get()); |
| const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
| const base::DictionaryValue* dictionary = nullptr; |
| ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
| @@ -894,9 +850,8 @@ TEST_F(SyncHandlerTest, ShowSetupSyncForAllTypesIndividually) { |
| } |
| } |
| -TEST_F(SyncHandlerTest, ShowSetupGaiaPassphraseRequired) { |
| - EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| - .WillRepeatedly(Return(true)); |
| +TEST_F(PeopleHandlerTest, ShowSetupGaiaPassphraseRequired) { |
| + EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillRepeatedly(Return(true)); |
| EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| .WillRepeatedly(Return(false)); |
| SetupInitializedProfileSyncService(); |
| @@ -914,9 +869,8 @@ TEST_F(SyncHandlerTest, ShowSetupGaiaPassphraseRequired) { |
| CheckBool(dictionary, "passphraseFailed", false); |
| } |
| -TEST_F(SyncHandlerTest, ShowSetupCustomPassphraseRequired) { |
| - EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| - .WillRepeatedly(Return(true)); |
| +TEST_F(PeopleHandlerTest, ShowSetupCustomPassphraseRequired) { |
| + EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillRepeatedly(Return(true)); |
| EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| .WillRepeatedly(Return(true)); |
| EXPECT_CALL(*mock_pss_, GetPassphraseType()) |
| @@ -936,9 +890,8 @@ TEST_F(SyncHandlerTest, ShowSetupCustomPassphraseRequired) { |
| CheckBool(dictionary, "passphraseFailed", false); |
| } |
| -TEST_F(SyncHandlerTest, ShowSetupEncryptAll) { |
| - EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| - .WillRepeatedly(Return(false)); |
| +TEST_F(PeopleHandlerTest, ShowSetupEncryptAll) { |
| + EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillRepeatedly(Return(false)); |
| EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| .WillRepeatedly(Return(false)); |
| SetupInitializedProfileSyncService(); |
| @@ -956,9 +909,8 @@ TEST_F(SyncHandlerTest, ShowSetupEncryptAll) { |
| CheckBool(dictionary, "encryptAllData", true); |
| } |
| -TEST_F(SyncHandlerTest, ShowSetupEncryptAllDisallowed) { |
| - EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| - .WillRepeatedly(Return(false)); |
| +TEST_F(PeopleHandlerTest, ShowSetupEncryptAllDisallowed) { |
| + EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillRepeatedly(Return(false)); |
| EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| .WillRepeatedly(Return(false)); |
| SetupInitializedProfileSyncService(); |
| @@ -977,15 +929,14 @@ TEST_F(SyncHandlerTest, ShowSetupEncryptAllDisallowed) { |
| CheckBool(dictionary, "encryptAllDataAllowed", false); |
| } |
| -TEST_F(SyncHandlerTest, TurnOnEncryptAllDisallowed) { |
| - std::string args = GetConfiguration( |
| - NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA); |
| +TEST_F(PeopleHandlerTest, TurnOnEncryptAllDisallowed) { |
| + std::string args = GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), |
| + std::string(), ENCRYPT_ALL_DATA); |
| base::ListValue list_args; |
| list_args.Append(new base::StringValue(args)); |
| EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
| .WillRepeatedly(Return(false)); |
| - EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| - .WillRepeatedly(Return(false)); |
| + EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillRepeatedly(Return(false)); |
| SetupInitializedProfileSyncService(); |
| EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) |
| .WillRepeatedly(Return(false)); |