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/sync_engine_initializer.
h" | 5 #include "chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.
h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 status = database->PopulateInitialData( | 122 status = database->PopulateInitialData( |
123 kInitialLargestChangeID, sync_root, app_root_list); | 123 kInitialLargestChangeID, sync_root, app_root_list); |
124 | 124 |
125 app_root_list.weak_clear(); | 125 app_root_list.weak_clear(); |
126 return status; | 126 return status; |
127 } | 127 } |
128 | 128 |
129 scoped_ptr<google_apis::FileResource> CreateRemoteFolder( | 129 scoped_ptr<google_apis::FileResource> CreateRemoteFolder( |
130 const std::string& parent_folder_id, | 130 const std::string& parent_folder_id, |
131 const std::string& title) { | 131 const std::string& title) { |
132 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; | 132 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR; |
133 scoped_ptr<google_apis::FileResource> entry; | 133 scoped_ptr<google_apis::FileResource> entry; |
134 sync_context_->GetDriveService()->AddNewDirectory( | 134 sync_context_->GetDriveService()->AddNewDirectory( |
135 parent_folder_id, title, | 135 parent_folder_id, title, |
136 drive::DriveServiceInterface::AddNewDirectoryOptions(), | 136 drive::DriveServiceInterface::AddNewDirectoryOptions(), |
137 CreateResultReceiver(&error, &entry)); | 137 CreateResultReceiver(&error, &entry)); |
138 base::RunLoop().RunUntilIdle(); | 138 base::RunLoop().RunUntilIdle(); |
139 | 139 |
140 EXPECT_EQ(google_apis::HTTP_CREATED, error); | 140 EXPECT_EQ(google_apis::HTTP_CREATED, error); |
141 return entry.Pass(); | 141 return entry.Pass(); |
142 } | 142 } |
143 | 143 |
144 scoped_ptr<google_apis::FileResource> CreateRemoteSyncRoot() { | 144 scoped_ptr<google_apis::FileResource> CreateRemoteSyncRoot() { |
145 scoped_ptr<google_apis::FileResource> sync_root( | 145 scoped_ptr<google_apis::FileResource> sync_root( |
146 CreateRemoteFolder(std::string(), kSyncRootFolderTitle)); | 146 CreateRemoteFolder(std::string(), kSyncRootFolderTitle)); |
147 | 147 |
148 for (size_t i = 0; i < sync_root->parents().size(); ++i) { | 148 for (size_t i = 0; i < sync_root->parents().size(); ++i) { |
149 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; | 149 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR; |
150 sync_context_->GetDriveService()->RemoveResourceFromDirectory( | 150 sync_context_->GetDriveService()->RemoveResourceFromDirectory( |
151 sync_root->parents()[i].file_id(), | 151 sync_root->parents()[i].file_id(), |
152 sync_root->file_id(), | 152 sync_root->file_id(), |
153 CreateResultReceiver(&error)); | 153 CreateResultReceiver(&error)); |
154 base::RunLoop().RunUntilIdle(); | 154 base::RunLoop().RunUntilIdle(); |
155 EXPECT_EQ(google_apis::HTTP_NO_CONTENT, error); | 155 EXPECT_EQ(google_apis::HTTP_NO_CONTENT, error); |
156 } | 156 } |
157 | 157 |
158 return sync_root.Pass(); | 158 return sync_root.Pass(); |
159 } | 159 } |
(...skipping 12 matching lines...) Expand all Loading... |
172 return trackers.size(); | 172 return trackers.size(); |
173 } | 173 } |
174 | 174 |
175 bool HasActiveTracker(const std::string& file_id) { | 175 bool HasActiveTracker(const std::string& file_id) { |
176 TrackerIDSet trackers; | 176 TrackerIDSet trackers; |
177 return metadata_database_->FindTrackersByFileID(file_id, &trackers) && | 177 return metadata_database_->FindTrackersByFileID(file_id, &trackers) && |
178 trackers.has_active(); | 178 trackers.has_active(); |
179 } | 179 } |
180 | 180 |
181 bool HasNoParent(const std::string& file_id) { | 181 bool HasNoParent(const std::string& file_id) { |
182 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; | 182 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR; |
183 scoped_ptr<google_apis::FileResource> entry; | 183 scoped_ptr<google_apis::FileResource> entry; |
184 sync_context_->GetDriveService()->GetFileResource( | 184 sync_context_->GetDriveService()->GetFileResource( |
185 file_id, | 185 file_id, |
186 CreateResultReceiver(&error, &entry)); | 186 CreateResultReceiver(&error, &entry)); |
187 base::RunLoop().RunUntilIdle(); | 187 base::RunLoop().RunUntilIdle(); |
188 EXPECT_EQ(google_apis::HTTP_SUCCESS, error); | 188 EXPECT_EQ(google_apis::HTTP_SUCCESS, error); |
189 return entry->parents().empty(); | 189 return entry->parents().empty(); |
190 } | 190 } |
191 | 191 |
192 size_t CountFileMetadata() { | 192 size_t CountFileMetadata() { |
193 return metadata_database_->CountFileMetadata(); | 193 return metadata_database_->CountFileMetadata(); |
194 } | 194 } |
195 | 195 |
196 size_t CountFileTracker() { | 196 size_t CountFileTracker() { |
197 return metadata_database_->CountFileTracker(); | 197 return metadata_database_->CountFileTracker(); |
198 } | 198 } |
199 | 199 |
200 google_apis::GDataErrorCode AddParentFolder( | 200 google_apis::DriveApiErrorCode AddParentFolder( |
201 const std::string& new_parent_folder_id, | 201 const std::string& new_parent_folder_id, |
202 const std::string& file_id) { | 202 const std::string& file_id) { |
203 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; | 203 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR; |
204 sync_context_->GetDriveService()->AddResourceToDirectory( | 204 sync_context_->GetDriveService()->AddResourceToDirectory( |
205 new_parent_folder_id, file_id, | 205 new_parent_folder_id, file_id, |
206 CreateResultReceiver(&error)); | 206 CreateResultReceiver(&error)); |
207 base::RunLoop().RunUntilIdle(); | 207 base::RunLoop().RunUntilIdle(); |
208 return error; | 208 return error; |
209 } | 209 } |
210 | 210 |
211 private: | 211 private: |
212 content::TestBrowserThreadBundle browser_threads_; | 212 content::TestBrowserThreadBundle browser_threads_; |
213 base::ScopedTempDir database_dir_; | 213 base::ScopedTempDir database_dir_; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 | 339 |
340 EXPECT_EQ(0u, CountTrackersForFile(sync_root->file_id())); | 340 EXPECT_EQ(0u, CountTrackersForFile(sync_root->file_id())); |
341 EXPECT_FALSE(HasNoParent(sync_root->file_id())); | 341 EXPECT_FALSE(HasNoParent(sync_root->file_id())); |
342 | 342 |
343 EXPECT_EQ(1u, CountFileMetadata()); | 343 EXPECT_EQ(1u, CountFileMetadata()); |
344 EXPECT_EQ(1u, CountFileTracker()); | 344 EXPECT_EQ(1u, CountFileTracker()); |
345 } | 345 } |
346 | 346 |
347 } // namespace drive_backend | 347 } // namespace drive_backend |
348 } // namespace sync_file_system | 348 } // namespace sync_file_system |
OLD | NEW |