Commit 50d29054 authored by Adam Rice's avatar Adam Rice Committed by Commit Bot

Revert "[s13n] Convert c/b/ui/webui/settings/people_handler_unittest.cc to IdentityManager"

This reverts commit 947d8086.

Reason for revert: Caused failure on memory bot:

https://findit-for-me.appspot.com/waterfall/failure?url=https://build.chromium.org/p/chromium.memory/builders/Linux%20CFI/builds/11050

Original change's description:
> [s13n] Convert c/b/ui/webui/settings/people_handler_unittest.cc to IdentityManager
> 
> This CL converts the PeopleHandler unittests away from SignManager and
> ProfileOAuth2TokenService, in favor of the new IdentityManager.
> 
> Production code has been converted in [1]. This is a follow up steps.
> 
> [1] https://crrev.com/c/1261637
> 
> BUG=890810
> 
> Change-Id: I405e46d2126180a2da61393bf32263ae43877b6b
> Reviewed-on: https://chromium-review.googlesource.com/c/1311093
> Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
> Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
> Cr-Commit-Position: refs/heads/master@{#604377}

TBR=xiyuan@chromium.org,tonikitoo@igalia.com

Change-Id: Idbab8bee31fd8a61ca66bb60cf2a680506866d39
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 890810
Reviewed-on: https://chromium-review.googlesource.com/c/1312152Reviewed-by: default avatarAdam Rice <ricea@chromium.org>
Commit-Queue: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604547}
parent 4d2bcd38
...@@ -16,9 +16,11 @@ ...@@ -16,9 +16,11 @@
#include "base/values.h" #include "base/values.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/signin/account_tracker_service_factory.h" #include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/identity_test_environment_profile_adaptor.h" #include "chrome/browser/signin/fake_signin_manager_builder.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/scoped_account_consistency.h" #include "chrome/browser/signin/scoped_account_consistency.h"
#include "chrome/browser/signin/signin_error_controller_factory.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_service_factory.h"
#include "chrome/browser/sync/profile_sync_test_util.h" #include "chrome/browser/sync/profile_sync_test_util.h"
#include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/chrome_pages.h"
...@@ -35,6 +37,8 @@ ...@@ -35,6 +37,8 @@
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/signin/core/browser/account_tracker_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/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" #include "components/sync/base/sync_prefs.h"
#include "components/sync_preferences/pref_service_syncable.h" #include "components/sync_preferences/pref_service_syncable.h"
#include "components/unified_consent/scoped_unified_consent.h" #include "components/unified_consent/scoped_unified_consent.h"
...@@ -46,7 +50,6 @@ ...@@ -46,7 +50,6 @@
#include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/test_web_ui.h" #include "content/public/test/test_web_ui.h"
#include "content/public/test/web_contents_tester.h" #include "content/public/test/web_contents_tester.h"
#include "services/identity/public/cpp/identity_manager.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/layout.h" #include "ui/base/layout.h"
...@@ -203,12 +206,10 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness { ...@@ -203,12 +206,10 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness {
error_ = GoogleServiceAuthError::AuthErrorNone(); error_ = GoogleServiceAuthError::AuthErrorNone();
// Sign in the user. // Sign in the user.
identity_test_env_adaptor_ = mock_signin_ = SigninManagerFactory::GetForProfile(profile());
std::make_unique<IdentityTestEnvironmentProfileAdaptor>(profile());
std::string username = GetTestUser(); std::string username = GetTestUser();
if (!username.empty()) if (!username.empty())
identity_test_env()->SetPrimaryAccount(username); mock_signin_->SetAuthenticatedAccountInfo(username, username);
mock_pss_ = static_cast<ProfileSyncServiceMock*>( mock_pss_ = static_cast<ProfileSyncServiceMock*>(
ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
...@@ -235,7 +236,6 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness { ...@@ -235,7 +236,6 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness {
handler_->set_web_ui(nullptr); handler_->set_web_ui(nullptr);
handler_->DisallowJavascript(); handler_->DisallowJavascript();
handler_->sync_startup_tracker_.reset(); handler_->sync_startup_tracker_.reset();
identity_test_env_adaptor_.reset();
ChromeRenderViewHostTestHarness::TearDown(); ChromeRenderViewHostTestHarness::TearDown();
} }
...@@ -258,6 +258,7 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness { ...@@ -258,6 +258,7 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness {
void SetupInitializedProfileSyncService() { void SetupInitializedProfileSyncService() {
// An initialized ProfileSyncService will have already completed sync setup // An initialized ProfileSyncService will have already completed sync setup
// and will have an initialized sync engine. // and will have an initialized sync engine.
ASSERT_TRUE(mock_signin_->IsInitialized());
ON_CALL(*mock_pss_, GetTransportState()) ON_CALL(*mock_pss_, GetTransportState())
.WillByDefault(Return(syncer::SyncService::TransportState::ACTIVE)); .WillByDefault(Return(syncer::SyncService::TransportState::ACTIVE));
} }
...@@ -324,14 +325,9 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness { ...@@ -324,14 +325,9 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness {
return std::string(kTestUser); return std::string(kTestUser);
} }
identity::IdentityTestEnvironment* identity_test_env() {
return identity_test_env_adaptor_->identity_test_env();
}
ProfileSyncServiceMock* mock_pss_; ProfileSyncServiceMock* mock_pss_;
GoogleServiceAuthError error_; GoogleServiceAuthError error_;
std::unique_ptr<IdentityTestEnvironmentProfileAdaptor> SigninManagerBase* mock_signin_;
identity_test_env_adaptor_;
content::TestWebUI web_ui_; content::TestWebUI web_ui_;
TestWebUIProvider test_provider_; TestWebUIProvider test_provider_;
std::unique_ptr<TestChromeWebUIControllerFactory> test_factory_; std::unique_ptr<TestChromeWebUIControllerFactory> test_factory_;
...@@ -351,7 +347,9 @@ TEST_F(PeopleHandlerFirstSigninTest, DisplayBasicLogin) { ...@@ -351,7 +347,9 @@ TEST_F(PeopleHandlerFirstSigninTest, DisplayBasicLogin) {
.WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NOT_SIGNED_IN)); .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NOT_SIGNED_IN));
ON_CALL(*mock_pss_, IsFirstSetupComplete()).WillByDefault(Return(false)); ON_CALL(*mock_pss_, IsFirstSetupComplete()).WillByDefault(Return(false));
// Ensure that the user is not signed in before calling |HandleStartSignin()|. // Ensure that the user is not signed in before calling |HandleStartSignin()|.
identity_test_env()->ClearPrimaryAccount(); SigninManager* manager = SigninManager::FromSigninManagerBase(mock_signin_);
manager->SignOut(signin_metrics::SIGNOUT_TEST,
signin_metrics::SignoutDelete::IGNORE_METRIC);
base::ListValue list_args; base::ListValue list_args;
handler_->HandleStartSignin(&list_args); handler_->HandleStartSignin(&list_args);
...@@ -820,9 +818,7 @@ TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) { ...@@ -820,9 +818,7 @@ TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) {
GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
SetupInitializedProfileSyncService(); SetupInitializedProfileSyncService();
DCHECK_EQ( mock_signin_->SetAuthenticatedAccountInfo(kTestUser, kTestUser);
identity_test_env()->identity_manager()->GetPrimaryAccountInfo().email,
kTestUser);
FakeAuthStatusProvider provider( FakeAuthStatusProvider provider(
SigninErrorControllerFactory::GetForProfile(profile())); SigninErrorControllerFactory::GetForProfile(profile()));
provider.SetAuthError(kTestUser, error_); provider.SetAuthError(kTestUser, error_);
...@@ -1031,25 +1027,21 @@ TEST_P(PeopleHandlerDiceUnifiedConsentTest, StoredAccountsList) { ...@@ -1031,25 +1027,21 @@ TEST_P(PeopleHandlerDiceUnifiedConsentTest, StoredAccountsList) {
: signin::AccountConsistencyMethod::kDiceFixAuthErrors); : signin::AccountConsistencyMethod::kDiceFixAuthErrors);
// Setup the profile. // Setup the profile.
std::unique_ptr<TestingProfile> profile = TestingProfile profile;
IdentityTestEnvironmentProfileAdaptor::
CreateProfileForIdentityTestEnvironment();
AccountTrackerService* account_tracker = AccountTrackerService* account_tracker =
AccountTrackerServiceFactory::GetForProfile(profile.get()); AccountTrackerServiceFactory::GetForProfile(&profile);
SigninManager* signin_manager = SigninManagerFactory::GetForProfile(&profile);
ProfileOAuth2TokenService* token_service =
ProfileOAuth2TokenServiceFactory::GetForProfile(&profile);
std::string account_1 = std::string account_1 =
account_tracker->SeedAccountInfo("1234", "a@gmail.com"); account_tracker->SeedAccountInfo("1234", "a@gmail.com");
std::string account_2 = std::string account_2 =
account_tracker->SeedAccountInfo("5678", "b@gmail.com"); 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");
auto identity_test_env_adaptor = PeopleHandler handler(&profile);
std::make_unique<IdentityTestEnvironmentProfileAdaptor>(profile.get());
auto* identity_test_env = identity_test_env_adaptor->identity_test_env();
identity_test_env->SetRefreshTokenForAccount(account_1);
identity_test_env->SetRefreshTokenForAccount(account_2);
identity_test_env->SetPrimaryAccount("a@gmail.com");
PeopleHandler handler(profile.get());
std::unique_ptr<base::ListValue> accounts_list = std::unique_ptr<base::ListValue> accounts_list =
handler.GetStoredAccountsList(); handler.GetStoredAccountsList();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment