Commit c23aa196 authored by Anastasiia N's avatar Anastasiia N Committed by Commit Bot

Use immediate callback runner in testing profile

Currently |TestingProfile| initializes Chrome OS Account Manager with
|chromeos::DelayNetworkCall|, which uses |NetworkHandler|.
It leads to crashes in tests which do not initialize |NetworkHandler|
properly. (This code path was not exercised before, but in
https://crrev.com/c/2232324 we start using Account Manager in tests
and some tests crash because of this issue.)

Fix this by not using |chromeos::DelayNetworkCall| and instead supplying
a fake runner which immediately executes its callbacks.

Bug: 1068240
Change-Id: I220ebc32fa069876f4cd607ba1bae89a35ac7d41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2346350Reviewed-by: default avatarKush Sinha <sinhak@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Commit-Queue: Anastasiia N <anastasiian@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796760}
parent 9475af58
...@@ -364,11 +364,11 @@ void TestingProfile::Init() { ...@@ -364,11 +364,11 @@ void TestingProfile::Init() {
g_browser_process->platform_part()->GetAccountManagerFactory(); g_browser_process->platform_part()->GetAccountManagerFactory();
chromeos::AccountManager* account_manager = chromeos::AccountManager* account_manager =
factory->GetAccountManager(profile_path_.value()); factory->GetAccountManager(profile_path_.value());
account_manager->Initialize( chromeos::AccountManager::DelayNetworkCallRunner immediate_callback_runner =
profile_path_, GetURLLoaderFactory(), base::BindRepeating(
base::BindRepeating(&chromeos::DelayNetworkCall, [](base::OnceClosure closure) -> void { std::move(closure).Run(); });
base::TimeDelta::FromMilliseconds( account_manager->Initialize(profile_path_, GetURLLoaderFactory(),
chromeos::kDefaultNetworkRetryDelayMS))); immediate_callback_runner);
account_manager->SetPrefService(GetPrefs()); account_manager->SetPrefService(GetPrefs());
if (!chromeos::CrosSettings::IsInitialized()) { if (!chromeos::CrosSettings::IsInitialized()) {
scoped_cros_settings_test_helper_.reset( scoped_cros_settings_test_helper_.reset(
......
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