Commit d697bdd7 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Migrate MultiProfileFileManagerBrowserTest to IdentityManager

identity::IdentityManager is the new API that replaces SigninManager[Base].

Bug: 825190, 814307
Change-Id: I3cf7261fad64a63bdc449c190f7d175025408d7c
Reviewed-on: https://chromium-review.googlesource.com/1025751Reviewed-by: default avatarKazuhiro Inaba <kinaba@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553581}
parent 428cb89f
......@@ -10,11 +10,11 @@
#include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/file_manager/file_manager_browsertest_base.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chromeos/chromeos_switches.h"
#include "components/session_manager/core/session_manager.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/user_manager/user_manager.h"
#include "services/identity/public/cpp/identity_manager.h"
namespace file_manager {
......@@ -602,8 +602,13 @@ class MultiProfileFileManagerBrowserTest : public FileManagerBrowserTestBase {
// This is used for preparing all accounts in PRE_ test setup, and for testing
// actual login behavior.
void AddAllUsers() {
for (size_t i = 0; i < arraysize(kTestAccounts); ++i)
for (size_t i = 0; i < arraysize(kTestAccounts); ++i) {
// The primary account was already set up in SetUpOnMainThread, so skip it
// here.
if (i == PRIMARY_ACCOUNT_INDEX)
continue;
AddUser(kTestAccounts[i], i >= SECONDARY_ACCOUNT_INDEX_START);
}
}
// Returns primary profile (if it is already created.)
......@@ -628,9 +633,16 @@ class MultiProfileFileManagerBrowserTest : public FileManagerBrowserTestBase {
}
user_manager::UserManager::Get()->SaveUserDisplayName(
account_id, base::UTF8ToUTF16(info.display_name));
SigninManagerFactory::GetForProfile(
chromeos::ProfileHelper::GetProfileByUserIdHashForTest(info.hash))
->SetAuthenticatedAccountInfo(info.gaia_id, info.email);
Profile* profile =
chromeos::ProfileHelper::GetProfileByUserIdHashForTest(info.hash);
// TODO(https://crbug.com/814307): We can't use
// identity::MakePrimaryAccountAvailable from identity_test_utils.h here
// because that DCHECKs that the SigninManager isn't authenticated yet.
// Here, it *can* be already authenticated if a PRE_ test previously set up
// the user.
IdentityManagerFactory::GetForProfile(profile)
->SetPrimaryAccountSynchronouslyForTests(info.gaia_id, info.email,
"refresh_token");
}
private:
......
......@@ -27,6 +27,11 @@ class ChromeSessionManager;
class UserSessionManager;
}
// Necessary to declare this class as a friend.
namespace file_manager {
class MultiProfileFileManagerBrowserTest;
}
// Necessary to declare this class as a friend.
class ProfileSyncServiceHarness;
......@@ -115,6 +120,7 @@ class IdentityManager : public SigninManagerBase::Observer,
IdentityManager* identity_manager,
const std::string& email);
friend ProfileSyncServiceHarness;
friend file_manager::MultiProfileFileManagerBrowserTest;
// These clients needs to call SetPrimaryAccountSynchronously().
friend chromeos::ChromeSessionManager;
......
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