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_unittest.cc

Issue 1421003007: [Sync] Componentize ProfileSyncComponentsFactoryImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 5 years, 1 month 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 ACTION_P(ReturnNewDataTypeManager, configure_called) { 98 ACTION_P(ReturnNewDataTypeManager, configure_called) {
99 return new FakeDataTypeManager(configure_called); 99 return new FakeDataTypeManager(configure_called);
100 } 100 }
101 101
102 using testing::Return; 102 using testing::Return;
103 using testing::StrictMock; 103 using testing::StrictMock;
104 using testing::_; 104 using testing::_;
105 105
106 class TestChromeSyncClient : public ChromeSyncClient { 106 class TestChromeSyncClient : public ChromeSyncClient {
107 public: 107 public:
108 TestChromeSyncClient( 108 TestChromeSyncClient(Profile* profile,
109 Profile* profile, 109 sync_driver::ClearBrowsingDataCallback callback)
110 scoped_ptr<sync_driver::SyncApiComponentFactory> component_factory, 110 : ChromeSyncClient(profile), callback_(callback) {}
111 sync_driver::ClearBrowsingDataCallback callback)
112 : ChromeSyncClient(profile, component_factory.Pass()),
113 callback_(callback) {}
114 ~TestChromeSyncClient() override {} 111 ~TestChromeSyncClient() override {}
115 112
116 private: 113 private:
117 // SyncClient: 114 // SyncClient:
118 sync_driver::ClearBrowsingDataCallback GetClearBrowsingDataCallback() 115 sync_driver::ClearBrowsingDataCallback GetClearBrowsingDataCallback()
119 override { 116 override {
120 return callback_; 117 return callback_;
121 } 118 }
122 119
123 sync_driver::ClearBrowsingDataCallback callback_; 120 sync_driver::ClearBrowsingDataCallback callback_;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_) 290 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)
294 ->UpdateCredentials(account_id, "oauth2_login_token"); 291 ->UpdateCredentials(account_id, "oauth2_login_token");
295 } 292 }
296 293
297 void CreateService(ProfileSyncServiceStartBehavior behavior) { 294 void CreateService(ProfileSyncServiceStartBehavior behavior) {
298 SigninManagerBase* signin = 295 SigninManagerBase* signin =
299 SigninManagerFactory::GetForProfile(profile_); 296 SigninManagerFactory::GetForProfile(profile_);
300 signin->SetAuthenticatedAccountInfo(kGaiaId, kEmail); 297 signin->SetAuthenticatedAccountInfo(kGaiaId, kEmail);
301 ProfileOAuth2TokenService* oauth2_token_service = 298 ProfileOAuth2TokenService* oauth2_token_service =
302 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); 299 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
303 scoped_ptr<SyncApiComponentFactoryMock> components_factory(
304 new SyncApiComponentFactoryMock());
305 components_factory_ = components_factory.get();
306 scoped_ptr<ChromeSyncClient> sync_client(new TestChromeSyncClient( 300 scoped_ptr<ChromeSyncClient> sync_client(new TestChromeSyncClient(
307 profile_, components_factory.Pass(), 301 profile_, base::Bind(&ProfileSyncServiceTest::ClearBrowsingDataCallback,
308 base::Bind(&ProfileSyncServiceTest::ClearBrowsingDataCallback, 302 base::Unretained(this))));
309 base::Unretained(this))));
310 service_.reset(new ProfileSyncService( 303 service_.reset(new ProfileSyncService(
311 sync_client.Pass(), 304 sync_client.Pass(),
312 make_scoped_ptr(new SigninManagerWrapper(signin)), oauth2_token_service, 305 make_scoped_ptr(new SigninManagerWrapper(signin)), oauth2_token_service,
313 behavior, base::Bind(&EmptyNetworkTimeUpdate), profile_->GetPath(), 306 behavior, base::Bind(&EmptyNetworkTimeUpdate), profile_->GetPath(),
314 profile_->GetRequestContext(), profile_->GetDebugName(), 307 profile_->GetRequestContext(), profile_->GetDebugName(),
315 chrome::GetChannel(), 308 chrome::GetChannel(),
316 content::BrowserThread::GetMessageLoopProxyForThread( 309 content::BrowserThread::GetMessageLoopProxyForThread(
317 content::BrowserThread::DB), 310 content::BrowserThread::DB),
318 content::BrowserThread::GetMessageLoopProxyForThread( 311 content::BrowserThread::GetMessageLoopProxyForThread(
319 content::BrowserThread::FILE), 312 content::BrowserThread::FILE),
320 content::BrowserThread::GetBlockingPool())); 313 content::BrowserThread::GetBlockingPool()));
314
315 scoped_ptr<SyncApiComponentFactoryMock> components_factory(
316 new SyncApiComponentFactoryMock());
317 components_factory_ = components_factory.get();
318 service_->GetSyncClient()->Initialize(components_factory.Pass(),
319 service_.get());
321 service_->RegisterDataTypeController( 320 service_->RegisterDataTypeController(
322 new sync_driver::FakeDataTypeController(syncer::BOOKMARKS)); 321 new sync_driver::FakeDataTypeController(syncer::BOOKMARKS));
323 } 322 }
324 323
325 #if defined(OS_WIN) || defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(OS_C HROMEOS)) 324 #if defined(OS_WIN) || defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(OS_C HROMEOS))
326 void CreateServiceWithoutSignIn() { 325 void CreateServiceWithoutSignIn() {
327 CreateService(browser_sync::AUTO_START); 326 CreateService(browser_sync::AUTO_START);
328 SigninManagerFactory::GetForProfile(profile())->SignOut( 327 SigninManagerFactory::GetForProfile(profile())->SignOut(
329 signin_metrics::SIGNOUT_TEST); 328 signin_metrics::SIGNOUT_TEST);
330 } 329 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 383
385 void ExpectDataTypeManagerCreation( 384 void ExpectDataTypeManagerCreation(
386 int times, 385 int times,
387 const FakeDataTypeManager::ConfigureCalled& callback) { 386 const FakeDataTypeManager::ConfigureCalled& callback) {
388 EXPECT_CALL(*components_factory_, CreateDataTypeManager(_, _, _, _, _)) 387 EXPECT_CALL(*components_factory_, CreateDataTypeManager(_, _, _, _, _))
389 .Times(times) 388 .Times(times)
390 .WillRepeatedly(ReturnNewDataTypeManager(callback)); 389 .WillRepeatedly(ReturnNewDataTypeManager(callback));
391 } 390 }
392 391
393 void ExpectSyncBackendHostCreation(int times) { 392 void ExpectSyncBackendHostCreation(int times) {
394 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _, _)) 393 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _))
395 .Times(times) 394 .Times(times)
396 .WillRepeatedly(ReturnNewSyncBackendHostMock()); 395 .WillRepeatedly(ReturnNewSyncBackendHostMock());
397 } 396 }
398 397
399 void ExpectSyncBackendHostCreationCollectDeleteDir( 398 void ExpectSyncBackendHostCreationCollectDeleteDir(
400 int times, std::vector<bool> *delete_dir_param) { 399 int times, std::vector<bool> *delete_dir_param) {
401 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _, _)) 400 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _))
402 .Times(times) 401 .Times(times)
403 .WillRepeatedly( 402 .WillRepeatedly(
404 ReturnNewMockHostCollectDeleteDirParam(delete_dir_param)); 403 ReturnNewMockHostCollectDeleteDirParam(delete_dir_param));
405 } 404 }
406 405
407 void ExpectSyncBackendHostCreationCaptureClearServerData( 406 void ExpectSyncBackendHostCreationCaptureClearServerData(
408 syncer::SyncManager::ClearServerDataCallback* captured_callback) { 407 syncer::SyncManager::ClearServerDataCallback* captured_callback) {
409 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _, _)) 408 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _))
410 .Times(1) 409 .Times(1)
411 .WillOnce(ReturnNewMockHostCaptureClearServerData(captured_callback)); 410 .WillOnce(ReturnNewMockHostCaptureClearServerData(captured_callback));
412 } 411 }
413 412
414 void PrepareDelayedInitSyncBackendHost() { 413 void PrepareDelayedInitSyncBackendHost() {
415 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _, _)) 414 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _))
416 .WillOnce(ReturnNewSyncBackendHostNoReturn()); 415 .WillOnce(ReturnNewSyncBackendHostNoReturn());
417 } 416 }
418 417
419 TestingProfile* profile() { 418 TestingProfile* profile() {
420 return profile_; 419 return profile_;
421 } 420 }
422 421
423 ProfileSyncService* service() { 422 ProfileSyncService* service() {
424 return service_.get(); 423 return service_.get();
425 } 424 }
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 InitializeForNthSync(); 1054 InitializeForNthSync();
1056 1055
1057 syncer::SyncProtocolError client_cmd; 1056 syncer::SyncProtocolError client_cmd;
1058 client_cmd.action = syncer::RESET_LOCAL_SYNC_DATA; 1057 client_cmd.action = syncer::RESET_LOCAL_SYNC_DATA;
1059 service()->OnActionableError(client_cmd); 1058 service()->OnActionableError(client_cmd);
1060 EXPECT_EQ(ProfileSyncService::SYNC, service()->backend_mode()); 1059 EXPECT_EQ(ProfileSyncService::SYNC, service()->backend_mode());
1061 } 1060 }
1062 1061
1063 } // namespace 1062 } // namespace
1064 } // namespace browser_sync 1063 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698