diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-13 15:05:36 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-14 10:33:47 +0000 |
commit | e684a3455bcc29a6e3e66a004e352dea4e1141e7 (patch) | |
tree | d55b4003bde34d7d05f558f02cfd82b2a66a7aac /chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc | |
parent | 2b94bfe47ccb6c08047959d1c26e392919550e86 (diff) |
BASELINE: Update Chromium to 72.0.3626.110 and Ninja to 1.9.0
Change-Id: Ic57220b00ecc929a893c91f5cc552f5d3e99e922
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc')
-rw-r--r-- | chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc | 90 |
1 files changed, 52 insertions, 38 deletions
diff --git a/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc index 02cc8300a10..f8566400196 100644 --- a/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc @@ -15,12 +15,10 @@ #include "base/stl_util.h" #include "base/values.h" #include "build/build_config.h" -#include "chrome/browser/signin/account_tracker_service_factory.h" -#include "chrome/browser/signin/fake_signin_manager_builder.h" +#include "chrome/browser/signin/identity_test_environment_profile_adaptor.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/scoped_account_consistency.h" #include "chrome/browser/signin/signin_error_controller_factory.h" -#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/sync/profile_sync_test_util.h" #include "chrome/browser/ui/chrome_pages.h" @@ -35,8 +33,6 @@ #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" #include "components/prefs/pref_service.h" -#include "components/signin/core/browser/account_tracker_service.h" -#include "components/signin/core/browser/fake_auth_status_provider.h" #include "components/signin/core/browser/profile_oauth2_token_service.h" #include "components/signin/core/browser/signin_manager.h" #include "components/sync/base/sync_prefs.h" @@ -50,6 +46,8 @@ #include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_web_ui.h" #include "content/public/test/web_contents_tester.h" +#include "google_apis/gaia/oauth2_token_service_delegate.h" +#include "services/identity/public/cpp/identity_manager.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/layout.h" @@ -113,7 +111,6 @@ std::string GetConfiguration(const base::DictionaryValue* extra_values, result.SetBoolean("tabsSynced", types.Has(syncer::PROXY_TABS)); result.SetBoolean("themesSynced", types.Has(syncer::THEMES)); result.SetBoolean("typedUrlsSynced", types.Has(syncer::TYPED_URLS)); - result.SetBoolean("userEventsSynced", types.Has(syncer::USER_EVENTS)); result.SetBoolean("paymentsIntegrationEnabled", false); std::string args; base::JSONWriter::Write(result, &args); @@ -161,7 +158,6 @@ void CheckConfigDataTypeArguments(const base::DictionaryValue* dictionary, CheckBool(dictionary, "tabsSynced", types.Has(syncer::PROXY_TABS)); CheckBool(dictionary, "themesSynced", types.Has(syncer::THEMES)); CheckBool(dictionary, "typedUrlsSynced", types.Has(syncer::TYPED_URLS)); - CheckBool(dictionary, "userEventsSynced", types.Has(syncer::USER_EVENTS)); } } // namespace @@ -206,10 +202,12 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness { error_ = GoogleServiceAuthError::AuthErrorNone(); // Sign in the user. - mock_signin_ = SigninManagerFactory::GetForProfile(profile()); + identity_test_env_adaptor_ = + std::make_unique<IdentityTestEnvironmentProfileAdaptor>(profile()); + std::string username = GetTestUser(); if (!username.empty()) - mock_signin_->SetAuthenticatedAccountInfo(username, username); + identity_test_env()->SetPrimaryAccount(username); mock_pss_ = static_cast<ProfileSyncServiceMock*>( ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( @@ -236,9 +234,18 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness { handler_->set_web_ui(nullptr); handler_->DisallowJavascript(); handler_->sync_startup_tracker_.reset(); + identity_test_env_adaptor_.reset(); ChromeRenderViewHostTestHarness::TearDown(); } + content::BrowserContext* CreateBrowserContext() override { + // Setup the profile. + std::unique_ptr<TestingProfile> profile = + IdentityTestEnvironmentProfileAdaptor:: + CreateProfileForIdentityTestEnvironment(); + return profile.release(); + } + // Setup the expectations for calls made when displaying the config page. void SetDefaultExpectationsForConfigPage() { ON_CALL(*mock_pss_, GetDisableReasons()) @@ -258,7 +265,6 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness { void SetupInitializedProfileSyncService() { // An initialized ProfileSyncService will have already completed sync setup // and will have an initialized sync engine. - ASSERT_TRUE(mock_signin_->IsInitialized()); ON_CALL(*mock_pss_, GetTransportState()) .WillByDefault(Return(syncer::SyncService::TransportState::ACTIVE)); } @@ -325,9 +331,14 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness { return std::string(kTestUser); } + identity::IdentityTestEnvironment* identity_test_env() { + return identity_test_env_adaptor_->identity_test_env(); + } + ProfileSyncServiceMock* mock_pss_; GoogleServiceAuthError error_; - SigninManagerBase* mock_signin_; + std::unique_ptr<IdentityTestEnvironmentProfileAdaptor> + identity_test_env_adaptor_; content::TestWebUI web_ui_; TestWebUIProvider test_provider_; std::unique_ptr<TestChromeWebUIControllerFactory> test_factory_; @@ -347,9 +358,7 @@ TEST_F(PeopleHandlerFirstSigninTest, DisplayBasicLogin) { .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NOT_SIGNED_IN)); ON_CALL(*mock_pss_, IsFirstSetupComplete()).WillByDefault(Return(false)); // Ensure that the user is not signed in before calling |HandleStartSignin()|. - SigninManager* manager = SigninManager::FromSigninManagerBase(mock_signin_); - manager->SignOut(signin_metrics::SIGNOUT_TEST, - signin_metrics::SignoutDelete::IGNORE_METRIC); + identity_test_env()->ClearPrimaryAccount(); base::ListValue list_args; handler_->HandleStartSignin(&list_args); @@ -696,9 +705,7 @@ TEST_F(PeopleHandlerTest, SetNewCustomPassphrase) { ON_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) .WillByDefault(Return(false)); SetupInitializedProfileSyncService(); - EXPECT_CALL(*mock_pss_, - SetEncryptionPassphrase("custom_passphrase", - ProfileSyncService::EXPLICIT)); + EXPECT_CALL(*mock_pss_, SetEncryptionPassphrase("custom_passphrase")); handler_->HandleSetEncryption(&list_args); ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus); @@ -820,10 +827,20 @@ TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) { GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); SetupInitializedProfileSyncService(); - mock_signin_->SetAuthenticatedAccountInfo(kTestUser, kTestUser); - FakeAuthStatusProvider provider( - SigninErrorControllerFactory::GetForProfile(profile())); - provider.SetAuthError(kTestUser, error_); + DCHECK_EQ( + identity_test_env()->identity_manager()->GetPrimaryAccountInfo().email, + kTestUser); + const std::string& account_id = identity_test_env() + ->identity_manager() + ->GetPrimaryAccountInfo() + .account_id; + ProfileOAuth2TokenService* token_service = + ProfileOAuth2TokenServiceFactory::GetForProfile(profile()); + token_service->UpdateCredentials(account_id, "refresh_token"); + // TODO(https://crbug.com/836212): Do not use the delegate directly, because + // it is internal API. + token_service->GetDelegate()->UpdateAuthError(account_id, error_); + ON_CALL(*mock_pss_, GetDisableReasons()) .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE)); ON_CALL(*mock_pss_, IsPassphraseRequired()).WillByDefault(Return(false)); @@ -876,7 +893,6 @@ TEST_F(PeopleHandlerTest, ShowSetupSyncEverything) { CheckBool(dictionary, "tabsRegistered", true); CheckBool(dictionary, "themesRegistered", true); CheckBool(dictionary, "typedUrlsRegistered", true); - CheckBool(dictionary, "userEventsRegistered", true); CheckBool(dictionary, "paymentsIntegrationEnabled", true); CheckBool(dictionary, "passphraseRequired", false); CheckBool(dictionary, "passphraseTypeIsCustom", false); @@ -1022,28 +1038,26 @@ TEST_P(PeopleHandlerDiceUnifiedConsentTest, StoredAccountsList) { std::tie(dice_enabled, unified_consent_enabled) = GetParam(); unified_consent::ScopedUnifiedConsent unified_consent( unified_consent_enabled - ? unified_consent::UnifiedConsentFeatureState::kEnabledWithBump + ? unified_consent::UnifiedConsentFeatureState::kEnabled : unified_consent::UnifiedConsentFeatureState::kDisabled); ScopedAccountConsistency dice( dice_enabled ? signin::AccountConsistencyMethod::kDice : signin::AccountConsistencyMethod::kDiceFixAuthErrors); // Setup the profile. - TestingProfile profile; - AccountTrackerService* account_tracker = - AccountTrackerServiceFactory::GetForProfile(&profile); - SigninManager* signin_manager = SigninManagerFactory::GetForProfile(&profile); - ProfileOAuth2TokenService* token_service = - ProfileOAuth2TokenServiceFactory::GetForProfile(&profile); - std::string account_1 = - account_tracker->SeedAccountInfo("1234", "a@gmail.com"); - std::string account_2 = - account_tracker->SeedAccountInfo("5678", "b@gmail.com"); - token_service->UpdateCredentials(account_1, "token"); - token_service->UpdateCredentials(account_2, "token"); - signin_manager->SetAuthenticatedAccountInfo("1234", "a@gmail.com"); - - PeopleHandler handler(&profile); + std::unique_ptr<TestingProfile> profile = + IdentityTestEnvironmentProfileAdaptor:: + CreateProfileForIdentityTestEnvironment(); + + auto identity_test_env_adaptor = + std::make_unique<IdentityTestEnvironmentProfileAdaptor>(profile.get()); + auto* identity_test_env = identity_test_env_adaptor->identity_test_env(); + + auto account_1 = identity_test_env->MakeAccountAvailable("a@gmail.com"); + auto account_2 = identity_test_env->MakeAccountAvailable("b@gmail.com"); + identity_test_env->SetPrimaryAccount(account_1.email); + + PeopleHandler handler(profile.get()); std::unique_ptr<base::ListValue> accounts_list = handler.GetStoredAccountsList(); |