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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/files/file.h" | 7 #include "base/files/file.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 base::FilePath::FromUTF8Unsafe(kDirectoryPath), | 157 base::FilePath::FromUTF8Unsafe(kDirectoryPath), |
158 base::Bind(&CallbackLogger::OnGetMetadata, callback_logger.GetWeakPtr())); | 158 base::Bind(&CallbackLogger::OnGetMetadata, callback_logger.GetWeakPtr())); |
159 get_metadata.SetDispatchEventImplForTesting( | 159 get_metadata.SetDispatchEventImplForTesting( |
160 base::Bind(&LoggingDispatchEventImpl::OnDispatchEventImpl, | 160 base::Bind(&LoggingDispatchEventImpl::OnDispatchEventImpl, |
161 base::Unretained(&dispatcher))); | 161 base::Unretained(&dispatcher))); |
162 | 162 |
163 EXPECT_FALSE(get_metadata.Execute(kRequestId)); | 163 EXPECT_FALSE(get_metadata.Execute(kRequestId)); |
164 } | 164 } |
165 | 165 |
166 TEST_F(FileSystemProviderOperationsGetMetadataTest, OnSuccess) { | 166 TEST_F(FileSystemProviderOperationsGetMetadataTest, OnSuccess) { |
167 using extensions::api::file_system_provider::EntryMetadata; | |
168 using extensions::api::file_system_provider_internal:: | 167 using extensions::api::file_system_provider_internal:: |
169 GetMetadataRequestedSuccess::Params; | 168 GetMetadataRequestedSuccess::Params; |
170 | 169 |
171 LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 170 LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
172 CallbackLogger callback_logger; | 171 CallbackLogger callback_logger; |
173 | 172 |
174 GetMetadata get_metadata( | 173 GetMetadata get_metadata( |
175 NULL, | 174 NULL, |
176 file_system_info_, | 175 file_system_info_, |
177 base::FilePath::FromUTF8Unsafe(kDirectoryPath), | 176 base::FilePath::FromUTF8Unsafe(kDirectoryPath), |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 const base::File::Info& file_info = event->file_info(); | 222 const base::File::Info& file_info = event->file_info(); |
224 EXPECT_FALSE(file_info.is_directory); | 223 EXPECT_FALSE(file_info.is_directory); |
225 EXPECT_EQ(4096, file_info.size); | 224 EXPECT_EQ(4096, file_info.size); |
226 base::Time expected_time; | 225 base::Time expected_time; |
227 EXPECT_TRUE( | 226 EXPECT_TRUE( |
228 base::Time::FromString("Thu Apr 24 00:46:52 UTC 2014", &expected_time)); | 227 base::Time::FromString("Thu Apr 24 00:46:52 UTC 2014", &expected_time)); |
229 EXPECT_EQ(expected_time, file_info.last_modified); | 228 EXPECT_EQ(expected_time, file_info.last_modified); |
230 } | 229 } |
231 | 230 |
232 TEST_F(FileSystemProviderOperationsGetMetadataTest, OnError) { | 231 TEST_F(FileSystemProviderOperationsGetMetadataTest, OnError) { |
233 using extensions::api::file_system_provider::EntryMetadata; | |
234 using extensions::api::file_system_provider_internal:: | |
235 GetMetadataRequestedError::Params; | |
236 | |
237 LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 232 LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
238 CallbackLogger callback_logger; | 233 CallbackLogger callback_logger; |
239 | 234 |
240 GetMetadata get_metadata( | 235 GetMetadata get_metadata( |
241 NULL, | 236 NULL, |
242 file_system_info_, | 237 file_system_info_, |
243 base::FilePath::FromUTF8Unsafe(kDirectoryPath), | 238 base::FilePath::FromUTF8Unsafe(kDirectoryPath), |
244 base::Bind(&CallbackLogger::OnGetMetadata, callback_logger.GetWeakPtr())); | 239 base::Bind(&CallbackLogger::OnGetMetadata, callback_logger.GetWeakPtr())); |
245 get_metadata.SetDispatchEventImplForTesting( | 240 get_metadata.SetDispatchEventImplForTesting( |
246 base::Bind(&LoggingDispatchEventImpl::OnDispatchEventImpl, | 241 base::Bind(&LoggingDispatchEventImpl::OnDispatchEventImpl, |
247 base::Unretained(&dispatcher))); | 242 base::Unretained(&dispatcher))); |
248 | 243 |
249 EXPECT_TRUE(get_metadata.Execute(kRequestId)); | 244 EXPECT_TRUE(get_metadata.Execute(kRequestId)); |
250 | 245 |
251 get_metadata.OnError(kRequestId, base::File::FILE_ERROR_TOO_MANY_OPENED); | 246 get_metadata.OnError(kRequestId, |
| 247 scoped_ptr<RequestValue>(new RequestValue()), |
| 248 base::File::FILE_ERROR_TOO_MANY_OPENED); |
252 | 249 |
253 ASSERT_EQ(1u, callback_logger.events().size()); | 250 ASSERT_EQ(1u, callback_logger.events().size()); |
254 CallbackLogger::Event* event = callback_logger.events()[0]; | 251 CallbackLogger::Event* event = callback_logger.events()[0]; |
255 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, event->result()); | 252 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, event->result()); |
256 } | 253 } |
257 | 254 |
258 } // namespace operations | 255 } // namespace operations |
259 } // namespace file_system_provider | 256 } // namespace file_system_provider |
260 } // namespace chromeos | 257 } // namespace chromeos |
OLD | NEW |