Commit 1c1528b7 authored by Colin Blundell's avatar Colin Blundell Committed by Commit Bot

Document IdentityTestEnvironment's requirement of a task environment

After https://chromium-review.googlesource.com/c/chromium/src/+/1302175,
IdentityTestEnvironment now requires a properly set-up task environment.
The error that ensues at runtime if this is lacking is currently quite
cryptic. This CL adds documentation of the requirement and a transparent
runtime error for the case where the task environment is missing.

Bug: 798699
Change-Id: I7187b9d30f3072c2a0e697e7e325b01d238665bc
Reviewed-on: https://chromium-review.googlesource.com/c/1323073
Commit-Queue: Colin Blundell <blundell@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606417}
parent af1b5245
......@@ -7,6 +7,7 @@
#include "build/build_config.h"
#include "base/run_loop.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/signin/core/browser/account_consistency_method.h"
#include "components/signin/core/browser/test_signin_client.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
......@@ -145,6 +146,12 @@ IdentityTestEnvironment::IdentityTestEnvironment(
std::unique_ptr<IdentityManagerDependenciesOwner> dependencies_owner,
IdentityManager* identity_manager)
: weak_ptr_factory_(this) {
DCHECK(base::ThreadTaskRunnerHandle::Get())
<< "IdentityTestEnvironment requires a properly set up task environment. "
"If your test has an existing one, move it to be initialized before "
"IdentityTestEnvironment. Otherwise, use "
"base::test::ScopedTaskEnvironment.";
if (dependencies_owner) {
DCHECK(!(account_tracker_service || token_service || signin_manager ||
gaia_cookie_manager_service || identity_manager));
......
......@@ -26,6 +26,10 @@ class IdentityManagerDependenciesOwner;
// provides facilities for driving that IdentityManager. The IdentityManager
// instance is brought up in an environment where the primary account is
// not available; call MakePrimaryAccountAvailable() as needed.
// NOTE: IdentityTestEnvironment requires that tests have a properly set up
// task environment. If your test doesn't already have one, use a
// base::test::ScopedTaskEnvironment instance variable to fulfill this
// requirement.
class IdentityTestEnvironment : public IdentityManager::DiagnosticsObserver {
#if defined(OS_CHROMEOS)
using SigninManagerForTest = FakeSigninManagerBase;
......
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