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

Unified Diff: chrome/browser/sync/profile_sync_service_startup_unittest.cc

Issue 11428125: [Sync] Fix auth error handling while the backend is initializing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | chrome/browser/sync/test_profile_sync_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 01c5e6f100d1cebc8710dc8cd1f67b53f6b54bf0..8c24a35f952b50374a6a4662ca9e814a1c16253a 100644
--- a/chrome/browser/sync/profile_sync_service_startup_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_startup_unittest.cc
@@ -235,6 +235,42 @@ TEST_F(ProfileSyncServiceStartupTest, StartNoCredentials) {
EXPECT_TRUE(service_->ShouldPushChanges());
}
+TEST_F(ProfileSyncServiceStartupTest, StartInvalidCredentials) {
+ DataTypeManagerMock* data_type_manager = SetUpDataTypeManager();
+ EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(0);
+ TokenService* token_service = static_cast<TokenService*>(
+ TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse(
+ profile_.get(), BuildFakeTokenService));
+ token_service->LoadTokensFromDB();
+
+ // Tell the backend to stall while downloading control types (simulating an
+ // auth error).
+ service_->fail_initial_download();
+
+ EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
+ service_->Initialize();
+ EXPECT_TRUE(service_->GetBackendForTest());
+ EXPECT_FALSE(service_->sync_initialized());
+ EXPECT_FALSE(service_->ShouldPushChanges());
+ Mock::VerifyAndClearExpectations(data_type_manager);
+
+ // Update the credentials, unstalling the backend.
+ EXPECT_CALL(*data_type_manager, Configure(_, _));
+ EXPECT_CALL(*data_type_manager, state()).
+ WillRepeatedly(Return(DataTypeManager::CONFIGURED));
+ EXPECT_CALL(*data_type_manager, Stop()).Times(1);
+ EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
+ service_->SetSetupInProgress(true);
+ service_->signin()->StartSignIn("test_user", "", "", "");
+ token_service->IssueAuthTokenForTest(
+ GaiaConstants::kSyncService, "sync_token");
+ service_->SetSetupInProgress(false);
+ MessageLoop::current()->Run();
+
+ // Verify we successfully finish startup and configuration.
+ EXPECT_TRUE(service_->ShouldPushChanges());
+}
+
TEST_F(ProfileSyncServiceStartupCrosTest, StartCrosNoCredentials) {
EXPECT_CALL(*factory_mock(), CreateDataTypeManager(_, _, _, _)).Times(0);
profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted);
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | chrome/browser/sync/test_profile_sync_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698