Commit 5a8ddec2 authored by Abhijeet Kandalkar's avatar Abhijeet Kandalkar Committed by Commit Bot

Eliminate identity_apitest.cc's interaction with AccountFetcherService

This CL replaces use of AccountFetcherService::OnRefreshTokensLoaded()
method by IdentityTestEnvironment.

As per new implementation, AccountFetcherService is wrapped inside
ITE to interact with identity_apitest.

Bug: 929603
Change-Id: I95bd34d549e6a03703ca15014de87359469547e8
Reviewed-on: https://chromium-review.googlesource.com/c/1458404
Commit-Queue: Colin Blundell <blundell@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634575}
parent 63deffe7
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "chrome/browser/extensions/extension_function_test_utils.h" #include "chrome/browser/extensions/extension_function_test_utils.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/account_fetcher_service_factory.h"
#include "chrome/browser/signin/account_reconcilor_factory.h" #include "chrome/browser/signin/account_reconcilor_factory.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h" #include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/chrome_signin_client_test_util.h" #include "chrome/browser/signin/chrome_signin_client_test_util.h"
...@@ -46,7 +45,6 @@ ...@@ -46,7 +45,6 @@
#include "components/crx_file/id_util.h" #include "components/crx_file/id_util.h"
#include "components/guest_view/browser/guest_view_base.h" #include "components/guest_view/browser/guest_view_base.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/signin/core/browser/account_fetcher_service.h"
#include "components/signin/core/browser/account_reconcilor.h" #include "components/signin/core/browser/account_reconcilor.h"
#include "components/signin/core/browser/list_accounts_test_utils.h" #include "components/signin/core/browser/list_accounts_test_utils.h"
#include "components/signin/core/browser/signin_pref_names.h" #include "components/signin/core/browser/signin_pref_names.h"
...@@ -467,15 +465,6 @@ class IdentityTestWithSignin : public AsyncExtensionBrowserTest { ...@@ -467,15 +465,6 @@ class IdentityTestWithSignin : public AsyncExtensionBrowserTest {
ChromeSigninClientFactory::GetInstance()->SetTestingFactory( ChromeSigninClientFactory::GetInstance()->SetTestingFactory(
context, base::BindRepeating(&BuildChromeSigninClientWithURLLoader, context, base::BindRepeating(&BuildChromeSigninClientWithURLLoader,
&test_url_loader_factory_)); &test_url_loader_factory_));
// Ensure that AccountFetcherService is (1) created at all and (2) created
// early enough for it to observe the Profile initialization process and
// loading of tokens by PO2TS. Explicitly forcing this setup (which happens
// naturally in production) is necessary for the flow of
// AccountTrackerService having accounts removed when tokens are revoked
// with PO2TS to work as expected in this testing context.
AccountFetcherServiceFactory::GetInstance()->GetForProfile(
Profile::FromBrowserContext(context));
} }
void SetUpOnMainThread() override { void SetUpOnMainThread() override {
...@@ -484,18 +473,10 @@ class IdentityTestWithSignin : public AsyncExtensionBrowserTest { ...@@ -484,18 +473,10 @@ class IdentityTestWithSignin : public AsyncExtensionBrowserTest {
identity_test_env_profile_adaptor_ = identity_test_env_profile_adaptor_ =
std::make_unique<IdentityTestEnvironmentProfileAdaptor>(profile()); std::make_unique<IdentityTestEnvironmentProfileAdaptor>(profile());
#if defined(OS_CHROMEOS) // This test requires these callbacks to be fired on account
// On ChromeOS, ProfileOAuth2TokenService does not fire // update/removal.
// OnRefreshTokensLoaded() in text contexts. However, AccountFetcherService identity_test_env()
// must receive this call in order to forward later ->EnableOnAccountUpdatedAndOnAccountRemovedWithInfoCallbacks();
// OnRefreshToken{Available, Revoked} callbacks on to AccountTrackerService
// as expected. Hence, we make that call explicitly here.
// TODO(blundell): Hide this detail when converting this code to interact
// with IdentityTestEnvironment.
AccountFetcherServiceFactory::GetInstance()
->GetForProfile(profile())
->OnRefreshTokensLoaded();
#endif
} }
void TearDownOnMainThread() override { void TearDownOnMainThread() override {
......
...@@ -116,8 +116,11 @@ void AccountFetcherService::OnNetworkInitialized() { ...@@ -116,8 +116,11 @@ void AccountFetcherService::OnNetworkInitialized() {
} }
void AccountFetcherService::EnableNetworkFetchesForTest() { void AccountFetcherService::EnableNetworkFetchesForTest() {
OnNetworkInitialized(); if (!network_initialized_)
OnRefreshTokensLoaded(); OnNetworkInitialized();
if (!refresh_tokens_loaded_)
OnRefreshTokensLoaded();
} }
void AccountFetcherService::RefreshAllAccountInfo(bool only_fetch_if_invalid) { void AccountFetcherService::RefreshAllAccountInfo(bool only_fetch_if_invalid) {
......
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