Commit 78fb8f64 authored by atwilson@chromium.org's avatar atwilson@chromium.org

Enabled SignInAfterInit test.

Also added comment about how to use TokenService from tests.

BUG=141123
TEST=none


Review URL: https://chromiumcodereview.appspot.com/10834262

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151180 0039d316-1c4b-4281-b951-d872f2087c98
parent ad7b31e4
...@@ -14,7 +14,10 @@ ...@@ -14,7 +14,10 @@
#include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/signin_manager_fake.h" #include "chrome/browser/signin/signin_manager_fake.h"
#include "chrome/browser/signin/token_service.h"
#include "chrome/browser/signin/token_service_factory.h"
#include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_notification_types.h"
#include "chrome/common/net/gaia/gaia_constants.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_pref_service.h" #include "chrome/test/base/testing_pref_service.h"
...@@ -55,6 +58,7 @@ class UserPolicySigninServiceTest : public testing::Test { ...@@ -55,6 +58,7 @@ class UserPolicySigninServiceTest : public testing::Test {
TestingProfile::Builder builder; TestingProfile::Builder builder;
builder.SetUserCloudPolicyManager(manager.Pass()); builder.SetUserCloudPolicyManager(manager.Pass());
profile_ = builder.Build().Pass(); profile_ = builder.Build().Pass();
profile_->CreateRequestContext();
profile_->GetPrefs()->SetBoolean(prefs::kLoadCloudPolicyOnSignin, true); profile_->GetPrefs()->SetBoolean(prefs::kLoadCloudPolicyOnSignin, true);
SigninManagerFactory::GetInstance()->SetTestingFactory( SigninManagerFactory::GetInstance()->SetTestingFactory(
profile_.get(), FakeSigninManager::Build); profile_.get(), FakeSigninManager::Build);
...@@ -119,9 +123,7 @@ TEST_F(UserPolicySigninServiceTest, InitWhileSignedIn) { ...@@ -119,9 +123,7 @@ TEST_F(UserPolicySigninServiceTest, InitWhileSignedIn) {
ASSERT_TRUE(profile_->GetUserCloudPolicyManager()->cloud_policy_service()); ASSERT_TRUE(profile_->GetUserCloudPolicyManager()->cloud_policy_service());
} }
// TODO(atwilson): Enable test for signing in once it is possible to use a TEST_F(UserPolicySigninServiceTest, SignInAfterInit) {
// mock TokenService (http://crbug.com/138618).
TEST_F(UserPolicySigninServiceTest, DISABLED_SignInAfterInit) {
// Let the SigninService know that the profile has been created. // Let the SigninService know that the profile has been created.
content::NotificationService::current()->Notify( content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PROFILE_ADDED, chrome::NOTIFICATION_PROFILE_ADDED,
...@@ -135,7 +137,9 @@ TEST_F(UserPolicySigninServiceTest, DISABLED_SignInAfterInit) { ...@@ -135,7 +137,9 @@ TEST_F(UserPolicySigninServiceTest, DISABLED_SignInAfterInit) {
SigninManagerFactory::GetForProfile(profile_.get())->SetAuthenticatedUsername( SigninManagerFactory::GetForProfile(profile_.get())->SetAuthenticatedUsername(
"testuser@test.com"); "testuser@test.com");
// Make oauth token available (needs MockTokenService - see TODO above). // Make oauth token available.
TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest(
GaiaConstants::kGaiaOAuth2LoginRefreshToken, "oauth_login_refresh_token");
// UserCloudPolicyManager should be initialized. // UserCloudPolicyManager should be initialized.
ASSERT_TRUE(profile_->GetUserCloudPolicyManager()->cloud_policy_service()); ASSERT_TRUE(profile_->GetUserCloudPolicyManager()->cloud_policy_service());
......
...@@ -31,6 +31,15 @@ ...@@ -31,6 +31,15 @@
// SetMyToken(notification.token()) // SetMyToken(notification.token())
// } // }
// } // }
//
// There is currently no easy way to create a fake TokenService. Tests that want
// to use TokenService to issue tokens without the use of fake GaiaAuthFetchers
// or persisting the tokens to disk via WebDataService can do this by
// creating a TokenService (skipping the Initialize() step to avoid interacting
// with WebDataService) and calling IssueAuthTokenForTest() to issue new tokens.
// This will result in the TokenService sending out the appropriate
// TOKEN_AVAILABLE notification and returning the correct response to future
// calls to Has/GetTokenForService().
#ifndef CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_H_ #ifndef CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_H_
#define CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_H_ #define CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_H_
......
...@@ -371,6 +371,7 @@ void URLFetcherCore::GetExtraRequestHeaders( ...@@ -371,6 +371,7 @@ void URLFetcherCore::GetExtraRequestHeaders(
void URLFetcherCore::SetRequestContext( void URLFetcherCore::SetRequestContext(
URLRequestContextGetter* request_context_getter) { URLRequestContextGetter* request_context_getter) {
DCHECK(!request_context_getter_); DCHECK(!request_context_getter_);
DCHECK(request_context_getter);
request_context_getter_ = request_context_getter; request_context_getter_ = request_context_getter;
} }
......
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