| 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/create_file.h" | 5 #include "chrome/browser/chromeos/file_system_provider/operations/create_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 19 matching lines...) Expand all Loading... |
| 30 const base::FilePath::CharType kFilePath[] = "/kitty/and/puppy/happy"; | 30 const base::FilePath::CharType kFilePath[] = "/kitty/and/puppy/happy"; |
| 31 | 31 |
| 32 } // namespace | 32 } // namespace |
| 33 | 33 |
| 34 class FileSystemProviderOperationsCreateFileTest : public testing::Test { | 34 class FileSystemProviderOperationsCreateFileTest : public testing::Test { |
| 35 protected: | 35 protected: |
| 36 FileSystemProviderOperationsCreateFileTest() {} | 36 FileSystemProviderOperationsCreateFileTest() {} |
| 37 virtual ~FileSystemProviderOperationsCreateFileTest() {} | 37 virtual ~FileSystemProviderOperationsCreateFileTest() {} |
| 38 | 38 |
| 39 virtual void SetUp() override { | 39 virtual void SetUp() override { |
| 40 MountOptions mount_options(kFileSystemId, "" /* display_name */); |
| 41 mount_options.writable = true; |
| 40 file_system_info_ = | 42 file_system_info_ = |
| 41 ProvidedFileSystemInfo(kExtensionId, | 43 ProvidedFileSystemInfo(kExtensionId, mount_options, base::FilePath()); |
| 42 kFileSystemId, | |
| 43 "" /* file_system_name */, | |
| 44 true /* writable */, | |
| 45 false /* supports_notify_tag */, | |
| 46 base::FilePath() /* mount_path */); | |
| 47 } | 44 } |
| 48 | 45 |
| 49 ProvidedFileSystemInfo file_system_info_; | 46 ProvidedFileSystemInfo file_system_info_; |
| 50 }; | 47 }; |
| 51 | 48 |
| 52 TEST_F(FileSystemProviderOperationsCreateFileTest, Execute) { | 49 TEST_F(FileSystemProviderOperationsCreateFileTest, Execute) { |
| 53 using extensions::api::file_system_provider::CreateFileRequestedOptions; | 50 using extensions::api::file_system_provider::CreateFileRequestedOptions; |
| 54 | 51 |
| 55 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 52 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
| 56 util::StatusCallbackLog callback_log; | 53 util::StatusCallbackLog callback_log; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 95 |
| 99 EXPECT_FALSE(create_file.Execute(kRequestId)); | 96 EXPECT_FALSE(create_file.Execute(kRequestId)); |
| 100 } | 97 } |
| 101 | 98 |
| 102 TEST_F(FileSystemProviderOperationsCreateFileTest, Execute_ReadOnly) { | 99 TEST_F(FileSystemProviderOperationsCreateFileTest, Execute_ReadOnly) { |
| 103 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 100 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
| 104 util::StatusCallbackLog callback_log; | 101 util::StatusCallbackLog callback_log; |
| 105 | 102 |
| 106 const ProvidedFileSystemInfo read_only_file_system_info( | 103 const ProvidedFileSystemInfo read_only_file_system_info( |
| 107 kExtensionId, | 104 kExtensionId, |
| 108 kFileSystemId, | 105 MountOptions(kFileSystemId, "" /* display_name */), |
| 109 "" /* file_system_name */, | |
| 110 false /* writable */, | |
| 111 false /* supports_notify_tag */, | |
| 112 base::FilePath() /* mount_path */); | 106 base::FilePath() /* mount_path */); |
| 113 | 107 |
| 114 CreateFile create_file(NULL, | 108 CreateFile create_file(NULL, |
| 115 read_only_file_system_info, | 109 read_only_file_system_info, |
| 116 base::FilePath::FromUTF8Unsafe(kFilePath), | 110 base::FilePath::FromUTF8Unsafe(kFilePath), |
| 117 base::Bind(&util::LogStatusCallback, &callback_log)); | 111 base::Bind(&util::LogStatusCallback, &callback_log)); |
| 118 create_file.SetDispatchEventImplForTesting( | 112 create_file.SetDispatchEventImplForTesting( |
| 119 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, | 113 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
| 120 base::Unretained(&dispatcher))); | 114 base::Unretained(&dispatcher))); |
| 121 | 115 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 create_file.OnError(kRequestId, | 154 create_file.OnError(kRequestId, |
| 161 scoped_ptr<RequestValue>(new RequestValue()), | 155 scoped_ptr<RequestValue>(new RequestValue()), |
| 162 base::File::FILE_ERROR_TOO_MANY_OPENED); | 156 base::File::FILE_ERROR_TOO_MANY_OPENED); |
| 163 ASSERT_EQ(1u, callback_log.size()); | 157 ASSERT_EQ(1u, callback_log.size()); |
| 164 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); | 158 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); |
| 165 } | 159 } |
| 166 | 160 |
| 167 } // namespace operations | 161 } // namespace operations |
| 168 } // namespace file_system_provider | 162 } // namespace file_system_provider |
| 169 } // namespace chromeos | 163 } // namespace chromeos |
| OLD | NEW |