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