| 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" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 13 #include "base/prefs/testing_pref_service.h" | 14 #include "base/prefs/testing_pref_service.h" |
| 14 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/chrome_notification_types.h" | 18 #include "chrome/browser/chrome_notification_types.h" |
| 18 #include "chrome/browser/prefs/browser_prefs.h" | 19 #include "chrome/browser/prefs/browser_prefs.h" |
| 19 #include "chrome/browser/signin/account_tracker_service_factory.h" | 20 #include "chrome/browser/signin/account_tracker_service_factory.h" |
| 20 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 21 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
| 21 #include "chrome/browser/signin/fake_account_tracker_service.h" | 22 #include "chrome/browser/signin/fake_account_tracker_service.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 41 #include "net/url_request/test_url_fetcher_factory.h" | 42 #include "net/url_request/test_url_fetcher_factory.h" |
| 42 #include "net/url_request/url_request.h" | 43 #include "net/url_request/url_request.h" |
| 43 #include "net/url_request/url_request_context_getter.h" | 44 #include "net/url_request/url_request_context_getter.h" |
| 44 #include "net/url_request/url_request_status.h" | 45 #include "net/url_request/url_request_status.h" |
| 45 | 46 |
| 46 #include "testing/gmock/include/gmock/gmock.h" | 47 #include "testing/gmock/include/gmock/gmock.h" |
| 47 #include "testing/gtest/include/gtest/gtest.h" | 48 #include "testing/gtest/include/gtest/gtest.h" |
| 48 | 49 |
| 49 namespace { | 50 namespace { |
| 50 | 51 |
| 51 KeyedService* SigninManagerBuild(content::BrowserContext* context) { | 52 scoped_ptr<KeyedService> SigninManagerBuild(content::BrowserContext* context) { |
| 52 SigninManager* service = NULL; | |
| 53 Profile* profile = static_cast<Profile*>(context); | 53 Profile* profile = static_cast<Profile*>(context); |
| 54 service = new SigninManager( | 54 scoped_ptr<SigninManager> service(new SigninManager( |
| 55 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile), | 55 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile), |
| 56 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 56 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
| 57 AccountTrackerServiceFactory::GetForProfile(profile), | 57 AccountTrackerServiceFactory::GetForProfile(profile), |
| 58 GaiaCookieManagerServiceFactory::GetForProfile(profile)); | 58 GaiaCookieManagerServiceFactory::GetForProfile(profile))); |
| 59 service->Initialize(NULL); | 59 service->Initialize(NULL); |
| 60 return service; | 60 return service.Pass(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 class TestSigninManagerObserver : public SigninManagerBase::Observer { | 63 class TestSigninManagerObserver : public SigninManagerBase::Observer { |
| 64 public: | 64 public: |
| 65 TestSigninManagerObserver() : num_failed_signins_(0), | 65 TestSigninManagerObserver() : num_failed_signins_(0), |
| 66 num_successful_signins_(0), | 66 num_successful_signins_(0), |
| 67 num_signouts_(0) { | 67 num_signouts_(0) { |
| 68 } | 68 } |
| 69 | 69 |
| 70 ~TestSigninManagerObserver() override {} | 70 ~TestSigninManagerObserver() override {} |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 profile()->GetPrefs()->GetString(prefs::kGoogleServicesUsername)); | 437 profile()->GetPrefs()->GetString(prefs::kGoogleServicesUsername)); |
| 438 | 438 |
| 439 // Make sure account tracker was updated. | 439 // Make sure account tracker was updated. |
| 440 AccountTrackerService* service = | 440 AccountTrackerService* service = |
| 441 AccountTrackerServiceFactory::GetForProfile(profile()); | 441 AccountTrackerServiceFactory::GetForProfile(profile()); |
| 442 AccountTrackerService::AccountInfo info = service->GetAccountInfo( | 442 AccountTrackerService::AccountInfo info = service->GetAccountInfo( |
| 443 manager_->GetAuthenticatedAccountId()); | 443 manager_->GetAuthenticatedAccountId()); |
| 444 EXPECT_EQ("user@gmail.com", info.email); | 444 EXPECT_EQ("user@gmail.com", info.email); |
| 445 EXPECT_EQ("account_id", info.gaia); | 445 EXPECT_EQ("account_id", info.gaia); |
| 446 } | 446 } |
| OLD | NEW |