| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 virtual void SetUp() OVERRIDE { | 46 virtual void SetUp() OVERRIDE { |
| 47 ASSERT_TRUE(base_dir_.CreateUniqueTempDir()); | 47 ASSERT_TRUE(base_dir_.CreateUniqueTempDir()); |
| 48 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); | 48 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); |
| 49 | 49 |
| 50 io_task_runner_ = content::BrowserThread::GetMessageLoopProxyForThread( | 50 io_task_runner_ = content::BrowserThread::GetMessageLoopProxyForThread( |
| 51 content::BrowserThread::IO); | 51 content::BrowserThread::IO); |
| 52 file_task_runner_ = content::BrowserThread::GetMessageLoopProxyForThread( | 52 file_task_runner_ = content::BrowserThread::GetMessageLoopProxyForThread( |
| 53 content::BrowserThread::FILE); | 53 content::BrowserThread::FILE); |
| 54 | 54 |
| 55 RegisterSyncableFileSystem(); | 55 RegisterSyncableFileSystem(); |
| 56 local_sync_service_.reset(new LocalFileSyncService(&profile_)); | 56 local_sync_service_ = LocalFileSyncService::CreateForTesting( |
| 57 &profile_, in_memory_env_.get()); |
| 57 | 58 |
| 58 scoped_ptr<drive::FakeDriveService> drive_service( | 59 scoped_ptr<drive::FakeDriveService> drive_service( |
| 59 new drive::FakeDriveService()); | 60 new drive::FakeDriveService()); |
| 60 drive_service->Initialize("test@example.com"); | 61 drive_service->Initialize("test@example.com"); |
| 61 ASSERT_TRUE(drive_service->LoadAccountMetadataForWapi( | 62 ASSERT_TRUE(drive_service->LoadAccountMetadataForWapi( |
| 62 "sync_file_system/account_metadata.json")); | 63 "sync_file_system/account_metadata.json")); |
| 63 ASSERT_TRUE(drive_service->LoadResourceListForWapi( | 64 ASSERT_TRUE(drive_service->LoadResourceListForWapi( |
| 64 "gdata/root_feed.json")); | 65 "gdata/root_feed.json")); |
| 65 | 66 |
| 66 scoped_ptr<drive::DriveUploaderInterface> uploader( | 67 scoped_ptr<drive::DriveUploaderInterface> uploader( |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 path != result_path) | 137 path != result_path) |
| 137 return false; | 138 return false; |
| 138 *file_id = tracker.file_id(); | 139 *file_id = tracker.file_id(); |
| 139 return true; | 140 return true; |
| 140 } | 141 } |
| 141 | 142 |
| 142 SyncStatusCode RegisterApp(const std::string& app_id) { | 143 SyncStatusCode RegisterApp(const std::string& app_id) { |
| 143 GURL origin = extensions::Extension::GetBaseURLFromExtensionId(app_id); | 144 GURL origin = extensions::Extension::GetBaseURLFromExtensionId(app_id); |
| 144 if (!ContainsKey(file_systems_, app_id)) { | 145 if (!ContainsKey(file_systems_, app_id)) { |
| 145 CannedSyncableFileSystem* file_system = new CannedSyncableFileSystem( | 146 CannedSyncableFileSystem* file_system = new CannedSyncableFileSystem( |
| 146 origin, io_task_runner_.get(), file_task_runner_.get()); | 147 origin, in_memory_env_.get(), |
| 148 io_task_runner_.get(), file_task_runner_.get()); |
| 147 file_system->SetUp(); | 149 file_system->SetUp(); |
| 148 | 150 |
| 149 SyncStatusCode status = SYNC_STATUS_UNKNOWN; | 151 SyncStatusCode status = SYNC_STATUS_UNKNOWN; |
| 150 local_sync_service_->MaybeInitializeFileSystemContext( | 152 local_sync_service_->MaybeInitializeFileSystemContext( |
| 151 origin, file_system->file_system_context(), | 153 origin, file_system->file_system_context(), |
| 152 CreateResultReceiver(&status)); | 154 CreateResultReceiver(&status)); |
| 153 base::RunLoop().RunUntilIdle(); | 155 base::RunLoop().RunUntilIdle(); |
| 154 EXPECT_EQ(SYNC_STATUS_OK, status); | 156 EXPECT_EQ(SYNC_STATUS_OK, status); |
| 155 | 157 |
| 156 file_system->backend()->sync_context()-> | 158 file_system->backend()->sync_context()-> |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 EXPECT_EQ(1u, CountApp()); | 639 EXPECT_EQ(1u, CountApp()); |
| 638 EXPECT_EQ(2u, CountLocalFile(app_id)); | 640 EXPECT_EQ(2u, CountLocalFile(app_id)); |
| 639 VerifyLocalFile(app_id, base::FilePath(FPL("file")), "abcde"); | 641 VerifyLocalFile(app_id, base::FilePath(FPL("file")), "abcde"); |
| 640 | 642 |
| 641 EXPECT_EQ(3u, CountMetadata()); | 643 EXPECT_EQ(3u, CountMetadata()); |
| 642 EXPECT_EQ(3u, CountTracker()); | 644 EXPECT_EQ(3u, CountTracker()); |
| 643 } | 645 } |
| 644 | 646 |
| 645 } // namespace drive_backend | 647 } // namespace drive_backend |
| 646 } // namespace sync_file_system | 648 } // namespace sync_file_system |
| OLD | NEW |