| 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/open_file.h" | 5 #include "chrome/browser/chromeos/file_system_provider/operations/open_file.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 } // namespace | 67 } // namespace |
| 68 | 68 |
| 69 class FileSystemProviderOperationsOpenFileTest : public testing::Test { | 69 class FileSystemProviderOperationsOpenFileTest : public testing::Test { |
| 70 protected: | 70 protected: |
| 71 FileSystemProviderOperationsOpenFileTest() {} | 71 FileSystemProviderOperationsOpenFileTest() {} |
| 72 virtual ~FileSystemProviderOperationsOpenFileTest() {} | 72 virtual ~FileSystemProviderOperationsOpenFileTest() {} |
| 73 | 73 |
| 74 virtual void SetUp() override { | 74 virtual void SetUp() override { |
| 75 file_system_info_ = | 75 file_system_info_ = ProvidedFileSystemInfo( |
| 76 ProvidedFileSystemInfo(kExtensionId, | 76 kExtensionId, |
| 77 kFileSystemId, | 77 MountOptions(kFileSystemId, "" /* display_name */), |
| 78 "" /* display_name */, | 78 base::FilePath()); |
| 79 false /* writable */, | |
| 80 false /* supports_notify_tag */, | |
| 81 base::FilePath() /* mount_path */); | |
| 82 } | 79 } |
| 83 | 80 |
| 84 ProvidedFileSystemInfo file_system_info_; | 81 ProvidedFileSystemInfo file_system_info_; |
| 85 }; | 82 }; |
| 86 | 83 |
| 87 TEST_F(FileSystemProviderOperationsOpenFileTest, Execute) { | 84 TEST_F(FileSystemProviderOperationsOpenFileTest, Execute) { |
| 88 using extensions::api::file_system_provider::OpenFileRequestedOptions; | 85 using extensions::api::file_system_provider::OpenFileRequestedOptions; |
| 89 | 86 |
| 90 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 87 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
| 91 CallbackLogger callback_logger; | 88 CallbackLogger callback_logger; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 135 |
| 139 EXPECT_FALSE(open_file.Execute(kRequestId)); | 136 EXPECT_FALSE(open_file.Execute(kRequestId)); |
| 140 } | 137 } |
| 141 | 138 |
| 142 TEST_F(FileSystemProviderOperationsOpenFileTest, Execute_ReadOnly) { | 139 TEST_F(FileSystemProviderOperationsOpenFileTest, Execute_ReadOnly) { |
| 143 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 140 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
| 144 CallbackLogger callback_logger; | 141 CallbackLogger callback_logger; |
| 145 | 142 |
| 146 const ProvidedFileSystemInfo read_only_file_system_info( | 143 const ProvidedFileSystemInfo read_only_file_system_info( |
| 147 kExtensionId, | 144 kExtensionId, |
| 148 kFileSystemId, | 145 MountOptions(kFileSystemId, "" /* display_name */), |
| 149 "" /* file_system_name */, | |
| 150 false /* writable */, | |
| 151 false /* supports_notify_tag */, | |
| 152 base::FilePath() /* mount_path */); | 146 base::FilePath() /* mount_path */); |
| 153 | 147 |
| 154 // Opening for read on a read-only file system is allowed. | 148 // Opening for read on a read-only file system is allowed. |
| 155 { | 149 { |
| 156 OpenFile open_file(NULL, | 150 OpenFile open_file(NULL, |
| 157 read_only_file_system_info, | 151 read_only_file_system_info, |
| 158 base::FilePath::FromUTF8Unsafe(kFilePath), | 152 base::FilePath::FromUTF8Unsafe(kFilePath), |
| 159 ProvidedFileSystemInterface::OPEN_FILE_MODE_READ, | 153 ProvidedFileSystemInterface::OPEN_FILE_MODE_READ, |
| 160 base::Bind(&CallbackLogger::OnOpenFile, | 154 base::Bind(&CallbackLogger::OnOpenFile, |
| 161 base::Unretained(&callback_logger))); | 155 base::Unretained(&callback_logger))); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 base::File::FILE_ERROR_TOO_MANY_OPENED); | 222 base::File::FILE_ERROR_TOO_MANY_OPENED); |
| 229 ASSERT_EQ(1u, callback_logger.events().size()); | 223 ASSERT_EQ(1u, callback_logger.events().size()); |
| 230 CallbackLogger::Event* event = callback_logger.events()[0]; | 224 CallbackLogger::Event* event = callback_logger.events()[0]; |
| 231 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, event->result()); | 225 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, event->result()); |
| 232 ASSERT_EQ(0, event->file_handle()); | 226 ASSERT_EQ(0, event->file_handle()); |
| 233 } | 227 } |
| 234 | 228 |
| 235 } // namespace operations | 229 } // namespace operations |
| 236 } // namespace file_system_provider | 230 } // namespace file_system_provider |
| 237 } // namespace chromeos | 231 } // namespace chromeos |
| OLD | NEW |