| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 EXPECT_FALSE(manager_->IsAuthenticated()); | 249 EXPECT_FALSE(manager_->IsAuthenticated()); |
| 250 | 250 |
| 251 std::string gaia_id = "12345"; | 251 std::string gaia_id = "12345"; |
| 252 std::string email = "user@google.com"; | 252 std::string email = "user@google.com"; |
| 253 | 253 |
| 254 FakeAccountTrackerService* account_tracker_service = | 254 FakeAccountTrackerService* account_tracker_service = |
| 255 static_cast<FakeAccountTrackerService*>( | 255 static_cast<FakeAccountTrackerService*>( |
| 256 AccountTrackerServiceFactory::GetForProfile(profile())); | 256 AccountTrackerServiceFactory::GetForProfile(profile())); |
| 257 account_tracker_service->SeedAccountInfo(gaia_id, email); | 257 account_tracker_service->SeedAccountInfo(gaia_id, email); |
| 258 account_tracker_service->EnableNetworkFetches(); | 258 account_tracker_service->EnableNetworkFetches(); |
| 259 std::string account_id = account_tracker_service->PickAccountIdForAccount( | |
| 260 gaia_id, email); | |
| 261 | 259 |
| 262 ASSERT_TRUE(signin_client()->get_signed_in_password().empty()); | 260 ASSERT_TRUE(signin_client()->get_signed_in_password().empty()); |
| 263 | 261 |
| 264 manager_->StartSignInWithRefreshToken( | 262 manager_->StartSignInWithRefreshToken( |
| 265 "rt1", | 263 "rt1", |
| 266 email, | 264 email, |
| 267 "password", | 265 "password", |
| 268 SigninManager::OAuthTokenFetchedCallback()); | 266 SigninManager::OAuthTokenFetchedCallback()); |
| 269 | 267 |
| 270 // PostSignedIn is not called until the AccountTrackerService returns. | 268 // PostSignedIn is not called until the AccountTrackerService returns. |
| 271 ASSERT_EQ("", signin_client()->get_signed_in_password()); | 269 ASSERT_EQ("", signin_client()->get_signed_in_password()); |
| 272 | 270 |
| 273 account_tracker_service->FakeUserInfoFetchSuccess( | 271 account_tracker_service->FakeUserInfoFetchSuccess(email, |
| 274 account_id, email, gaia_id, "google.com"); | 272 gaia_id, |
| 273 "google.com", |
| 274 "full_name", |
| 275 "given_name", |
| 276 "locale", |
| 277 "http://www.google.com"); |
| 275 | 278 |
| 276 // AccountTracker and SigninManager are both done and PostSignedIn was called. | 279 // AccountTracker and SigninManager are both done and PostSignedIn was called. |
| 277 ASSERT_EQ("password", signin_client()->get_signed_in_password()); | 280 ASSERT_EQ("password", signin_client()->get_signed_in_password()); |
| 278 | 281 |
| 279 ExpectSignInWithRefreshTokenSuccess(); | 282 ExpectSignInWithRefreshTokenSuccess(); |
| 280 | 283 |
| 281 } | 284 } |
| 282 | 285 |
| 283 TEST_F(SigninManagerTest, SignOut) { | 286 TEST_F(SigninManagerTest, SignOut) { |
| 284 SetUpSigninManagerAsService(); | 287 SetUpSigninManagerAsService(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 profile()->GetPrefs()->GetString(prefs::kGoogleServicesUsername)); | 376 profile()->GetPrefs()->GetString(prefs::kGoogleServicesUsername)); |
| 374 EXPECT_EQ("external@example.com", manager_->GetAuthenticatedUsername()); | 377 EXPECT_EQ("external@example.com", manager_->GetAuthenticatedUsername()); |
| 375 } | 378 } |
| 376 | 379 |
| 377 TEST_F(SigninManagerTest, SigninNotAllowed) { | 380 TEST_F(SigninManagerTest, SigninNotAllowed) { |
| 378 std::string user("user@google.com"); | 381 std::string user("user@google.com"); |
| 379 profile()->GetPrefs()->SetString(prefs::kGoogleServicesUsername, user); | 382 profile()->GetPrefs()->SetString(prefs::kGoogleServicesUsername, user); |
| 380 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); | 383 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); |
| 381 SetUpSigninManagerAsService(); | 384 SetUpSigninManagerAsService(); |
| 382 } | 385 } |
| OLD | NEW |