| 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 "chrome/browser/chromeos/file_system_provider/operations/write_file.h" | 5 #include "chrome/browser/chromeos/file_system_provider/operations/write_file.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 protected: | 38 protected: |
| 39 FileSystemProviderOperationsWriteFileTest() {} | 39 FileSystemProviderOperationsWriteFileTest() {} |
| 40 virtual ~FileSystemProviderOperationsWriteFileTest() {} | 40 virtual ~FileSystemProviderOperationsWriteFileTest() {} |
| 41 | 41 |
| 42 virtual void SetUp() override { | 42 virtual void SetUp() override { |
| 43 file_system_info_ = | 43 file_system_info_ = |
| 44 ProvidedFileSystemInfo(kExtensionId, | 44 ProvidedFileSystemInfo(kExtensionId, |
| 45 kFileSystemId, | 45 kFileSystemId, |
| 46 "" /* display_name */, | 46 "" /* display_name */, |
| 47 true /* writable */, | 47 true /* writable */, |
| 48 false /* supports_notify_tag */, |
| 48 base::FilePath() /* mount_path */); | 49 base::FilePath() /* mount_path */); |
| 49 io_buffer_ = make_scoped_refptr(new net::StringIOBuffer(kWriteData)); | 50 io_buffer_ = make_scoped_refptr(new net::StringIOBuffer(kWriteData)); |
| 50 } | 51 } |
| 51 | 52 |
| 52 ProvidedFileSystemInfo file_system_info_; | 53 ProvidedFileSystemInfo file_system_info_; |
| 53 scoped_refptr<net::StringIOBuffer> io_buffer_; | 54 scoped_refptr<net::StringIOBuffer> io_buffer_; |
| 54 }; | 55 }; |
| 55 | 56 |
| 56 TEST_F(FileSystemProviderOperationsWriteFileTest, Execute) { | 57 TEST_F(FileSystemProviderOperationsWriteFileTest, Execute) { |
| 57 using extensions::api::file_system_provider::WriteFileRequestedOptions; | 58 using extensions::api::file_system_provider::WriteFileRequestedOptions; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 base::Unretained(&dispatcher))); | 109 base::Unretained(&dispatcher))); |
| 109 | 110 |
| 110 EXPECT_FALSE(write_file.Execute(kRequestId)); | 111 EXPECT_FALSE(write_file.Execute(kRequestId)); |
| 111 } | 112 } |
| 112 | 113 |
| 113 TEST_F(FileSystemProviderOperationsWriteFileTest, Execute_ReadOnly) { | 114 TEST_F(FileSystemProviderOperationsWriteFileTest, Execute_ReadOnly) { |
| 114 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 115 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
| 115 util::StatusCallbackLog callback_log; | 116 util::StatusCallbackLog callback_log; |
| 116 | 117 |
| 117 const ProvidedFileSystemInfo read_only_file_system_info( | 118 const ProvidedFileSystemInfo read_only_file_system_info( |
| 118 kExtensionId, | 119 kExtensionId, |
| 119 kFileSystemId, | 120 kFileSystemId, |
| 120 "" /* file_system_name */, | 121 "" /* file_system_name */, |
| 121 false /* writable */, | 122 false /* writable */, |
| 122 base::FilePath() /* mount_path */); | 123 false /* supports_notify_tag */, |
| 124 base::FilePath() /* mount_path */); |
| 123 | 125 |
| 124 WriteFile write_file(NULL, | 126 WriteFile write_file(NULL, |
| 125 read_only_file_system_info, | 127 read_only_file_system_info, |
| 126 kFileHandle, | 128 kFileHandle, |
| 127 io_buffer_.get(), | 129 io_buffer_.get(), |
| 128 kOffset, | 130 kOffset, |
| 129 io_buffer_->size(), | 131 io_buffer_->size(), |
| 130 base::Bind(&util::LogStatusCallback, &callback_log)); | 132 base::Bind(&util::LogStatusCallback, &callback_log)); |
| 131 write_file.SetDispatchEventImplForTesting( | 133 write_file.SetDispatchEventImplForTesting( |
| 132 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, | 134 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 scoped_ptr<RequestValue>(new RequestValue()), | 182 scoped_ptr<RequestValue>(new RequestValue()), |
| 181 base::File::FILE_ERROR_TOO_MANY_OPENED); | 183 base::File::FILE_ERROR_TOO_MANY_OPENED); |
| 182 | 184 |
| 183 ASSERT_EQ(1u, callback_log.size()); | 185 ASSERT_EQ(1u, callback_log.size()); |
| 184 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); | 186 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); |
| 185 } | 187 } |
| 186 | 188 |
| 187 } // namespace operations | 189 } // namespace operations |
| 188 } // namespace file_system_provider | 190 } // namespace file_system_provider |
| 189 } // namespace chromeos | 191 } // namespace chromeos |
| OLD | NEW |