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

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

Issue 23767004: Revert "Handling of multiple concurrent requests from different clients in OAuth2TokenService" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 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 "base/run_loop.h" 5 #include "base/run_loop.h"
6 #include "chrome/browser/signin/profile_oauth2_token_service.h" 6 #include "chrome/browser/signin/profile_oauth2_token_service.h"
7 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 7 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
8 #include "chrome/browser/signin/token_service_unittest.h" 8 #include "chrome/browser/signin/token_service_unittest.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "google_apis/gaia/gaia_constants.h" 10 #include "google_apis/gaia/gaia_constants.h"
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 service()->EraseTokensFromDB(); 324 service()->EraseTokensFromDB();
325 ExpectOneTokensClearedNotification(); 325 ExpectOneTokensClearedNotification();
326 326
327 EXPECT_EQ(0, oauth2_service_->cache_size_for_testing()); 327 EXPECT_EQ(0, oauth2_service_->cache_size_for_testing());
328 service()->IssueAuthTokenForTest(GaiaConstants::kGaiaOAuth2LoginRefreshToken, 328 service()->IssueAuthTokenForTest(GaiaConstants::kGaiaOAuth2LoginRefreshToken,
329 "refreshToken"); 329 "refreshToken");
330 ExpectOneTokenAvailableNotification(); 330 ExpectOneTokenAvailableNotification();
331 331
332 request = oauth2_service_->StartRequest(scope_list, &consumer_); 332 request = oauth2_service_->StartRequest(scope_list, &consumer_);
333 base::RunLoop().RunUntilIdle(); 333 base::RunLoop().RunUntilIdle();
334 fetcher = factory_.GetFetcherByID(1); 334 fetcher = factory_.GetFetcherByID(0);
335 fetcher->set_response_code(net::HTTP_OK); 335 fetcher->set_response_code(net::HTTP_OK);
336 fetcher->SetResponseString(GetValidTokenResponse("another token", 3600)); 336 fetcher->SetResponseString(GetValidTokenResponse("another token", 3600));
337 fetcher->delegate()->OnURLFetchComplete(fetcher); 337 fetcher->delegate()->OnURLFetchComplete(fetcher);
338 EXPECT_EQ(2, consumer_.number_of_successful_tokens_); 338 EXPECT_EQ(2, consumer_.number_of_successful_tokens_);
339 EXPECT_EQ(0, consumer_.number_of_errors_); 339 EXPECT_EQ(0, consumer_.number_of_errors_);
340 EXPECT_EQ("another token", consumer_.last_token_); 340 EXPECT_EQ("another token", consumer_.last_token_);
341 EXPECT_EQ(1, oauth2_service_->cache_size_for_testing()); 341 EXPECT_EQ(1, oauth2_service_->cache_size_for_testing());
342 } 342 }
343 343
344 // Android doesn't use the current profile's TokenService login refresh token. 344 // Android doesn't use the current profile's TokenService login refresh token.
345 #if !defined(OS_ANDROID) 345 #if !defined(OS_ANDROID)
346 TEST_F(ProfileOAuth2TokenServiceTest, StaleRefreshTokensNotCached) { 346 TEST_F(ProfileOAuth2TokenServiceTest, StaleRefreshTokensNotCached) {
347 EXPECT_FALSE(service()->HasOAuthLoginToken()); 347 EXPECT_FALSE(service()->HasOAuthLoginToken());
348 EXPECT_FALSE(oauth2_service_->ShouldCacheForRefreshToken(service(), "T1")); 348 EXPECT_FALSE(oauth2_service_->ShouldCacheForRefreshToken(service(), "T1"));
349 349
350 service()->IssueAuthTokenForTest(GaiaConstants::kGaiaOAuth2LoginRefreshToken, 350 service()->IssueAuthTokenForTest(GaiaConstants::kGaiaOAuth2LoginRefreshToken,
351 "T1"); 351 "T1");
352 ExpectOneTokenAvailableNotification(); 352 ExpectOneTokenAvailableNotification();
353 EXPECT_TRUE(oauth2_service_->ShouldCacheForRefreshToken(service(), "T1")); 353 EXPECT_TRUE(oauth2_service_->ShouldCacheForRefreshToken(service(), "T1"));
354 EXPECT_FALSE(oauth2_service_->ShouldCacheForRefreshToken(service(), "T2")); 354 EXPECT_FALSE(oauth2_service_->ShouldCacheForRefreshToken(service(), "T2"));
355 355
356 service()->IssueAuthTokenForTest(GaiaConstants::kGaiaOAuth2LoginRefreshToken, 356 service()->IssueAuthTokenForTest(GaiaConstants::kGaiaOAuth2LoginRefreshToken,
357 "T2"); 357 "T2");
358 ExpectOneTokenAvailableNotification(); 358 ExpectOneTokenAvailableNotification();
359 EXPECT_TRUE(oauth2_service_->ShouldCacheForRefreshToken(service(), "T2")); 359 EXPECT_TRUE(oauth2_service_->ShouldCacheForRefreshToken(service(), "T2"));
360 EXPECT_FALSE(oauth2_service_->ShouldCacheForRefreshToken(NULL, "T2")); 360 EXPECT_FALSE(oauth2_service_->ShouldCacheForRefreshToken(NULL, "T2"));
361 } 361 }
362 #endif 362 #endif
OLDNEW
« no previous file with comments | « chrome/browser/signin/profile_oauth2_token_service.cc ('k') | chrome/browser/sync/test_profile_sync_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698