| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 RevokeSyncableFileSystem(); | 88 RevokeSyncableFileSystem(); |
| 89 | 89 |
| 90 fake_remote_change_processor_.reset(); | 90 fake_remote_change_processor_.reset(); |
| 91 fake_drive_helper_.reset(); | 91 fake_drive_helper_.reset(); |
| 92 context_.reset(); | 92 context_.reset(); |
| 93 base::RunLoop().RunUntilIdle(); | 93 base::RunLoop().RunUntilIdle(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void InitializeMetadataDatabase() { | 96 void InitializeMetadataDatabase() { |
| 97 SyncEngineInitializer initializer(context_.get(), | 97 SyncEngineInitializer* initializer = |
| 98 base::MessageLoopProxy::current(), | 98 new SyncEngineInitializer(context_.get(), |
| 99 context_->GetDriveService(), | 99 base::MessageLoopProxy::current(), |
| 100 database_dir_.path(), | 100 context_->GetDriveService(), |
| 101 in_memory_env_.get()); | 101 database_dir_.path(), |
| 102 in_memory_env_.get()); |
| 102 SyncStatusCode status = SYNC_STATUS_UNKNOWN; | 103 SyncStatusCode status = SYNC_STATUS_UNKNOWN; |
| 103 initializer.RunSequential(CreateResultReceiver(&status)); | 104 sync_task_manager_->ScheduleSyncTask( |
| 105 FROM_HERE, |
| 106 scoped_ptr<SyncTask>(initializer), |
| 107 SyncTaskManager::PRIORITY_MED, |
| 108 base::Bind(&ConflictResolverTest::DidInitializeMetadataDatabase, |
| 109 base::Unretained(this), initializer, &status)); |
| 110 |
| 104 base::RunLoop().RunUntilIdle(); | 111 base::RunLoop().RunUntilIdle(); |
| 105 EXPECT_EQ(SYNC_STATUS_OK, status); | 112 EXPECT_EQ(SYNC_STATUS_OK, status); |
| 106 context_->SetMetadataDatabase(initializer.PassMetadataDatabase()); | 113 } |
| 114 |
| 115 void DidInitializeMetadataDatabase(SyncEngineInitializer* initializer, |
| 116 SyncStatusCode* status_out, |
| 117 SyncStatusCode status) { |
| 118 context_->SetMetadataDatabase(initializer->PassMetadataDatabase()); |
| 119 *status_out = status; |
| 107 } | 120 } |
| 108 | 121 |
| 109 void RegisterApp(const std::string& app_id, | 122 void RegisterApp(const std::string& app_id, |
| 110 const std::string& app_root_folder_id) { | 123 const std::string& app_root_folder_id) { |
| 111 SyncStatusCode status = SYNC_STATUS_FAILED; | 124 SyncStatusCode status = SYNC_STATUS_FAILED; |
| 112 context_->GetMetadataDatabase()->RegisterApp(app_id, app_root_folder_id, | 125 context_->GetMetadataDatabase()->RegisterApp(app_id, app_root_folder_id, |
| 113 CreateResultReceiver(&status)); | 126 CreateResultReceiver(&status)); |
| 114 base::RunLoop().RunUntilIdle(); | 127 base::RunLoop().RunUntilIdle(); |
| 115 EXPECT_EQ(SYNC_STATUS_OK, status); | 128 EXPECT_EQ(SYNC_STATUS_OK, status); |
| 116 } | 129 } |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 | 517 |
| 505 EXPECT_EQ(4, CountParents(file)); | 518 EXPECT_EQ(4, CountParents(file)); |
| 506 | 519 |
| 507 EXPECT_EQ(SYNC_STATUS_OK, RunConflictResolver()); | 520 EXPECT_EQ(SYNC_STATUS_OK, RunConflictResolver()); |
| 508 | 521 |
| 509 EXPECT_EQ(1, CountParents(file)); | 522 EXPECT_EQ(1, CountParents(file)); |
| 510 } | 523 } |
| 511 | 524 |
| 512 } // namespace drive_backend | 525 } // namespace drive_backend |
| 513 } // namespace sync_file_system | 526 } // namespace sync_file_system |
| OLD | NEW |