OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "webkit/blob/blob_storage_context.h" |
12 #include "webkit/blob/mock_blob_url_request_context.h" | 13 #include "webkit/blob/mock_blob_url_request_context.h" |
13 #include "webkit/fileapi/file_system_context.h" | 14 #include "webkit/fileapi/file_system_context.h" |
14 #include "webkit/fileapi/syncable/canned_syncable_file_system.h" | 15 #include "webkit/fileapi/syncable/canned_syncable_file_system.h" |
15 #include "webkit/fileapi/syncable/local_file_change_tracker.h" | 16 #include "webkit/fileapi/syncable/local_file_change_tracker.h" |
16 #include "webkit/fileapi/syncable/local_file_sync_context.h" | 17 #include "webkit/fileapi/syncable/local_file_sync_context.h" |
17 #include "webkit/fileapi/syncable/local_file_sync_status.h" | 18 #include "webkit/fileapi/syncable/local_file_sync_status.h" |
18 #include "webkit/fileapi/syncable/syncable_file_operation_runner.h" | 19 #include "webkit/fileapi/syncable/syncable_file_operation_runner.h" |
19 #include "webkit/fileapi/syncable/syncable_file_system_operation.h" | 20 #include "webkit/fileapi/syncable/syncable_file_system_operation.h" |
20 #include "webkit/fileapi/syncable/syncable_file_system_util.h" | 21 #include "webkit/fileapi/syncable/syncable_file_system_util.h" |
21 | 22 |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 MessageLoop::current()->RunUntilIdle(); | 268 MessageLoop::current()->RunUntilIdle(); |
268 EXPECT_EQ(1, callback_count_); | 269 EXPECT_EQ(1, callback_count_); |
269 | 270 |
270 // Now we should have "dest-move". | 271 // Now we should have "dest-move". |
271 EXPECT_EQ(base::PLATFORM_FILE_OK, | 272 EXPECT_EQ(base::PLATFORM_FILE_OK, |
272 file_system_.DirectoryExists(URL("dest-move"))); | 273 file_system_.DirectoryExists(URL("dest-move"))); |
273 } | 274 } |
274 | 275 |
275 TEST_F(SyncableFileOperationRunnerTest, Write) { | 276 TEST_F(SyncableFileOperationRunnerTest, Write) { |
276 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_.CreateFile(URL(kFile))); | 277 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_.CreateFile(URL(kFile))); |
277 const GURL kBlobURL("blob:foo"); | |
278 const std::string kData("Lorem ipsum."); | 278 const std::string kData("Lorem ipsum."); |
279 ScopedTextBlob blob(url_request_context_, kBlobURL, kData); | 279 ScopedTextBlob blob(url_request_context_, "blob_id:foo", kData); |
280 | 280 |
281 sync_status()->StartSyncing(URL(kFile)); | 281 sync_status()->StartSyncing(URL(kFile)); |
282 | 282 |
283 ResetCallbackStatus(); | 283 ResetCallbackStatus(); |
284 file_system_.NewOperation()->Write( | 284 file_system_.NewOperation()->Write( |
285 &url_request_context_, | 285 &url_request_context_, |
286 URL(kFile), kBlobURL, 0, GetWriteCallback(FROM_HERE)); | 286 URL(kFile), blob.GetBlobDataHandle(), 0, GetWriteCallback(FROM_HERE)); |
287 MessageLoop::current()->RunUntilIdle(); | 287 MessageLoop::current()->RunUntilIdle(); |
288 EXPECT_EQ(0, callback_count_); | 288 EXPECT_EQ(0, callback_count_); |
289 | 289 |
290 sync_status()->EndSyncing(URL(kFile)); | 290 sync_status()->EndSyncing(URL(kFile)); |
291 ResetCallbackStatus(); | 291 ResetCallbackStatus(); |
292 | 292 |
293 while (!write_complete_) | 293 while (!write_complete_) |
294 MessageLoop::current()->RunUntilIdle(); | 294 MessageLoop::current()->RunUntilIdle(); |
295 | 295 |
296 EXPECT_EQ(base::PLATFORM_FILE_OK, write_status_); | 296 EXPECT_EQ(base::PLATFORM_FILE_OK, write_status_); |
(...skipping 18 matching lines...) Expand all Loading... |
315 ResetCallbackStatus(); | 315 ResetCallbackStatus(); |
316 | 316 |
317 // This shouldn't crash nor leak memory. | 317 // This shouldn't crash nor leak memory. |
318 sync_context_->ShutdownOnUIThread(); | 318 sync_context_->ShutdownOnUIThread(); |
319 sync_context_ = NULL; | 319 sync_context_ = NULL; |
320 MessageLoop::current()->RunUntilIdle(); | 320 MessageLoop::current()->RunUntilIdle(); |
321 EXPECT_EQ(2, callback_count_); | 321 EXPECT_EQ(2, callback_count_); |
322 } | 322 } |
323 | 323 |
324 } // namespace sync_file_system | 324 } // namespace sync_file_system |
OLD | NEW |