| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/signin/signin_tracker.h" | 5 #include "chrome/browser/signin/signin_tracker.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/signin/fake_auth_status_provider.h" | 12 #include "chrome/browser/signin/fake_auth_status_provider.h" |
| 13 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 13 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
| 14 #include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" |
| 14 #include "chrome/browser/signin/fake_signin_manager.h" | 15 #include "chrome/browser/signin/fake_signin_manager.h" |
| 15 #include "chrome/browser/signin/profile_oauth2_token_service.h" | 16 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
| 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 17 #include "chrome/browser/signin/signin_manager.h" | 18 #include "chrome/browser/signin/signin_manager.h" |
| 18 #include "chrome/browser/signin/signin_manager_factory.h" | 19 #include "chrome/browser/signin/signin_manager_factory.h" |
| 19 #include "chrome/browser/sync/profile_sync_service_factory.h" | 20 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 20 #include "chrome/browser/sync/profile_sync_service_mock.h" | 21 #include "chrome/browser/sync/profile_sync_service_mock.h" |
| 21 #include "chrome/test/base/testing_profile.h" | 22 #include "chrome/test/base/testing_profile.h" |
| 22 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/test/test_browser_thread_bundle.h" | 24 #include "content/public/test/test_browser_thread_bundle.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 46 }; | 47 }; |
| 47 | 48 |
| 48 } // namespace | 49 } // namespace |
| 49 | 50 |
| 50 class SigninTrackerTest : public testing::Test { | 51 class SigninTrackerTest : public testing::Test { |
| 51 public: | 52 public: |
| 52 SigninTrackerTest() {} | 53 SigninTrackerTest() {} |
| 53 virtual void SetUp() OVERRIDE { | 54 virtual void SetUp() OVERRIDE { |
| 54 TestingProfile::Builder builder; | 55 TestingProfile::Builder builder; |
| 55 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), | 56 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), |
| 56 FakeProfileOAuth2TokenService::Build); | 57 FakeProfileOAuth2TokenServiceWrapper::Build); |
| 57 | 58 |
| 58 profile_ = builder.Build(); | 59 profile_ = builder.Build(); |
| 59 | 60 |
| 60 fake_oauth2_token_service_ = | 61 fake_oauth2_token_service_ = |
| 61 static_cast<FakeProfileOAuth2TokenService*>( | 62 static_cast<FakeProfileOAuth2TokenService*>( |
| 62 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get())); | 63 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get())); |
| 63 | 64 |
| 64 mock_signin_manager_ = static_cast<FakeSigninManagerForTesting*>( | 65 mock_signin_manager_ = static_cast<FakeSigninManagerForTesting*>( |
| 65 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( | 66 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( |
| 66 profile_.get(), FakeSigninManagerBase::Build)); | 67 profile_.get(), FakeSigninManagerBase::Build)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 94 content::Details<const GoogleServiceAuthError>(&error)); | 95 content::Details<const GoogleServiceAuthError>(&error)); |
| 95 } | 96 } |
| 96 | 97 |
| 97 TEST_F(SigninTrackerTest, SignInSucceeds) { | 98 TEST_F(SigninTrackerTest, SignInSucceeds) { |
| 98 EXPECT_CALL(observer_, SigninSuccess()); | 99 EXPECT_CALL(observer_, SigninSuccess()); |
| 99 EXPECT_CALL(observer_, SigninFailed(_)).Times(0); | 100 EXPECT_CALL(observer_, SigninFailed(_)).Times(0); |
| 100 | 101 |
| 101 mock_signin_manager_->SetAuthenticatedUsername("user@gmail.com"); | 102 mock_signin_manager_->SetAuthenticatedUsername("user@gmail.com"); |
| 102 fake_oauth2_token_service_->IssueRefreshToken("refresh_token"); | 103 fake_oauth2_token_service_->IssueRefreshToken("refresh_token"); |
| 103 } | 104 } |
| OLD | NEW |