| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 FileSystemOperationImplWriteTest() | 56 FileSystemOperationImplWriteTest() |
| 57 : status_(base::File::FILE_OK), | 57 : status_(base::File::FILE_OK), |
| 58 cancel_status_(base::File::FILE_ERROR_FAILED), | 58 cancel_status_(base::File::FILE_ERROR_FAILED), |
| 59 bytes_written_(0), | 59 bytes_written_(0), |
| 60 complete_(false), | 60 complete_(false), |
| 61 weak_factory_(this) { | 61 weak_factory_(this) { |
| 62 change_observers_ = | 62 change_observers_ = |
| 63 storage::MockFileChangeObserver::CreateList(&change_observer_); | 63 storage::MockFileChangeObserver::CreateList(&change_observer_); |
| 64 } | 64 } |
| 65 | 65 |
| 66 virtual void SetUp() { | 66 void SetUp() override { |
| 67 ASSERT_TRUE(dir_.CreateUniqueTempDir()); | 67 ASSERT_TRUE(dir_.CreateUniqueTempDir()); |
| 68 | 68 |
| 69 quota_manager_ = | 69 quota_manager_ = |
| 70 new MockQuotaManager(false /* is_incognito */, | 70 new MockQuotaManager(false /* is_incognito */, |
| 71 dir_.path(), | 71 dir_.path(), |
| 72 base::MessageLoopProxy::current().get(), | 72 base::MessageLoopProxy::current().get(), |
| 73 base::MessageLoopProxy::current().get(), | 73 base::MessageLoopProxy::current().get(), |
| 74 NULL /* special storage policy */); | 74 NULL /* special storage policy */); |
| 75 virtual_path_ = base::FilePath(FILE_PATH_LITERAL("temporary file")); | 75 virtual_path_ = base::FilePath(FILE_PATH_LITERAL("temporary file")); |
| 76 | 76 |
| 77 file_system_context_ = CreateFileSystemContextForTesting( | 77 file_system_context_ = CreateFileSystemContextForTesting( |
| 78 quota_manager_->proxy(), dir_.path()); | 78 quota_manager_->proxy(), dir_.path()); |
| 79 url_request_context_.reset( | 79 url_request_context_.reset( |
| 80 new MockBlobURLRequestContext(file_system_context_.get())); | 80 new MockBlobURLRequestContext(file_system_context_.get())); |
| 81 | 81 |
| 82 file_system_context_->operation_runner()->CreateFile( | 82 file_system_context_->operation_runner()->CreateFile( |
| 83 URLForPath(virtual_path_), true /* exclusive */, | 83 URLForPath(virtual_path_), true /* exclusive */, |
| 84 base::Bind(&AssertStatusEq, base::File::FILE_OK)); | 84 base::Bind(&AssertStatusEq, base::File::FILE_OK)); |
| 85 | 85 |
| 86 static_cast<TestFileSystemBackend*>( | 86 static_cast<TestFileSystemBackend*>( |
| 87 file_system_context_->GetFileSystemBackend(kFileSystemType)) | 87 file_system_context_->GetFileSystemBackend(kFileSystemType)) |
| 88 ->AddFileChangeObserver(change_observer()); | 88 ->AddFileChangeObserver(change_observer()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 virtual void TearDown() { | 91 void TearDown() override { |
| 92 quota_manager_ = NULL; | 92 quota_manager_ = NULL; |
| 93 file_system_context_ = NULL; | 93 file_system_context_ = NULL; |
| 94 base::RunLoop().RunUntilIdle(); | 94 base::RunLoop().RunUntilIdle(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 base::File::Error status() const { return status_; } | 97 base::File::Error status() const { return status_; } |
| 98 base::File::Error cancel_status() const { return cancel_status_; } | 98 base::File::Error cancel_status() const { return cancel_status_; } |
| 99 void add_bytes_written(int64 bytes, bool complete) { | 99 void add_bytes_written(int64 bytes, bool complete) { |
| 100 bytes_written_ += bytes; | 100 bytes_written_ += bytes; |
| 101 EXPECT_FALSE(complete_); | 101 EXPECT_FALSE(complete_); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 EXPECT_EQ(base::File::FILE_ERROR_ABORT, status()); | 323 EXPECT_EQ(base::File::FILE_ERROR_ABORT, status()); |
| 324 EXPECT_EQ(base::File::FILE_OK, cancel_status()); | 324 EXPECT_EQ(base::File::FILE_OK, cancel_status()); |
| 325 EXPECT_TRUE(complete()); | 325 EXPECT_TRUE(complete()); |
| 326 | 326 |
| 327 EXPECT_EQ(0, change_observer()->get_and_reset_modify_file_count()); | 327 EXPECT_EQ(0, change_observer()->get_and_reset_modify_file_count()); |
| 328 } | 328 } |
| 329 | 329 |
| 330 // TODO(ericu,dmikurube,kinuko): Add more tests for cancel cases. | 330 // TODO(ericu,dmikurube,kinuko): Add more tests for cancel cases. |
| 331 | 331 |
| 332 } // namespace content | 332 } // namespace content |
| OLD | NEW |