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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 fake_remote_change_processor_.reset(); | 85 fake_remote_change_processor_.reset(); |
86 metadata_database_.reset(); | 86 metadata_database_.reset(); |
87 fake_drive_helper_.reset(); | 87 fake_drive_helper_.reset(); |
88 drive_uploader_.reset(); | 88 drive_uploader_.reset(); |
89 fake_drive_service_.reset(); | 89 fake_drive_service_.reset(); |
90 base::RunLoop().RunUntilIdle(); | 90 base::RunLoop().RunUntilIdle(); |
91 } | 91 } |
92 | 92 |
93 void InitializeMetadataDatabase() { | 93 void InitializeMetadataDatabase() { |
94 SyncEngineInitializer initializer(this, | 94 SyncEngineInitializer* initializer = |
95 base::MessageLoopProxy::current(), | 95 new SyncEngineInitializer(this, |
96 fake_drive_service_.get(), | 96 base::MessageLoopProxy::current(), |
97 database_dir_.path(), | 97 fake_drive_service_.get(), |
98 in_memory_env_.get()); | 98 database_dir_.path(), |
| 99 in_memory_env_.get()); |
99 SyncStatusCode status = SYNC_STATUS_UNKNOWN; | 100 SyncStatusCode status = SYNC_STATUS_UNKNOWN; |
100 initializer.RunSequential(CreateResultReceiver(&status)); | 101 sync_task_manager_->ScheduleSyncTask( |
| 102 FROM_HERE, |
| 103 scoped_ptr<SyncTask>(initializer), |
| 104 SyncTaskManager::PRIORITY_MED, |
| 105 base::Bind(&ConflictResolverTest::DidInitializeMetadataDatabase, |
| 106 base::Unretained(this), initializer, &status)); |
| 107 |
101 base::RunLoop().RunUntilIdle(); | 108 base::RunLoop().RunUntilIdle(); |
102 EXPECT_EQ(SYNC_STATUS_OK, status); | 109 EXPECT_EQ(SYNC_STATUS_OK, status); |
103 metadata_database_ = initializer.PassMetadataDatabase(); | 110 } |
| 111 |
| 112 void DidInitializeMetadataDatabase(SyncEngineInitializer* initializer, |
| 113 SyncStatusCode* status_out, |
| 114 SyncStatusCode status) { |
| 115 metadata_database_ = initializer->PassMetadataDatabase(); |
| 116 *status_out = status; |
104 } | 117 } |
105 | 118 |
106 void RegisterApp(const std::string& app_id, | 119 void RegisterApp(const std::string& app_id, |
107 const std::string& app_root_folder_id) { | 120 const std::string& app_root_folder_id) { |
108 SyncStatusCode status = SYNC_STATUS_FAILED; | 121 SyncStatusCode status = SYNC_STATUS_FAILED; |
109 metadata_database_->RegisterApp(app_id, app_root_folder_id, | 122 metadata_database_->RegisterApp(app_id, app_root_folder_id, |
110 CreateResultReceiver(&status)); | 123 CreateResultReceiver(&status)); |
111 base::RunLoop().RunUntilIdle(); | 124 base::RunLoop().RunUntilIdle(); |
112 EXPECT_EQ(SYNC_STATUS_OK, status); | 125 EXPECT_EQ(SYNC_STATUS_OK, status); |
113 } | 126 } |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 | 534 |
522 EXPECT_EQ(4, CountParents(file)); | 535 EXPECT_EQ(4, CountParents(file)); |
523 | 536 |
524 EXPECT_EQ(SYNC_STATUS_OK, RunConflictResolver()); | 537 EXPECT_EQ(SYNC_STATUS_OK, RunConflictResolver()); |
525 | 538 |
526 EXPECT_EQ(1, CountParents(file)); | 539 EXPECT_EQ(1, CountParents(file)); |
527 } | 540 } |
528 | 541 |
529 } // namespace drive_backend | 542 } // namespace drive_backend |
530 } // namespace sync_file_system | 543 } // namespace sync_file_system |
OLD | NEW |