Chromium Code Reviews| 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..f3cfa01c827037e41a12614558a3aa116c2d1486 100644 |
| --- a/chrome/browser/signin/signin_manager_unittest.cc |
| +++ b/chrome/browser/signin/signin_manager_unittest.cc |
| @@ -15,16 +15,18 @@ |
| #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/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" |
|
fgorski
2013/11/13 20:36:48
did you use those two includes anywhere?
Roger Tawa OOO till Jul 10th
2013/11/13 20:56:12
Yes. For example line 81 for notification_source,
|
| #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 +64,7 @@ BrowserContextKeyedService* SigninManagerBuild( |
| } // namespace |
| -class SigninManagerTest : public TokenServiceTestHarness { |
| +class SigninManagerTest : public testing::Test { |
| public: |
| SigninManagerTest() : manager_(NULL) {} |
| virtual ~SigninManagerTest() {} |
| @@ -73,7 +75,7 @@ class SigninManagerTest : public TokenServiceTestHarness { |
| chrome::RegisterLocalState(prefs_->registry()); |
| TestingBrowserProcess::GetGlobal()->SetLocalState( |
| prefs_.get()); |
| - TokenServiceTestHarness::SetUp(); |
| + profile_.reset(new TestingProfile()); |
| google_login_success_.ListenFor( |
| chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, |
| content::Source<Profile>(profile())); |
| @@ -89,10 +91,12 @@ class SigninManagerTest : public TokenServiceTestHarness { |
| naked_manager_.reset(NULL); |
| } |
| TestingBrowserProcess::GetGlobal()->SetLocalState(NULL); |
| - prefs_.reset(NULL); |
| - TokenServiceTestHarness::TearDown(); |
| + 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 +192,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 +212,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 +232,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_; |