| 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 |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 for (size_t i = 0; i < test::kRegularTestCaseSize; ++i) { | 354 for (size_t i = 0; i < test::kRegularTestCaseSize; ++i) { |
| 355 const test::TestCaseRecord& test_case = test::kRegularTestCases[i]; | 355 const test::TestCaseRecord& test_case = test::kRegularTestCases[i]; |
| 356 if (!test_case.is_directory) | 356 if (!test_case.is_directory) |
| 357 continue; | 357 continue; |
| 358 | 358 |
| 359 SCOPED_TRACE(testing::Message() << "Testing RegularTestCases " << i | 359 SCOPED_TRACE(testing::Message() << "Testing RegularTestCases " << i |
| 360 << ": " << test_case.path); | 360 << ": " << test_case.path); |
| 361 | 361 |
| 362 // Read entries in the directory to construct the expected results map. | 362 // Read entries in the directory to construct the expected results map. |
| 363 typedef std::map<base::FilePath::StringType, | 363 typedef std::map<base::FilePath::StringType, |
| 364 base::FileUtilProxy::Entry> EntryMap; | 364 FileSystemOperation::Entry> EntryMap; |
| 365 EntryMap expected_entry_map; | 365 EntryMap expected_entry_map; |
| 366 | 366 |
| 367 base::FilePath dir_path = GetTestCasePlatformPath(test_case.path); | 367 base::FilePath dir_path = GetTestCasePlatformPath(test_case.path); |
| 368 FileEnumerator file_enum( | 368 FileEnumerator file_enum( |
| 369 dir_path, false /* not recursive */, | 369 dir_path, false /* not recursive */, |
| 370 FileEnumerator::FILES | FileEnumerator::DIRECTORIES); | 370 FileEnumerator::FILES | FileEnumerator::DIRECTORIES); |
| 371 base::FilePath current; | 371 base::FilePath current; |
| 372 while (!(current = file_enum.Next()).empty()) { | 372 while (!(current = file_enum.Next()).empty()) { |
| 373 FileEnumerator::FindInfo file_info; | 373 FileEnumerator::FindInfo file_info; |
| 374 file_enum.GetFindInfo(&file_info); | 374 file_enum.GetFindInfo(&file_info); |
| 375 base::FileUtilProxy::Entry entry; | 375 FileSystemOperation::Entry entry; |
| 376 entry.is_directory = FileEnumerator::IsDirectory(file_info); | 376 entry.is_directory = FileEnumerator::IsDirectory(file_info); |
| 377 entry.name = current.BaseName().value(); | 377 entry.name = current.BaseName().value(); |
| 378 entry.size = FileEnumerator::GetFilesize(file_info); | 378 entry.size = FileEnumerator::GetFilesize(file_info); |
| 379 entry.last_modified_time = FileEnumerator::GetLastModifiedTime(file_info); | 379 entry.last_modified_time = FileEnumerator::GetLastModifiedTime(file_info); |
| 380 expected_entry_map[entry.name] = entry; | 380 expected_entry_map[entry.name] = entry; |
| 381 | 381 |
| 382 #if defined(OS_POSIX) | 382 #if defined(OS_POSIX) |
| 383 // Creates a symlink for each file/directory. | 383 // Creates a symlink for each file/directory. |
| 384 // 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 |
| 385 // to expected_entry_map. | 385 // to expected_entry_map. |
| 386 file_util::CreateSymbolicLink( | 386 file_util::CreateSymbolicLink( |
| 387 current, | 387 current, |
| 388 dir_path.Append(current.BaseName().AddExtension( | 388 dir_path.Append(current.BaseName().AddExtension( |
| 389 FILE_PATH_LITERAL("link")))); | 389 FILE_PATH_LITERAL("link")))); |
| 390 #endif | 390 #endif |
| 391 } | 391 } |
| 392 | 392 |
| 393 // Perform ReadDirectory in the isolated filesystem. | 393 // Perform ReadDirectory in the isolated filesystem. |
| 394 FileSystemURL url = GetFileSystemURL(base::FilePath(test_case.path)); | 394 FileSystemURL url = GetFileSystemURL(base::FilePath(test_case.path)); |
| 395 FileEntryList entries; | 395 FileEntryList entries; |
| 396 ASSERT_EQ(base::PLATFORM_FILE_OK, | 396 ASSERT_EQ(base::PLATFORM_FILE_OK, |
| 397 AsyncFileTestHelper::ReadDirectory( | 397 AsyncFileTestHelper::ReadDirectory( |
| 398 file_system_context(), url, &entries)); | 398 file_system_context(), url, &entries)); |
| 399 | 399 |
| 400 EXPECT_EQ(expected_entry_map.size(), entries.size()); | 400 EXPECT_EQ(expected_entry_map.size(), entries.size()); |
| 401 for (size_t i = 0; i < entries.size(); ++i) { | 401 for (size_t i = 0; i < entries.size(); ++i) { |
| 402 const base::FileUtilProxy::Entry& entry = entries[i]; | 402 const FileSystemOperation::Entry& entry = entries[i]; |
| 403 EntryMap::iterator found = expected_entry_map.find(entry.name); | 403 EntryMap::iterator found = expected_entry_map.find(entry.name); |
| 404 EXPECT_TRUE(found != expected_entry_map.end()); | 404 EXPECT_TRUE(found != expected_entry_map.end()); |
| 405 EXPECT_EQ(found->second.name, entry.name); | 405 EXPECT_EQ(found->second.name, entry.name); |
| 406 EXPECT_EQ(found->second.is_directory, entry.is_directory); | 406 EXPECT_EQ(found->second.is_directory, entry.is_directory); |
| 407 EXPECT_EQ(found->second.size, entry.size); | 407 EXPECT_EQ(found->second.size, entry.size); |
| 408 EXPECT_EQ(found->second.last_modified_time.ToDoubleT(), | 408 EXPECT_EQ(found->second.last_modified_time.ToDoubleT(), |
| 409 entry.last_modified_time.ToDoubleT()); | 409 entry.last_modified_time.ToDoubleT()); |
| 410 } | 410 } |
| 411 } | 411 } |
| 412 } | 412 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 EXPECT_EQ(base::PLATFORM_FILE_OK, | 545 EXPECT_EQ(base::PLATFORM_FILE_OK, |
| 546 file_util()->Truncate(GetOperationContext().get(), url, 999)); | 546 file_util()->Truncate(GetOperationContext().get(), url, 999)); |
| 547 ASSERT_EQ(base::PLATFORM_FILE_OK, | 547 ASSERT_EQ(base::PLATFORM_FILE_OK, |
| 548 file_util()->GetFileInfo(GetOperationContext().get(), url, | 548 file_util()->GetFileInfo(GetOperationContext().get(), url, |
| 549 &info, &platform_path)); | 549 &info, &platform_path)); |
| 550 EXPECT_EQ(999, info.size); | 550 EXPECT_EQ(999, info.size); |
| 551 } | 551 } |
| 552 } | 552 } |
| 553 | 553 |
| 554 } // namespace fileapi | 554 } // namespace fileapi |
| OLD | NEW |