| 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 22 matching lines...) Expand all Loading... |
| 33 const int kOffset = 10; | 33 const int kOffset = 10; |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| 36 | 36 |
| 37 class FileSystemProviderOperationsWriteFileTest : public testing::Test { | 37 class FileSystemProviderOperationsWriteFileTest : public testing::Test { |
| 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 MountOptions mount_options(kFileSystemId, "" /* display_name */); |
| 44 mount_options.writable = true; |
| 43 file_system_info_ = | 45 file_system_info_ = |
| 44 ProvidedFileSystemInfo(kExtensionId, | 46 ProvidedFileSystemInfo(kExtensionId, mount_options, base::FilePath()); |
| 45 kFileSystemId, | |
| 46 "" /* display_name */, | |
| 47 true /* writable */, | |
| 48 false /* supports_notify_tag */, | |
| 49 base::FilePath() /* mount_path */); | |
| 50 io_buffer_ = make_scoped_refptr(new net::StringIOBuffer(kWriteData)); | 47 io_buffer_ = make_scoped_refptr(new net::StringIOBuffer(kWriteData)); |
| 51 } | 48 } |
| 52 | 49 |
| 53 ProvidedFileSystemInfo file_system_info_; | 50 ProvidedFileSystemInfo file_system_info_; |
| 54 scoped_refptr<net::StringIOBuffer> io_buffer_; | 51 scoped_refptr<net::StringIOBuffer> io_buffer_; |
| 55 }; | 52 }; |
| 56 | 53 |
| 57 TEST_F(FileSystemProviderOperationsWriteFileTest, Execute) { | 54 TEST_F(FileSystemProviderOperationsWriteFileTest, Execute) { |
| 58 using extensions::api::file_system_provider::WriteFileRequestedOptions; | 55 using extensions::api::file_system_provider::WriteFileRequestedOptions; |
| 59 | 56 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 107 |
| 111 EXPECT_FALSE(write_file.Execute(kRequestId)); | 108 EXPECT_FALSE(write_file.Execute(kRequestId)); |
| 112 } | 109 } |
| 113 | 110 |
| 114 TEST_F(FileSystemProviderOperationsWriteFileTest, Execute_ReadOnly) { | 111 TEST_F(FileSystemProviderOperationsWriteFileTest, Execute_ReadOnly) { |
| 115 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 112 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
| 116 util::StatusCallbackLog callback_log; | 113 util::StatusCallbackLog callback_log; |
| 117 | 114 |
| 118 const ProvidedFileSystemInfo read_only_file_system_info( | 115 const ProvidedFileSystemInfo read_only_file_system_info( |
| 119 kExtensionId, | 116 kExtensionId, |
| 120 kFileSystemId, | 117 MountOptions(kFileSystemId, "" /* display_name */), |
| 121 "" /* file_system_name */, | |
| 122 false /* writable */, | |
| 123 false /* supports_notify_tag */, | |
| 124 base::FilePath() /* mount_path */); | 118 base::FilePath() /* mount_path */); |
| 125 | 119 |
| 126 WriteFile write_file(NULL, | 120 WriteFile write_file(NULL, |
| 127 read_only_file_system_info, | 121 read_only_file_system_info, |
| 128 kFileHandle, | 122 kFileHandle, |
| 129 io_buffer_.get(), | 123 io_buffer_.get(), |
| 130 kOffset, | 124 kOffset, |
| 131 io_buffer_->size(), | 125 io_buffer_->size(), |
| 132 base::Bind(&util::LogStatusCallback, &callback_log)); | 126 base::Bind(&util::LogStatusCallback, &callback_log)); |
| 133 write_file.SetDispatchEventImplForTesting( | 127 write_file.SetDispatchEventImplForTesting( |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 scoped_ptr<RequestValue>(new RequestValue()), | 176 scoped_ptr<RequestValue>(new RequestValue()), |
| 183 base::File::FILE_ERROR_TOO_MANY_OPENED); | 177 base::File::FILE_ERROR_TOO_MANY_OPENED); |
| 184 | 178 |
| 185 ASSERT_EQ(1u, callback_log.size()); | 179 ASSERT_EQ(1u, callback_log.size()); |
| 186 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); | 180 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); |
| 187 } | 181 } |
| 188 | 182 |
| 189 } // namespace operations | 183 } // namespace operations |
| 190 } // namespace file_system_provider | 184 } // namespace file_system_provider |
| 191 } // namespace chromeos | 185 } // namespace chromeos |
| OLD | NEW |