OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <map> | 5 #include <map> |
6 #include <queue> | 6 #include <queue> |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/files/file_enumerator.h" |
12 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
15 #include "base/message_loop_proxy.h" | 16 #include "base/message_loop_proxy.h" |
16 #include "base/time.h" | 17 #include "base/time.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "webkit/browser/fileapi/async_file_test_helper.h" | 19 #include "webkit/browser/fileapi/async_file_test_helper.h" |
19 #include "webkit/browser/fileapi/file_system_context.h" | 20 #include "webkit/browser/fileapi/file_system_context.h" |
20 #include "webkit/browser/fileapi/file_system_operation_context.h" | 21 #include "webkit/browser/fileapi/file_system_operation_context.h" |
21 #include "webkit/browser/fileapi/file_system_task_runners.h" | 22 #include "webkit/browser/fileapi/file_system_task_runners.h" |
22 #include "webkit/browser/fileapi/isolated_context.h" | 23 #include "webkit/browser/fileapi/isolated_context.h" |
23 #include "webkit/browser/fileapi/isolated_file_util.h" | 24 #include "webkit/browser/fileapi/isolated_file_util.h" |
24 #include "webkit/browser/fileapi/local_file_system_operation.h" | 25 #include "webkit/browser/fileapi/local_file_system_operation.h" |
25 #include "webkit/browser/fileapi/local_file_util.h" | 26 #include "webkit/browser/fileapi/local_file_util.h" |
26 #include "webkit/browser/fileapi/mock_file_system_context.h" | 27 #include "webkit/browser/fileapi/mock_file_system_context.h" |
27 #include "webkit/browser/fileapi/native_file_util.h" | 28 #include "webkit/browser/fileapi/native_file_util.h" |
28 #include "webkit/browser/fileapi/test_file_set.h" | 29 #include "webkit/browser/fileapi/test_file_set.h" |
29 | 30 |
30 using file_util::FileEnumerator; | |
31 | |
32 namespace fileapi { | 31 namespace fileapi { |
33 | 32 |
34 namespace { | 33 namespace { |
35 | 34 |
36 typedef AsyncFileTestHelper::FileEntryList FileEntryList; | 35 typedef AsyncFileTestHelper::FileEntryList FileEntryList; |
37 | 36 |
38 // Used in IsolatedFileUtilTest::SimulateDropFiles(). | 37 // Used in IsolatedFileUtilTest::SimulateDropFiles(). |
39 // Random root paths in which we create each file/directory of the | 38 // Random root paths in which we create each file/directory of the |
40 // RegularTestCases (so that we can simulate a drop with files/directories | 39 // RegularTestCases (so that we can simulate a drop with files/directories |
41 // from multiple directories). | 40 // from multiple directories). |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 continue; | 355 continue; |
357 | 356 |
358 SCOPED_TRACE(testing::Message() << "Testing RegularTestCases " << i | 357 SCOPED_TRACE(testing::Message() << "Testing RegularTestCases " << i |
359 << ": " << test_case.path); | 358 << ": " << test_case.path); |
360 | 359 |
361 // Read entries in the directory to construct the expected results map. | 360 // Read entries in the directory to construct the expected results map. |
362 typedef std::map<base::FilePath::StringType, DirectoryEntry> EntryMap; | 361 typedef std::map<base::FilePath::StringType, DirectoryEntry> EntryMap; |
363 EntryMap expected_entry_map; | 362 EntryMap expected_entry_map; |
364 | 363 |
365 base::FilePath dir_path = GetTestCasePlatformPath(test_case.path); | 364 base::FilePath dir_path = GetTestCasePlatformPath(test_case.path); |
366 FileEnumerator file_enum( | 365 base::FileEnumerator file_enum( |
367 dir_path, false /* not recursive */, | 366 dir_path, false /* not recursive */, |
368 FileEnumerator::FILES | FileEnumerator::DIRECTORIES); | 367 base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); |
369 base::FilePath current; | 368 base::FilePath current; |
370 while (!(current = file_enum.Next()).empty()) { | 369 while (!(current = file_enum.Next()).empty()) { |
371 FileEnumerator::FindInfo file_info; | 370 base::FileEnumerator::FileInfo file_info = file_enum.GetInfo(); |
372 file_enum.GetFindInfo(&file_info); | |
373 DirectoryEntry entry; | 371 DirectoryEntry entry; |
374 entry.is_directory = FileEnumerator::IsDirectory(file_info); | 372 entry.is_directory = file_info.IsDirectory(); |
375 entry.name = current.BaseName().value(); | 373 entry.name = current.BaseName().value(); |
376 entry.size = FileEnumerator::GetFilesize(file_info); | 374 entry.size = file_info.GetSize(); |
377 entry.last_modified_time = FileEnumerator::GetLastModifiedTime(file_info); | 375 entry.last_modified_time = file_info.GetLastModifiedTime(); |
378 expected_entry_map[entry.name] = entry; | 376 expected_entry_map[entry.name] = entry; |
379 | 377 |
380 #if defined(OS_POSIX) | 378 #if defined(OS_POSIX) |
381 // Creates a symlink for each file/directory. | 379 // Creates a symlink for each file/directory. |
382 // They should be ignored by ReadDirectory, so we don't add them | 380 // They should be ignored by ReadDirectory, so we don't add them |
383 // to expected_entry_map. | 381 // to expected_entry_map. |
384 file_util::CreateSymbolicLink( | 382 file_util::CreateSymbolicLink( |
385 current, | 383 current, |
386 dir_path.Append(current.BaseName().AddExtension( | 384 dir_path.Append(current.BaseName().AddExtension( |
387 FILE_PATH_LITERAL("link")))); | 385 FILE_PATH_LITERAL("link")))); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 EXPECT_EQ(base::PLATFORM_FILE_OK, | 541 EXPECT_EQ(base::PLATFORM_FILE_OK, |
544 file_util()->Truncate(GetOperationContext().get(), url, 999)); | 542 file_util()->Truncate(GetOperationContext().get(), url, 999)); |
545 ASSERT_EQ(base::PLATFORM_FILE_OK, | 543 ASSERT_EQ(base::PLATFORM_FILE_OK, |
546 file_util()->GetFileInfo(GetOperationContext().get(), url, | 544 file_util()->GetFileInfo(GetOperationContext().get(), url, |
547 &info, &platform_path)); | 545 &info, &platform_path)); |
548 EXPECT_EQ(999, info.size); | 546 EXPECT_EQ(999, info.size); |
549 } | 547 } |
550 } | 548 } |
551 | 549 |
552 } // namespace fileapi | 550 } // namespace fileapi |
OLD | NEW |