OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/sync_file_system/drive_backend/conflict_resolver.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/conflict_resolver.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 void TearDown() override { | 90 void TearDown() override { |
91 sync_task_manager_.reset(); | 91 sync_task_manager_.reset(); |
92 RevokeSyncableFileSystem(); | 92 RevokeSyncableFileSystem(); |
93 fake_drive_helper_.reset(); | 93 fake_drive_helper_.reset(); |
94 context_.reset(); | 94 context_.reset(); |
95 base::RunLoop().RunUntilIdle(); | 95 base::RunLoop().RunUntilIdle(); |
96 } | 96 } |
97 | 97 |
98 void InitializeMetadataDatabase() { | 98 void InitializeMetadataDatabase() { |
99 SyncEngineInitializer* initializer = | 99 SyncEngineInitializer* initializer = new SyncEngineInitializer( |
100 new SyncEngineInitializer(context_.get(), | 100 context_.get(), database_dir_.GetPath(), in_memory_env_.get()); |
101 database_dir_.path(), | |
102 in_memory_env_.get()); | |
103 SyncStatusCode status = SYNC_STATUS_UNKNOWN; | 101 SyncStatusCode status = SYNC_STATUS_UNKNOWN; |
104 sync_task_manager_->ScheduleSyncTask( | 102 sync_task_manager_->ScheduleSyncTask( |
105 FROM_HERE, std::unique_ptr<SyncTask>(initializer), | 103 FROM_HERE, std::unique_ptr<SyncTask>(initializer), |
106 SyncTaskManager::PRIORITY_MED, | 104 SyncTaskManager::PRIORITY_MED, |
107 base::Bind(&ConflictResolverTest::DidInitializeMetadataDatabase, | 105 base::Bind(&ConflictResolverTest::DidInitializeMetadataDatabase, |
108 base::Unretained(this), initializer, &status)); | 106 base::Unretained(this), initializer, &status)); |
109 | 107 |
110 base::RunLoop().RunUntilIdle(); | 108 base::RunLoop().RunUntilIdle(); |
111 EXPECT_EQ(SYNC_STATUS_OK, status); | 109 EXPECT_EQ(SYNC_STATUS_OK, status); |
112 } | 110 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 CreateResultReceiver(&status))); | 183 CreateResultReceiver(&status))); |
186 base::RunLoop().RunUntilIdle(); | 184 base::RunLoop().RunUntilIdle(); |
187 return status; | 185 return status; |
188 } | 186 } |
189 | 187 |
190 SyncStatusCode RunLocalToRemoteSyncer(const storage::FileSystemURL& url, | 188 SyncStatusCode RunLocalToRemoteSyncer(const storage::FileSystemURL& url, |
191 const FileChange& file_change) { | 189 const FileChange& file_change) { |
192 SyncStatusCode status = SYNC_STATUS_UNKNOWN; | 190 SyncStatusCode status = SYNC_STATUS_UNKNOWN; |
193 base::FilePath local_path = base::FilePath(FILE_PATH_LITERAL("dummy")); | 191 base::FilePath local_path = base::FilePath(FILE_PATH_LITERAL("dummy")); |
194 if (file_change.IsAddOrUpdate()) | 192 if (file_change.IsAddOrUpdate()) |
195 CreateTemporaryFileInDir(database_dir_.path(), &local_path); | 193 CreateTemporaryFileInDir(database_dir_.GetPath(), &local_path); |
196 std::unique_ptr<LocalToRemoteSyncer> syncer(new LocalToRemoteSyncer( | 194 std::unique_ptr<LocalToRemoteSyncer> syncer(new LocalToRemoteSyncer( |
197 context_.get(), | 195 context_.get(), |
198 SyncFileMetadata(file_change.file_type(), 0, base::Time()), file_change, | 196 SyncFileMetadata(file_change.file_type(), 0, base::Time()), file_change, |
199 local_path, url)); | 197 local_path, url)); |
200 syncer->RunPreflight(SyncTaskToken::CreateForTesting( | 198 syncer->RunPreflight(SyncTaskToken::CreateForTesting( |
201 CreateResultReceiver(&status))); | 199 CreateResultReceiver(&status))); |
202 base::RunLoop().RunUntilIdle(); | 200 base::RunLoop().RunUntilIdle(); |
203 if (status == SYNC_STATUS_OK) | 201 if (status == SYNC_STATUS_OK) |
204 remote_change_processor_->ClearLocalChanges(url); | 202 remote_change_processor_->ClearLocalChanges(url); |
205 return status; | 203 return status; |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 | 516 |
519 EXPECT_EQ(4, CountParents(file)); | 517 EXPECT_EQ(4, CountParents(file)); |
520 | 518 |
521 EXPECT_EQ(SYNC_STATUS_OK, RunConflictResolver()); | 519 EXPECT_EQ(SYNC_STATUS_OK, RunConflictResolver()); |
522 | 520 |
523 EXPECT_EQ(1, CountParents(file)); | 521 EXPECT_EQ(1, CountParents(file)); |
524 } | 522 } |
525 | 523 |
526 } // namespace drive_backend | 524 } // namespace drive_backend |
527 } // namespace sync_file_system | 525 } // namespace sync_file_system |
OLD | NEW |