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