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

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

Issue 9301003: Change X-Auto-Login implementation to use OAuth token. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Copyright. Created 8 years, 10 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 credentials_.token = "token"; 66 credentials_.token = "token";
67 credentials_.data = "data"; 67 credentials_.data = "data";
68 oauth_token_ = "oauth"; 68 oauth_token_ = "oauth";
69 oauth_secret_ = "secret"; 69 oauth_secret_ = "secret";
70 70
71 ASSERT_TRUE(db_thread_.Start()); 71 ASSERT_TRUE(db_thread_.Start());
72 72
73 profile_.reset(new TestingProfile()); 73 profile_.reset(new TestingProfile());
74 profile_->CreateWebDataService(false); 74 profile_->CreateWebDataService(false);
75 WaitForDBLoadCompletion(); 75 WaitForDBLoadCompletion();
76 service_ = profile_->GetTokenService();
76 77
77 success_tracker_.ListenFor(chrome::NOTIFICATION_TOKEN_AVAILABLE, 78 success_tracker_.ListenFor(chrome::NOTIFICATION_TOKEN_AVAILABLE,
78 content::Source<TokenService>(&service_)); 79 content::Source<TokenService>(service_));
79 failure_tracker_.ListenFor(chrome::NOTIFICATION_TOKEN_REQUEST_FAILED, 80 failure_tracker_.ListenFor(chrome::NOTIFICATION_TOKEN_REQUEST_FAILED,
80 content::Source<TokenService>(&service_)); 81 content::Source<TokenService>(service_));
81 82
82 service_.Initialize("test", profile_.get()); 83 service_->Initialize("test", profile_.get());
83 } 84 }
84 85
85 void TokenServiceTestHarness::TearDown() { 86 void TokenServiceTestHarness::TearDown() {
86 // You have to destroy the profile before the db_thread_ stops. 87 // You have to destroy the profile before the db_thread_ stops.
87 if (profile_.get()) { 88 if (profile_.get()) {
88 profile_.reset(NULL); 89 profile_.reset(NULL);
89 } 90 }
90 91
91 db_thread_.Stop(); 92 db_thread_.Stop();
92 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 93 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
(...skipping 12 matching lines...) Expand all
105 done.Wait(); 106 done.Wait();
106 107
107 // Notifications should be returned from the DB thread onto the UI thread. 108 // Notifications should be returned from the DB thread onto the UI thread.
108 message_loop_.RunAllPending(); 109 message_loop_.RunAllPending();
109 } 110 }
110 111
111 class TokenServiceTest : public TokenServiceTestHarness { 112 class TokenServiceTest : public TokenServiceTestHarness {
112 public: 113 public:
113 virtual void SetUp() { 114 virtual void SetUp() {
114 TokenServiceTestHarness::SetUp(); 115 TokenServiceTestHarness::SetUp();
115 service_.UpdateCredentials(credentials_); 116 service_->UpdateCredentials(credentials_);
116 service_.UpdateOAuthCredentials(oauth_token_, oauth_secret_); 117 service_->UpdateOAuthCredentials(oauth_token_, oauth_secret_);
117 } 118 }
118 protected: 119 protected:
119 void TestLoadSingleToken( 120 void TestLoadSingleToken(
120 std::map<std::string, std::string>* db_tokens, 121 std::map<std::string, std::string>* db_tokens,
121 std::map<std::string, std::string>* memory_tokens, 122 std::map<std::string, std::string>* memory_tokens,
122 const std::string& service) { 123 const std::string& service) {
123 std::string token = service + "_token"; 124 std::string token = service + "_token";
124 (*db_tokens)[service] = token; 125 (*db_tokens)[service] = token;
125 size_t prev_success_size = success_tracker_.size(); 126 size_t prev_success_size = success_tracker_.size();
126 service_.LoadTokensIntoMemory(*db_tokens, memory_tokens); 127 service_->LoadTokensIntoMemory(*db_tokens, memory_tokens);
127 128
128 // Check notification. 129 // Check notification.
129 EXPECT_EQ(prev_success_size + 1, success_tracker_.size()); 130 EXPECT_EQ(prev_success_size + 1, success_tracker_.size());
130 TokenService::TokenAvailableDetails details = success_tracker_.details(); 131 TokenService::TokenAvailableDetails details = success_tracker_.details();
131 EXPECT_EQ(details.service(), service); 132 EXPECT_EQ(details.service(), service);
132 EXPECT_EQ(details.token(), token); 133 EXPECT_EQ(details.token(), token);
133 // Check memory tokens. 134 // Check memory tokens.
134 EXPECT_EQ(1U, memory_tokens->count(service)); 135 EXPECT_EQ(1U, memory_tokens->count(service));
135 EXPECT_EQ((*memory_tokens)[service], token); 136 EXPECT_EQ((*memory_tokens)[service], token);
136 } 137 }
137 }; 138 };
138 139
139 TEST_F(TokenServiceTest, SanityCheck) { 140 TEST_F(TokenServiceTest, SanityCheck) {
140 EXPECT_TRUE(service_.HasLsid()); 141 EXPECT_TRUE(service_->HasLsid());
141 EXPECT_EQ(service_.GetLsid(), "lsid"); 142 EXPECT_EQ(service_->GetLsid(), "lsid");
142 EXPECT_FALSE(service_.HasTokenForService("nonexistent service")); 143 EXPECT_FALSE(service_->HasTokenForService("nonexistent service"));
143 EXPECT_TRUE(service_.HasOAuthCredentials()); 144 EXPECT_TRUE(service_->HasOAuthCredentials());
144 EXPECT_EQ(service_.GetOAuthToken(), "oauth"); 145 EXPECT_EQ(service_->GetOAuthToken(), "oauth");
145 EXPECT_EQ(service_.GetOAuthSecret(), "secret"); 146 EXPECT_EQ(service_->GetOAuthSecret(), "secret");
146 } 147 }
147 148
148 TEST_F(TokenServiceTest, NoToken) { 149 TEST_F(TokenServiceTest, NoToken) {
149 EXPECT_FALSE(service_.HasTokenForService("nonexistent service")); 150 EXPECT_FALSE(service_->HasTokenForService("nonexistent service"));
150 EXPECT_EQ(service_.GetTokenForService("nonexistent service"), std::string()); 151 EXPECT_EQ(service_->GetTokenForService("nonexistent service"), std::string());
151 } 152 }
152 153
153 TEST_F(TokenServiceTest, NotificationSuccess) { 154 TEST_F(TokenServiceTest, NotificationSuccess) {
154 EXPECT_EQ(0U, success_tracker_.size()); 155 EXPECT_EQ(0U, success_tracker_.size());
155 EXPECT_EQ(0U, failure_tracker_.size()); 156 EXPECT_EQ(0U, failure_tracker_.size());
156 service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token"); 157 service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
157 EXPECT_EQ(1U, success_tracker_.size()); 158 EXPECT_EQ(1U, success_tracker_.size());
158 EXPECT_EQ(0U, failure_tracker_.size()); 159 EXPECT_EQ(0U, failure_tracker_.size());
159 160
160 TokenService::TokenAvailableDetails details = success_tracker_.details(); 161 TokenService::TokenAvailableDetails details = success_tracker_.details();
161 // MSVC doesn't like this comparison as EQ. 162 // MSVC doesn't like this comparison as EQ.
162 EXPECT_TRUE(details.service() == GaiaConstants::kSyncService); 163 EXPECT_TRUE(details.service() == GaiaConstants::kSyncService);
163 EXPECT_EQ(details.token(), "token"); 164 EXPECT_EQ(details.token(), "token");
164 } 165 }
165 166
166 TEST_F(TokenServiceTest, NotificationOAuthLoginTokenSuccess) { 167 TEST_F(TokenServiceTest, NotificationOAuthLoginTokenSuccess) {
167 EXPECT_EQ(0U, success_tracker_.size()); 168 EXPECT_EQ(0U, success_tracker_.size());
168 EXPECT_EQ(0U, failure_tracker_.size()); 169 EXPECT_EQ(0U, failure_tracker_.size());
169 service_.OnOAuthLoginTokenSuccess("rt1", "at1", 3600); 170 service_->OnOAuthLoginTokenSuccess("rt1", "at1", 3600);
170 EXPECT_EQ(1U, success_tracker_.size()); 171 EXPECT_EQ(1U, success_tracker_.size());
171 EXPECT_EQ(0U, failure_tracker_.size()); 172 EXPECT_EQ(0U, failure_tracker_.size());
172 173
173 TokenService::TokenAvailableDetails details = success_tracker_.details(); 174 TokenService::TokenAvailableDetails details = success_tracker_.details();
174 // MSVC doesn't like this comparison as EQ. 175 // MSVC doesn't like this comparison as EQ.
175 EXPECT_TRUE(details.service() == 176 EXPECT_TRUE(details.service() ==
176 GaiaConstants::kGaiaOAuth2LoginRefreshToken); 177 GaiaConstants::kGaiaOAuth2LoginRefreshToken);
177 EXPECT_EQ(details.token(), "rt1"); 178 EXPECT_EQ(details.token(), "rt1");
178 } 179 }
179 180
180 TEST_F(TokenServiceTest, NotificationSuccessOAuth) { 181 TEST_F(TokenServiceTest, NotificationSuccessOAuth) {
181 EXPECT_EQ(0U, success_tracker_.size()); 182 EXPECT_EQ(0U, success_tracker_.size());
182 EXPECT_EQ(0U, failure_tracker_.size()); 183 EXPECT_EQ(0U, failure_tracker_.size());
183 service_.OnOAuthWrapBridgeSuccess( 184 service_->OnOAuthWrapBridgeSuccess(
184 GaiaConstants::kSyncServiceOAuth, "token", "3600"); 185 GaiaConstants::kSyncServiceOAuth, "token", "3600");
185 EXPECT_EQ(1U, success_tracker_.size()); 186 EXPECT_EQ(1U, success_tracker_.size());
186 EXPECT_EQ(0U, failure_tracker_.size()); 187 EXPECT_EQ(0U, failure_tracker_.size());
187 188
188 TokenService::TokenAvailableDetails details = success_tracker_.details(); 189 TokenService::TokenAvailableDetails details = success_tracker_.details();
189 // MSVC doesn't like this comparison as EQ. 190 // MSVC doesn't like this comparison as EQ.
190 EXPECT_TRUE(details.service() == GaiaConstants::kSyncServiceOAuth); 191 EXPECT_TRUE(details.service() == GaiaConstants::kSyncServiceOAuth);
191 EXPECT_EQ(details.token(), "token"); 192 EXPECT_EQ(details.token(), "token");
192 } 193 }
193 194
194 TEST_F(TokenServiceTest, NotificationFailed) { 195 TEST_F(TokenServiceTest, NotificationFailed) {
195 EXPECT_EQ(0U, success_tracker_.size()); 196 EXPECT_EQ(0U, success_tracker_.size());
196 EXPECT_EQ(0U, failure_tracker_.size()); 197 EXPECT_EQ(0U, failure_tracker_.size());
197 GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED); 198 GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED);
198 service_.OnIssueAuthTokenFailure(GaiaConstants::kSyncService, error); 199 service_->OnIssueAuthTokenFailure(GaiaConstants::kSyncService, error);
199 EXPECT_EQ(0U, success_tracker_.size()); 200 EXPECT_EQ(0U, success_tracker_.size());
200 EXPECT_EQ(1U, failure_tracker_.size()); 201 EXPECT_EQ(1U, failure_tracker_.size());
201 202
202 TokenService::TokenRequestFailedDetails details = failure_tracker_.details(); 203 TokenService::TokenRequestFailedDetails details = failure_tracker_.details();
203 204
204 // MSVC doesn't like this comparison as EQ. 205 // MSVC doesn't like this comparison as EQ.
205 EXPECT_TRUE(details.service() == GaiaConstants::kSyncService); 206 EXPECT_TRUE(details.service() == GaiaConstants::kSyncService);
206 EXPECT_TRUE(details.error() == error); // Struct has no print function. 207 EXPECT_TRUE(details.error() == error); // Struct has no print function.
207 } 208 }
208 209
209 TEST_F(TokenServiceTest, NotificationOAuthLoginTokenFailed) { 210 TEST_F(TokenServiceTest, NotificationOAuthLoginTokenFailed) {
210 EXPECT_EQ(0U, success_tracker_.size()); 211 EXPECT_EQ(0U, success_tracker_.size());
211 EXPECT_EQ(0U, failure_tracker_.size()); 212 EXPECT_EQ(0U, failure_tracker_.size());
212 GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED); 213 GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED);
213 service_.OnOAuthLoginTokenFailure(error); 214 service_->OnOAuthLoginTokenFailure(error);
214 EXPECT_EQ(0U, success_tracker_.size()); 215 EXPECT_EQ(0U, success_tracker_.size());
215 EXPECT_EQ(1U, failure_tracker_.size()); 216 EXPECT_EQ(1U, failure_tracker_.size());
216 217
217 TokenService::TokenRequestFailedDetails details = failure_tracker_.details(); 218 TokenService::TokenRequestFailedDetails details = failure_tracker_.details();
218 219
219 // MSVC doesn't like this comparison as EQ. 220 // MSVC doesn't like this comparison as EQ.
220 EXPECT_TRUE(details.service() == 221 EXPECT_TRUE(details.service() ==
221 GaiaConstants::kGaiaOAuth2LoginRefreshToken); 222 GaiaConstants::kGaiaOAuth2LoginRefreshToken);
222 EXPECT_TRUE(details.error() == error); // Struct has no print function. 223 EXPECT_TRUE(details.error() == error); // Struct has no print function.
223 } 224 }
224 225
225 TEST_F(TokenServiceTest, NotificationFailedOAuth) { 226 TEST_F(TokenServiceTest, NotificationFailedOAuth) {
226 EXPECT_EQ(0U, success_tracker_.size()); 227 EXPECT_EQ(0U, success_tracker_.size());
227 EXPECT_EQ(0U, failure_tracker_.size()); 228 EXPECT_EQ(0U, failure_tracker_.size());
228 GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED); 229 GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED);
229 service_.OnOAuthWrapBridgeFailure(GaiaConstants::kSyncServiceOAuth, error); 230 service_->OnOAuthWrapBridgeFailure(GaiaConstants::kSyncServiceOAuth, error);
230 EXPECT_EQ(0U, success_tracker_.size()); 231 EXPECT_EQ(0U, success_tracker_.size());
231 EXPECT_EQ(1U, failure_tracker_.size()); 232 EXPECT_EQ(1U, failure_tracker_.size());
232 233
233 TokenService::TokenRequestFailedDetails details = failure_tracker_.details(); 234 TokenService::TokenRequestFailedDetails details = failure_tracker_.details();
234 235
235 // MSVC doesn't like this comparison as EQ. 236 // MSVC doesn't like this comparison as EQ.
236 EXPECT_TRUE(details.service() == GaiaConstants::kSyncServiceOAuth); 237 EXPECT_TRUE(details.service() == GaiaConstants::kSyncServiceOAuth);
237 EXPECT_TRUE(details.error() == error); // Struct has no print function. 238 EXPECT_TRUE(details.error() == error); // Struct has no print function.
238 } 239 }
239 240
240 TEST_F(TokenServiceTest, OnTokenSuccessUpdate) { 241 TEST_F(TokenServiceTest, OnTokenSuccessUpdate) {
241 service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token"); 242 service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
242 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService)); 243 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
243 EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncService), "token"); 244 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), "token");
244 245
245 service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token2"); 246 service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token2");
246 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService)); 247 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
247 EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncService), "token2"); 248 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService),
249 "token2");
248 250
249 service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, ""); 251 service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "");
250 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService)); 252 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
251 EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncService), ""); 253 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), "");
252 } 254 }
253 255
254 TEST_F(TokenServiceTest, OnOAuth2LoginTokenSuccessUpdate) { 256 TEST_F(TokenServiceTest, OnOAuth2LoginTokenSuccessUpdate) {
255 std::string service = GaiaConstants::kGaiaOAuth2LoginRefreshToken; 257 std::string service = GaiaConstants::kGaiaOAuth2LoginRefreshToken;
256 service_.OnOAuthLoginTokenSuccess("rt1", "at1", 3600); 258 service_->OnOAuthLoginTokenSuccess("rt1", "at1", 3600);
257 EXPECT_TRUE(service_.HasOAuthLoginToken()); 259 EXPECT_TRUE(service_->HasOAuthLoginToken());
258 EXPECT_EQ(service_.GetOAuth2LoginRefreshToken(), "rt1"); 260 EXPECT_EQ(service_->GetOAuth2LoginRefreshToken(), "rt1");
259 261
260 service_.OnOAuthLoginTokenSuccess("rt2", "at2", 3600); 262 service_->OnOAuthLoginTokenSuccess("rt2", "at2", 3600);
261 EXPECT_TRUE(service_.HasOAuthLoginToken()); 263 EXPECT_TRUE(service_->HasOAuthLoginToken());
262 EXPECT_EQ(service_.GetOAuth2LoginRefreshToken(), "rt2"); 264 EXPECT_EQ(service_->GetOAuth2LoginRefreshToken(), "rt2");
263 265
264 service_.OnOAuthLoginTokenSuccess("rt3", "at3", 3600); 266 service_->OnOAuthLoginTokenSuccess("rt3", "at3", 3600);
265 EXPECT_TRUE(service_.HasOAuthLoginToken()); 267 EXPECT_TRUE(service_->HasOAuthLoginToken());
266 EXPECT_EQ(service_.GetOAuth2LoginRefreshToken(), "rt3"); 268 EXPECT_EQ(service_->GetOAuth2LoginRefreshToken(), "rt3");
267 } 269 }
268 270
269 TEST_F(TokenServiceTest, OnTokenSuccess) { 271 TEST_F(TokenServiceTest, OnTokenSuccess) {
270 // Don't "start fetching", just go ahead and issue the callback. 272 // Don't "start fetching", just go ahead and issue the callback.
271 service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token"); 273 service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
272 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService)); 274 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
273 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth)); 275 EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
274 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kTalkService)); 276 EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService));
275 // Gaia returns the entire result as the token so while this is a shared 277 // Gaia returns the entire result as the token so while this is a shared
276 // result with ClientLogin, it doesn't matter, we should still get it back. 278 // result with ClientLogin, it doesn't matter, we should still get it back.
277 EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncService), "token"); 279 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), "token");
278 280
279 // Try the OAuth service. 281 // Try the OAuth service.
280 service_.OnOAuthWrapBridgeSuccess( 282 service_->OnOAuthWrapBridgeSuccess(
281 GaiaConstants::kSyncServiceOAuth, "token2", "3600"); 283 GaiaConstants::kSyncServiceOAuth, "token2", "3600");
282 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth)); 284 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
283 EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncServiceOAuth), 285 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncServiceOAuth),
284 "token2"); 286 "token2");
285 287
286 // First didn't change. 288 // First didn't change.
287 EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncService), "token"); 289 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), "token");
288 } 290 }
289 291
290 TEST_F(TokenServiceTest, ResetSimple) { 292 TEST_F(TokenServiceTest, ResetSimple) {
291 service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token"); 293 service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
292 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService)); 294 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
293 EXPECT_TRUE(service_.HasLsid()); 295 EXPECT_TRUE(service_->HasLsid());
294 service_.OnOAuthGetAccessTokenSuccess("token2", "secret"); 296 service_->OnOAuthGetAccessTokenSuccess("token2", "secret");
295 service_.OnOAuthWrapBridgeSuccess( 297 service_->OnOAuthWrapBridgeSuccess(
296 GaiaConstants::kSyncServiceOAuth, "token3", "4321"); 298 GaiaConstants::kSyncServiceOAuth, "token3", "4321");
297 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth)); 299 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
298 EXPECT_TRUE(service_.HasOAuthCredentials()); 300 EXPECT_TRUE(service_->HasOAuthCredentials());
299 301
300 service_.ResetCredentialsInMemory(); 302 service_->ResetCredentialsInMemory();
301 303
302 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncService)); 304 EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncService));
303 EXPECT_FALSE(service_.HasLsid()); 305 EXPECT_FALSE(service_->HasLsid());
304 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth)); 306 EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
305 EXPECT_FALSE(service_.HasOAuthCredentials()); 307 EXPECT_FALSE(service_->HasOAuthCredentials());
306 } 308 }
307 309
308 TEST_F(TokenServiceTest, ResetComplex) { 310 TEST_F(TokenServiceTest, ResetComplex) {
309 TestURLFetcherFactory factory; 311 TestURLFetcherFactory factory;
310 service_.StartFetchingTokens(); 312 service_->StartFetchingTokens();
311 // You have to call delegates by hand with the test fetcher, 313 // You have to call delegates by hand with the test fetcher,
312 // Let's pretend only one returned. 314 // Let's pretend only one returned.
313 315
314 service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "eraseme"); 316 service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "eraseme");
315 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService)); 317 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
316 EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncService), 318 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService),
317 "eraseme"); 319 "eraseme");
318 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth)); 320 EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
319 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kTalkService)); 321 EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService));
320 322
321 service_.OnOAuthWrapBridgeSuccess( 323 service_->OnOAuthWrapBridgeSuccess(
322 GaiaConstants::kSyncServiceOAuth, "erasemetoo", "1234"); 324 GaiaConstants::kSyncServiceOAuth, "erasemetoo", "1234");
323 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService)); 325 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
324 EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncService), 326 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService),
325 "eraseme"); 327 "eraseme");
326 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth)); 328 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
327 EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncServiceOAuth), 329 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncServiceOAuth),
328 "erasemetoo"); 330 "erasemetoo");
329 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kTalkService)); 331 EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService));
330 332
331 service_.ResetCredentialsInMemory(); 333 service_->ResetCredentialsInMemory();
332 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncService)); 334 EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncService));
333 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth)); 335 EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
334 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kTalkService)); 336 EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService));
335 EXPECT_FALSE(service_.HasLsid()); 337 EXPECT_FALSE(service_->HasLsid());
336 EXPECT_FALSE(service_.HasOAuthCredentials()); 338 EXPECT_FALSE(service_->HasOAuthCredentials());
337 339
338 // Now start using it again. 340 // Now start using it again.
339 service_.UpdateCredentials(credentials_); 341 service_->UpdateCredentials(credentials_);
340 EXPECT_TRUE(service_.HasLsid()); 342 EXPECT_TRUE(service_->HasLsid());
341 service_.StartFetchingTokens(); 343 service_->StartFetchingTokens();
342 service_.UpdateOAuthCredentials(oauth_token_, oauth_secret_); 344 service_->UpdateOAuthCredentials(oauth_token_, oauth_secret_);
343 EXPECT_TRUE(service_.HasOAuthCredentials()); 345 EXPECT_TRUE(service_->HasOAuthCredentials());
344 service_.StartFetchingOAuthTokens(); 346 service_->StartFetchingOAuthTokens();
345 347
346 service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token"); 348 service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
347 service_.OnOAuthWrapBridgeSuccess( 349 service_->OnOAuthWrapBridgeSuccess(
348 GaiaConstants::kSyncServiceOAuth, "token2", "3600"); 350 GaiaConstants::kSyncServiceOAuth, "token2", "3600");
349 service_.OnIssueAuthTokenSuccess(GaiaConstants::kTalkService, "token3"); 351 service_->OnIssueAuthTokenSuccess(GaiaConstants::kTalkService, "token3");
350 352
351 EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncService), "token"); 353 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), "token");
352 EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncServiceOAuth), 354 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncServiceOAuth),
353 "token2"); 355 "token2");
354 EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kTalkService), "token3"); 356 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kTalkService),
357 "token3");
355 } 358 }
356 359
357 TEST_F(TokenServiceTest, FullIntegration) { 360 TEST_F(TokenServiceTest, FullIntegration) {
358 std::string result = "SID=sid\nLSID=lsid\nAuth=auth\n"; 361 std::string result = "SID=sid\nLSID=lsid\nAuth=auth\n";
359 362
360 { 363 {
361 MockFactory<MockFetcher> factory; 364 MockFactory<MockFetcher> factory;
362 factory.set_results(result); 365 factory.set_results(result);
363 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncService)); 366 EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncService));
364 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth)); 367 EXPECT_FALSE(service_->HasTokenForService(
365 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kTalkService)); 368 GaiaConstants::kSyncServiceOAuth));
366 service_.StartFetchingTokens(); 369 EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService));
370 service_->StartFetchingTokens();
367 } 371 }
368 372
369 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService)); 373 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
370 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kTalkService)); 374 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kTalkService));
371 // Gaia returns the entire result as the token so while this is a shared 375 // Gaia returns the entire result as the token so while this is a shared
372 // result with ClientLogin, it doesn't matter, we should still get it back. 376 // result with ClientLogin, it doesn't matter, we should still get it back.
373 EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncService), result); 377 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), result);
374 EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kTalkService), result); 378 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kTalkService), result);
375 379
376 service_.ResetCredentialsInMemory(); 380 service_->ResetCredentialsInMemory();
377 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncService)); 381 EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncService));
378 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kTalkService)); 382 EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService));
379 } 383 }
380 384
381 TEST_F(TokenServiceTest, LoadTokensIntoMemoryBasic) { 385 TEST_F(TokenServiceTest, LoadTokensIntoMemoryBasic) {
382 // Validate that the method sets proper data in notifications and map. 386 // Validate that the method sets proper data in notifications and map.
383 std::map<std::string, std::string> db_tokens; 387 std::map<std::string, std::string> db_tokens;
384 std::map<std::string, std::string> memory_tokens; 388 std::map<std::string, std::string> memory_tokens;
385 389
386 service_.LoadTokensIntoMemory(db_tokens, &memory_tokens); 390 service_->LoadTokensIntoMemory(db_tokens, &memory_tokens);
387 EXPECT_TRUE(db_tokens.empty()); 391 EXPECT_TRUE(db_tokens.empty());
388 EXPECT_TRUE(memory_tokens.empty()); 392 EXPECT_TRUE(memory_tokens.empty());
389 EXPECT_EQ(0U, success_tracker_.size()); 393 EXPECT_EQ(0U, success_tracker_.size());
390 394
391 std::string service; 395 std::string service;
392 std::string token; 396 std::string token;
393 for (int i = 0; i < TokenService::kNumServices; ++i) { 397 for (int i = 0; i < TokenService::kNumServices; ++i) {
394 service = TokenService::kServices[i]; 398 service = TokenService::kServices[i];
395 TestLoadSingleToken(&db_tokens, &memory_tokens, service); 399 TestLoadSingleToken(&db_tokens, &memory_tokens, service);
396 } 400 }
397 for (int i = 0; i < TokenService::kNumOAuthServices; ++i) { 401 for (int i = 0; i < TokenService::kNumOAuthServices; ++i) {
398 service = TokenService::kOAuthServices[i]; 402 service = TokenService::kOAuthServices[i];
399 TestLoadSingleToken(&db_tokens, &memory_tokens, service); 403 TestLoadSingleToken(&db_tokens, &memory_tokens, service);
400 } 404 }
401 service = GaiaConstants::kGaiaOAuth2LoginRefreshToken; 405 service = GaiaConstants::kGaiaOAuth2LoginRefreshToken;
402 TestLoadSingleToken(&db_tokens, &memory_tokens, service); 406 TestLoadSingleToken(&db_tokens, &memory_tokens, service);
403 service = GaiaConstants::kGaiaOAuth2LoginAccessToken; 407 service = GaiaConstants::kGaiaOAuth2LoginAccessToken;
404 TestLoadSingleToken(&db_tokens, &memory_tokens, service); 408 TestLoadSingleToken(&db_tokens, &memory_tokens, service);
405 } 409 }
406 410
407 TEST_F(TokenServiceTest, LoadTokensIntoMemoryAdvanced) { 411 TEST_F(TokenServiceTest, LoadTokensIntoMemoryAdvanced) {
408 // LoadTokensIntoMemory should avoid setting tokens already in the 412 // LoadTokensIntoMemory should avoid setting tokens already in the
409 // token map. 413 // token map.
410 std::map<std::string, std::string> db_tokens; 414 std::map<std::string, std::string> db_tokens;
411 std::map<std::string, std::string> memory_tokens; 415 std::map<std::string, std::string> memory_tokens;
412 416
413 db_tokens["ignore"] = "token"; 417 db_tokens["ignore"] = "token";
414 418
415 service_.LoadTokensIntoMemory(db_tokens, &memory_tokens); 419 service_->LoadTokensIntoMemory(db_tokens, &memory_tokens);
416 EXPECT_TRUE(memory_tokens.empty()); 420 EXPECT_TRUE(memory_tokens.empty());
417 db_tokens[GaiaConstants::kSyncService] = "pepper"; 421 db_tokens[GaiaConstants::kSyncService] = "pepper";
418 422
419 service_.LoadTokensIntoMemory(db_tokens, &memory_tokens); 423 service_->LoadTokensIntoMemory(db_tokens, &memory_tokens);
420 EXPECT_EQ(1U, memory_tokens.count(GaiaConstants::kSyncService)); 424 EXPECT_EQ(1U, memory_tokens.count(GaiaConstants::kSyncService));
421 EXPECT_EQ(memory_tokens[GaiaConstants::kSyncService], "pepper"); 425 EXPECT_EQ(memory_tokens[GaiaConstants::kSyncService], "pepper");
422 EXPECT_EQ(1U, success_tracker_.size()); 426 EXPECT_EQ(1U, success_tracker_.size());
423 success_tracker_.Reset(); 427 success_tracker_.Reset();
424 428
425 // SyncService token is already in memory. Pretend we got it off 429 // SyncService token is already in memory. Pretend we got it off
426 // the disk as well, but an older token. 430 // the disk as well, but an older token.
427 db_tokens[GaiaConstants::kSyncService] = "ignoreme"; 431 db_tokens[GaiaConstants::kSyncService] = "ignoreme";
428 db_tokens[GaiaConstants::kSyncServiceOAuth] = "tomato"; 432 db_tokens[GaiaConstants::kSyncServiceOAuth] = "tomato";
429 service_.LoadTokensIntoMemory(db_tokens, &memory_tokens); 433 service_->LoadTokensIntoMemory(db_tokens, &memory_tokens);
430 434
431 EXPECT_EQ(2U, memory_tokens.size()); 435 EXPECT_EQ(2U, memory_tokens.size());
432 EXPECT_EQ(1U, memory_tokens.count(GaiaConstants::kSyncServiceOAuth)); 436 EXPECT_EQ(1U, memory_tokens.count(GaiaConstants::kSyncServiceOAuth));
433 EXPECT_EQ(memory_tokens[GaiaConstants::kSyncServiceOAuth], "tomato"); 437 EXPECT_EQ(memory_tokens[GaiaConstants::kSyncServiceOAuth], "tomato");
434 EXPECT_EQ(1U, success_tracker_.size()); 438 EXPECT_EQ(1U, success_tracker_.size());
435 EXPECT_EQ(1U, memory_tokens.count(GaiaConstants::kSyncService)); 439 EXPECT_EQ(1U, memory_tokens.count(GaiaConstants::kSyncService));
436 EXPECT_EQ(memory_tokens[GaiaConstants::kSyncService], "pepper"); 440 EXPECT_EQ(memory_tokens[GaiaConstants::kSyncService], "pepper");
437 } 441 }
438 442
439 TEST_F(TokenServiceTest, WebDBLoadIntegration) { 443 TEST_F(TokenServiceTest, WebDBLoadIntegration) {
440 service_.LoadTokensFromDB(); 444 service_->LoadTokensFromDB();
441 WaitForDBLoadCompletion(); 445 WaitForDBLoadCompletion();
442 EXPECT_EQ(0U, success_tracker_.size()); 446 EXPECT_EQ(0U, success_tracker_.size());
443 447
444 // Should result in DB write. 448 // Should result in DB write.
445 service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token"); 449 service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
446 EXPECT_EQ(1U, success_tracker_.size()); 450 EXPECT_EQ(1U, success_tracker_.size());
447 service_.OnOAuthGetAccessTokenSuccess("token1", "secret"); 451 service_->OnOAuthGetAccessTokenSuccess("token1", "secret");
448 service_.OnOAuthWrapBridgeSuccess( 452 service_->OnOAuthWrapBridgeSuccess(
449 GaiaConstants::kSyncServiceOAuth, "token2", "3600"); 453 GaiaConstants::kSyncServiceOAuth, "token2", "3600");
450 EXPECT_EQ(2U, success_tracker_.size()); 454 EXPECT_EQ(2U, success_tracker_.size());
451 455
452 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService)); 456 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
453 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth)); 457 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
454 // Clean slate. 458 // Clean slate.
455 service_.ResetCredentialsInMemory(); 459 service_->ResetCredentialsInMemory();
456 success_tracker_.Reset(); 460 success_tracker_.Reset();
457 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncService)); 461 EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncService));
458 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth)); 462 EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
459 463
460 service_.LoadTokensFromDB(); 464 service_->LoadTokensFromDB();
461 WaitForDBLoadCompletion(); 465 WaitForDBLoadCompletion();
462 466
463 EXPECT_EQ(2U, success_tracker_.size()); 467 EXPECT_EQ(2U, success_tracker_.size());
464 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService)); 468 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
465 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth)); 469 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
466 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kTalkService)); 470 EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService));
467 EXPECT_TRUE(service_.HasLsid()); 471 EXPECT_TRUE(service_->HasLsid());
468 EXPECT_TRUE(service_.HasOAuthCredentials()); 472 EXPECT_TRUE(service_->HasOAuthCredentials());
469 } 473 }
470 474
471 TEST_F(TokenServiceTest, MultipleLoadResetIntegration) { 475 TEST_F(TokenServiceTest, MultipleLoadResetIntegration) {
472 // Should result in DB write. 476 // Should result in DB write.
473 service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token"); 477 service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
474 service_.ResetCredentialsInMemory(); 478 service_->ResetCredentialsInMemory();
475 success_tracker_.Reset(); 479 success_tracker_.Reset();
476 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncService)); 480 EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncService));
477 EXPECT_FALSE(service_.HasLsid()); 481 EXPECT_FALSE(service_->HasLsid());
478 482
479 service_.OnOAuthGetAccessTokenSuccess("token2", "secret"); 483 service_->OnOAuthGetAccessTokenSuccess("token2", "secret");
480 service_.OnOAuthWrapBridgeSuccess( 484 service_->OnOAuthWrapBridgeSuccess(
481 GaiaConstants::kSyncServiceOAuth, "token3", "3600"); 485 GaiaConstants::kSyncServiceOAuth, "token3", "3600");
482 service_.ResetCredentialsInMemory(); 486 service_->ResetCredentialsInMemory();
483 success_tracker_.Reset(); 487 success_tracker_.Reset();
484 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth)); 488 EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
485 EXPECT_FALSE(service_.HasOAuthCredentials()); 489 EXPECT_FALSE(service_->HasOAuthCredentials());
486 490
487 service_.LoadTokensFromDB(); 491 service_->LoadTokensFromDB();
488 WaitForDBLoadCompletion(); 492 WaitForDBLoadCompletion();
489 493
490 service_.LoadTokensFromDB(); // Should do nothing. 494 service_->LoadTokensFromDB(); // Should do nothing.
491 WaitForDBLoadCompletion(); 495 WaitForDBLoadCompletion();
492 496
493 EXPECT_EQ(2U, success_tracker_.size()); 497 EXPECT_EQ(2U, success_tracker_.size());
494 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService)); 498 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
495 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth)); 499 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
496 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kTalkService)); 500 EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService));
497 EXPECT_TRUE(service_.HasLsid()); 501 EXPECT_TRUE(service_->HasLsid());
498 EXPECT_TRUE(service_.HasOAuthCredentials()); 502 EXPECT_TRUE(service_->HasOAuthCredentials());
499 503
500 // Reset it one more time so there's no surprises. 504 // Reset it one more time so there's no surprises.
501 service_.ResetCredentialsInMemory(); 505 service_->ResetCredentialsInMemory();
502 success_tracker_.Reset(); 506 success_tracker_.Reset();
503 507
504 service_.LoadTokensFromDB(); 508 service_->LoadTokensFromDB();
505 WaitForDBLoadCompletion(); 509 WaitForDBLoadCompletion();
506 510
507 EXPECT_EQ(2U, success_tracker_.size()); 511 EXPECT_EQ(2U, success_tracker_.size());
508 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService)); 512 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
509 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncServiceOAuth)); 513 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth));
510 EXPECT_TRUE(service_.HasLsid()); 514 EXPECT_TRUE(service_->HasLsid());
511 EXPECT_TRUE(service_.HasOAuthCredentials()); 515 EXPECT_TRUE(service_->HasOAuthCredentials());
512 } 516 }
513 517
514 #ifndef NDEBUG 518 #ifndef NDEBUG
515 class TokenServiceCommandLineTest : public TokenServiceTestHarness { 519 class TokenServiceCommandLineTest : public TokenServiceTestHarness {
516 public: 520 public:
517 virtual void SetUp() { 521 virtual void SetUp() {
518 CommandLine original_cl(*CommandLine::ForCurrentProcess()); 522 CommandLine original_cl(*CommandLine::ForCurrentProcess());
519 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 523 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
520 switches::kSetToken, "my_service:my_value"); 524 switches::kSetToken, "my_service:my_value");
521 TokenServiceTestHarness::SetUp(); 525 TokenServiceTestHarness::SetUp();
522 service_.UpdateCredentials(credentials_); 526 service_->UpdateCredentials(credentials_);
523 service_.UpdateOAuthCredentials(oauth_token_, oauth_secret_); 527 service_->UpdateOAuthCredentials(oauth_token_, oauth_secret_);
524 528
525 *CommandLine::ForCurrentProcess() = original_cl; 529 *CommandLine::ForCurrentProcess() = original_cl;
526 } 530 }
527 }; 531 };
528 532
529 TEST_F(TokenServiceCommandLineTest, TestValueOverride) { 533 TEST_F(TokenServiceCommandLineTest, TestValueOverride) {
530 EXPECT_TRUE(service_.HasTokenForService("my_service")); 534 EXPECT_TRUE(service_->HasTokenForService("my_service"));
531 EXPECT_EQ("my_value", service_.GetTokenForService("my_service")); 535 EXPECT_EQ("my_value", service_->GetTokenForService("my_service"));
532 } 536 }
533 #endif // ifndef NDEBUG 537 #endif // ifndef NDEBUG
OLDNEW
« no previous file with comments | « chrome/browser/signin/token_service_unittest.h ('k') | chrome/browser/signin/ubertoken_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698