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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 file_system_info_, | 94 file_system_info_, |
95 base::FilePath::FromUTF8Unsafe(kFilePath), | 95 base::FilePath::FromUTF8Unsafe(kFilePath), |
96 base::Bind(&util::LogStatusCallback, &callback_log)); | 96 base::Bind(&util::LogStatusCallback, &callback_log)); |
97 create_file.SetDispatchEventImplForTesting( | 97 create_file.SetDispatchEventImplForTesting( |
98 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, | 98 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
99 base::Unretained(&dispatcher))); | 99 base::Unretained(&dispatcher))); |
100 | 100 |
101 EXPECT_FALSE(create_file.Execute(kRequestId)); | 101 EXPECT_FALSE(create_file.Execute(kRequestId)); |
102 } | 102 } |
103 | 103 |
| 104 TEST_F(FileSystemProviderOperationsCreateFileTest, Execute_ReadOnly) { |
| 105 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
| 106 util::StatusCallbackLog callback_log; |
| 107 |
| 108 const ProvidedFileSystemInfo read_only_file_system_info( |
| 109 kExtensionId, |
| 110 kFileSystemId, |
| 111 "" /* file_system_name */, |
| 112 false /* writable */, |
| 113 base::FilePath() /* mount_path */); |
| 114 |
| 115 CreateFile create_file(NULL, |
| 116 read_only_file_system_info, |
| 117 base::FilePath::FromUTF8Unsafe(kFilePath), |
| 118 base::Bind(&util::LogStatusCallback, &callback_log)); |
| 119 create_file.SetDispatchEventImplForTesting( |
| 120 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
| 121 base::Unretained(&dispatcher))); |
| 122 |
| 123 EXPECT_FALSE(create_file.Execute(kRequestId)); |
| 124 } |
| 125 |
104 TEST_F(FileSystemProviderOperationsCreateFileTest, OnSuccess) { | 126 TEST_F(FileSystemProviderOperationsCreateFileTest, OnSuccess) { |
105 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 127 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
106 util::StatusCallbackLog callback_log; | 128 util::StatusCallbackLog callback_log; |
107 | 129 |
108 CreateFile create_file(NULL, | 130 CreateFile create_file(NULL, |
109 file_system_info_, | 131 file_system_info_, |
110 base::FilePath::FromUTF8Unsafe(kFilePath), | 132 base::FilePath::FromUTF8Unsafe(kFilePath), |
111 base::Bind(&util::LogStatusCallback, &callback_log)); | 133 base::Bind(&util::LogStatusCallback, &callback_log)); |
112 create_file.SetDispatchEventImplForTesting( | 134 create_file.SetDispatchEventImplForTesting( |
113 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, | 135 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
(...skipping 25 matching lines...) Expand all Loading... |
139 create_file.OnError(kRequestId, | 161 create_file.OnError(kRequestId, |
140 scoped_ptr<RequestValue>(new RequestValue()), | 162 scoped_ptr<RequestValue>(new RequestValue()), |
141 base::File::FILE_ERROR_TOO_MANY_OPENED); | 163 base::File::FILE_ERROR_TOO_MANY_OPENED); |
142 ASSERT_EQ(1u, callback_log.size()); | 164 ASSERT_EQ(1u, callback_log.size()); |
143 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); | 165 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); |
144 } | 166 } |
145 | 167 |
146 } // namespace operations | 168 } // namespace operations |
147 } // namespace file_system_provider | 169 } // namespace file_system_provider |
148 } // namespace chromeos | 170 } // namespace chromeos |
OLD | NEW |