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_directo
ry.h" | 5 #include "chrome/browser/chromeos/file_system_provider/operations/create_directo
ry.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 kDirectoryPath[] = "/kitty/and/puppy/happy"; | 30 const base::FilePath::CharType kDirectoryPath[] = "/kitty/and/puppy/happy"; |
31 | 31 |
32 } // namespace | 32 } // namespace |
33 | 33 |
34 class FileSystemProviderOperationsCreateDirectoryTest : public testing::Test { | 34 class FileSystemProviderOperationsCreateDirectoryTest : public testing::Test { |
35 protected: | 35 protected: |
36 FileSystemProviderOperationsCreateDirectoryTest() {} | 36 FileSystemProviderOperationsCreateDirectoryTest() {} |
37 virtual ~FileSystemProviderOperationsCreateDirectoryTest() {} | 37 virtual ~FileSystemProviderOperationsCreateDirectoryTest() {} |
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(FileSystemProviderOperationsCreateDirectoryTest, Execute) { | 49 TEST_F(FileSystemProviderOperationsCreateDirectoryTest, Execute) { |
53 using extensions::api::file_system_provider::CreateDirectoryRequestedOptions; | 50 using extensions::api::file_system_provider::CreateDirectoryRequestedOptions; |
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 100 |
104 EXPECT_FALSE(create_directory.Execute(kRequestId)); | 101 EXPECT_FALSE(create_directory.Execute(kRequestId)); |
105 } | 102 } |
106 | 103 |
107 TEST_F(FileSystemProviderOperationsCreateDirectoryTest, Execute_ReadOnly) { | 104 TEST_F(FileSystemProviderOperationsCreateDirectoryTest, Execute_ReadOnly) { |
108 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 105 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
109 util::StatusCallbackLog callback_log; | 106 util::StatusCallbackLog callback_log; |
110 | 107 |
111 const ProvidedFileSystemInfo read_only_file_system_info( | 108 const ProvidedFileSystemInfo read_only_file_system_info( |
112 kExtensionId, | 109 kExtensionId, |
113 kFileSystemId, | 110 MountOptions(kFileSystemId, "" /* display_name */), |
114 "" /* file_system_name */, | |
115 false /* writable */, | |
116 false /* supports_notify_tag */, | |
117 base::FilePath() /* mount_path */); | 111 base::FilePath() /* mount_path */); |
118 | 112 |
119 CreateDirectory create_directory( | 113 CreateDirectory create_directory( |
120 NULL, | 114 NULL, |
121 read_only_file_system_info, | 115 read_only_file_system_info, |
122 base::FilePath::FromUTF8Unsafe(kDirectoryPath), | 116 base::FilePath::FromUTF8Unsafe(kDirectoryPath), |
123 true /* recursive */, | 117 true /* recursive */, |
124 base::Bind(&util::LogStatusCallback, &callback_log)); | 118 base::Bind(&util::LogStatusCallback, &callback_log)); |
125 create_directory.SetDispatchEventImplForTesting( | 119 create_directory.SetDispatchEventImplForTesting( |
126 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, | 120 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 create_directory.OnError(kRequestId, | 165 create_directory.OnError(kRequestId, |
172 scoped_ptr<RequestValue>(new RequestValue()), | 166 scoped_ptr<RequestValue>(new RequestValue()), |
173 base::File::FILE_ERROR_TOO_MANY_OPENED); | 167 base::File::FILE_ERROR_TOO_MANY_OPENED); |
174 ASSERT_EQ(1u, callback_log.size()); | 168 ASSERT_EQ(1u, callback_log.size()); |
175 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); | 169 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); |
176 } | 170 } |
177 | 171 |
178 } // namespace operations | 172 } // namespace operations |
179 } // namespace file_system_provider | 173 } // namespace file_system_provider |
180 } // namespace chromeos | 174 } // namespace chromeos |
OLD | NEW |