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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 116 |
117 } // namespace | 117 } // namespace |
118 | 118 |
119 class ProfileSigninConfirmationHelperTest : public testing::Test { | 119 class ProfileSigninConfirmationHelperTest : public testing::Test { |
120 public: | 120 public: |
121 ProfileSigninConfirmationHelperTest() | 121 ProfileSigninConfirmationHelperTest() |
122 : user_prefs_(NULL), | 122 : user_prefs_(NULL), |
123 model_(NULL) { | 123 model_(NULL) { |
124 } | 124 } |
125 | 125 |
126 virtual void SetUp() override { | 126 void SetUp() override { |
127 // Create the profile. | 127 // Create the profile. |
128 TestingProfile::Builder builder; | 128 TestingProfile::Builder builder; |
129 user_prefs_ = new TestingPrefStoreWithCustomReadError; | 129 user_prefs_ = new TestingPrefStoreWithCustomReadError; |
130 TestingPrefServiceSyncable* pref_service = new TestingPrefServiceSyncable( | 130 TestingPrefServiceSyncable* pref_service = new TestingPrefServiceSyncable( |
131 new TestingPrefStore(), | 131 new TestingPrefStore(), |
132 user_prefs_, | 132 user_prefs_, |
133 new TestingPrefStore(), | 133 new TestingPrefStore(), |
134 new user_prefs::PrefRegistrySyncable(), | 134 new user_prefs::PrefRegistrySyncable(), |
135 new PrefNotifierImpl()); | 135 new PrefNotifierImpl()); |
136 chrome::RegisterUserProfilePrefs(pref_service->registry()); | 136 chrome::RegisterUserProfilePrefs(pref_service->registry()); |
137 builder.SetPrefService(make_scoped_ptr<PrefServiceSyncable>(pref_service)); | 137 builder.SetPrefService(make_scoped_ptr<PrefServiceSyncable>(pref_service)); |
138 profile_ = builder.Build(); | 138 profile_ = builder.Build(); |
139 | 139 |
140 // Initialize the services we check. | 140 // Initialize the services we check. |
141 profile_->CreateBookmarkModel(true); | 141 profile_->CreateBookmarkModel(true); |
142 model_ = BookmarkModelFactory::GetForProfile(profile_.get()); | 142 model_ = BookmarkModelFactory::GetForProfile(profile_.get()); |
143 bookmarks::test::WaitForBookmarkModelToLoad(model_); | 143 bookmarks::test::WaitForBookmarkModelToLoad(model_); |
144 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); | 144 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); |
145 #if defined(ENABLE_EXTENSIONS) | 145 #if defined(ENABLE_EXTENSIONS) |
146 extensions::TestExtensionSystem* system = | 146 extensions::TestExtensionSystem* system = |
147 static_cast<extensions::TestExtensionSystem*>( | 147 static_cast<extensions::TestExtensionSystem*>( |
148 extensions::ExtensionSystem::Get(profile_.get())); | 148 extensions::ExtensionSystem::Get(profile_.get())); |
149 CommandLine command_line(CommandLine::NO_PROGRAM); | 149 CommandLine command_line(CommandLine::NO_PROGRAM); |
150 system->CreateExtensionService(&command_line, | 150 system->CreateExtensionService(&command_line, |
151 base::FilePath(kExtensionFilePath), | 151 base::FilePath(kExtensionFilePath), |
152 false); | 152 false); |
153 #endif | 153 #endif |
154 } | 154 } |
155 | 155 |
156 virtual void TearDown() override { | 156 void TearDown() override { |
157 // TestExtensionSystem uses DeleteSoon, so we need to delete the profile | 157 // TestExtensionSystem uses DeleteSoon, so we need to delete the profile |
158 // and then run the message queue to clean up. | 158 // and then run the message queue to clean up. |
159 profile_.reset(); | 159 profile_.reset(); |
160 base::RunLoop().RunUntilIdle(); | 160 base::RunLoop().RunUntilIdle(); |
161 } | 161 } |
162 | 162 |
163 protected: | 163 protected: |
164 content::TestBrowserThreadBundle thread_bundle_; | 164 content::TestBrowserThreadBundle thread_bundle_; |
165 scoped_ptr<TestingProfile> profile_; | 165 scoped_ptr<TestingProfile> profile_; |
166 TestingPrefStoreWithCustomReadError* user_prefs_; | 166 TestingPrefStoreWithCustomReadError* user_prefs_; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 271 |
272 TEST_F(ProfileSigninConfirmationHelperTest, PromptForNewProfile_Restarted) { | 272 TEST_F(ProfileSigninConfirmationHelperTest, PromptForNewProfile_Restarted) { |
273 // Browser has been shut down since profile was created. | 273 // Browser has been shut down since profile was created. |
274 user_prefs_->set_read_error(PersistentPrefStore::PREF_READ_ERROR_NONE); | 274 user_prefs_->set_read_error(PersistentPrefStore::PREF_READ_ERROR_NONE); |
275 EXPECT_TRUE( | 275 EXPECT_TRUE( |
276 GetCallbackResult( | 276 GetCallbackResult( |
277 base::Bind( | 277 base::Bind( |
278 &ui::CheckShouldPromptForNewProfile, | 278 &ui::CheckShouldPromptForNewProfile, |
279 profile_.get()))); | 279 profile_.get()))); |
280 } | 280 } |
OLD | NEW |