| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <stack> | 6 #include <stack> |
| 7 | 7 |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 virtual void SetUp() OVERRIDE { | 44 virtual void SetUp() OVERRIDE { |
| 45 ASSERT_TRUE(base_dir_.CreateUniqueTempDir()); | 45 ASSERT_TRUE(base_dir_.CreateUniqueTempDir()); |
| 46 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); | 46 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); |
| 47 | 47 |
| 48 io_task_runner_ = content::BrowserThread::GetMessageLoopProxyForThread( | 48 io_task_runner_ = content::BrowserThread::GetMessageLoopProxyForThread( |
| 49 content::BrowserThread::IO); | 49 content::BrowserThread::IO); |
| 50 file_task_runner_ = content::BrowserThread::GetMessageLoopProxyForThread( | 50 file_task_runner_ = content::BrowserThread::GetMessageLoopProxyForThread( |
| 51 content::BrowserThread::FILE); | 51 content::BrowserThread::FILE); |
| 52 | 52 |
| 53 RegisterSyncableFileSystem(); | 53 RegisterSyncableFileSystem(); |
| 54 local_sync_service_.reset(new LocalFileSyncService(&profile_)); | 54 local_sync_service_ = LocalFileSyncService::CreateForTesting( |
| 55 &profile_, in_memory_env_.get()); |
| 55 | 56 |
| 56 scoped_ptr<drive::FakeDriveService> drive_service( | 57 scoped_ptr<drive::FakeDriveService> drive_service( |
| 57 new drive::FakeDriveService()); | 58 new drive::FakeDriveService()); |
| 58 drive_service->Initialize("test@example.com"); | 59 drive_service->Initialize("test@example.com"); |
| 59 ASSERT_TRUE(drive_service->LoadAccountMetadataForWapi( | 60 ASSERT_TRUE(drive_service->LoadAccountMetadataForWapi( |
| 60 "sync_file_system/account_metadata.json")); | 61 "sync_file_system/account_metadata.json")); |
| 61 ASSERT_TRUE(drive_service->LoadResourceListForWapi( | 62 ASSERT_TRUE(drive_service->LoadResourceListForWapi( |
| 62 "gdata/root_feed.json")); | 63 "gdata/root_feed.json")); |
| 63 | 64 |
| 64 scoped_ptr<drive::DriveUploaderInterface> uploader( | 65 scoped_ptr<drive::DriveUploaderInterface> uploader( |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 path != result_path) | 129 path != result_path) |
| 129 return false; | 130 return false; |
| 130 *file_id = tracker.file_id(); | 131 *file_id = tracker.file_id(); |
| 131 return true; | 132 return true; |
| 132 } | 133 } |
| 133 | 134 |
| 134 SyncStatusCode RegisterApp(const std::string& app_id) { | 135 SyncStatusCode RegisterApp(const std::string& app_id) { |
| 135 GURL origin = extensions::Extension::GetBaseURLFromExtensionId(app_id); | 136 GURL origin = extensions::Extension::GetBaseURLFromExtensionId(app_id); |
| 136 if (!ContainsKey(file_systems_, app_id)) { | 137 if (!ContainsKey(file_systems_, app_id)) { |
| 137 CannedSyncableFileSystem* file_system = new CannedSyncableFileSystem( | 138 CannedSyncableFileSystem* file_system = new CannedSyncableFileSystem( |
| 138 origin, io_task_runner_.get(), file_task_runner_.get()); | 139 origin, in_memory_env_.get(), |
| 140 io_task_runner_.get(), file_task_runner_.get()); |
| 139 file_system->SetUp(); | 141 file_system->SetUp(); |
| 140 | 142 |
| 141 SyncStatusCode status = SYNC_STATUS_UNKNOWN; | 143 SyncStatusCode status = SYNC_STATUS_UNKNOWN; |
| 142 local_sync_service_->MaybeInitializeFileSystemContext( | 144 local_sync_service_->MaybeInitializeFileSystemContext( |
| 143 origin, file_system->file_system_context(), | 145 origin, file_system->file_system_context(), |
| 144 CreateResultReceiver(&status)); | 146 CreateResultReceiver(&status)); |
| 145 base::RunLoop().RunUntilIdle(); | 147 base::RunLoop().RunUntilIdle(); |
| 146 EXPECT_EQ(SYNC_STATUS_OK, status); | 148 EXPECT_EQ(SYNC_STATUS_OK, status); |
| 147 | 149 |
| 148 file_system->backend()->sync_context()-> | 150 file_system->backend()->sync_context()-> |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 EXPECT_EQ(google_apis::HTTP_SUCCESS, | 530 EXPECT_EQ(google_apis::HTTP_SUCCESS, |
| 529 fake_drive_service_helper()->RenameResource( | 531 fake_drive_service_helper()->RenameResource( |
| 530 file_id, base::FilePath(path).AsUTF8Unsafe())); | 532 file_id, base::FilePath(path).AsUTF8Unsafe())); |
| 531 | 533 |
| 532 EXPECT_EQ(SYNC_STATUS_OK, ProcessChangesUntilDone()); | 534 EXPECT_EQ(SYNC_STATUS_OK, ProcessChangesUntilDone()); |
| 533 VerifyConsistency(); | 535 VerifyConsistency(); |
| 534 } | 536 } |
| 535 | 537 |
| 536 } // namespace drive_backend | 538 } // namespace drive_backend |
| 537 } // namespace sync_file_system | 539 } // namespace sync_file_system |
| OLD | NEW |