OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/sync/profile_signin_confirmation_helper.h" | 5 #include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 11 #include "base/callback.h" |
10 #include "base/command_line.h" | 12 #include "base/command_line.h" |
11 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
12 #include "base/macros.h" | 14 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/ptr_util.h" |
14 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
15 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
16 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
17 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
18 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
19 #include "build/build_config.h" | 21 #include "build/build_config.h" |
20 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 22 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
21 #include "chrome/browser/history/history_service_factory.h" | 23 #include "chrome/browser/history/history_service_factory.h" |
22 #include "chrome/browser/prefs/browser_prefs.h" | 24 #include "chrome/browser/prefs/browser_prefs.h" |
23 #include "chrome/test/base/testing_profile.h" | 25 #include "chrome/test/base/testing_profile.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 void SetUp() override { | 132 void SetUp() override { |
131 // Create the profile. | 133 // Create the profile. |
132 TestingProfile::Builder builder; | 134 TestingProfile::Builder builder; |
133 user_prefs_ = new TestingPrefStoreWithCustomReadError; | 135 user_prefs_ = new TestingPrefStoreWithCustomReadError; |
134 syncable_prefs::TestingPrefServiceSyncable* pref_service = | 136 syncable_prefs::TestingPrefServiceSyncable* pref_service = |
135 new syncable_prefs::TestingPrefServiceSyncable( | 137 new syncable_prefs::TestingPrefServiceSyncable( |
136 new TestingPrefStore(), user_prefs_, new TestingPrefStore(), | 138 new TestingPrefStore(), user_prefs_, new TestingPrefStore(), |
137 new user_prefs::PrefRegistrySyncable(), new PrefNotifierImpl()); | 139 new user_prefs::PrefRegistrySyncable(), new PrefNotifierImpl()); |
138 chrome::RegisterUserProfilePrefs(pref_service->registry()); | 140 chrome::RegisterUserProfilePrefs(pref_service->registry()); |
139 builder.SetPrefService( | 141 builder.SetPrefService( |
140 make_scoped_ptr<syncable_prefs::PrefServiceSyncable>(pref_service)); | 142 base::WrapUnique<syncable_prefs::PrefServiceSyncable>(pref_service)); |
141 profile_ = builder.Build(); | 143 profile_ = builder.Build(); |
142 | 144 |
143 // Initialize the services we check. | 145 // Initialize the services we check. |
144 profile_->CreateBookmarkModel(true); | 146 profile_->CreateBookmarkModel(true); |
145 model_ = BookmarkModelFactory::GetForProfile(profile_.get()); | 147 model_ = BookmarkModelFactory::GetForProfile(profile_.get()); |
146 bookmarks::test::WaitForBookmarkModelToLoad(model_); | 148 bookmarks::test::WaitForBookmarkModelToLoad(model_); |
147 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); | 149 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); |
148 #if defined(ENABLE_EXTENSIONS) | 150 #if defined(ENABLE_EXTENSIONS) |
149 extensions::TestExtensionSystem* system = | 151 extensions::TestExtensionSystem* system = |
150 static_cast<extensions::TestExtensionSystem*>( | 152 static_cast<extensions::TestExtensionSystem*>( |
151 extensions::ExtensionSystem::Get(profile_.get())); | 153 extensions::ExtensionSystem::Get(profile_.get())); |
152 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 154 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
153 system->CreateExtensionService(&command_line, | 155 system->CreateExtensionService(&command_line, |
154 base::FilePath(kExtensionFilePath), | 156 base::FilePath(kExtensionFilePath), |
155 false); | 157 false); |
156 #endif | 158 #endif |
157 } | 159 } |
158 | 160 |
159 void TearDown() override { | 161 void TearDown() override { |
160 // TestExtensionSystem uses DeleteSoon, so we need to delete the profile | 162 // TestExtensionSystem uses DeleteSoon, so we need to delete the profile |
161 // and then run the message queue to clean up. | 163 // and then run the message queue to clean up. |
162 profile_.reset(); | 164 profile_.reset(); |
163 base::RunLoop().RunUntilIdle(); | 165 base::RunLoop().RunUntilIdle(); |
164 } | 166 } |
165 | 167 |
166 protected: | 168 protected: |
167 content::TestBrowserThreadBundle thread_bundle_; | 169 content::TestBrowserThreadBundle thread_bundle_; |
168 scoped_ptr<TestingProfile> profile_; | 170 std::unique_ptr<TestingProfile> profile_; |
169 TestingPrefStoreWithCustomReadError* user_prefs_; | 171 TestingPrefStoreWithCustomReadError* user_prefs_; |
170 BookmarkModel* model_; | 172 BookmarkModel* model_; |
171 | 173 |
172 #if defined OS_CHROMEOS | 174 #if defined OS_CHROMEOS |
173 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 175 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
174 chromeos::ScopedTestCrosSettings test_cros_settings_; | 176 chromeos::ScopedTestCrosSettings test_cros_settings_; |
175 chromeos::ScopedTestUserManager test_user_manager_; | 177 chromeos::ScopedTestUserManager test_user_manager_; |
176 #endif | 178 #endif |
177 }; | 179 }; |
178 | 180 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 276 |
275 TEST_F(ProfileSigninConfirmationHelperTest, PromptForNewProfile_Restarted) { | 277 TEST_F(ProfileSigninConfirmationHelperTest, PromptForNewProfile_Restarted) { |
276 // Browser has been shut down since profile was created. | 278 // Browser has been shut down since profile was created. |
277 user_prefs_->set_read_error(PersistentPrefStore::PREF_READ_ERROR_NONE); | 279 user_prefs_->set_read_error(PersistentPrefStore::PREF_READ_ERROR_NONE); |
278 EXPECT_TRUE( | 280 EXPECT_TRUE( |
279 GetCallbackResult( | 281 GetCallbackResult( |
280 base::Bind( | 282 base::Bind( |
281 &ui::CheckShouldPromptForNewProfile, | 283 &ui::CheckShouldPromptForNewProfile, |
282 profile_.get()))); | 284 profile_.get()))); |
283 } | 285 } |
OLD | NEW |