Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(671)

Side by Side Diff: chrome/browser/extensions/api/identity/account_tracker_unittest.cc

Issue 33173005: Correctly deal with tokens for supervised users in ProfileOAuth2TokenService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698