Commit 838777d5 authored by Jialiu Lin's avatar Jialiu Lin Committed by Commit Bot

Seed AccountTrackerService and SigninManager properly in Arc* tests

During the migration to IdentityManager, we noticed that some Arc*
related tests setup are incomplete, such that they will potentially fail
after IdentityManager migration.

This CL adds more initial test setup to seed AccountTrackerService and
SigninManager properly. No behavior or logic change.

Bug: 883318, 892116
Change-Id: I4db443d7bd0c7df396e1c188743b869d2b9c2e82
Reviewed-on: https://chromium-review.googlesource.com/c/1265079Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Reviewed-by: default avatarYury Khmel <khmel@chromium.org>
Commit-Queue: Jialiu Lin <jialiul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597361}
parent 08e7487d
......@@ -26,8 +26,11 @@
#include "chrome/browser/policy/profile_policy_connector_factory.h"
#include "chrome/browser/policy/test/local_policy_test_server.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
#include "chrome/browser/signin/fake_signin_manager_builder.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_profile.h"
#include "components/account_id/account_id.h"
......@@ -42,7 +45,9 @@
#include "components/policy/core/common/policy_switches.h"
#include "components/prefs/pref_member.h"
#include "components/prefs/pref_service.h"
#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/fake_profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager_base.h"
#include "components/user_manager/scoped_user_manager.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_thread.h"
......@@ -146,10 +151,22 @@ class ArcSessionManagerTest : public InProcessBrowserTest {
profile_builder.AddTestingFactory(
ProfileOAuth2TokenServiceFactory::GetInstance(),
base::BindRepeating(&BuildFakeProfileOAuth2TokenService));
profile_builder.AddTestingFactory(
SigninManagerFactory::GetInstance(),
base::BindRepeating(&BuildFakeSigninManagerBase));
profile_ = profile_builder.Build();
// Seed account info properly.
const std::string account_id_str =
AccountTrackerServiceFactory::GetForProfile(profile_.get())
->SeedAccountInfo(kFakeGaiaId, kFakeUserName);
token_service_ = static_cast<FakeProfileOAuth2TokenService*>(
ProfileOAuth2TokenServiceFactory::GetForProfile(profile()));
token_service_->UpdateCredentials("", kRefreshToken);
FakeSigninManagerForTesting* fake_signin_manager =
static_cast<FakeSigninManagerForTesting*>(
SigninManagerFactory::GetForProfile(profile()));
fake_signin_manager->SignIn(account_id_str);
token_service_->UpdateCredentials(account_id_str, kRefreshToken);
profile()->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true);
profile()->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true);
......
......@@ -203,6 +203,7 @@ class ArcAuthServiceTest : public InProcessBrowserTest {
profile_ = profile_builder.Build();
SeedAccountInfo(kFakeGaiaId, kFakeUserName);
chromeos::AccountManagerFactory* factory =
g_browser_process->platform_part()->GetAccountManagerFactory();
chromeos::AccountManager* account_manager =
......@@ -264,12 +265,12 @@ class ArcAuthServiceTest : public InProcessBrowserTest {
account_info.gaia, account_info.email);
ASSERT_TRUE(account_info.IsValid());
account_tracker_service->SeedAccountInfo(account_info);
FakeProfileOAuth2TokenService* token_service =
static_cast<FakeProfileOAuth2TokenService*>(
ProfileOAuth2TokenServiceFactory::GetForProfile(profile()));
token_service->UpdateCredentials(account_info.account_id, kRefreshToken);
token_service->UpdateCredentials(
account_tracker_service->SeedAccountInfo(account_info), kRefreshToken);
}
Profile* profile() { return profile_.get(); }
......
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