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

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

Issue 23382008: Making OAuth2TokenService multi-login aware, updating callers, minor fixes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing to include the update to ProfileSyncService: r224220 Created 7 years, 3 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 namespace browser_sync { 76 namespace browser_sync {
77 77
78 namespace { 78 namespace {
79 79
80 class FakeProfileSyncService : public TestProfileSyncService { 80 class FakeProfileSyncService : public TestProfileSyncService {
81 public: 81 public:
82 FakeProfileSyncService( 82 FakeProfileSyncService(
83 ProfileSyncComponentsFactory* factory, 83 ProfileSyncComponentsFactory* factory,
84 Profile* profile, 84 Profile* profile,
85 SigninManagerBase* signin, 85 SigninManagerBase* signin,
86 OAuth2TokenService* oauth2_token_service, 86 ProfileOAuth2TokenService* oauth2_token_service,
87 ProfileSyncService::StartBehavior behavior, 87 ProfileSyncService::StartBehavior behavior,
88 bool synchronous_backend_initialization) 88 bool synchronous_backend_initialization)
89 : TestProfileSyncService(factory, 89 : TestProfileSyncService(factory,
90 profile, 90 profile,
91 signin, 91 signin,
92 oauth2_token_service, 92 oauth2_token_service,
93 behavior, 93 behavior,
94 synchronous_backend_initialization) {} 94 synchronous_backend_initialization) {}
95 virtual ~FakeProfileSyncService() {} 95 virtual ~FakeProfileSyncService() {}
96 96
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 BrowserWithTestWindowTest::TearDown(); 268 BrowserWithTestWindowTest::TearDown();
269 } 269 }
270 270
271 bool StartSyncService(const base::Closure& callback, 271 bool StartSyncService(const base::Closure& callback,
272 bool will_fail_association) { 272 bool will_fail_association) {
273 if (sync_service_) 273 if (sync_service_)
274 return false; 274 return false;
275 SigninManagerBase* signin = 275 SigninManagerBase* signin =
276 SigninManagerFactory::GetForProfile(profile()); 276 SigninManagerFactory::GetForProfile(profile());
277 signin->SetAuthenticatedUsername("test_user"); 277 signin->SetAuthenticatedUsername("test_user");
278 OAuth2TokenService* oauth2_token_service = 278 ProfileOAuth2TokenService* oauth2_token_service =
279 ProfileOAuth2TokenServiceFactory::GetForProfile(profile()); 279 ProfileOAuth2TokenServiceFactory::GetForProfile(profile());
280 ProfileSyncComponentsFactoryMock* factory = 280 ProfileSyncComponentsFactoryMock* factory =
281 new ProfileSyncComponentsFactoryMock(); 281 new ProfileSyncComponentsFactoryMock();
282 sync_service_.reset(new FakeProfileSyncService( 282 sync_service_.reset(new FakeProfileSyncService(
283 factory, 283 factory,
284 profile(), 284 profile(),
285 signin, 285 signin,
286 oauth2_token_service, 286 oauth2_token_service,
287 ProfileSyncService::AUTO_START, 287 ProfileSyncService::AUTO_START,
288 false)); 288 false));
(...skipping 10 matching lines...) Expand all
299 true /* setup_for_test */); 299 true /* setup_for_test */);
300 change_processor_ = new SessionChangeProcessor( 300 change_processor_ = new SessionChangeProcessor(
301 dtc, model_associator_, 301 dtc, model_associator_,
302 true /* setup_for_test */); 302 true /* setup_for_test */);
303 EXPECT_CALL(*factory, CreateSessionSyncComponents(_, _)). 303 EXPECT_CALL(*factory, CreateSessionSyncComponents(_, _)).
304 WillOnce(Return(ProfileSyncComponentsFactory::SyncComponents( 304 WillOnce(Return(ProfileSyncComponentsFactory::SyncComponents(
305 model_associator_, change_processor_))); 305 model_associator_, change_processor_)));
306 EXPECT_CALL(*factory, CreateDataTypeManager(_, _, _, _, _, _)). 306 EXPECT_CALL(*factory, CreateDataTypeManager(_, _, _, _, _, _)).
307 WillOnce(ReturnNewDataTypeManager()); 307 WillOnce(ReturnNewDataTypeManager());
308 308
309 TokenServiceFactory::GetForProfile(profile())->IssueAuthTokenForTest( 309 ProfileOAuth2TokenServiceFactory::GetForProfile(profile())
310 GaiaConstants::kGaiaOAuth2LoginRefreshToken, "oauth2_login_token"); 310 ->UpdateCredentials("test_user", "oauth2_login_token");
311 TokenServiceFactory::GetForProfile(profile())->IssueAuthTokenForTest( 311 TokenServiceFactory::GetForProfile(profile())
312 GaiaConstants::kSyncService, "token"); 312 ->IssueAuthTokenForTest(GaiaConstants::kSyncService, "token");
313 sync_service_->Initialize(); 313 sync_service_->Initialize();
314 base::MessageLoop::current()->Run(); 314 base::MessageLoop::current()->Run();
315 return true; 315 return true;
316 } 316 }
317 317
318 // Path used in testing. 318 // Path used in testing.
319 base::ScopedTempDir temp_dir_; 319 base::ScopedTempDir temp_dir_;
320 SessionModelAssociator* model_associator_; 320 SessionModelAssociator* model_associator_;
321 SessionChangeProcessor* change_processor_; 321 SessionChangeProcessor* change_processor_;
322 SessionID window_id_; 322 SessionID window_id_;
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 tab_node.SetSessionSpecifics(specifics); 1400 tab_node.SetSessionSpecifics(specifics);
1401 } 1401 }
1402 1402
1403 error = model_associator_->DisassociateModels(); 1403 error = model_associator_->DisassociateModels();
1404 ASSERT_FALSE(error.IsSet()); 1404 ASSERT_FALSE(error.IsSet());
1405 error = model_associator_->AssociateModels(NULL, NULL); 1405 error = model_associator_->AssociateModels(NULL, NULL);
1406 ASSERT_FALSE(error.IsSet()); 1406 ASSERT_FALSE(error.IsSet());
1407 } 1407 }
1408 1408
1409 } // namespace browser_sync 1409 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698