Index: chrome/browser/sync/profile_sync_service_startup_unittest.cc |
diff --git a/chrome/browser/sync/profile_sync_service_startup_unittest.cc b/chrome/browser/sync/profile_sync_service_startup_unittest.cc |
index 2282a67304c8af0c1b49cb56409c8a93a8e09ce2..f5abada5ac80407d8ff9f2e8ec326cde79835821 100644 |
--- a/chrome/browser/sync/profile_sync_service_startup_unittest.cc |
+++ b/chrome/browser/sync/profile_sync_service_startup_unittest.cc |
@@ -164,6 +164,67 @@ TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) { |
EXPECT_TRUE(service_->ShouldPushChanges()); |
} |
+TEST_F(ProfileSyncServiceStartupTest, StartNoCredentials) { |
+ DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); |
+ EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(0); |
+ |
+ // We've never completed startup. |
+ profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); |
+ // Make sure SigninManager doesn't think we're signed in (undoes the call to |
+ // SetAuthenticatedUsername() in CreateSyncService()). |
+ SigninManagerFactory::GetForProfile(profile_.get())->SignOut(); |
+ |
+ // Should not actually start, rather just clean things up and wait |
+ // to be enabled. |
+ EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
+ service_->Initialize(); |
Nicolas Zea
2012/05/23 22:54:11
maybe add EXPECT_FALSE(GetBackendForTest()) to ens
Andrew T Wilson (Slow)
2012/05/23 23:44:53
Done.
|
+ |
+ // Preferences should be back to defaults. |
+ EXPECT_EQ(0, profile_->GetPrefs()->GetInt64(prefs::kSyncLastSyncedTime)); |
+ EXPECT_FALSE(profile_->GetPrefs()->GetBoolean(prefs::kSyncHasSetupCompleted)); |
+ Mock::VerifyAndClearExpectations(data_type_manager); |
+ |
+ // Then start things up. |
+ EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(1); |
+ EXPECT_CALL(*data_type_manager, state()). |
+ WillOnce(Return(DataTypeManager::CONFIGURED)). |
+ WillOnce(Return(DataTypeManager::CONFIGURED)); |
+ EXPECT_CALL(*data_type_manager, Stop()).Times(1); |
+ EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
+ |
+ service_->set_setup_in_progress(true); |
+ service_->signin()->StartSignIn("test_user", "", "", ""); |
+ // NOTE: Unlike StartFirstTime, this test does not issue any auth tokens. |
+ content::NotificationService::current()->Notify( |
+ chrome::NOTIFICATION_TOKEN_LOADING_FINISHED, |
+ content::Source<TokenService>( |
+ TokenServiceFactory::GetForProfile(profile_.get())), |
+ content::NotificationService::NoDetails()); |
+ service_->set_setup_in_progress(false); |
+ service_->OnUserChoseDatatypes( |
+ false, syncable::ModelTypeSet(syncable::BOOKMARKS)); |
+ // Backend should initialize using a bogus GAIA token for credentials. |
+ EXPECT_TRUE(service_->ShouldPushChanges()); |
+} |
+ |
+TEST_F(ProfileSyncServiceStartupCrosTest, StartCrosNoCredentials) { |
+ EXPECT_CALL(*factory_mock(), CreateDataTypeManager(_, _)).Times(0); |
+ profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); |
+ EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
+ |
+ service_->Initialize(); |
Nicolas Zea
2012/05/23 22:54:11
after this too
Andrew T Wilson (Slow)
2012/05/23 23:44:53
Done.
|
+ // Sync should not start because there are no tokens yet. |
+ EXPECT_FALSE(service_->ShouldPushChanges()); |
+ content::NotificationService::current()->Notify( |
+ chrome::NOTIFICATION_TOKEN_LOADING_FINISHED, |
+ content::Source<TokenService>( |
+ TokenServiceFactory::GetForProfile(profile_.get())), |
+ content::NotificationService::NoDetails()); |
+ service_->set_setup_in_progress(false); |
+ // Sync should not start because there are still no tokens. |
+ EXPECT_FALSE(service_->ShouldPushChanges()); |
Nicolas Zea
2012/05/23 22:54:11
and here
Andrew T Wilson (Slow)
2012/05/23 23:44:53
Done.
|
+} |
+ |
TEST_F(ProfileSyncServiceStartupCrosTest, StartFirstTime) { |
DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); |
profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); |