| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_ = |
| 76 ProvidedFileSystemInfo(kExtensionId, | 76 ProvidedFileSystemInfo(kExtensionId, |
| 77 kFileSystemId, | 77 kFileSystemId, |
| 78 "" /* display_name */, | 78 "" /* display_name */, |
| 79 false /* writable */, | 79 false /* writable */, |
| 80 false /* supports_notify_tag */, |
| 80 base::FilePath() /* mount_path */); | 81 base::FilePath() /* mount_path */); |
| 81 } | 82 } |
| 82 | 83 |
| 83 ProvidedFileSystemInfo file_system_info_; | 84 ProvidedFileSystemInfo file_system_info_; |
| 84 }; | 85 }; |
| 85 | 86 |
| 86 TEST_F(FileSystemProviderOperationsOpenFileTest, Execute) { | 87 TEST_F(FileSystemProviderOperationsOpenFileTest, Execute) { |
| 87 using extensions::api::file_system_provider::OpenFileRequestedOptions; | 88 using extensions::api::file_system_provider::OpenFileRequestedOptions; |
| 88 | 89 |
| 89 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 90 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 141 |
| 141 TEST_F(FileSystemProviderOperationsOpenFileTest, Execute_ReadOnly) { | 142 TEST_F(FileSystemProviderOperationsOpenFileTest, Execute_ReadOnly) { |
| 142 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 143 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
| 143 CallbackLogger callback_logger; | 144 CallbackLogger callback_logger; |
| 144 | 145 |
| 145 const ProvidedFileSystemInfo read_only_file_system_info( | 146 const ProvidedFileSystemInfo read_only_file_system_info( |
| 146 kExtensionId, | 147 kExtensionId, |
| 147 kFileSystemId, | 148 kFileSystemId, |
| 148 "" /* file_system_name */, | 149 "" /* file_system_name */, |
| 149 false /* writable */, | 150 false /* writable */, |
| 151 false /* supports_notify_tag */, |
| 150 base::FilePath() /* mount_path */); | 152 base::FilePath() /* mount_path */); |
| 151 | 153 |
| 152 // Opening for read on a read-only file system is allowed. | 154 // Opening for read on a read-only file system is allowed. |
| 153 { | 155 { |
| 154 OpenFile open_file(NULL, | 156 OpenFile open_file(NULL, |
| 155 read_only_file_system_info, | 157 read_only_file_system_info, |
| 156 base::FilePath::FromUTF8Unsafe(kFilePath), | 158 base::FilePath::FromUTF8Unsafe(kFilePath), |
| 157 ProvidedFileSystemInterface::OPEN_FILE_MODE_READ, | 159 ProvidedFileSystemInterface::OPEN_FILE_MODE_READ, |
| 158 base::Bind(&CallbackLogger::OnOpenFile, | 160 base::Bind(&CallbackLogger::OnOpenFile, |
| 159 base::Unretained(&callback_logger))); | 161 base::Unretained(&callback_logger))); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 base::File::FILE_ERROR_TOO_MANY_OPENED); | 228 base::File::FILE_ERROR_TOO_MANY_OPENED); |
| 227 ASSERT_EQ(1u, callback_logger.events().size()); | 229 ASSERT_EQ(1u, callback_logger.events().size()); |
| 228 CallbackLogger::Event* event = callback_logger.events()[0]; | 230 CallbackLogger::Event* event = callback_logger.events()[0]; |
| 229 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, event->result()); | 231 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, event->result()); |
| 230 ASSERT_EQ(0, event->file_handle()); | 232 ASSERT_EQ(0, event->file_handle()); |
| 231 } | 233 } |
| 232 | 234 |
| 233 } // namespace operations | 235 } // namespace operations |
| 234 } // namespace file_system_provider | 236 } // namespace file_system_provider |
| 235 } // namespace chromeos | 237 } // namespace chromeos |
| OLD | NEW |