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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 continue; | 363 continue; |
364 | 364 |
365 SCOPED_TRACE(testing::Message() << "Testing RegularTestCases " << i | 365 SCOPED_TRACE(testing::Message() << "Testing RegularTestCases " << i |
366 << ": " << test_case.path); | 366 << ": " << test_case.path); |
367 | 367 |
368 // Read entries in the directory to construct the expected results map. | 368 // Read entries in the directory to construct the expected results map. |
369 typedef std::map<base::FilePath::StringType, | 369 typedef std::map<base::FilePath::StringType, |
370 base::FileUtilProxy::Entry> EntryMap; | 370 base::FileUtilProxy::Entry> EntryMap; |
371 EntryMap expected_entry_map; | 371 EntryMap expected_entry_map; |
372 | 372 |
| 373 base::FilePath dir_path = GetTestCasePlatformPath(test_case.path); |
373 FileEnumerator file_enum( | 374 FileEnumerator file_enum( |
374 GetTestCasePlatformPath(test_case.path), false /* not recursive */, | 375 dir_path, false /* not recursive */, |
375 FileEnumerator::FILES | FileEnumerator::DIRECTORIES); | 376 FileEnumerator::FILES | FileEnumerator::DIRECTORIES); |
376 base::FilePath current; | 377 base::FilePath current; |
377 while (!(current = file_enum.Next()).empty()) { | 378 while (!(current = file_enum.Next()).empty()) { |
378 FileEnumerator::FindInfo file_info; | 379 FileEnumerator::FindInfo file_info; |
379 file_enum.GetFindInfo(&file_info); | 380 file_enum.GetFindInfo(&file_info); |
380 base::FileUtilProxy::Entry entry; | 381 base::FileUtilProxy::Entry entry; |
381 entry.is_directory = FileEnumerator::IsDirectory(file_info); | 382 entry.is_directory = FileEnumerator::IsDirectory(file_info); |
382 entry.name = current.BaseName().value(); | 383 entry.name = current.BaseName().value(); |
383 entry.size = FileEnumerator::GetFilesize(file_info); | 384 entry.size = FileEnumerator::GetFilesize(file_info); |
384 entry.last_modified_time = FileEnumerator::GetLastModifiedTime(file_info); | 385 entry.last_modified_time = FileEnumerator::GetLastModifiedTime(file_info); |
385 expected_entry_map[entry.name] = entry; | 386 expected_entry_map[entry.name] = entry; |
| 387 |
| 388 #if defined(OS_POSIX) |
| 389 // Creates a symlink for each file/directory. |
| 390 // They should be ignored by ReadDirectory, so we don't add them |
| 391 // to expected_entry_map. |
| 392 file_util::CreateSymbolicLink( |
| 393 current, |
| 394 dir_path.Append(current.BaseName().AddExtension( |
| 395 FILE_PATH_LITERAL("link")))); |
| 396 #endif |
386 } | 397 } |
387 | 398 |
388 // Perform ReadDirectory in the isolated filesystem. | 399 // Perform ReadDirectory in the isolated filesystem. |
389 FileSystemURL url = GetFileSystemURL(base::FilePath(test_case.path)); | 400 FileSystemURL url = GetFileSystemURL(base::FilePath(test_case.path)); |
390 FileEntryList entries; | 401 FileEntryList entries; |
391 ASSERT_EQ(base::PLATFORM_FILE_OK, | 402 ASSERT_EQ(base::PLATFORM_FILE_OK, |
392 AsyncFileTestHelper::ReadDirectory( | 403 AsyncFileTestHelper::ReadDirectory( |
393 file_system_context(), url, &entries)); | 404 file_system_context(), url, &entries)); |
394 | 405 |
395 EXPECT_EQ(expected_entry_map.size(), entries.size()); | 406 EXPECT_EQ(expected_entry_map.size(), entries.size()); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 EXPECT_EQ(base::PLATFORM_FILE_OK, | 551 EXPECT_EQ(base::PLATFORM_FILE_OK, |
541 file_util()->Truncate(GetOperationContext().get(), url, 999)); | 552 file_util()->Truncate(GetOperationContext().get(), url, 999)); |
542 ASSERT_EQ(base::PLATFORM_FILE_OK, | 553 ASSERT_EQ(base::PLATFORM_FILE_OK, |
543 file_util()->GetFileInfo(GetOperationContext().get(), url, | 554 file_util()->GetFileInfo(GetOperationContext().get(), url, |
544 &info, &platform_path)); | 555 &info, &platform_path)); |
545 EXPECT_EQ(999, info.size); | 556 EXPECT_EQ(999, info.size); |
546 } | 557 } |
547 } | 558 } |
548 | 559 |
549 } // namespace fileapi | 560 } // namespace fileapi |
OLD | NEW |