| 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 "chrome/browser/profiles/gaia_info_update_service.h" | 5 #include "chrome/browser/profiles/gaia_info_update_service.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 10 #include "chrome/browser/profiles/profile_downloader.h" | 11 #include "chrome/browser/profiles/profile_downloader.h" |
| 11 #include "chrome/browser/profiles/profile_info_cache.h" | 12 #include "chrome/browser/profiles/profile_info_cache.h" |
| 12 #include "chrome/browser/profiles/profile_info_cache_unittest.h" | 13 #include "chrome/browser/profiles/profile_info_cache_unittest.h" |
| 14 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
| 13 #include "chrome/browser/signin/signin_manager_factory.h" | 15 #include "chrome/browser/signin/signin_manager_factory.h" |
| 16 #include "chrome/browser/signin/test_signin_client_builder.h" |
| 14 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 15 #include "chrome/test/base/testing_browser_process.h" | 18 #include "chrome/test/base/testing_browser_process.h" |
| 16 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
| 17 #include "chrome/test/base/testing_profile_manager.h" | 20 #include "chrome/test/base/testing_profile_manager.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
| 19 #include "ui/gfx/image/image.h" | 22 #include "ui/gfx/image/image.h" |
| 20 #include "ui/gfx/image/image_unittest_util.h" | 23 #include "ui/gfx/image/image_unittest_util.h" |
| 21 | 24 |
| 22 using ::testing::Return; | 25 using ::testing::Return; |
| 23 using ::testing::NiceMock; | 26 using ::testing::NiceMock; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 Profile* profile() { | 64 Profile* profile() { |
| 62 if (!profile_) | 65 if (!profile_) |
| 63 profile_ = CreateProfile("Person 1"); | 66 profile_ = CreateProfile("Person 1"); |
| 64 return profile_; | 67 return profile_; |
| 65 } | 68 } |
| 66 | 69 |
| 67 NiceMock<GAIAInfoUpdateServiceMock>* service() { return service_.get(); } | 70 NiceMock<GAIAInfoUpdateServiceMock>* service() { return service_.get(); } |
| 68 NiceMock<ProfileDownloaderMock>* downloader() { return downloader_.get(); } | 71 NiceMock<ProfileDownloaderMock>* downloader() { return downloader_.get(); } |
| 69 | 72 |
| 70 Profile* CreateProfile(const std::string& name) { | 73 Profile* CreateProfile(const std::string& name) { |
| 71 Profile* profile = testing_profile_manager_.CreateTestingProfile(name); | 74 TestingProfile::TestingFactories testing_factories; |
| 75 testing_factories.push_back(std::make_pair( |
| 76 ChromeSigninClientFactory::GetInstance(), |
| 77 signin::BuildTestSigninClient)); |
| 78 Profile* profile = testing_profile_manager_.CreateTestingProfile(name, |
| 79 scoped_ptr<PrefServiceSyncable>(), base::UTF8ToUTF16(name), 0, |
| 80 std::string(), testing_factories); |
| 72 // The testing manager sets the profile name manually, which counts as | 81 // The testing manager sets the profile name manually, which counts as |
| 73 // a user-customized profile name. Reset this to match the default name | 82 // a user-customized profile name. Reset this to match the default name |
| 74 // we are actually using. | 83 // we are actually using. |
| 75 size_t index = GetCache()->GetIndexOfProfileWithPath(profile->GetPath()); | 84 size_t index = GetCache()->GetIndexOfProfileWithPath(profile->GetPath()); |
| 76 GetCache()->SetProfileIsUsingDefaultNameAtIndex(index, true); | 85 GetCache()->SetProfileIsUsingDefaultNameAtIndex(index, true); |
| 77 return profile; | 86 return profile; |
| 78 } | 87 } |
| 79 | 88 |
| 80 static std::string GivenName(const std::string& id) { | 89 static std::string GivenName(const std::string& id) { |
| 81 return id + "first"; | 90 return id + "first"; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 | 275 |
| 267 TEST_F(GAIAInfoUpdateServiceTest, LogIn) { | 276 TEST_F(GAIAInfoUpdateServiceTest, LogIn) { |
| 268 // Log in. | 277 // Log in. |
| 269 EXPECT_CALL(*service(), Update()); | 278 EXPECT_CALL(*service(), Update()); |
| 270 SigninManager* signin_manager = | 279 SigninManager* signin_manager = |
| 271 SigninManagerFactory::GetForProfile(profile()); | 280 SigninManagerFactory::GetForProfile(profile()); |
| 272 signin_manager->OnExternalSigninCompleted("pat@example.com"); | 281 signin_manager->OnExternalSigninCompleted("pat@example.com"); |
| 273 } | 282 } |
| 274 | 283 |
| 275 #endif | 284 #endif |
| OLD | NEW |