OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/api/identity/account_tracker.h" | 5 #include "chrome/browser/extensions/api/identity/account_tracker.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 11 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
| 12 #include "chrome/browser/signin/fake_signin_manager.h" |
12 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
13 #include "chrome/browser/signin/signin_manager_base.h" | 14 #include "chrome/browser/signin/signin_manager_base.h" |
| 15 #include "chrome/browser/signin/signin_manager_factory.h" |
14 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
15 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
16 #include "content/public/test/test_browser_thread_bundle.h" | 18 #include "content/public/test/test_browser_thread_bundle.h" |
17 #include "google_apis/gaia/gaia_oauth_client.h" | 19 #include "google_apis/gaia/gaia_oauth_client.h" |
18 #include "net/http/http_status_code.h" | 20 #include "net/http/http_status_code.h" |
19 #include "net/url_request/test_url_fetcher_factory.h" | 21 #include "net/url_request/test_url_fetcher_factory.h" |
20 #include "net/url_request/url_fetcher_delegate.h" | 22 #include "net/url_request/url_fetcher_delegate.h" |
21 #include "net/url_request/url_request_test_util.h" | 23 #include "net/url_request/url_request_test_util.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
23 | 25 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 class IdentityAccountTrackerTest : public testing::Test { | 205 class IdentityAccountTrackerTest : public testing::Test { |
204 public: | 206 public: |
205 IdentityAccountTrackerTest() {} | 207 IdentityAccountTrackerTest() {} |
206 | 208 |
207 virtual ~IdentityAccountTrackerTest() {} | 209 virtual ~IdentityAccountTrackerTest() {} |
208 | 210 |
209 virtual void SetUp() OVERRIDE { | 211 virtual void SetUp() OVERRIDE { |
210 TestingProfile::Builder builder; | 212 TestingProfile::Builder builder; |
211 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), | 213 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), |
212 FakeProfileOAuth2TokenService::Build); | 214 FakeProfileOAuth2TokenService::Build); |
| 215 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), |
| 216 FakeSigninManagerBase::Build); |
213 | 217 |
214 test_profile_ = builder.Build(); | 218 test_profile_ = builder.Build(); |
215 | 219 |
216 fake_oauth2_token_service_ = static_cast<FakeProfileOAuth2TokenService*>( | 220 fake_oauth2_token_service_ = static_cast<FakeProfileOAuth2TokenService*>( |
217 ProfileOAuth2TokenServiceFactory::GetForProfile(test_profile_.get())); | 221 ProfileOAuth2TokenServiceFactory::GetForProfile(test_profile_.get())); |
218 | 222 |
| 223 SigninManagerBase* signin_manager = |
| 224 SigninManagerFactory::GetForProfile(test_profile_.get()); |
| 225 signin_manager->Initialize(test_profile_.get(), NULL); |
| 226 signin_manager->SetAuthenticatedUsername("foo@example.com"); |
| 227 |
219 account_tracker_.reset(new AccountTracker(test_profile_.get())); | 228 account_tracker_.reset(new AccountTracker(test_profile_.get())); |
220 account_tracker_->AddObserver(&observer_); | 229 account_tracker_->AddObserver(&observer_); |
221 } | 230 } |
222 | 231 |
223 virtual void TearDown() OVERRIDE { | 232 virtual void TearDown() OVERRIDE { |
224 account_tracker_->RemoveObserver(&observer_); | 233 account_tracker_->RemoveObserver(&observer_); |
225 account_tracker_->Shutdown(); | 234 account_tracker_->Shutdown(); |
226 } | 235 } |
227 | 236 |
228 Profile* profile() { | 237 Profile* profile() { |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 EXPECT_TRUE(observer()->CheckEvents()); | 504 EXPECT_TRUE(observer()->CheckEvents()); |
496 | 505 |
497 NotifyTokenAvailable("user@example.com"); | 506 NotifyTokenAvailable("user@example.com"); |
498 ReturnOAuthUrlFetchSuccess("user@example.com"); | 507 ReturnOAuthUrlFetchSuccess("user@example.com"); |
499 EXPECT_TRUE(observer()->CheckEvents( | 508 EXPECT_TRUE(observer()->CheckEvents( |
500 TrackingEvent(ADDED, "user@example.com", kFakeGaiaId), | 509 TrackingEvent(ADDED, "user@example.com", kFakeGaiaId), |
501 TrackingEvent(SIGN_IN, "user@example.com", kFakeGaiaId))); | 510 TrackingEvent(SIGN_IN, "user@example.com", kFakeGaiaId))); |
502 } | 511 } |
503 | 512 |
504 } // namespace extensions | 513 } // namespace extensions |
OLD | NEW |