| Index: chrome/browser/signin/signin_manager_unittest.cc
|
| diff --git a/chrome/browser/signin/signin_manager_unittest.cc b/chrome/browser/signin/signin_manager_unittest.cc
|
| index c6863f59207691820a2a13ed9c31237c75172222..64d946b1dd21330a2d899d916b103565cdd66853 100644
|
| --- a/chrome/browser/signin/signin_manager_unittest.cc
|
| +++ b/chrome/browser/signin/signin_manager_unittest.cc
|
| @@ -15,16 +15,19 @@
|
| #include "chrome/browser/chrome_notification_types.h"
|
| #include "chrome/browser/prefs/browser_prefs.h"
|
| #include "chrome/browser/signin/chrome_signin_manager_delegate.h"
|
| +#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
|
| +#include "chrome/browser/signin/profile_oauth2_token_service.h"
|
| +#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
|
| #include "chrome/browser/signin/signin_manager_factory.h"
|
| -#include "chrome/browser/signin/token_service.h"
|
| -#include "chrome/browser/signin/token_service_unittest.h"
|
| #include "chrome/common/pref_names.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "chrome/test/base/testing_browser_process.h"
|
| #include "chrome/test/base/testing_profile.h"
|
| #include "components/webdata/encryptor/encryptor.h"
|
| #include "content/public/browser/child_process_security_policy.h"
|
| +#include "content/public/browser/notification_source.h"
|
| #include "content/public/test/test_browser_thread_bundle.h"
|
| +#include "content/public/test/test_notification_tracker.h"
|
| #include "google_apis/gaia/gaia_constants.h"
|
| #include "google_apis/gaia/gaia_urls.h"
|
| #include "net/cookies/cookie_monster.h"
|
| @@ -62,7 +65,7 @@ BrowserContextKeyedService* SigninManagerBuild(
|
| } // namespace
|
|
|
|
|
| -class SigninManagerTest : public TokenServiceTestHarness {
|
| +class SigninManagerTest : public testing::Test {
|
| public:
|
| SigninManagerTest() : manager_(NULL) {}
|
| virtual ~SigninManagerTest() {}
|
| @@ -73,7 +76,10 @@ class SigninManagerTest : public TokenServiceTestHarness {
|
| chrome::RegisterLocalState(prefs_->registry());
|
| TestingBrowserProcess::GetGlobal()->SetLocalState(
|
| prefs_.get());
|
| - TokenServiceTestHarness::SetUp();
|
| + TestingProfile::Builder builder;
|
| + builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(),
|
| + FakeProfileOAuth2TokenService::Build);
|
| + profile_ = builder.Build();
|
| google_login_success_.ListenFor(
|
| chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL,
|
| content::Source<Profile>(profile()));
|
| @@ -89,10 +95,16 @@ class SigninManagerTest : public TokenServiceTestHarness {
|
| naked_manager_.reset(NULL);
|
| }
|
| TestingBrowserProcess::GetGlobal()->SetLocalState(NULL);
|
| - prefs_.reset(NULL);
|
| - TokenServiceTestHarness::TearDown();
|
| +
|
| + // Manually destroy PrefService and Profile so that they are shutdown
|
| + // in the correct order. Both need to be destroyed before the
|
| + // |thread_bundle_| member.
|
| + prefs_.reset();
|
| + profile_.reset();
|
| }
|
|
|
| + TestingProfile* profile() { return profile_.get(); }
|
| +
|
| // Create a signin manager as a service if other code will try to get it as
|
| // a PKS.
|
| void CreateSigninManagerAsService() {
|
| @@ -188,9 +200,10 @@ class SigninManagerTest : public TokenServiceTestHarness {
|
|
|
| EXPECT_FALSE(manager_->GetAuthenticatedUsername().empty());
|
|
|
| - // This is flow, the oauth2 credentials should already be available in
|
| - // the token service.
|
| - EXPECT_TRUE(service()->HasOAuthLoginToken());
|
| + ProfileOAuth2TokenService* token_service =
|
| + ProfileOAuth2TokenServiceFactory::GetForProfile(profile());
|
| + EXPECT_TRUE(token_service->RefreshTokenIsAvailable(
|
| + manager_->GetAuthenticatedUsername()));
|
|
|
| // Should go into token service and stop.
|
| EXPECT_EQ(1U, google_login_success_.size());
|
| @@ -207,9 +220,10 @@ class SigninManagerTest : public TokenServiceTestHarness {
|
| if (requestSent)
|
| SimulateValidResponseSignInWithCredentials();
|
|
|
| - // The oauth2 credentials should not be available in the token service
|
| - // because the email was incorrect.
|
| - EXPECT_FALSE(service()->HasOAuthLoginToken());
|
| + ProfileOAuth2TokenService* token_service =
|
| + ProfileOAuth2TokenServiceFactory::GetForProfile(profile());
|
| + EXPECT_FALSE(token_service->RefreshTokenIsAvailable(
|
| + manager_->GetAuthenticatedUsername()));
|
|
|
| // Should go into token service and stop.
|
| EXPECT_EQ(0U, google_login_success_.size());
|
| @@ -226,9 +240,11 @@ class SigninManagerTest : public TokenServiceTestHarness {
|
| manager_->SignOut();
|
| }
|
|
|
| + content::TestBrowserThreadBundle thread_bundle_;
|
| net::TestURLFetcherFactory factory_;
|
| scoped_ptr<SigninManager> naked_manager_;
|
| SigninManager* manager_;
|
| + scoped_ptr<TestingProfile> profile_;
|
| content::TestNotificationTracker google_login_success_;
|
| content::TestNotificationTracker google_login_failure_;
|
| std::vector<std::string> oauth_tokens_fetched_;
|
|
|