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

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

Issue 15421011: Use OAuth2 token for sync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years, 6 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
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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 BrowserWithTestWindowTest::TearDown(); 255 BrowserWithTestWindowTest::TearDown();
256 } 256 }
257 257
258 bool StartSyncService(const base::Closure& callback, 258 bool StartSyncService(const base::Closure& callback,
259 bool will_fail_association) { 259 bool will_fail_association) {
260 if (sync_service_) 260 if (sync_service_)
261 return false; 261 return false;
262 SigninManagerBase* signin = 262 SigninManagerBase* signin =
263 SigninManagerFactory::GetForProfile(profile()); 263 SigninManagerFactory::GetForProfile(profile());
264 signin->SetAuthenticatedUsername("test_user"); 264 signin->SetAuthenticatedUsername("test_user");
265 ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory(
266 profile(), FakeOAuth2TokenService::BuildTokenService);
265 ProfileSyncComponentsFactoryMock* factory = 267 ProfileSyncComponentsFactoryMock* factory =
266 new ProfileSyncComponentsFactoryMock(); 268 new ProfileSyncComponentsFactoryMock();
267 sync_service_.reset(new FakeProfileSyncService( 269 sync_service_.reset(new FakeProfileSyncService(
268 factory, 270 factory,
269 profile(), 271 profile(),
270 signin, 272 signin,
271 ProfileSyncService::AUTO_START, 273 ProfileSyncService::AUTO_START,
272 false)); 274 false));
273 sync_service_->set_backend_init_callback(callback); 275 sync_service_->set_backend_init_callback(callback);
274 276
275 // Register the session data type. 277 // Register the session data type.
276 SessionDataTypeController *dtc = new SessionDataTypeController(factory, 278 SessionDataTypeController *dtc = new SessionDataTypeController(factory,
277 profile(), 279 profile(),
278 sync_service_.get()); 280 sync_service_.get());
279 sync_service_->RegisterDataTypeController(dtc); 281 sync_service_->RegisterDataTypeController(dtc);
280 282
281 model_associator_ = 283 model_associator_ =
282 new SessionModelAssociator(sync_service_.get(), 284 new SessionModelAssociator(sync_service_.get(),
283 true /* setup_for_test */); 285 true /* setup_for_test */);
284 change_processor_ = new SessionChangeProcessor( 286 change_processor_ = new SessionChangeProcessor(
285 dtc, model_associator_, 287 dtc, model_associator_,
286 true /* setup_for_test */); 288 true /* setup_for_test */);
287 EXPECT_CALL(*factory, CreateSessionSyncComponents(_, _)). 289 EXPECT_CALL(*factory, CreateSessionSyncComponents(_, _)).
288 WillOnce(Return(ProfileSyncComponentsFactory::SyncComponents( 290 WillOnce(Return(ProfileSyncComponentsFactory::SyncComponents(
289 model_associator_, change_processor_))); 291 model_associator_, change_processor_)));
290 EXPECT_CALL(*factory, CreateDataTypeManager(_, _, _, _, _, _)). 292 EXPECT_CALL(*factory, CreateDataTypeManager(_, _, _, _, _, _)).
291 WillOnce(ReturnNewDataTypeManager()); 293 WillOnce(ReturnNewDataTypeManager());
292 294
293 TokenServiceFactory::GetForProfile(profile())->IssueAuthTokenForTest( 295 TokenServiceFactory::GetForProfile(profile())->IssueAuthTokenForTest(
296 GaiaConstants::kGaiaOAuth2LoginRefreshToken, "oauth2_login_token");
297 TokenServiceFactory::GetForProfile(profile())->IssueAuthTokenForTest(
294 GaiaConstants::kSyncService, "token"); 298 GaiaConstants::kSyncService, "token");
295 sync_service_->Initialize(); 299 sync_service_->Initialize();
296 base::MessageLoop::current()->Run(); 300 base::MessageLoop::current()->Run();
297 return true; 301 return true;
298 } 302 }
299 303
300 content::TestBrowserThread io_thread_; 304 content::TestBrowserThread io_thread_;
301 // Path used in testing. 305 // Path used in testing.
302 base::ScopedTempDir temp_dir_; 306 base::ScopedTempDir temp_dir_;
303 SessionModelAssociator* model_associator_; 307 SessionModelAssociator* model_associator_;
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 sync_pb::SessionSpecifics specifics; 1248 sync_pb::SessionSpecifics specifics;
1245 header.SetSessionSpecifics(specifics); 1249 header.SetSessionSpecifics(specifics);
1246 } 1250 }
1247 // Ensure we associate properly despite the pre-existing node with our local 1251 // Ensure we associate properly despite the pre-existing node with our local
1248 // tag. 1252 // tag.
1249 error = model_associator_->AssociateModels(NULL, NULL); 1253 error = model_associator_->AssociateModels(NULL, NULL);
1250 ASSERT_FALSE(error.IsSet()); 1254 ASSERT_FALSE(error.IsSet());
1251 } 1255 }
1252 1256
1253 } // namespace browser_sync 1257 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698