Commit 71365522 authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

Ensure that IdentityTestEnvironment use the correct PO2TS

IdentityTestEnvironment's method casts the PO2TS to a FakePO2TS
but do not enforce this at compilation (in order to support
IdentityTestEnvironmentProfileAdaptor).

Add a DCHECK in IdentityTestEnvironment::Initialize() to check
that the PO2TS is a FakeProfileOAuth2TokenService (required to
add a new virtual method to determine this as Chromium builds
without RTTI).

Bug: 982751
Change-Id: I151a3e63f22b941d6be40151bba2e453e43be43c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1795602
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697961}
parent f49fd4cf
......@@ -99,3 +99,8 @@ FakeOAuth2AccessTokenManager*
FakeProfileOAuth2TokenService::GetFakeAccessTokenManager() {
return static_cast<FakeOAuth2AccessTokenManager*>(GetAccessTokenManager());
}
bool FakeProfileOAuth2TokenService::IsFakeProfileOAuth2TokenServiceForTesting()
const {
return true;
}
......@@ -81,6 +81,8 @@ class FakeProfileOAuth2TokenService : public ProfileOAuth2TokenService {
void set_auto_post_fetch_response_on_message_loop(bool auto_post_response);
bool IsFakeProfileOAuth2TokenServiceForTesting() const override;
private:
FakeOAuth2AccessTokenManager* GetFakeAccessTokenManager();
......
......@@ -355,6 +355,11 @@ void ProfileOAuth2TokenService::OverrideAccessTokenManagerForTesting(
token_manager_ = std::move(token_manager);
}
bool ProfileOAuth2TokenService::IsFakeProfileOAuth2TokenServiceForTesting()
const {
return false;
}
OAuth2AccessTokenManager* ProfileOAuth2TokenService::GetAccessTokenManager() {
return token_manager_.get();
}
......
......@@ -257,6 +257,8 @@ class ProfileOAuth2TokenService : public OAuth2AccessTokenManager::Delegate,
void OverrideAccessTokenManagerForTesting(
std::unique_ptr<OAuth2AccessTokenManager> token_manager);
virtual bool IsFakeProfileOAuth2TokenServiceForTesting() const;
protected:
OAuth2AccessTokenManager* GetAccessTokenManager();
......
......@@ -128,6 +128,11 @@ void IdentityTestEnvironment::Initialize() {
"If your test has an existing one, move it to be initialized before "
"IdentityTestEnvironment. Otherwise, use "
"base::test::TaskEnvironment.";
DCHECK(identity_manager()
->GetTokenService()
->IsFakeProfileOAuth2TokenServiceForTesting())
<< "IdentityTestEnvironment requires the ProfileOAuth2TokenService used "
"to subclass FakeProfileOAuth2TokenServiceForTesting.";
test_identity_manager_observer_ =
std::make_unique<TestIdentityManagerObserver>(this->identity_manager());
this->identity_manager()->AddDiagnosticsObserver(this);
......
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