OLD | NEW |
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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService)); | 224 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService)); |
225 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), | 225 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), |
226 "token2"); | 226 "token2"); |
227 | 227 |
228 service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, std::string()); | 228 service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, std::string()); |
229 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService)); | 229 EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService)); |
230 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), ""); | 230 EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), ""); |
231 } | 231 } |
232 | 232 |
233 TEST_F(TokenServiceTest, OnOAuth2LoginTokenSuccessUpdate) { | 233 TEST_F(TokenServiceTest, OnOAuth2LoginTokenSuccessUpdate) { |
234 std::string service = GaiaConstants::kGaiaOAuth2LoginRefreshToken; | 234 EXPECT_FALSE(service_->HasOAuthLoginToken()); |
| 235 |
235 service_->OnClientOAuthSuccess( | 236 service_->OnClientOAuthSuccess( |
236 GaiaAuthConsumer::ClientOAuthResult("rt1", "at1", 3600)); | 237 GaiaAuthConsumer::ClientOAuthResult("rt1", "at1", 3600)); |
237 EXPECT_TRUE(service_->HasOAuthLoginToken()); | 238 EXPECT_TRUE(service_->HasOAuthLoginToken()); |
238 EXPECT_EQ(service_->GetOAuth2LoginRefreshToken(), "rt1"); | 239 EXPECT_EQ(service_->GetOAuth2LoginRefreshToken(), "rt1"); |
239 | 240 |
240 service_->OnClientOAuthSuccess( | 241 service_->OnClientOAuthSuccess( |
241 GaiaAuthConsumer::ClientOAuthResult("rt2", "at2", 3600)); | 242 GaiaAuthConsumer::ClientOAuthResult("rt2", "at2", 3600)); |
242 EXPECT_TRUE(service_->HasOAuthLoginToken()); | 243 EXPECT_TRUE(service_->HasOAuthLoginToken()); |
243 EXPECT_EQ(service_->GetOAuth2LoginRefreshToken(), "rt2"); | 244 EXPECT_EQ(service_->GetOAuth2LoginRefreshToken(), "rt2"); |
244 | 245 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 | 418 |
418 *CommandLine::ForCurrentProcess() = original_cl; | 419 *CommandLine::ForCurrentProcess() = original_cl; |
419 } | 420 } |
420 }; | 421 }; |
421 | 422 |
422 TEST_F(TokenServiceCommandLineTest, TestValueOverride) { | 423 TEST_F(TokenServiceCommandLineTest, TestValueOverride) { |
423 EXPECT_TRUE(service_->HasTokenForService("my_service")); | 424 EXPECT_TRUE(service_->HasTokenForService("my_service")); |
424 EXPECT_EQ("my_value", service_->GetTokenForService("my_service")); | 425 EXPECT_EQ("my_value", service_->GetTokenForService("my_service")); |
425 } | 426 } |
426 #endif // ifndef NDEBUG | 427 #endif // ifndef NDEBUG |
OLD | NEW |