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

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

Issue 14630003: signin: move SigninManagerBase::Signout to SigninManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 "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/fake_signin_manager.h" 10 #include "chrome/browser/signin/fake_signin_manager.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 166 }
167 167
168 protected: 168 protected:
169 virtual void CreateSyncService() OVERRIDE { 169 virtual void CreateSyncService() OVERRIDE {
170 sync_ = static_cast<TestProfileSyncService*>( 170 sync_ = static_cast<TestProfileSyncService*>(
171 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( 171 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
172 profile_.get(), BuildCrosService)); 172 profile_.get(), BuildCrosService));
173 } 173 }
174 }; 174 };
175 175
176 ProfileKeyedService* BuildFakeTokenService(Profile* profile) {
177 return new FakeTokenService();
178 }
179
180 #if !defined(OS_CHROMEOS) // See ProfileSyncServiceCrosTest for Chrome OS.
181 // TODO(tim): Bug 237866, split these into two files, one per platform.
182
176 TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) { 183 TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) {
177 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); 184 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager();
178 EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(0); 185 EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(0);
179 186
180 // We've never completed startup. 187 // We've never completed startup.
181 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); 188 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted);
182 // Make sure SigninManager doesn't think we're signed in (undoes the call to 189 // Make sure SigninManager doesn't think we're signed in (undoes the call to
183 // SetAuthenticatedUsername() in CreateSyncService()). 190 // SetAuthenticatedUsername() in CreateSyncService()).
184 SigninManagerFactory::GetForProfile(profile_.get())->SignOut(); 191 SigninManagerFactory::GetForProfile(profile_.get())->SignOut();
185 192
(...skipping 20 matching lines...) Expand all
206 sync_->SetSetupInProgress(true); 213 sync_->SetSetupInProgress(true);
207 Signin(); 214 Signin();
208 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( 215 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest(
209 GaiaConstants::kSyncService, "sync_token"); 216 GaiaConstants::kSyncService, "sync_token");
210 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( 217 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest(
211 GaiaConstants::kGaiaOAuth2LoginRefreshToken, "oauth2_login_token"); 218 GaiaConstants::kGaiaOAuth2LoginRefreshToken, "oauth2_login_token");
212 sync_->SetSetupInProgress(false); 219 sync_->SetSetupInProgress(false);
213 EXPECT_TRUE(sync_->ShouldPushChanges()); 220 EXPECT_TRUE(sync_->ShouldPushChanges());
214 } 221 }
215 222
216 ProfileKeyedService* BuildFakeTokenService(Profile* profile) {
217 return new FakeTokenService();
218 }
219
220 TEST_F(ProfileSyncServiceStartupTest, StartNoCredentials) { 223 TEST_F(ProfileSyncServiceStartupTest, StartNoCredentials) {
221 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); 224 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager();
222 EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(0); 225 EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(0);
223 TokenService* token_service = static_cast<TokenService*>( 226 TokenService* token_service = static_cast<TokenService*>(
224 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( 227 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse(
225 profile_.get(), BuildFakeTokenService)); 228 profile_.get(), BuildFakeTokenService));
226 229
227 // We've never completed startup. 230 // We've never completed startup.
228 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); 231 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted);
229 // Make sure SigninManager doesn't think we're signed in (undoes the call to 232 // Make sure SigninManager doesn't think we're signed in (undoes the call to
(...skipping 21 matching lines...) Expand all
251 254
252 sync_->SetSetupInProgress(true); 255 sync_->SetSetupInProgress(true);
253 Signin(); 256 Signin();
254 // NOTE: Unlike StartFirstTime, this test does not issue any auth tokens. 257 // NOTE: Unlike StartFirstTime, this test does not issue any auth tokens.
255 token_service->LoadTokensFromDB(); 258 token_service->LoadTokensFromDB();
256 sync_->SetSetupInProgress(false); 259 sync_->SetSetupInProgress(false);
257 // Backend should initialize using a bogus GAIA token for credentials. 260 // Backend should initialize using a bogus GAIA token for credentials.
258 EXPECT_TRUE(sync_->ShouldPushChanges()); 261 EXPECT_TRUE(sync_->ShouldPushChanges());
259 } 262 }
260 263
264 #endif // !defined (OS_CHROMEOS)
265
261 TEST_F(ProfileSyncServiceStartupTest, StartInvalidCredentials) { 266 TEST_F(ProfileSyncServiceStartupTest, StartInvalidCredentials) {
262 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); 267 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager();
263 EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(0); 268 EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(0);
264 TokenService* token_service = static_cast<TokenService*>( 269 TokenService* token_service = static_cast<TokenService*>(
265 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( 270 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse(
266 profile_.get(), BuildFakeTokenService)); 271 profile_.get(), BuildFakeTokenService));
267 token_service->LoadTokensFromDB(); 272 token_service->LoadTokensFromDB();
268 273
269 // Tell the backend to stall while downloading control types (simulating an 274 // Tell the backend to stall while downloading control types (simulating an
270 // auth error). 275 // auth error).
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 484
480 // Preload the tokens. 485 // Preload the tokens.
481 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( 486 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest(
482 GaiaConstants::kSyncService, "sync_token"); 487 GaiaConstants::kSyncService, "sync_token");
483 sync_->fail_initial_download(); 488 sync_->fail_initial_download();
484 489
485 sync_->Initialize(); 490 sync_->Initialize();
486 EXPECT_FALSE(sync_->sync_initialized()); 491 EXPECT_FALSE(sync_->sync_initialized());
487 EXPECT_FALSE(sync_->GetBackendForTest()); 492 EXPECT_FALSE(sync_->GetBackendForTest());
488 } 493 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698