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

Side by Side Diff: chrome/browser/signin/token_service_unittest.cc

Issue 23068005: Convert UserPolicySigninService to use OAuth2TokenService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with ToT Created 7 years, 4 months 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 (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 // This file defines a unit test for the profile's token service. 5 // This file defines a unit test for the profile's token service.
6 6
7 #include "chrome/browser/signin/token_service_unittest.h" 7 #include "chrome/browser/signin/token_service_unittest.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #if defined(OS_MACOSX) 57 #if defined(OS_MACOSX)
58 Encryptor::UseMockKeychain(true); 58 Encryptor::UseMockKeychain(true);
59 #endif 59 #endif
60 credentials_.sid = "sid"; 60 credentials_.sid = "sid";
61 credentials_.lsid = "lsid"; 61 credentials_.lsid = "lsid";
62 credentials_.token = "token"; 62 credentials_.token = "token";
63 credentials_.data = "data"; 63 credentials_.data = "data";
64 oauth_token_ = "oauth"; 64 oauth_token_ = "oauth";
65 oauth_secret_ = "secret"; 65 oauth_secret_ = "secret";
66 66
67 profile_.reset(new TestingProfile()); 67 profile_ = CreateProfile().Pass();
68
68 profile_->CreateWebDataService(); 69 profile_->CreateWebDataService();
69 70
70 // Force the loading of the WebDataService. 71 // Force the loading of the WebDataService.
71 TokenWebData::FromBrowserContext(profile_.get()); 72 TokenWebData::FromBrowserContext(profile_.get());
72 base::RunLoop().RunUntilIdle(); 73 base::RunLoop().RunUntilIdle();
73 74
74 service_ = TokenServiceFactory::GetForProfile(profile_.get()); 75 service_ = TokenServiceFactory::GetForProfile(profile_.get());
75 76
76 success_tracker_.ListenFor(chrome::NOTIFICATION_TOKEN_AVAILABLE, 77 success_tracker_.ListenFor(chrome::NOTIFICATION_TOKEN_AVAILABLE,
77 content::Source<TokenService>(service_)); 78 content::Source<TokenService>(service_));
78 failure_tracker_.ListenFor(chrome::NOTIFICATION_TOKEN_REQUEST_FAILED, 79 failure_tracker_.ListenFor(chrome::NOTIFICATION_TOKEN_REQUEST_FAILED,
79 content::Source<TokenService>(service_)); 80 content::Source<TokenService>(service_));
80 81
81 service()->Initialize("test", profile_.get()); 82 service()->Initialize("test", profile_.get());
82 } 83 }
83 84
85 scoped_ptr<TestingProfile> TokenServiceTestHarness::CreateProfile() {
86 return make_scoped_ptr(new TestingProfile());
87 }
88
84 void TokenServiceTestHarness::TearDown() { 89 void TokenServiceTestHarness::TearDown() {
85 // You have to destroy the profile before the threads are shut down. 90 // You have to destroy the profile before the threads are shut down.
86 profile_.reset(); 91 profile_.reset();
87 } 92 }
88 93
89 void TokenServiceTestHarness::UpdateCredentialsOnService() { 94 void TokenServiceTestHarness::UpdateCredentialsOnService() {
90 service()->UpdateCredentials(credentials_); 95 service()->UpdateCredentials(credentials_);
91 } 96 }
92 97
93 class TokenServiceTest : public TokenServiceTestHarness { 98 class TokenServiceTest : public TokenServiceTestHarness {
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 400
396 *CommandLine::ForCurrentProcess() = original_cl; 401 *CommandLine::ForCurrentProcess() = original_cl;
397 } 402 }
398 }; 403 };
399 404
400 TEST_F(TokenServiceCommandLineTest, TestValueOverride) { 405 TEST_F(TokenServiceCommandLineTest, TestValueOverride) {
401 EXPECT_TRUE(service()->HasTokenForService("my_service")); 406 EXPECT_TRUE(service()->HasTokenForService("my_service"));
402 EXPECT_EQ("my_value", service()->GetTokenForService("my_service")); 407 EXPECT_EQ("my_value", service()->GetTokenForService("my_service"));
403 } 408 }
404 #endif // ifndef NDEBUG 409 #endif // ifndef NDEBUG
OLDNEW
« no previous file with comments | « chrome/browser/signin/token_service_unittest.h ('k') | chrome/browser/signin/ubertoken_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698