| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 base::FilePath dir_path = GetTestCasePlatformPath(test_case.path); | 367 base::FilePath dir_path = GetTestCasePlatformPath(test_case.path); |
| 368 base::FileEnumerator file_enum( | 368 base::FileEnumerator file_enum( |
| 369 dir_path, false /* not recursive */, | 369 dir_path, false /* not recursive */, |
| 370 base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); | 370 base::FileEnumerator::FILES | base::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 base::FileEnumerator::FileInfo file_info = file_enum.GetInfo(); | 373 base::FileEnumerator::FileInfo file_info = file_enum.GetInfo(); |
| 374 storage::DirectoryEntry entry; | 374 storage::DirectoryEntry entry; |
| 375 entry.is_directory = file_info.IsDirectory(); | 375 entry.is_directory = file_info.IsDirectory(); |
| 376 entry.name = current.BaseName().value(); | 376 entry.name = current.BaseName().value(); |
| 377 entry.size = file_info.GetSize(); | |
| 378 entry.last_modified_time = file_info.GetLastModifiedTime(); | |
| 379 expected_entry_map[entry.name] = entry; | 377 expected_entry_map[entry.name] = entry; |
| 380 | 378 |
| 381 #if defined(OS_POSIX) | 379 #if defined(OS_POSIX) |
| 382 // Creates a symlink for each file/directory. | 380 // Creates a symlink for each file/directory. |
| 383 // They should be ignored by ReadDirectory, so we don't add them | 381 // They should be ignored by ReadDirectory, so we don't add them |
| 384 // to expected_entry_map. | 382 // to expected_entry_map. |
| 385 base::CreateSymbolicLink( | 383 base::CreateSymbolicLink( |
| 386 current, | 384 current, |
| 387 dir_path.Append(current.BaseName().AddExtension( | 385 dir_path.Append(current.BaseName().AddExtension( |
| 388 FILE_PATH_LITERAL("link")))); | 386 FILE_PATH_LITERAL("link")))); |
| 389 #endif | 387 #endif |
| 390 } | 388 } |
| 391 | 389 |
| 392 // Perform ReadDirectory in the isolated filesystem. | 390 // Perform ReadDirectory in the isolated filesystem. |
| 393 FileSystemURL url = GetFileSystemURL(base::FilePath(test_case.path)); | 391 FileSystemURL url = GetFileSystemURL(base::FilePath(test_case.path)); |
| 394 FileEntryList entries; | 392 FileEntryList entries; |
| 395 ASSERT_EQ(base::File::FILE_OK, | 393 ASSERT_EQ(base::File::FILE_OK, |
| 396 AsyncFileTestHelper::ReadDirectory( | 394 AsyncFileTestHelper::ReadDirectory( |
| 397 file_system_context(), url, &entries)); | 395 file_system_context(), url, &entries)); |
| 398 | 396 |
| 399 EXPECT_EQ(expected_entry_map.size(), entries.size()); | 397 EXPECT_EQ(expected_entry_map.size(), entries.size()); |
| 400 for (size_t i = 0; i < entries.size(); ++i) { | 398 for (size_t i = 0; i < entries.size(); ++i) { |
| 401 const storage::DirectoryEntry& entry = entries[i]; | 399 const storage::DirectoryEntry& entry = entries[i]; |
| 402 EntryMap::iterator found = expected_entry_map.find(entry.name); | 400 EntryMap::iterator found = expected_entry_map.find(entry.name); |
| 403 EXPECT_TRUE(found != expected_entry_map.end()); | 401 EXPECT_TRUE(found != expected_entry_map.end()); |
| 404 EXPECT_EQ(found->second.name, entry.name); | 402 EXPECT_EQ(found->second.name, entry.name); |
| 405 EXPECT_EQ(found->second.is_directory, entry.is_directory); | 403 EXPECT_EQ(found->second.is_directory, entry.is_directory); |
| 406 EXPECT_EQ(found->second.size, entry.size); | |
| 407 EXPECT_EQ(found->second.last_modified_time.ToDoubleT(), | |
| 408 entry.last_modified_time.ToDoubleT()); | |
| 409 } | 404 } |
| 410 } | 405 } |
| 411 } | 406 } |
| 412 | 407 |
| 413 TEST_F(DraggedFileUtilTest, GetLocalFilePathTest) { | 408 TEST_F(DraggedFileUtilTest, GetLocalFilePathTest) { |
| 414 for (size_t i = 0; i < kRegularFileSystemTestCaseSize; ++i) { | 409 for (size_t i = 0; i < kRegularFileSystemTestCaseSize; ++i) { |
| 415 const FileSystemTestCaseRecord& test_case = | 410 const FileSystemTestCaseRecord& test_case = |
| 416 kRegularFileSystemTestCases[i]; | 411 kRegularFileSystemTestCases[i]; |
| 417 FileSystemURL url = GetFileSystemURL(base::FilePath(test_case.path)); | 412 FileSystemURL url = GetFileSystemURL(base::FilePath(test_case.path)); |
| 418 | 413 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 EXPECT_EQ(base::File::FILE_OK, | 542 EXPECT_EQ(base::File::FILE_OK, |
| 548 file_util()->Truncate(GetOperationContext().get(), url, 999)); | 543 file_util()->Truncate(GetOperationContext().get(), url, 999)); |
| 549 ASSERT_EQ(base::File::FILE_OK, | 544 ASSERT_EQ(base::File::FILE_OK, |
| 550 file_util()->GetFileInfo(GetOperationContext().get(), url, | 545 file_util()->GetFileInfo(GetOperationContext().get(), url, |
| 551 &info, &platform_path)); | 546 &info, &platform_path)); |
| 552 EXPECT_EQ(999, info.size); | 547 EXPECT_EQ(999, info.size); |
| 553 } | 548 } |
| 554 } | 549 } |
| 555 | 550 |
| 556 } // namespace content | 551 } // namespace content |
| OLD | NEW |