Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: chrome/browser/sync/profile_sync_service_unittest.cc

Issue 12502017: signin: pull basic SigninManager functionality into new SigninManagerBase class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: deal with new enterprise_platform_keys_private_api Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 true, true, false, true, syncer::STORAGE_IN_MEMORY); 89 true, true, false, true, syncer::STORAGE_IN_MEMORY);
90 } 90 }
91 91
92 void StartSyncServiceAndSetInitialSyncEnded( 92 void StartSyncServiceAndSetInitialSyncEnded(
93 bool set_initial_sync_ended, 93 bool set_initial_sync_ended,
94 bool issue_auth_token, 94 bool issue_auth_token,
95 bool synchronous_sync_configuration, 95 bool synchronous_sync_configuration,
96 bool sync_setup_completed, 96 bool sync_setup_completed,
97 syncer::StorageOption storage_option) { 97 syncer::StorageOption storage_option) {
98 if (!service.get()) { 98 if (!service.get()) {
99 SigninManager* signin = 99 SigninManagerBase* signin =
100 SigninManagerFactory::GetForProfile(profile.get()); 100 SigninManagerFactory::GetForProfile(profile.get());
101 signin->SetAuthenticatedUsername("test"); 101 signin->SetAuthenticatedUsername("test");
102 ProfileSyncComponentsFactoryMock* factory = 102 ProfileSyncComponentsFactoryMock* factory =
103 new ProfileSyncComponentsFactoryMock(); 103 new ProfileSyncComponentsFactoryMock();
104 service.reset(new TestProfileSyncService( 104 service.reset(new TestProfileSyncService(
105 factory, 105 factory,
106 profile.get(), 106 profile.get(),
107 signin, 107 signin,
108 ProfileSyncService::AUTO_START, 108 ProfileSyncService::AUTO_START,
109 true)); 109 true));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 } 169 }
170 170
171 virtual void TearDown() { 171 virtual void TearDown() {
172 harness_.TearDown(); 172 harness_.TearDown();
173 } 173 }
174 174
175 ProfileSyncServiceTestHarness harness_; 175 ProfileSyncServiceTestHarness harness_;
176 }; 176 };
177 177
178 TEST_F(ProfileSyncServiceTest, InitialState) { 178 TEST_F(ProfileSyncServiceTest, InitialState) {
179 SigninManager* signin = 179 SigninManagerBase* signin =
180 SigninManagerFactory::GetForProfile(harness_.profile.get()); 180 SigninManagerFactory::GetForProfile(harness_.profile.get());
181 harness_.service.reset(new TestProfileSyncService( 181 harness_.service.reset(new TestProfileSyncService(
182 new ProfileSyncComponentsFactoryMock(), 182 new ProfileSyncComponentsFactoryMock(),
183 harness_.profile.get(), 183 harness_.profile.get(),
184 signin, 184 signin,
185 ProfileSyncService::MANUAL_START, 185 ProfileSyncService::MANUAL_START,
186 true)); 186 true));
187 harness_.service->Initialize(); 187 harness_.service->Initialize();
188 EXPECT_TRUE( 188 EXPECT_TRUE(
189 harness_.service->sync_service_url().spec() == 189 harness_.service->sync_service_url().spec() ==
(...skipping 13 matching lines...) Expand all
203 EXPECT_TRUE(observer.first_setup_in_progress()); 203 EXPECT_TRUE(observer.first_setup_in_progress());
204 service.SetSetupInProgress(false); 204 service.SetSetupInProgress(false);
205 EXPECT_FALSE(observer.first_setup_in_progress()); 205 EXPECT_FALSE(observer.first_setup_in_progress());
206 service.RemoveObserver(&observer); 206 service.RemoveObserver(&observer);
207 } 207 }
208 208
209 TEST_F(ProfileSyncServiceTest, DisabledByPolicy) { 209 TEST_F(ProfileSyncServiceTest, DisabledByPolicy) {
210 harness_.profile->GetTestingPrefService()->SetManagedPref( 210 harness_.profile->GetTestingPrefService()->SetManagedPref(
211 prefs::kSyncManaged, 211 prefs::kSyncManaged,
212 Value::CreateBooleanValue(true)); 212 Value::CreateBooleanValue(true));
213 SigninManager* signin = 213 SigninManagerBase* signin =
214 SigninManagerFactory::GetForProfile(harness_.profile.get()); 214 SigninManagerFactory::GetForProfile(harness_.profile.get());
215 harness_.service.reset(new TestProfileSyncService( 215 harness_.service.reset(new TestProfileSyncService(
216 new ProfileSyncComponentsFactoryMock(), 216 new ProfileSyncComponentsFactoryMock(),
217 harness_.profile.get(), 217 harness_.profile.get(),
218 signin, 218 signin,
219 ProfileSyncService::MANUAL_START, 219 ProfileSyncService::MANUAL_START,
220 true)); 220 true));
221 harness_.service->Initialize(); 221 harness_.service->Initialize();
222 EXPECT_TRUE(harness_.service->IsManaged()); 222 EXPECT_TRUE(harness_.service->IsManaged());
223 } 223 }
224 224
225 TEST_F(ProfileSyncServiceTest, AbortedByShutdown) { 225 TEST_F(ProfileSyncServiceTest, AbortedByShutdown) {
226 SigninManager* signin = 226 SigninManagerBase* signin =
227 SigninManagerFactory::GetForProfile(harness_.profile.get()); 227 SigninManagerFactory::GetForProfile(harness_.profile.get());
228 signin->SetAuthenticatedUsername("test"); 228 signin->SetAuthenticatedUsername("test");
229 ProfileSyncComponentsFactoryMock* factory = 229 ProfileSyncComponentsFactoryMock* factory =
230 new ProfileSyncComponentsFactoryMock(); 230 new ProfileSyncComponentsFactoryMock();
231 harness_.service.reset(new TestProfileSyncService( 231 harness_.service.reset(new TestProfileSyncService(
232 factory, 232 factory,
233 harness_.profile.get(), 233 harness_.profile.get(),
234 signin, 234 signin,
235 ProfileSyncService::AUTO_START, 235 ProfileSyncService::AUTO_START,
236 true)); 236 true));
237 EXPECT_CALL(*factory, CreateDataTypeManager(_, _, _, _, _)).Times(0); 237 EXPECT_CALL(*factory, CreateDataTypeManager(_, _, _, _, _)).Times(0);
238 EXPECT_CALL(*factory, CreateBookmarkSyncComponents(_, _)). 238 EXPECT_CALL(*factory, CreateBookmarkSyncComponents(_, _)).
239 Times(0); 239 Times(0);
240 harness_.service->RegisterDataTypeController( 240 harness_.service->RegisterDataTypeController(
241 new BookmarkDataTypeController(harness_.service->factory(), 241 new BookmarkDataTypeController(harness_.service->factory(),
242 harness_.profile.get(), 242 harness_.profile.get(),
243 harness_.service.get())); 243 harness_.service.get()));
244 244
245 harness_.service->Initialize(); 245 harness_.service->Initialize();
246 harness_.service->Shutdown(); 246 harness_.service->Shutdown();
247 harness_.service.reset(); 247 harness_.service.reset();
248 } 248 }
249 249
250 TEST_F(ProfileSyncServiceTest, DisableAndEnableSyncTemporarily) { 250 TEST_F(ProfileSyncServiceTest, DisableAndEnableSyncTemporarily) {
251 SigninManager* signin = 251 SigninManagerBase* signin =
252 SigninManagerFactory::GetForProfile(harness_.profile.get()); 252 SigninManagerFactory::GetForProfile(harness_.profile.get());
253 signin->SetAuthenticatedUsername("test"); 253 signin->SetAuthenticatedUsername("test");
254 ProfileSyncComponentsFactoryMock* factory = 254 ProfileSyncComponentsFactoryMock* factory =
255 new ProfileSyncComponentsFactoryMock(); 255 new ProfileSyncComponentsFactoryMock();
256 harness_.service.reset(new TestProfileSyncService( 256 harness_.service.reset(new TestProfileSyncService(
257 factory, 257 factory,
258 harness_.profile.get(), 258 harness_.profile.get(),
259 signin, 259 signin,
260 ProfileSyncService::AUTO_START, 260 ProfileSyncService::AUTO_START,
261 true)); 261 true));
(...skipping 14 matching lines...) Expand all
276 EXPECT_TRUE( 276 EXPECT_TRUE(
277 harness_.profile->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); 277 harness_.profile->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart));
278 278
279 harness_.service->UnsuppressAndStart(); 279 harness_.service->UnsuppressAndStart();
280 EXPECT_TRUE(harness_.service->sync_initialized()); 280 EXPECT_TRUE(harness_.service->sync_initialized());
281 EXPECT_FALSE( 281 EXPECT_FALSE(
282 harness_.profile->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); 282 harness_.profile->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart));
283 } 283 }
284 284
285 TEST_F(ProfileSyncServiceTest, EnableSyncAndSignOut) { 285 TEST_F(ProfileSyncServiceTest, EnableSyncAndSignOut) {
286 SigninManager* signin = 286 SigninManagerBase* signin =
287 SigninManagerFactory::GetForProfile(harness_.profile.get()); 287 SigninManagerFactory::GetForProfile(harness_.profile.get());
288 signin->SetAuthenticatedUsername("test@test.com"); 288 signin->SetAuthenticatedUsername("test@test.com");
289 ProfileSyncComponentsFactoryMock* factory = 289 ProfileSyncComponentsFactoryMock* factory =
290 new ProfileSyncComponentsFactoryMock(); 290 new ProfileSyncComponentsFactoryMock();
291 harness_.service.reset(new TestProfileSyncService( 291 harness_.service.reset(new TestProfileSyncService(
292 factory, 292 factory,
293 harness_.profile.get(), 293 harness_.profile.get(),
294 signin, 294 signin,
295 ProfileSyncService::AUTO_START, 295 ProfileSyncService::AUTO_START,
296 true)); 296 true));
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 namespace syncer { 623 namespace syncer {
624 namespace { 624 namespace {
625 625
626 // ProfileSyncService should behave just like an invalidator. 626 // ProfileSyncService should behave just like an invalidator.
627 INSTANTIATE_TYPED_TEST_CASE_P( 627 INSTANTIATE_TYPED_TEST_CASE_P(
628 ProfileSyncServiceInvalidatorTest, InvalidatorTest, 628 ProfileSyncServiceInvalidatorTest, InvalidatorTest,
629 ::browser_sync::ProfileSyncServiceInvalidatorTestDelegate); 629 ::browser_sync::ProfileSyncServiceInvalidatorTestDelegate);
630 630
631 } // namespace 631 } // namespace
632 } // namespace syncer 632 } // namespace syncer
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_typed_url_unittest.cc ('k') | chrome/browser/sync/sync_global_error.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698