| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 using fileapi::FileSystemOperation; | 23 using fileapi::FileSystemOperation; |
| 24 using fileapi::FileSystemURL; | 24 using fileapi::FileSystemURL; |
| 25 using webkit_blob::MockBlobURLRequestContext; | 25 using webkit_blob::MockBlobURLRequestContext; |
| 26 using webkit_blob::ScopedTextBlob; | 26 using webkit_blob::ScopedTextBlob; |
| 27 using base::PlatformFileError; | 27 using base::PlatformFileError; |
| 28 | 28 |
| 29 namespace sync_file_system { | 29 namespace sync_file_system { |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 const std::string kServiceName = "test"; | |
| 33 const std::string kParent = "foo"; | 32 const std::string kParent = "foo"; |
| 34 const std::string kFile = "foo/file"; | 33 const std::string kFile = "foo/file"; |
| 35 const std::string kDir = "foo/dir"; | 34 const std::string kDir = "foo/dir"; |
| 36 const std::string kChild = "foo/dir/bar"; | 35 const std::string kChild = "foo/dir/bar"; |
| 37 const std::string kOther = "bar"; | 36 const std::string kOther = "bar"; |
| 38 } // namespace | 37 } // namespace |
| 39 | 38 |
| 40 class SyncableFileOperationRunnerTest : public testing::Test { | 39 class SyncableFileOperationRunnerTest : public testing::Test { |
| 41 protected: | 40 protected: |
| 42 typedef FileSystemOperation::StatusCallback StatusCallback; | 41 typedef FileSystemOperation::StatusCallback StatusCallback; |
| 43 | 42 |
| 44 // Use the current thread as IO thread so that we can directly call | 43 // Use the current thread as IO thread so that we can directly call |
| 45 // operations in the tests. | 44 // operations in the tests. |
| 46 SyncableFileOperationRunnerTest() | 45 SyncableFileOperationRunnerTest() |
| 47 : message_loop_(base::MessageLoop::TYPE_IO), | 46 : message_loop_(base::MessageLoop::TYPE_IO), |
| 48 file_system_(GURL("http://example.com"), kServiceName, | 47 file_system_(GURL("http://example.com"), |
| 49 base::MessageLoopProxy::current(), | 48 base::MessageLoopProxy::current(), |
| 50 base::MessageLoopProxy::current()), | 49 base::MessageLoopProxy::current()), |
| 51 callback_count_(0), | 50 callback_count_(0), |
| 52 write_status_(base::PLATFORM_FILE_ERROR_FAILED), | 51 write_status_(base::PLATFORM_FILE_ERROR_FAILED), |
| 53 write_bytes_(0), | 52 write_bytes_(0), |
| 54 write_complete_(false), | 53 write_complete_(false), |
| 55 url_request_context_(file_system_.file_system_context()), | 54 url_request_context_(file_system_.file_system_context()), |
| 56 weak_factory_(this) {} | 55 weak_factory_(this) {} |
| 57 | 56 |
| 58 virtual void SetUp() OVERRIDE { | 57 virtual void SetUp() OVERRIDE { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 69 file_system_.CreateDirectory(URL(kParent))); | 68 file_system_.CreateDirectory(URL(kParent))); |
| 70 } | 69 } |
| 71 | 70 |
| 72 virtual void TearDown() OVERRIDE { | 71 virtual void TearDown() OVERRIDE { |
| 73 if (sync_context_.get()) | 72 if (sync_context_.get()) |
| 74 sync_context_->ShutdownOnUIThread(); | 73 sync_context_->ShutdownOnUIThread(); |
| 75 sync_context_ = NULL; | 74 sync_context_ = NULL; |
| 76 | 75 |
| 77 file_system_.TearDown(); | 76 file_system_.TearDown(); |
| 78 message_loop_.RunUntilIdle(); | 77 message_loop_.RunUntilIdle(); |
| 79 RevokeSyncableFileSystem(kServiceName); | 78 RevokeSyncableFileSystem(); |
| 80 } | 79 } |
| 81 | 80 |
| 82 FileSystemURL URL(const std::string& path) { | 81 FileSystemURL URL(const std::string& path) { |
| 83 return file_system_.URL(path); | 82 return file_system_.URL(path); |
| 84 } | 83 } |
| 85 | 84 |
| 86 LocalFileSyncStatus* sync_status() { | 85 LocalFileSyncStatus* sync_status() { |
| 87 return file_system_.file_system_context()->sync_context()->sync_status(); | 86 return file_system_.file_system_context()->sync_context()->sync_status(); |
| 88 } | 87 } |
| 89 | 88 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 // Now the file must have been created and have the same content as temp_path. | 362 // Now the file must have been created and have the same content as temp_path. |
| 364 ResetCallbackStatus(); | 363 ResetCallbackStatus(); |
| 365 file_system_.DoVerifyFile( | 364 file_system_.DoVerifyFile( |
| 366 URL(kFile), kTestData, | 365 URL(kFile), kTestData, |
| 367 ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK)); | 366 ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK)); |
| 368 base::MessageLoop::current()->RunUntilIdle(); | 367 base::MessageLoop::current()->RunUntilIdle(); |
| 369 EXPECT_EQ(1, callback_count_); | 368 EXPECT_EQ(1, callback_count_); |
| 370 } | 369 } |
| 371 | 370 |
| 372 } // namespace sync_file_system | 371 } // namespace sync_file_system |
| OLD | NEW |