OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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.h" | 7 #include "chrome/browser/net/gaia/token_service.h" |
8 #include "chrome/browser/password_manager/encryptor.h" | 8 #include "chrome/browser/password_manager/encryptor.h" |
9 #include "chrome/browser/webdata/web_data_service.h" | 9 #include "chrome/browser/webdata/web_data_service.h" |
10 #include "chrome/common/net/gaia/gaia_auth_consumer.h" | 10 #include "chrome/common/net/gaia/gaia_auth_consumer.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 TokenService service_; | 123 TokenService service_; |
124 TokenAvailableTracker success_tracker_; | 124 TokenAvailableTracker success_tracker_; |
125 TokenFailedTracker failure_tracker_; | 125 TokenFailedTracker failure_tracker_; |
126 GaiaAuthConsumer::ClientLoginResult credentials_; | 126 GaiaAuthConsumer::ClientLoginResult credentials_; |
127 scoped_ptr<TestingProfile> profile_; | 127 scoped_ptr<TestingProfile> profile_; |
128 }; | 128 }; |
129 | 129 |
130 TEST_F(TokenServiceTest, SanityCheck) { | 130 TEST_F(TokenServiceTest, SanityCheck) { |
131 EXPECT_TRUE(service_.HasLsid()); | 131 EXPECT_TRUE(service_.HasLsid()); |
132 EXPECT_EQ(service_.GetLsid(), "lsid"); | 132 EXPECT_EQ(service_.GetLsid(), "lsid"); |
133 EXPECT_FALSE(service_.HasTokenForService("nonexistant service")); | 133 EXPECT_FALSE(service_.HasTokenForService("nonexistent service")); |
134 } | 134 } |
135 | 135 |
136 TEST_F(TokenServiceTest, NoToken) { | 136 TEST_F(TokenServiceTest, NoToken) { |
137 EXPECT_FALSE(service_.HasTokenForService("nonexistant service")); | 137 EXPECT_FALSE(service_.HasTokenForService("nonexistent service")); |
138 EXPECT_EQ(service_.GetTokenForService("nonexistant service"), std::string()); | 138 EXPECT_EQ(service_.GetTokenForService("nonexistent service"), std::string()); |
139 } | 139 } |
140 | 140 |
141 TEST_F(TokenServiceTest, NotificationSuccess) { | 141 TEST_F(TokenServiceTest, NotificationSuccess) { |
142 EXPECT_EQ(0U, success_tracker_.size()); | 142 EXPECT_EQ(0U, success_tracker_.size()); |
143 EXPECT_EQ(0U, failure_tracker_.size()); | 143 EXPECT_EQ(0U, failure_tracker_.size()); |
144 service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token"); | 144 service_.OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token"); |
145 EXPECT_EQ(1U, success_tracker_.size()); | 145 EXPECT_EQ(1U, success_tracker_.size()); |
146 EXPECT_EQ(0U, failure_tracker_.size()); | 146 EXPECT_EQ(0U, failure_tracker_.size()); |
147 | 147 |
148 TokenService::TokenAvailableDetails details = | 148 TokenService::TokenAvailableDetails details = |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 // Reset it one more time so there's no surprises. | 361 // Reset it one more time so there's no surprises. |
362 service_.ResetCredentialsInMemory(); | 362 service_.ResetCredentialsInMemory(); |
363 success_tracker_.Reset(); | 363 success_tracker_.Reset(); |
364 | 364 |
365 service_.LoadTokensFromDB(); | 365 service_.LoadTokensFromDB(); |
366 WaitForDBLoadCompletion(); | 366 WaitForDBLoadCompletion(); |
367 | 367 |
368 EXPECT_EQ(1U, success_tracker_.size()); | 368 EXPECT_EQ(1U, success_tracker_.size()); |
369 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService)); | 369 EXPECT_TRUE(service_.HasTokenForService(GaiaConstants::kSyncService)); |
370 } | 370 } |
OLD | NEW |