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 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "chrome/browser/drive/drive_uploader.h" | 10 #include "chrome/browser/drive/drive_uploader.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 SyncStatusCode status = SYNC_STATUS_UNKNOWN; | 137 SyncStatusCode status = SYNC_STATUS_UNKNOWN; |
138 local_sync_service_->MaybeInitializeFileSystemContext( | 138 local_sync_service_->MaybeInitializeFileSystemContext( |
139 origin, file_system->file_system_context(), | 139 origin, file_system->file_system_context(), |
140 CreateResultReceiver(&status)); | 140 CreateResultReceiver(&status)); |
141 base::RunLoop().RunUntilIdle(); | 141 base::RunLoop().RunUntilIdle(); |
142 EXPECT_EQ(SYNC_STATUS_OK, status); | 142 EXPECT_EQ(SYNC_STATUS_OK, status); |
143 | 143 |
144 file_system->backend()->sync_context()-> | 144 file_system->backend()->sync_context()-> |
145 set_mock_notify_changes_duration_in_sec(0); | 145 set_mock_notify_changes_duration_in_sec(0); |
146 | 146 |
147 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system->OpenFileSystem()); | 147 EXPECT_EQ(base::File::FILE_OK, file_system->OpenFileSystem()); |
148 file_systems_[app_id] = file_system; | 148 file_systems_[app_id] = file_system; |
149 } | 149 } |
150 | 150 |
151 SyncStatusCode status = SYNC_STATUS_UNKNOWN; | 151 SyncStatusCode status = SYNC_STATUS_UNKNOWN; |
152 remote_sync_service_->RegisterOrigin(origin, CreateResultReceiver(&status)); | 152 remote_sync_service_->RegisterOrigin(origin, CreateResultReceiver(&status)); |
153 base::RunLoop().RunUntilIdle(); | 153 base::RunLoop().RunUntilIdle(); |
154 return status; | 154 return status; |
155 } | 155 } |
156 | 156 |
157 void AddLocalFolder(const std::string& app_id, | 157 void AddLocalFolder(const std::string& app_id, |
158 const base::FilePath::StringType& path) { | 158 const base::FilePath::StringType& path) { |
159 ASSERT_TRUE(ContainsKey(file_systems_, app_id)); | 159 ASSERT_TRUE(ContainsKey(file_systems_, app_id)); |
160 EXPECT_EQ(base::PLATFORM_FILE_OK, | 160 EXPECT_EQ(base::File::FILE_OK, |
161 file_systems_[app_id]->CreateDirectory( | 161 file_systems_[app_id]->CreateDirectory( |
162 CreateURL(app_id, path))); | 162 CreateURL(app_id, path))); |
163 } | 163 } |
164 | 164 |
165 void AddOrUpdateLocalFile(const std::string& app_id, | 165 void AddOrUpdateLocalFile(const std::string& app_id, |
166 const base::FilePath::StringType& path, | 166 const base::FilePath::StringType& path, |
167 const std::string& content) { | 167 const std::string& content) { |
168 fileapi::FileSystemURL url(CreateURL(app_id, path)); | 168 fileapi::FileSystemURL url(CreateURL(app_id, path)); |
169 ASSERT_TRUE(ContainsKey(file_systems_, app_id)); | 169 ASSERT_TRUE(ContainsKey(file_systems_, app_id)); |
170 EXPECT_EQ(base::PLATFORM_FILE_OK, file_systems_[app_id]->CreateFile(url)); | 170 EXPECT_EQ(base::File::FILE_OK, file_systems_[app_id]->CreateFile(url)); |
171 int64 bytes_written = file_systems_[app_id]->WriteString(url, content); | 171 int64 bytes_written = file_systems_[app_id]->WriteString(url, content); |
172 EXPECT_EQ(static_cast<int64>(content.size()), bytes_written); | 172 EXPECT_EQ(static_cast<int64>(content.size()), bytes_written); |
173 base::RunLoop().RunUntilIdle(); | 173 base::RunLoop().RunUntilIdle(); |
174 } | 174 } |
175 | 175 |
176 void UpdateLocalFile(const std::string& app_id, | 176 void UpdateLocalFile(const std::string& app_id, |
177 const base::FilePath::StringType& path, | 177 const base::FilePath::StringType& path, |
178 const std::string& content) { | 178 const std::string& content) { |
179 ASSERT_TRUE(ContainsKey(file_systems_, app_id)); | 179 ASSERT_TRUE(ContainsKey(file_systems_, app_id)); |
180 int64 bytes_written = file_systems_[app_id]->WriteString( | 180 int64 bytes_written = file_systems_[app_id]->WriteString( |
181 CreateURL(app_id, path), content); | 181 CreateURL(app_id, path), content); |
182 EXPECT_EQ(static_cast<int64>(content.size()), bytes_written); | 182 EXPECT_EQ(static_cast<int64>(content.size()), bytes_written); |
183 base::RunLoop().RunUntilIdle(); | 183 base::RunLoop().RunUntilIdle(); |
184 } | 184 } |
185 | 185 |
186 void RemoveLocal(const std::string& app_id, | 186 void RemoveLocal(const std::string& app_id, |
187 const base::FilePath::StringType& path) { | 187 const base::FilePath::StringType& path) { |
188 ASSERT_TRUE(ContainsKey(file_systems_, app_id)); | 188 ASSERT_TRUE(ContainsKey(file_systems_, app_id)); |
189 EXPECT_EQ(base::PLATFORM_FILE_OK, | 189 EXPECT_EQ(base::File::FILE_OK, |
190 file_systems_[app_id]->Remove( | 190 file_systems_[app_id]->Remove( |
191 CreateURL(app_id, path), | 191 CreateURL(app_id, path), |
192 true /* recursive */)); | 192 true /* recursive */)); |
193 base::RunLoop().RunUntilIdle(); | 193 base::RunLoop().RunUntilIdle(); |
194 } | 194 } |
195 | 195 |
196 SyncStatusCode ProcessLocalChange() { | 196 SyncStatusCode ProcessLocalChange() { |
197 SyncStatusCode status = SYNC_STATUS_UNKNOWN; | 197 SyncStatusCode status = SYNC_STATUS_UNKNOWN; |
198 fileapi::FileSystemURL url; | 198 fileapi::FileSystemURL url; |
199 local_sync_service_->ProcessLocalChange( | 199 local_sync_service_->ProcessLocalChange( |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 remote_entries.begin(); | 298 remote_entries.begin(); |
299 itr != remote_entries.end(); | 299 itr != remote_entries.end(); |
300 ++itr) { | 300 ++itr) { |
301 const google_apis::ResourceEntry& remote_entry = **itr; | 301 const google_apis::ResourceEntry& remote_entry = **itr; |
302 EXPECT_FALSE(ContainsKey(remote_entry_by_title, remote_entry.title())); | 302 EXPECT_FALSE(ContainsKey(remote_entry_by_title, remote_entry.title())); |
303 remote_entry_by_title[remote_entry.title()] = *itr; | 303 remote_entry_by_title[remote_entry.title()] = *itr; |
304 } | 304 } |
305 | 305 |
306 fileapi::FileSystemURL url(CreateURL(app_id, path)); | 306 fileapi::FileSystemURL url(CreateURL(app_id, path)); |
307 CannedSyncableFileSystem::FileEntryList local_entries; | 307 CannedSyncableFileSystem::FileEntryList local_entries; |
308 EXPECT_EQ(base::PLATFORM_FILE_OK, | 308 EXPECT_EQ(base::File::FILE_OK, |
309 file_system->ReadDirectory(url, &local_entries)); | 309 file_system->ReadDirectory(url, &local_entries)); |
310 for (CannedSyncableFileSystem::FileEntryList::iterator itr = | 310 for (CannedSyncableFileSystem::FileEntryList::iterator itr = |
311 local_entries.begin(); | 311 local_entries.begin(); |
312 itr != local_entries.end(); | 312 itr != local_entries.end(); |
313 ++itr) { | 313 ++itr) { |
314 const fileapi::DirectoryEntry& local_entry = *itr; | 314 const fileapi::DirectoryEntry& local_entry = *itr; |
315 fileapi::FileSystemURL entry_url( | 315 fileapi::FileSystemURL entry_url( |
316 CreateURL(app_id, path.Append(local_entry.name))); | 316 CreateURL(app_id, path.Append(local_entry.name))); |
317 std::string title = entry_url.path().AsUTF8Unsafe(); | 317 std::string title = entry_url.path().AsUTF8Unsafe(); |
318 ASSERT_TRUE(ContainsKey(remote_entry_by_title, title)); | 318 ASSERT_TRUE(ContainsKey(remote_entry_by_title, title)); |
(...skipping 17 matching lines...) Expand all Loading... |
336 } | 336 } |
337 | 337 |
338 void VerifyConsistencyForFile(const std::string& app_id, | 338 void VerifyConsistencyForFile(const std::string& app_id, |
339 const base::FilePath& path, | 339 const base::FilePath& path, |
340 const std::string& file_id, | 340 const std::string& file_id, |
341 CannedSyncableFileSystem* file_system) { | 341 CannedSyncableFileSystem* file_system) { |
342 fileapi::FileSystemURL url(CreateURL(app_id, path)); | 342 fileapi::FileSystemURL url(CreateURL(app_id, path)); |
343 std::string file_content; | 343 std::string file_content; |
344 EXPECT_EQ(google_apis::HTTP_SUCCESS, | 344 EXPECT_EQ(google_apis::HTTP_SUCCESS, |
345 fake_drive_service_helper_->ReadFile(file_id, &file_content)); | 345 fake_drive_service_helper_->ReadFile(file_id, &file_content)); |
346 EXPECT_EQ(base::PLATFORM_FILE_OK, | 346 EXPECT_EQ(base::File::FILE_OK, |
347 file_system->VerifyFile(url, file_content)); | 347 file_system->VerifyFile(url, file_content)); |
348 } | 348 } |
349 | 349 |
350 drive::FakeDriveService* fake_drive_service() { | 350 drive::FakeDriveService* fake_drive_service() { |
351 return static_cast<drive::FakeDriveService*>( | 351 return static_cast<drive::FakeDriveService*>( |
352 remote_sync_service_->GetDriveService()); | 352 remote_sync_service_->GetDriveService()); |
353 } | 353 } |
354 | 354 |
355 drive::DriveUploaderInterface* drive_uploader() { | 355 drive::DriveUploaderInterface* drive_uploader() { |
356 return remote_sync_service_->GetDriveUploader(); | 356 return remote_sync_service_->GetDriveUploader(); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 EXPECT_EQ(google_apis::HTTP_SUCCESS, | 523 EXPECT_EQ(google_apis::HTTP_SUCCESS, |
524 fake_drive_service_helper()->RenameResource( | 524 fake_drive_service_helper()->RenameResource( |
525 file_id, base::FilePath(path).AsUTF8Unsafe())); | 525 file_id, base::FilePath(path).AsUTF8Unsafe())); |
526 | 526 |
527 EXPECT_EQ(SYNC_STATUS_OK, ProcessChangesUntilDone()); | 527 EXPECT_EQ(SYNC_STATUS_OK, ProcessChangesUntilDone()); |
528 VerifyConsistency(); | 528 VerifyConsistency(); |
529 } | 529 } |
530 | 530 |
531 } // namespace drive_backend | 531 } // namespace drive_backend |
532 } // namespace sync_file_system | 532 } // namespace sync_file_system |
OLD | NEW |