#include "base/files/scoped_temp_dir.h"
#include "base/run_loop.h"
#include "chrome/browser/drive/drive_api_util.h"
+#include "chrome/browser/drive/drive_uploader.h"
#include "chrome/browser/drive/fake_drive_service.h"
#include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h"
#include "chrome/browser/sync_file_system/drive_backend/drive_backend_test_util.h"
#include "chrome/browser/sync_file_system/drive_backend/metadata_database.h"
#include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h"
+#include "chrome/browser/sync_file_system/drive_backend/sync_engine_context.h"
#include "chrome/browser/sync_file_system/drive_backend/sync_task_manager.h"
#include "chrome/browser/sync_file_system/sync_file_system_test_util.h"
#include "content/public/test/test_browser_thread_bundle.h"
virtual void SetUp() OVERRIDE {
ASSERT_TRUE(database_dir_.CreateUniqueTempDir());
in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default()));
- ASSERT_TRUE(fake_drive_service_.LoadAccountMetadataForWapi(
- "sync_file_system/account_metadata.json"));
- ASSERT_TRUE(fake_drive_service_.LoadResourceListForWapi(
- "gdata/empty_feed.json"));
+
+ scoped_ptr<drive::DriveServiceInterface>
+ fake_drive_service(new drive::FakeDriveService);
+
+ sync_context_.reset(new SyncEngineContext(
+ fake_drive_service.Pass(),
+ scoped_ptr<drive::DriveUploaderInterface>(),
+ base::MessageLoopProxy::current(),
+ base::MessageLoopProxy::current(),
+ base::MessageLoopProxy::current()));
sync_task_manager_.reset(new SyncTaskManager(
base::WeakPtr<SyncTaskManager::Client>(),
virtual void TearDown() OVERRIDE {
sync_task_manager_.reset();
metadata_database_.reset();
+ sync_context_.reset();
base::RunLoop().RunUntilIdle();
}
SyncStatusCode RunInitializer() {
SyncEngineInitializer* initializer =
new SyncEngineInitializer(
- NULL,
+ sync_context_.get(),
base::MessageLoopProxy::current(),
- &fake_drive_service_,
database_path(),
in_memory_env_.get());
SyncStatusCode status = SYNC_STATUS_UNKNOWN;
scoped_ptr<MetadataDatabase> database;
MetadataDatabase::Create(
base::MessageLoopProxy::current(),
+ base::MessageLoopProxy::current(),
database_path(),
in_memory_env_.get(),
CreateResultReceiver(&status, &database));
const std::string& title) {
google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
scoped_ptr<google_apis::ResourceEntry> entry;
- fake_drive_service_.AddNewDirectory(
+ sync_context_->GetDriveService()->AddNewDirectory(
parent_folder_id, title,
drive::DriveServiceInterface::AddNewDirectoryOptions(),
CreateResultReceiver(&error, &entry));
for (size_t i = 0; i < sync_root->parents().size(); ++i) {
google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
- fake_drive_service_.RemoveResourceFromDirectory(
+ sync_context_->GetDriveService()->RemoveResourceFromDirectory(
sync_root->parents()[i].file_id(),
sync_root->file_id(),
CreateResultReceiver(&error));
bool HasNoParent(const std::string& file_id) {
google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
scoped_ptr<google_apis::ResourceEntry> entry;
- fake_drive_service_.GetResourceEntry(
+ sync_context_->GetDriveService()->GetResourceEntry(
file_id,
CreateResultReceiver(&error, &entry));
base::RunLoop().RunUntilIdle();
const std::string& new_parent_folder_id,
const std::string& file_id) {
google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
- fake_drive_service_.AddResourceToDirectory(
+ sync_context_->GetDriveService()->AddResourceToDirectory(
new_parent_folder_id, file_id,
CreateResultReceiver(&error));
base::RunLoop().RunUntilIdle();
content::TestBrowserThreadBundle browser_threads_;
base::ScopedTempDir database_dir_;
scoped_ptr<leveldb::Env> in_memory_env_;
- drive::FakeDriveService fake_drive_service_;
scoped_ptr<MetadataDatabase> metadata_database_;
scoped_ptr<SyncTaskManager> sync_task_manager_;
+ scoped_ptr<SyncEngineContext> sync_context_;
DISALLOW_COPY_AND_ASSIGN(SyncEngineInitializerTest);
};