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 #include "components/signin/core/browser/signin_manager.h" | 5 #include "components/signin/core/browser/signin_manager.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 EXPECT_FALSE(manager_->IsAuthenticated()); | 269 EXPECT_FALSE(manager_->IsAuthenticated()); |
270 | 270 |
271 std::string gaia_id = "12345"; | 271 std::string gaia_id = "12345"; |
272 std::string email = "user@google.com"; | 272 std::string email = "user@google.com"; |
273 | 273 |
274 FakeAccountTrackerService* account_tracker_service = | 274 FakeAccountTrackerService* account_tracker_service = |
275 static_cast<FakeAccountTrackerService*>( | 275 static_cast<FakeAccountTrackerService*>( |
276 AccountTrackerServiceFactory::GetForProfile(profile())); | 276 AccountTrackerServiceFactory::GetForProfile(profile())); |
277 account_tracker_service->SeedAccountInfo(gaia_id, email); | 277 account_tracker_service->SeedAccountInfo(gaia_id, email); |
278 account_tracker_service->EnableNetworkFetches(); | 278 account_tracker_service->EnableNetworkFetches(); |
279 std::string account_id = account_tracker_service->PickAccountIdForAccount( | |
280 gaia_id, email); | |
281 | 279 |
282 ASSERT_TRUE(signin_client()->get_signed_in_password().empty()); | 280 ASSERT_TRUE(signin_client()->get_signed_in_password().empty()); |
283 | 281 |
284 manager_->StartSignInWithRefreshToken( | 282 manager_->StartSignInWithRefreshToken( |
285 "rt1", | 283 "rt1", |
286 gaia_id, | 284 gaia_id, |
287 email, | 285 email, |
288 "password", | 286 "password", |
289 SigninManager::OAuthTokenFetchedCallback()); | 287 SigninManager::OAuthTokenFetchedCallback()); |
290 | 288 |
291 // PostSignedIn is not called until the AccountTrackerService returns. | 289 // PostSignedIn is not called until the AccountTrackerService returns. |
292 ASSERT_EQ("", signin_client()->get_signed_in_password()); | 290 ASSERT_EQ("", signin_client()->get_signed_in_password()); |
293 | 291 |
294 account_tracker_service->FakeUserInfoFetchSuccess( | 292 account_tracker_service->FakeUserInfoFetchSuccess(email, |
295 account_id, email, gaia_id, "google.com"); | 293 gaia_id, |
| 294 "google.com", |
| 295 "full_name", |
| 296 "given_name", |
| 297 "locale", |
| 298 "http://www.google.com"); |
296 | 299 |
297 // AccountTracker and SigninManager are both done and PostSignedIn was called. | 300 // AccountTracker and SigninManager are both done and PostSignedIn was called. |
298 ASSERT_EQ("password", signin_client()->get_signed_in_password()); | 301 ASSERT_EQ("password", signin_client()->get_signed_in_password()); |
299 | 302 |
300 ExpectSignInWithRefreshTokenSuccess(); | 303 ExpectSignInWithRefreshTokenSuccess(); |
301 | 304 |
302 } | 305 } |
303 | 306 |
304 TEST_F(SigninManagerTest, SignOut) { | 307 TEST_F(SigninManagerTest, SignOut) { |
305 SetUpSigninManagerAsService(); | 308 SetUpSigninManagerAsService(); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 profile()->GetPrefs()->GetString(prefs::kGoogleServicesUsername)); | 437 profile()->GetPrefs()->GetString(prefs::kGoogleServicesUsername)); |
435 | 438 |
436 // Make sure account tracker was updated. | 439 // Make sure account tracker was updated. |
437 AccountTrackerService* service = | 440 AccountTrackerService* service = |
438 AccountTrackerServiceFactory::GetForProfile(profile()); | 441 AccountTrackerServiceFactory::GetForProfile(profile()); |
439 AccountTrackerService::AccountInfo info = service->GetAccountInfo( | 442 AccountTrackerService::AccountInfo info = service->GetAccountInfo( |
440 manager_->GetAuthenticatedAccountId()); | 443 manager_->GetAuthenticatedAccountId()); |
441 EXPECT_EQ("user@gmail.com", info.email); | 444 EXPECT_EQ("user@gmail.com", info.email); |
442 EXPECT_EQ("account_id", info.gaia); | 445 EXPECT_EQ("account_id", info.gaia); |
443 } | 446 } |
OLD | NEW |