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

Side by Side Diff: chrome/browser/net/gaia/token_service_unittest.cc

Issue 8769053: Remove stuff in TokenService that is not needed anymore (due to OAuth based approach): (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/net/gaia/token_service_unittest.h" 7 #include "chrome/browser/net/gaia/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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 // Gaia returns the entire result as the token so while this is a shared 371 // 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. 372 // result with ClientLogin, it doesn't matter, we should still get it back.
373 EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncService), result); 373 EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kSyncService), result);
374 EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kTalkService), result); 374 EXPECT_EQ(service_.GetTokenForService(GaiaConstants::kTalkService), result);
375 375
376 service_.ResetCredentialsInMemory(); 376 service_.ResetCredentialsInMemory();
377 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncService)); 377 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kSyncService));
378 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kTalkService)); 378 EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kTalkService));
379 } 379 }
380 380
381 TEST_F(TokenServiceTest, FullIntegrationNewServicesAdded) {
382 std::string token1 = "token1";
383
384 for (int i = 0; i < TokenService::kNumServices; ++i) {
385 const char* service = TokenService::kServices[i];
386 EXPECT_FALSE(service_.HasTokenForService(service));
387 }
388 {
389 MockFactory<MockFetcher> factory;
390 factory.set_results(token1);
391 service_.StartFetchingTokens();
392 }
393
394 for (int i = 0; i < TokenService::kNumServices; ++i) {
395 const char* service = TokenService::kServices[i];
396 EXPECT_TRUE(service_.HasTokenForService(service));
397 EXPECT_EQ(token1, service_.GetTokenForService(service));
398 }
399
400 // Clear tokens for some services to simulate that those services got
401 // added in a new Chrome release.
402 service_.token_map_.erase(GaiaConstants::kLSOService);
403 service_.token_map_.erase(GaiaConstants::kCWSService);
404
405 for (int i = 0; i < TokenService::kNumServices; ++i) {
406 const char* service = TokenService::kServices[i];
407 if (service == GaiaConstants::kLSOService ||
408 service == GaiaConstants::kCWSService) {
409 EXPECT_FALSE(service_.HasTokenForService(service));
410 } else {
411 EXPECT_TRUE(service_.HasTokenForService(service));
412 EXPECT_EQ(token1, service_.GetTokenForService(service));
413 }
414 }
415
416 std::string token2 = "token2";
417 {
418 MockFactory<MockFetcher> factory;
419 factory.set_results(token2);
420 service_.StartFetchingMissingTokens();
421 }
422
423 for (int i = 0; i < TokenService::kNumServices; ++i) {
424 const char* service = TokenService::kServices[i];
425 EXPECT_TRUE(service_.HasTokenForService(service));
426 if (service == GaiaConstants::kLSOService ||
427 service == GaiaConstants::kCWSService) {
428 EXPECT_EQ(token2, service_.GetTokenForService(service));
429 } else {
430 EXPECT_EQ(token1, service_.GetTokenForService(service));
431 }
432 }
433 }
434
435 TEST_F(TokenServiceTest, LoadTokensIntoMemoryBasic) { 381 TEST_F(TokenServiceTest, LoadTokensIntoMemoryBasic) {
436 // Validate that the method sets proper data in notifications and map. 382 // Validate that the method sets proper data in notifications and map.
437 std::map<std::string, std::string> db_tokens; 383 std::map<std::string, std::string> db_tokens;
438 std::map<std::string, std::string> memory_tokens; 384 std::map<std::string, std::string> memory_tokens;
439 385
440 service_.LoadTokensIntoMemory(db_tokens, &memory_tokens); 386 service_.LoadTokensIntoMemory(db_tokens, &memory_tokens);
441 EXPECT_TRUE(db_tokens.empty()); 387 EXPECT_TRUE(db_tokens.empty());
442 EXPECT_TRUE(memory_tokens.empty()); 388 EXPECT_TRUE(memory_tokens.empty());
443 EXPECT_EQ(0U, success_tracker_.size()); 389 EXPECT_EQ(0U, success_tracker_.size());
444 390
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 524
579 *CommandLine::ForCurrentProcess() = original_cl; 525 *CommandLine::ForCurrentProcess() = original_cl;
580 } 526 }
581 }; 527 };
582 528
583 TEST_F(TokenServiceCommandLineTest, TestValueOverride) { 529 TEST_F(TokenServiceCommandLineTest, TestValueOverride) {
584 EXPECT_TRUE(service_.HasTokenForService("my_service")); 530 EXPECT_TRUE(service_.HasTokenForService("my_service"));
585 EXPECT_EQ("my_value", service_.GetTokenForService("my_service")); 531 EXPECT_EQ("my_value", service_.GetTokenForService("my_service"));
586 } 532 }
587 #endif // ifndef NDEBUG 533 #endif // ifndef NDEBUG
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698