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

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

Issue 23068005: Convert UserPolicySigninService to use OAuth2TokenService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Corrected comment. Created 7 years, 4 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 <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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 tab->set_extension_app_id("app_id"); 205 tab->set_extension_app_id("app_id");
206 sync_pb::TabNavigation* navigation = tab->add_navigation(); 206 sync_pb::TabNavigation* navigation = tab->add_navigation();
207 navigation->set_virtual_url("http://foo/1"); 207 navigation->set_virtual_url("http://foo/1");
208 navigation->set_referrer("referrer"); 208 navigation->set_referrer("referrer");
209 navigation->set_title("title"); 209 navigation->set_title("title");
210 navigation->set_page_transition(sync_pb::SyncEnums_PageTransition_TYPED); 210 navigation->set_page_transition(sync_pb::SyncEnums_PageTransition_TYPED);
211 } 211 }
212 212
213 protected: 213 protected:
214 virtual TestingProfile* CreateProfile() OVERRIDE { 214 virtual TestingProfile* CreateProfile() OVERRIDE {
215 TestingProfile* profile = new TestingProfile(); 215 TestingProfile::Builder builder;
216 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(),
217 FakeOAuth2TokenService::BuildTokenService);
216 // Don't want the profile to create a real ProfileSyncService. 218 // Don't want the profile to create a real ProfileSyncService.
217 ProfileSyncServiceFactory::GetInstance()->SetTestingFactory(profile, 219 builder.AddTestingFactory(ProfileSyncServiceFactory::GetInstance(), NULL);
218 NULL); 220 scoped_ptr<TestingProfile> profile(builder.Build().Pass());
awong 2013/08/19 19:47:21 .Pass() on return values are always superfluous.
Andrew T Wilson (Slow) 2013/08/20 09:28:35 Thanks! I appreciate the drive-by - I learned thin
219 invalidation::InvalidationServiceFactory::GetInstance()-> 221 invalidation::InvalidationServiceFactory::GetInstance()->
220 SetBuildOnlyFakeInvalidatorsForTest(true); 222 SetBuildOnlyFakeInvalidatorsForTest(true);
221 return profile; 223 return profile.release();
222 } 224 }
223 225
224 virtual void SetUp() { 226 virtual void SetUp() {
225 // BrowserWithTestWindowTest implementation. 227 // BrowserWithTestWindowTest implementation.
226 BrowserWithTestWindowTest::SetUp(); 228 BrowserWithTestWindowTest::SetUp();
227 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 229 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
228 registrar_.Add(this, chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED, 230 registrar_.Add(this, chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED,
229 content::NotificationService::AllSources()); 231 content::NotificationService::AllSources());
230 registrar_.Add(this, chrome::NOTIFICATION_SYNC_REFRESH_LOCAL, 232 registrar_.Add(this, chrome::NOTIFICATION_SYNC_REFRESH_LOCAL,
231 content::NotificationService::AllSources()); 233 content::NotificationService::AllSources());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 BrowserWithTestWindowTest::TearDown(); 266 BrowserWithTestWindowTest::TearDown();
265 } 267 }
266 268
267 bool StartSyncService(const base::Closure& callback, 269 bool StartSyncService(const base::Closure& callback,
268 bool will_fail_association) { 270 bool will_fail_association) {
269 if (sync_service_) 271 if (sync_service_)
270 return false; 272 return false;
271 SigninManagerBase* signin = 273 SigninManagerBase* signin =
272 SigninManagerFactory::GetForProfile(profile()); 274 SigninManagerFactory::GetForProfile(profile());
273 signin->SetAuthenticatedUsername("test_user"); 275 signin->SetAuthenticatedUsername("test_user");
274 ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory(
275 profile(), FakeOAuth2TokenService::BuildTokenService);
276 ProfileSyncComponentsFactoryMock* factory = 276 ProfileSyncComponentsFactoryMock* factory =
277 new ProfileSyncComponentsFactoryMock(); 277 new ProfileSyncComponentsFactoryMock();
278 sync_service_.reset(new FakeProfileSyncService( 278 sync_service_.reset(new FakeProfileSyncService(
279 factory, 279 factory,
280 profile(), 280 profile(),
281 signin, 281 signin,
282 ProfileSyncService::AUTO_START, 282 ProfileSyncService::AUTO_START,
283 false)); 283 false));
284 sync_service_->set_backend_init_callback(callback); 284 sync_service_->set_backend_init_callback(callback);
285 285
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 tab_node.SetSessionSpecifics(specifics); 1395 tab_node.SetSessionSpecifics(specifics);
1396 } 1396 }
1397 1397
1398 error = model_associator_->DisassociateModels(); 1398 error = model_associator_->DisassociateModels();
1399 ASSERT_FALSE(error.IsSet()); 1399 ASSERT_FALSE(error.IsSet());
1400 error = model_associator_->AssociateModels(NULL, NULL); 1400 error = model_associator_->AssociateModels(NULL, NULL);
1401 ASSERT_FALSE(error.IsSet()); 1401 ASSERT_FALSE(error.IsSet());
1402 } 1402 }
1403 1403
1404 } // namespace browser_sync 1404 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698