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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 base::Bind(&CallbackLogger::OnReadDirectory, | 164 base::Bind(&CallbackLogger::OnReadDirectory, |
165 callback_logger.GetWeakPtr())); | 165 callback_logger.GetWeakPtr())); |
166 read_directory.SetDispatchEventImplForTesting( | 166 read_directory.SetDispatchEventImplForTesting( |
167 base::Bind(&LoggingDispatchEventImpl::OnDispatchEventImpl, | 167 base::Bind(&LoggingDispatchEventImpl::OnDispatchEventImpl, |
168 base::Unretained(&dispatcher))); | 168 base::Unretained(&dispatcher))); |
169 | 169 |
170 EXPECT_FALSE(read_directory.Execute(kRequestId)); | 170 EXPECT_FALSE(read_directory.Execute(kRequestId)); |
171 } | 171 } |
172 | 172 |
173 TEST_F(FileSystemProviderOperationsReadDirectoryTest, OnSuccess) { | 173 TEST_F(FileSystemProviderOperationsReadDirectoryTest, OnSuccess) { |
174 using extensions::api::file_system_provider::EntryMetadata; | |
175 using extensions::api::file_system_provider_internal:: | 174 using extensions::api::file_system_provider_internal:: |
176 ReadDirectoryRequestedSuccess::Params; | 175 ReadDirectoryRequestedSuccess::Params; |
177 | 176 |
178 LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 177 LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
179 CallbackLogger callback_logger; | 178 CallbackLogger callback_logger; |
180 | 179 |
181 ReadDirectory read_directory(NULL, | 180 ReadDirectory read_directory(NULL, |
182 file_system_info_, | 181 file_system_info_, |
183 base::FilePath::FromUTF8Unsafe(kDirectoryPath), | 182 base::FilePath::FromUTF8Unsafe(kDirectoryPath), |
184 base::Bind(&CallbackLogger::OnReadDirectory, | 183 base::Bind(&CallbackLogger::OnReadDirectory, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 EXPECT_FALSE(entry.is_directory); | 234 EXPECT_FALSE(entry.is_directory); |
236 EXPECT_EQ("blueberries.txt", entry.name); | 235 EXPECT_EQ("blueberries.txt", entry.name); |
237 EXPECT_EQ(4096, entry.size); | 236 EXPECT_EQ(4096, entry.size); |
238 base::Time expected_time; | 237 base::Time expected_time; |
239 EXPECT_TRUE( | 238 EXPECT_TRUE( |
240 base::Time::FromString("Thu Apr 24 00:46:52 UTC 2014", &expected_time)); | 239 base::Time::FromString("Thu Apr 24 00:46:52 UTC 2014", &expected_time)); |
241 EXPECT_EQ(expected_time, entry.last_modified_time); | 240 EXPECT_EQ(expected_time, entry.last_modified_time); |
242 } | 241 } |
243 | 242 |
244 TEST_F(FileSystemProviderOperationsReadDirectoryTest, OnError) { | 243 TEST_F(FileSystemProviderOperationsReadDirectoryTest, OnError) { |
245 using extensions::api::file_system_provider::EntryMetadata; | |
246 using extensions::api::file_system_provider_internal:: | |
247 ReadDirectoryRequestedSuccess::Params; | |
248 | |
249 LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 244 LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
250 CallbackLogger callback_logger; | 245 CallbackLogger callback_logger; |
251 | 246 |
252 ReadDirectory read_directory(NULL, | 247 ReadDirectory read_directory(NULL, |
253 file_system_info_, | 248 file_system_info_, |
254 base::FilePath::FromUTF8Unsafe(kDirectoryPath), | 249 base::FilePath::FromUTF8Unsafe(kDirectoryPath), |
255 base::Bind(&CallbackLogger::OnReadDirectory, | 250 base::Bind(&CallbackLogger::OnReadDirectory, |
256 callback_logger.GetWeakPtr())); | 251 callback_logger.GetWeakPtr())); |
257 read_directory.SetDispatchEventImplForTesting( | 252 read_directory.SetDispatchEventImplForTesting( |
258 base::Bind(&LoggingDispatchEventImpl::OnDispatchEventImpl, | 253 base::Bind(&LoggingDispatchEventImpl::OnDispatchEventImpl, |
259 base::Unretained(&dispatcher))); | 254 base::Unretained(&dispatcher))); |
260 | 255 |
261 EXPECT_TRUE(read_directory.Execute(kRequestId)); | 256 EXPECT_TRUE(read_directory.Execute(kRequestId)); |
262 | 257 |
263 read_directory.OnError(kRequestId, base::File::FILE_ERROR_TOO_MANY_OPENED); | 258 read_directory.OnError(kRequestId, |
| 259 scoped_ptr<RequestValue>(new RequestValue()), |
| 260 base::File::FILE_ERROR_TOO_MANY_OPENED); |
264 | 261 |
265 ASSERT_EQ(1u, callback_logger.events().size()); | 262 ASSERT_EQ(1u, callback_logger.events().size()); |
266 CallbackLogger::Event* event = callback_logger.events()[0]; | 263 CallbackLogger::Event* event = callback_logger.events()[0]; |
267 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, event->result()); | 264 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, event->result()); |
268 ASSERT_EQ(0u, event->entry_list().size()); | 265 ASSERT_EQ(0u, event->entry_list().size()); |
269 } | 266 } |
270 | 267 |
271 } // namespace operations | 268 } // namespace operations |
272 } // namespace file_system_provider | 269 } // namespace file_system_provider |
273 } // namespace chromeos | 270 } // namespace chromeos |
OLD | NEW |