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

Unified Diff: chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer_unittest.cc

Issue 213473008: [SyncFS] Split SyncEngine and SyncEngineContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer_unittest.cc
diff --git a/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer_unittest.cc b/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer_unittest.cc
index a416d0553127af9cc38a6e2818da9cd7e95275f6..2deac58bf04bc5441ecc58bfe9f86f0a1009d5c0 100644
--- a/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer_unittest.cc
+++ b/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer_unittest.cc
@@ -42,8 +42,7 @@ fileapi::FileSystemURL URL(const GURL& origin,
} // namespace
-class RemoteToLocalSyncerTest : public testing::Test,
- public SyncEngineContext {
+class RemoteToLocalSyncerTest : public testing::Test {
public:
typedef FakeRemoteChangeProcessor::URLToFileChangesMap URLToFileChangesMap;
@@ -55,19 +54,27 @@ class RemoteToLocalSyncerTest : public testing::Test,
ASSERT_TRUE(database_dir_.CreateUniqueTempDir());
in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default()));
- fake_drive_service_.reset(new drive::FakeDriveService);
- ASSERT_TRUE(fake_drive_service_->LoadAccountMetadataForWapi(
+ scoped_ptr<drive::FakeDriveService> fake_drive_service;
+ fake_drive_service.reset(new drive::FakeDriveService);
+ ASSERT_TRUE(fake_drive_service->LoadAccountMetadataForWapi(
"sync_file_system/account_metadata.json"));
- ASSERT_TRUE(fake_drive_service_->LoadResourceListForWapi(
+ ASSERT_TRUE(fake_drive_service->LoadResourceListForWapi(
"gdata/empty_feed.json"));
- drive_uploader_.reset(new drive::DriveUploader(
- fake_drive_service_.get(), base::MessageLoopProxy::current().get()));
+ scoped_ptr<drive::DriveUploader> drive_uploader;
+ drive_uploader.reset(new drive::DriveUploader(
+ fake_drive_service.get(), base::MessageLoopProxy::current().get()));
fake_drive_helper_.reset(new FakeDriveServiceHelper(
- fake_drive_service_.get(), drive_uploader_.get(),
+ fake_drive_service.get(), drive_uploader.get(),
kSyncRootFolderTitle));
fake_remote_change_processor_.reset(new FakeRemoteChangeProcessor);
+ context_.reset(new SyncEngineContext(
+ fake_drive_service.PassAs<drive::DriveServiceInterface>(),
+ drive_uploader.PassAs<drive::DriveUploaderInterface>(),
+ base::MessageLoopProxy::current()));
+ context_->SetRemoteChangeProcessor(fake_remote_change_processor_.get());
+
RegisterSyncableFileSystem();
}
@@ -75,53 +82,35 @@ class RemoteToLocalSyncerTest : public testing::Test,
RevokeSyncableFileSystem();
fake_remote_change_processor_.reset();
- metadata_database_.reset();
fake_drive_helper_.reset();
- drive_uploader_.reset();
- fake_drive_service_.reset();
+ context_.reset();
base::RunLoop().RunUntilIdle();
}
void InitializeMetadataDatabase() {
- SyncEngineInitializer initializer(this,
+ SyncEngineInitializer initializer(context_.get(),
base::MessageLoopProxy::current(),
- fake_drive_service_.get(),
+ context_->GetDriveService(),
database_dir_.path(),
in_memory_env_.get());
SyncStatusCode status = SYNC_STATUS_UNKNOWN;
initializer.RunSequential(CreateResultReceiver(&status));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(SYNC_STATUS_OK, status);
- metadata_database_ = initializer.PassMetadataDatabase();
+ context_->SetMetadataDatabase(initializer.PassMetadataDatabase());
}
void RegisterApp(const std::string& app_id,
const std::string& app_root_folder_id) {
SyncStatusCode status = SYNC_STATUS_FAILED;
- metadata_database_->RegisterApp(app_id, app_root_folder_id,
- CreateResultReceiver(&status));
+ context_->GetMetadataDatabase()->RegisterApp(app_id, app_root_folder_id,
+ CreateResultReceiver(&status));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(SYNC_STATUS_OK, status);
}
- virtual drive::DriveServiceInterface* GetDriveService() OVERRIDE {
- return fake_drive_service_.get();
- }
-
- virtual drive::DriveUploaderInterface* GetDriveUploader() OVERRIDE {
- return drive_uploader_.get();
- }
-
- virtual MetadataDatabase* GetMetadataDatabase() OVERRIDE {
- return metadata_database_.get();
- }
-
- virtual RemoteChangeProcessor* GetRemoteChangeProcessor() OVERRIDE {
- return fake_remote_change_processor_.get();
- }
-
- virtual base::SequencedTaskRunner* GetBlockingTaskRunner() OVERRIDE {
- return base::MessageLoopProxy::current().get();
+ MetadataDatabase* GetMetadataDatabase() {
+ return context_->GetMetadataDatabase();
}
protected:
@@ -171,7 +160,8 @@ class RemoteToLocalSyncerTest : public testing::Test,
SyncStatusCode RunSyncer() {
SyncStatusCode status = SYNC_STATUS_UNKNOWN;
- scoped_ptr<RemoteToLocalSyncer> syncer(new RemoteToLocalSyncer(this));
+ scoped_ptr<RemoteToLocalSyncer>
+ syncer(new RemoteToLocalSyncer(context_.get()));
syncer->RunSequential(CreateResultReceiver(&status));
base::RunLoop().RunUntilIdle();
return status;
@@ -184,7 +174,7 @@ class RemoteToLocalSyncerTest : public testing::Test,
}
SyncStatusCode ListChanges() {
- ListChangesTask list_changes(this);
+ ListChangesTask list_changes(context_.get());
SyncStatusCode status = SYNC_STATUS_UNKNOWN;
list_changes.RunSequential(CreateResultReceiver(&status));
base::RunLoop().RunUntilIdle();
@@ -206,10 +196,8 @@ class RemoteToLocalSyncerTest : public testing::Test,
base::ScopedTempDir database_dir_;
scoped_ptr<leveldb::Env> in_memory_env_;
- scoped_ptr<drive::FakeDriveService> fake_drive_service_;
- scoped_ptr<drive::DriveUploader> drive_uploader_;
+ scoped_ptr<SyncEngineContext> context_;
scoped_ptr<FakeDriveServiceHelper> fake_drive_helper_;
- scoped_ptr<MetadataDatabase> metadata_database_;
scoped_ptr<FakeRemoteChangeProcessor> fake_remote_change_processor_;
URLToFileChangesMap expected_changes_;

Powered by Google App Engine
This is Rietveld 408576698