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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "chrome/browser/signin/signin_manager.h" | 10 #include "chrome/browser/signin/signin_manager.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 ui_loop_.RunUntilIdle(); | 96 ui_loop_.RunUntilIdle(); |
97 io_thread_.Stop(); | 97 io_thread_.Stop(); |
98 file_thread_.Stop(); | 98 file_thread_.Stop(); |
99 ui_loop_.RunUntilIdle(); | 99 ui_loop_.RunUntilIdle(); |
100 } | 100 } |
101 | 101 |
102 static ProfileKeyedService* BuildService(Profile* profile) { | 102 static ProfileKeyedService* BuildService(Profile* profile) { |
103 SigninManager* signin = static_cast<SigninManager*>( | 103 SigninManager* signin = static_cast<SigninManager*>( |
104 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( | 104 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( |
105 profile, FakeSigninManager::Build)); | 105 profile, FakeSigninManager::Build)); |
106 signin->SetAuthenticatedUsername("test_user"); | 106 signin->SetAuthenticatedUsername("test_user@gmail.com"); |
107 return new TestProfileSyncService( | 107 return new TestProfileSyncService( |
108 new ProfileSyncComponentsFactoryMock(), | 108 new ProfileSyncComponentsFactoryMock(), |
109 profile, | 109 profile, |
110 signin, | 110 signin, |
111 ProfileSyncService::MANUAL_START, | 111 ProfileSyncService::MANUAL_START, |
112 true); | 112 true); |
113 } | 113 } |
114 | 114 |
115 protected: | 115 protected: |
116 // Overridden below by ProfileSyncServiceStartupCrosTest. | 116 // Overridden below by ProfileSyncServiceStartupCrosTest. |
(...skipping 18 matching lines...) Expand all Loading... |
135 content::TestBrowserThread io_thread_; | 135 content::TestBrowserThread io_thread_; |
136 scoped_ptr<TestingProfile> profile_; | 136 scoped_ptr<TestingProfile> profile_; |
137 TestProfileSyncService* sync_; | 137 TestProfileSyncService* sync_; |
138 ProfileSyncServiceObserverMock observer_; | 138 ProfileSyncServiceObserverMock observer_; |
139 }; | 139 }; |
140 | 140 |
141 class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest { | 141 class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest { |
142 public: | 142 public: |
143 static ProfileKeyedService* BuildCrosService(Profile* profile) { | 143 static ProfileKeyedService* BuildCrosService(Profile* profile) { |
144 SigninManager* signin = SigninManagerFactory::GetForProfile(profile); | 144 SigninManager* signin = SigninManagerFactory::GetForProfile(profile); |
145 signin->SetAuthenticatedUsername("test_user"); | 145 signin->SetAuthenticatedUsername("test_user@gmail.com"); |
146 return new TestProfileSyncService( | 146 return new TestProfileSyncService( |
147 new ProfileSyncComponentsFactoryMock(), | 147 new ProfileSyncComponentsFactoryMock(), |
148 profile, | 148 profile, |
149 signin, | 149 signin, |
150 ProfileSyncService::AUTO_START, | 150 ProfileSyncService::AUTO_START, |
151 true); | 151 true); |
152 } | 152 } |
153 protected: | 153 protected: |
154 virtual void CreateSyncService() OVERRIDE { | 154 virtual void CreateSyncService() OVERRIDE { |
155 sync_ = static_cast<TestProfileSyncService*>( | 155 sync_ = static_cast<TestProfileSyncService*>( |
(...skipping 26 matching lines...) Expand all Loading... |
182 EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(1); | 182 EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(1); |
183 EXPECT_CALL(*data_type_manager, state()). | 183 EXPECT_CALL(*data_type_manager, state()). |
184 WillOnce(Return(DataTypeManager::CONFIGURED)). | 184 WillOnce(Return(DataTypeManager::CONFIGURED)). |
185 WillOnce(Return(DataTypeManager::CONFIGURED)); | 185 WillOnce(Return(DataTypeManager::CONFIGURED)); |
186 EXPECT_CALL(*data_type_manager, Stop()).Times(1); | 186 EXPECT_CALL(*data_type_manager, Stop()).Times(1); |
187 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); | 187 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
188 | 188 |
189 // Create some tokens in the token service; the service will startup when | 189 // Create some tokens in the token service; the service will startup when |
190 // it is notified that tokens are available. | 190 // it is notified that tokens are available. |
191 sync_->SetSetupInProgress(true); | 191 sync_->SetSetupInProgress(true); |
192 sync_->signin()->StartSignIn("test_user", "", "", ""); | 192 sync_->signin()->StartSignIn("test_user@gmail.com", "", "", ""); |
193 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( | 193 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( |
194 GaiaConstants::kSyncService, "sync_token"); | 194 GaiaConstants::kSyncService, "sync_token"); |
195 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( | 195 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( |
196 GaiaConstants::kGaiaOAuth2LoginRefreshToken, "oauth2_login_token"); | 196 GaiaConstants::kGaiaOAuth2LoginRefreshToken, "oauth2_login_token"); |
197 sync_->SetSetupInProgress(false); | 197 sync_->SetSetupInProgress(false); |
198 EXPECT_TRUE(sync_->ShouldPushChanges()); | 198 EXPECT_TRUE(sync_->ShouldPushChanges()); |
199 } | 199 } |
200 | 200 |
201 ProfileKeyedService* BuildFakeTokenService(Profile* profile) { | 201 ProfileKeyedService* BuildFakeTokenService(Profile* profile) { |
202 return new FakeTokenService(); | 202 return new FakeTokenService(); |
(...skipping 25 matching lines...) Expand all Loading... |
228 | 228 |
229 // Then start things up. | 229 // Then start things up. |
230 EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(1); | 230 EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(1); |
231 EXPECT_CALL(*data_type_manager, state()). | 231 EXPECT_CALL(*data_type_manager, state()). |
232 WillOnce(Return(DataTypeManager::CONFIGURED)). | 232 WillOnce(Return(DataTypeManager::CONFIGURED)). |
233 WillOnce(Return(DataTypeManager::CONFIGURED)); | 233 WillOnce(Return(DataTypeManager::CONFIGURED)); |
234 EXPECT_CALL(*data_type_manager, Stop()).Times(1); | 234 EXPECT_CALL(*data_type_manager, Stop()).Times(1); |
235 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); | 235 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
236 | 236 |
237 sync_->SetSetupInProgress(true); | 237 sync_->SetSetupInProgress(true); |
238 sync_->signin()->StartSignIn("test_user", "", "", ""); | 238 sync_->signin()->StartSignIn("test_user@gmail.com", "", "", ""); |
239 // NOTE: Unlike StartFirstTime, this test does not issue any auth tokens. | 239 // NOTE: Unlike StartFirstTime, this test does not issue any auth tokens. |
240 token_service->LoadTokensFromDB(); | 240 token_service->LoadTokensFromDB(); |
241 sync_->SetSetupInProgress(false); | 241 sync_->SetSetupInProgress(false); |
242 // Backend should initialize using a bogus GAIA token for credentials. | 242 // Backend should initialize using a bogus GAIA token for credentials. |
243 EXPECT_TRUE(sync_->ShouldPushChanges()); | 243 EXPECT_TRUE(sync_->ShouldPushChanges()); |
244 } | 244 } |
245 | 245 |
246 TEST_F(ProfileSyncServiceStartupTest, StartInvalidCredentials) { | 246 TEST_F(ProfileSyncServiceStartupTest, StartInvalidCredentials) { |
247 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); | 247 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); |
248 EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(0); | 248 EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(0); |
(...skipping 13 matching lines...) Expand all Loading... |
262 EXPECT_FALSE(sync_->ShouldPushChanges()); | 262 EXPECT_FALSE(sync_->ShouldPushChanges()); |
263 Mock::VerifyAndClearExpectations(data_type_manager); | 263 Mock::VerifyAndClearExpectations(data_type_manager); |
264 | 264 |
265 // Update the credentials, unstalling the backend. | 265 // Update the credentials, unstalling the backend. |
266 EXPECT_CALL(*data_type_manager, Configure(_, _)); | 266 EXPECT_CALL(*data_type_manager, Configure(_, _)); |
267 EXPECT_CALL(*data_type_manager, state()). | 267 EXPECT_CALL(*data_type_manager, state()). |
268 WillRepeatedly(Return(DataTypeManager::CONFIGURED)); | 268 WillRepeatedly(Return(DataTypeManager::CONFIGURED)); |
269 EXPECT_CALL(*data_type_manager, Stop()).Times(1); | 269 EXPECT_CALL(*data_type_manager, Stop()).Times(1); |
270 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); | 270 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
271 sync_->SetSetupInProgress(true); | 271 sync_->SetSetupInProgress(true); |
272 sync_->signin()->StartSignIn("test_user", "", "", ""); | 272 sync_->signin()->StartSignIn("test_user@gmail.com", "", "", ""); |
273 token_service->IssueAuthTokenForTest( | 273 token_service->IssueAuthTokenForTest( |
274 GaiaConstants::kSyncService, "sync_token"); | 274 GaiaConstants::kSyncService, "sync_token"); |
275 sync_->SetSetupInProgress(false); | 275 sync_->SetSetupInProgress(false); |
276 MessageLoop::current()->Run(); | 276 MessageLoop::current()->Run(); |
277 | 277 |
278 // Verify we successfully finish startup and configuration. | 278 // Verify we successfully finish startup and configuration. |
279 EXPECT_TRUE(sync_->ShouldPushChanges()); | 279 EXPECT_TRUE(sync_->ShouldPushChanges()); |
280 } | 280 } |
281 | 281 |
282 TEST_F(ProfileSyncServiceStartupCrosTest, StartCrosNoCredentials) { | 282 TEST_F(ProfileSyncServiceStartupCrosTest, StartCrosNoCredentials) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 EXPECT_CALL(*data_type_manager, Configure(_, _)); | 320 EXPECT_CALL(*data_type_manager, Configure(_, _)); |
321 EXPECT_CALL(*data_type_manager, state()). | 321 EXPECT_CALL(*data_type_manager, state()). |
322 WillRepeatedly(Return(DataTypeManager::CONFIGURED)); | 322 WillRepeatedly(Return(DataTypeManager::CONFIGURED)); |
323 EXPECT_CALL(*data_type_manager, Stop()).Times(1); | 323 EXPECT_CALL(*data_type_manager, Stop()).Times(1); |
324 | 324 |
325 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); | 325 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
326 | 326 |
327 // Pre load the tokens | 327 // Pre load the tokens |
328 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( | 328 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( |
329 GaiaConstants::kSyncService, "sync_token"); | 329 GaiaConstants::kSyncService, "sync_token"); |
330 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "test_user"); | 330 profile_->GetPrefs()->SetString( |
| 331 prefs::kGoogleServicesUsername, |
| 332 "test_user@gmail.com"); |
331 sync_->Initialize(); | 333 sync_->Initialize(); |
332 } | 334 } |
333 | 335 |
334 // Test that we can recover from a case where a bug in the code resulted in | 336 // Test that we can recover from a case where a bug in the code resulted in |
335 // OnUserChoseDatatypes not being properly called and datatype preferences | 337 // OnUserChoseDatatypes not being properly called and datatype preferences |
336 // therefore being left unset. | 338 // therefore being left unset. |
337 TEST_F(ProfileSyncServiceStartupTest, StartRecoverDatatypePrefs) { | 339 TEST_F(ProfileSyncServiceStartupTest, StartRecoverDatatypePrefs) { |
338 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); | 340 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); |
339 EXPECT_CALL(*data_type_manager, Configure(_, _)); | 341 EXPECT_CALL(*data_type_manager, Configure(_, _)); |
340 EXPECT_CALL(*data_type_manager, state()). | 342 EXPECT_CALL(*data_type_manager, state()). |
341 WillRepeatedly(Return(DataTypeManager::CONFIGURED)); | 343 WillRepeatedly(Return(DataTypeManager::CONFIGURED)); |
342 EXPECT_CALL(*data_type_manager, Stop()).Times(1); | 344 EXPECT_CALL(*data_type_manager, Stop()).Times(1); |
343 | 345 |
344 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); | 346 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
345 | 347 |
346 // Clear the datatype preference fields (simulating bug 154940). | 348 // Clear the datatype preference fields (simulating bug 154940). |
347 profile_->GetPrefs()->ClearPref(prefs::kSyncKeepEverythingSynced); | 349 profile_->GetPrefs()->ClearPref(prefs::kSyncKeepEverythingSynced); |
348 syncer::ModelTypeSet user_types = syncer::UserTypes(); | 350 syncer::ModelTypeSet user_types = syncer::UserTypes(); |
349 for (syncer::ModelTypeSet::Iterator iter = user_types.First(); | 351 for (syncer::ModelTypeSet::Iterator iter = user_types.First(); |
350 iter.Good(); iter.Inc()) { | 352 iter.Good(); iter.Inc()) { |
351 profile_->GetPrefs()->ClearPref( | 353 profile_->GetPrefs()->ClearPref( |
352 browser_sync::SyncPrefs::GetPrefNameForDataType(iter.Get())); | 354 browser_sync::SyncPrefs::GetPrefNameForDataType(iter.Get())); |
353 } | 355 } |
354 | 356 |
355 // Pre load the tokens | 357 // Pre load the tokens |
356 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( | 358 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( |
357 GaiaConstants::kSyncService, "sync_token"); | 359 GaiaConstants::kSyncService, "sync_token"); |
358 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "test_user"); | 360 profile_->GetPrefs()->SetString( |
| 361 prefs::kGoogleServicesUsername, |
| 362 "test_user@gmail.com"); |
359 sync_->Initialize(); | 363 sync_->Initialize(); |
360 | 364 |
361 EXPECT_TRUE(profile_->GetPrefs()->GetBoolean( | 365 EXPECT_TRUE(profile_->GetPrefs()->GetBoolean( |
362 prefs::kSyncKeepEverythingSynced)); | 366 prefs::kSyncKeepEverythingSynced)); |
363 } | 367 } |
364 | 368 |
365 // Verify that the recovery of datatype preferences doesn't overwrite a valid | 369 // Verify that the recovery of datatype preferences doesn't overwrite a valid |
366 // case where only bookmarks are enabled. | 370 // case where only bookmarks are enabled. |
367 TEST_F(ProfileSyncServiceStartupTest, StartDontRecoverDatatypePrefs) { | 371 TEST_F(ProfileSyncServiceStartupTest, StartDontRecoverDatatypePrefs) { |
368 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); | 372 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); |
369 EXPECT_CALL(*data_type_manager, Configure(_, _)); | 373 EXPECT_CALL(*data_type_manager, Configure(_, _)); |
370 EXPECT_CALL(*data_type_manager, state()). | 374 EXPECT_CALL(*data_type_manager, state()). |
371 WillRepeatedly(Return(DataTypeManager::CONFIGURED)); | 375 WillRepeatedly(Return(DataTypeManager::CONFIGURED)); |
372 EXPECT_CALL(*data_type_manager, Stop()).Times(1); | 376 EXPECT_CALL(*data_type_manager, Stop()).Times(1); |
373 | 377 |
374 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); | 378 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
375 | 379 |
376 // Explicitly set Keep Everything Synced to false and have only bookmarks | 380 // Explicitly set Keep Everything Synced to false and have only bookmarks |
377 // enabled. | 381 // enabled. |
378 profile_->GetPrefs()->SetBoolean(prefs::kSyncKeepEverythingSynced, false); | 382 profile_->GetPrefs()->SetBoolean(prefs::kSyncKeepEverythingSynced, false); |
379 | 383 |
380 // Pre load the tokens | 384 // Pre load the tokens |
381 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( | 385 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( |
382 GaiaConstants::kSyncService, "sync_token"); | 386 GaiaConstants::kSyncService, "sync_token"); |
383 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "test_user"); | 387 profile_->GetPrefs()->SetString( |
| 388 prefs::kGoogleServicesUsername, |
| 389 "test_user@gmail.com"); |
384 sync_->Initialize(); | 390 sync_->Initialize(); |
385 | 391 |
386 EXPECT_FALSE(profile_->GetPrefs()->GetBoolean( | 392 EXPECT_FALSE(profile_->GetPrefs()->GetBoolean( |
387 prefs::kSyncKeepEverythingSynced)); | 393 prefs::kSyncKeepEverythingSynced)); |
388 } | 394 } |
389 | 395 |
390 TEST_F(ProfileSyncServiceStartupTest, ManagedStartup) { | 396 TEST_F(ProfileSyncServiceStartupTest, ManagedStartup) { |
391 // Disable sync through policy. | 397 // Disable sync through policy. |
392 profile_->GetPrefs()->SetBoolean(prefs::kSyncManaged, true); | 398 profile_->GetPrefs()->SetBoolean(prefs::kSyncManaged, true); |
393 | 399 |
394 EXPECT_CALL(*sync_->components_factory_mock(), | 400 EXPECT_CALL(*sync_->components_factory_mock(), |
395 CreateDataTypeManager(_, _, _, _, _)).Times(0); | 401 CreateDataTypeManager(_, _, _, _, _)).Times(0); |
396 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); | 402 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
397 | 403 |
398 // Service should not be started by Initialize() since it's managed. | 404 // Service should not be started by Initialize() since it's managed. |
399 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( | 405 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( |
400 GaiaConstants::kSyncService, "sync_token"); | 406 GaiaConstants::kSyncService, "sync_token"); |
401 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "test_user"); | 407 profile_->GetPrefs()->SetString( |
| 408 prefs::kGoogleServicesUsername, |
| 409 "test_user@gmail.com"); |
402 sync_->Initialize(); | 410 sync_->Initialize(); |
403 } | 411 } |
404 | 412 |
405 TEST_F(ProfileSyncServiceStartupTest, SwitchManaged) { | 413 TEST_F(ProfileSyncServiceStartupTest, SwitchManaged) { |
406 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); | 414 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); |
407 EXPECT_CALL(*data_type_manager, Configure(_, _)); | 415 EXPECT_CALL(*data_type_manager, Configure(_, _)); |
408 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); | 416 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
409 | 417 |
410 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( | 418 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( |
411 GaiaConstants::kSyncService, "sync_token"); | 419 GaiaConstants::kSyncService, "sync_token"); |
412 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "test_user"); | 420 profile_->GetPrefs()->SetString( |
| 421 prefs::kGoogleServicesUsername, |
| 422 "test_user@gmail.com"); |
413 sync_->Initialize(); | 423 sync_->Initialize(); |
414 | 424 |
415 // The service should stop when switching to managed mode. | 425 // The service should stop when switching to managed mode. |
416 Mock::VerifyAndClearExpectations(data_type_manager); | 426 Mock::VerifyAndClearExpectations(data_type_manager); |
417 EXPECT_CALL(*data_type_manager, state()). | 427 EXPECT_CALL(*data_type_manager, state()). |
418 WillOnce(Return(DataTypeManager::CONFIGURED)); | 428 WillOnce(Return(DataTypeManager::CONFIGURED)); |
419 EXPECT_CALL(*data_type_manager, Stop()).Times(1); | 429 EXPECT_CALL(*data_type_manager, Stop()).Times(1); |
420 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); | 430 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
421 profile_->GetPrefs()->SetBoolean(prefs::kSyncManaged, true); | 431 profile_->GetPrefs()->SetBoolean(prefs::kSyncManaged, true); |
422 | 432 |
(...skipping 22 matching lines...) Expand all Loading... |
445 WillRepeatedly( | 455 WillRepeatedly( |
446 DoAll(InvokeOnConfigureStart(sync_), | 456 DoAll(InvokeOnConfigureStart(sync_), |
447 InvokeOnConfigureDone(sync_, result))); | 457 InvokeOnConfigureDone(sync_, result))); |
448 EXPECT_CALL(*data_type_manager, state()). | 458 EXPECT_CALL(*data_type_manager, state()). |
449 WillOnce(Return(DataTypeManager::STOPPED)); | 459 WillOnce(Return(DataTypeManager::STOPPED)); |
450 | 460 |
451 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); | 461 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
452 | 462 |
453 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( | 463 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( |
454 GaiaConstants::kSyncService, "sync_token"); | 464 GaiaConstants::kSyncService, "sync_token"); |
455 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "test_user"); | 465 profile_->GetPrefs()->SetString( |
| 466 prefs::kGoogleServicesUsername, |
| 467 "test_user@gmail.com"); |
456 sync_->Initialize(); | 468 sync_->Initialize(); |
457 EXPECT_TRUE(sync_->HasUnrecoverableError()); | 469 EXPECT_TRUE(sync_->HasUnrecoverableError()); |
458 } | 470 } |
459 | 471 |
460 TEST_F(ProfileSyncServiceStartupTest, StartDownloadFailed) { | 472 TEST_F(ProfileSyncServiceStartupTest, StartDownloadFailed) { |
461 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); | 473 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); |
462 | 474 |
463 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); | 475 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
464 | 476 |
465 // Preload the tokens. | 477 // Preload the tokens. |
466 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( | 478 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( |
467 GaiaConstants::kSyncService, "sync_token"); | 479 GaiaConstants::kSyncService, "sync_token"); |
468 sync_->fail_initial_download(); | 480 sync_->fail_initial_download(); |
469 | 481 |
470 sync_->Initialize(); | 482 sync_->Initialize(); |
471 EXPECT_FALSE(sync_->sync_initialized()); | 483 EXPECT_FALSE(sync_->sync_initialized()); |
472 EXPECT_FALSE(sync_->GetBackendForTest()); | 484 EXPECT_FALSE(sync_->GetBackendForTest()); |
473 } | 485 } |
OLD | NEW |