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 "components/signin/core/browser/signin_tracker.h" | 5 #include "components/signin/core/browser/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" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 MOCK_METHOD1(SigninFailed, void(const GoogleServiceAuthError&)); | 44 MOCK_METHOD1(SigninFailed, void(const GoogleServiceAuthError&)); |
45 MOCK_METHOD0(SigninSuccess, void(void)); | 45 MOCK_METHOD0(SigninSuccess, void(void)); |
46 MOCK_METHOD1(MergeSessionComplete, void(const GoogleServiceAuthError&)); | 46 MOCK_METHOD1(MergeSessionComplete, void(const GoogleServiceAuthError&)); |
47 }; | 47 }; |
48 | 48 |
49 } // namespace | 49 } // namespace |
50 | 50 |
51 class SigninTrackerTest : public testing::Test { | 51 class SigninTrackerTest : public testing::Test { |
52 public: | 52 public: |
53 SigninTrackerTest() {} | 53 SigninTrackerTest() {} |
54 virtual void SetUp() OVERRIDE { | 54 virtual void SetUp() override { |
55 TestingProfile::Builder builder; | 55 TestingProfile::Builder builder; |
56 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), | 56 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), |
57 BuildFakeProfileOAuth2TokenService); | 57 BuildFakeProfileOAuth2TokenService); |
58 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), | 58 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), |
59 FakeSigninManagerBase::Build); | 59 FakeSigninManagerBase::Build); |
60 profile_ = builder.Build(); | 60 profile_ = builder.Build(); |
61 | 61 |
62 fake_oauth2_token_service_ = | 62 fake_oauth2_token_service_ = |
63 static_cast<FakeProfileOAuth2TokenService*>( | 63 static_cast<FakeProfileOAuth2TokenService*>( |
64 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get())); | 64 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get())); |
65 | 65 |
66 mock_signin_manager_ = static_cast<FakeSigninManagerForTesting*>( | 66 mock_signin_manager_ = static_cast<FakeSigninManagerForTesting*>( |
67 SigninManagerFactory::GetForProfile(profile_.get())); | 67 SigninManagerFactory::GetForProfile(profile_.get())); |
68 | 68 |
69 tracker_ = | 69 tracker_ = |
70 SigninTrackerFactory::CreateForProfile(profile_.get(), &observer_); | 70 SigninTrackerFactory::CreateForProfile(profile_.get(), &observer_); |
71 } | 71 } |
72 virtual void TearDown() OVERRIDE { | 72 virtual void TearDown() override { |
73 tracker_.reset(); | 73 tracker_.reset(); |
74 profile_.reset(); | 74 profile_.reset(); |
75 } | 75 } |
76 | 76 |
77 content::TestBrowserThreadBundle thread_bundle_; | 77 content::TestBrowserThreadBundle thread_bundle_; |
78 scoped_ptr<SigninTracker> tracker_; | 78 scoped_ptr<SigninTracker> tracker_; |
79 scoped_ptr<TestingProfile> profile_; | 79 scoped_ptr<TestingProfile> profile_; |
80 FakeSigninManagerForTesting* mock_signin_manager_; | 80 FakeSigninManagerForTesting* mock_signin_manager_; |
81 FakeProfileOAuth2TokenService* fake_oauth2_token_service_; | 81 FakeProfileOAuth2TokenService* fake_oauth2_token_service_; |
82 MockObserver observer_; | 82 MockObserver observer_; |
(...skipping 13 matching lines...) Expand all Loading... |
96 #endif // !defined(OS_CHROMEOS) | 96 #endif // !defined(OS_CHROMEOS) |
97 | 97 |
98 TEST_F(SigninTrackerTest, SignInSucceeds) { | 98 TEST_F(SigninTrackerTest, SignInSucceeds) { |
99 EXPECT_CALL(observer_, SigninSuccess()); | 99 EXPECT_CALL(observer_, SigninSuccess()); |
100 EXPECT_CALL(observer_, SigninFailed(_)).Times(0); | 100 EXPECT_CALL(observer_, SigninFailed(_)).Times(0); |
101 | 101 |
102 mock_signin_manager_->SetAuthenticatedUsername("user@gmail.com"); | 102 mock_signin_manager_->SetAuthenticatedUsername("user@gmail.com"); |
103 fake_oauth2_token_service_->IssueRefreshTokenForUser( | 103 fake_oauth2_token_service_->IssueRefreshTokenForUser( |
104 "user@gmail.com", "refresh_token"); | 104 "user@gmail.com", "refresh_token"); |
105 } | 105 } |
OLD | NEW |