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

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

Issue 12647008: Refactor OAuth2TokenService to have profile- and device-based implementations. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: move function to minimize diff Created 7 years, 9 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
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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService)); 227 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
228 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), 228 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService),
229 "token2"); 229 "token2");
230 230
231 service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, ""); 231 service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "");
232 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService)); 232 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService));
233 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), ""); 233 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), "");
234 } 234 }
235 235
236 TEST_F(TokenServiceTest, OnOAuth2LoginTokenSuccessUpdate) { 236 TEST_F(TokenServiceTest, OnOAuth2LoginTokenSuccessUpdate) {
237 std::string service = GaiaConstants::kGaiaOAuth2LoginRefreshToken; 237 EXPECT_FALSE(service_->HasOAuthLoginToken());
238
238 service_->OnClientOAuthSuccess( 239 service_->OnClientOAuthSuccess(
239 GaiaAuthConsumer::ClientOAuthResult("rt1", "at1", 3600)); 240 GaiaAuthConsumer::ClientOAuthResult("rt1", "at1", 3600));
240 EXPECT_TRUE(service_->HasOAuthLoginToken()); 241 EXPECT_TRUE(service_->HasOAuthLoginToken());
241 EXPECT_EQ(service_->GetOAuth2LoginRefreshToken(), "rt1"); 242 EXPECT_EQ(service_->GetOAuth2LoginRefreshToken(), "rt1");
242 243
243 service_->OnClientOAuthSuccess( 244 service_->OnClientOAuthSuccess(
244 GaiaAuthConsumer::ClientOAuthResult("rt2", "at2", 3600)); 245 GaiaAuthConsumer::ClientOAuthResult("rt2", "at2", 3600));
245 EXPECT_TRUE(service_->HasOAuthLoginToken()); 246 EXPECT_TRUE(service_->HasOAuthLoginToken());
246 EXPECT_EQ(service_->GetOAuth2LoginRefreshToken(), "rt2"); 247 EXPECT_EQ(service_->GetOAuth2LoginRefreshToken(), "rt2");
247 248
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 421
421 *CommandLine::ForCurrentProcess() = original_cl; 422 *CommandLine::ForCurrentProcess() = original_cl;
422 } 423 }
423 }; 424 };
424 425
425 TEST_F(TokenServiceCommandLineTest, TestValueOverride) { 426 TEST_F(TokenServiceCommandLineTest, TestValueOverride) {
426 EXPECT_TRUE(service_->HasTokenForService("my_service")); 427 EXPECT_TRUE(service_->HasTokenForService("my_service"));
427 EXPECT_EQ("my_value", service_->GetTokenForService("my_service")); 428 EXPECT_EQ("my_value", service_->GetTokenForService("my_service"));
428 } 429 }
429 #endif // ifndef NDEBUG 430 #endif // ifndef NDEBUG
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698