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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 ASSERT_FALSE(file_util::DevicePathToDriveLetterPath( | 586 ASSERT_FALSE(file_util::DevicePathToDriveLetterPath( |
587 real_device_path_plus_numbers, | 587 real_device_path_plus_numbers, |
588 &win32_path)); | 588 &win32_path)); |
589 | 589 |
590 ASSERT_FALSE(file_util::DevicePathToDriveLetterPath( | 590 ASSERT_FALSE(file_util::DevicePathToDriveLetterPath( |
591 real_device_path_plus_numbers.Append(kRelativePath), | 591 real_device_path_plus_numbers.Append(kRelativePath), |
592 &win32_path)); | 592 &win32_path)); |
593 } | 593 } |
594 | 594 |
595 TEST_F(FileUtilTest, GetPlatformFileInfoForDirectory) { | 595 TEST_F(FileUtilTest, GetPlatformFileInfoForDirectory) { |
596 FilePath empty_dir = temp_dir_.path().Append(FPL("gpfi_test")); | 596 FilePath empty_dir = temp_dir_.path().Append(FPL("gpfifd_test")); |
597 ASSERT_TRUE(file_util::CreateDirectory(empty_dir)); | 597 ASSERT_TRUE(file_util::CreateDirectory(empty_dir)); |
598 base::win::ScopedHandle dir( | 598 base::win::ScopedHandle dir( |
599 ::CreateFile(empty_dir.value().c_str(), | 599 ::CreateFile(empty_dir.value().c_str(), |
600 FILE_ALL_ACCESS, | 600 FILE_ALL_ACCESS, |
601 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, | 601 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, |
602 NULL, | 602 NULL, |
603 OPEN_EXISTING, | 603 OPEN_EXISTING, |
604 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory. | 604 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory. |
605 NULL)); | 605 NULL)); |
606 ASSERT_TRUE(dir.IsValid()); | 606 ASSERT_TRUE(dir.IsValid()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 CreateTextFile(link_to, bogus_content); | 671 CreateTextFile(link_to, bogus_content); |
672 | 672 |
673 ASSERT_TRUE(file_util::CreateSymbolicLink(link_to, link_from)) | 673 ASSERT_TRUE(file_util::CreateSymbolicLink(link_to, link_from)) |
674 << "Failed to create file symlink."; | 674 << "Failed to create file symlink."; |
675 | 675 |
676 // If we created the link properly, we should be able to read the contents | 676 // If we created the link properly, we should be able to read the contents |
677 // through it. | 677 // through it. |
678 std::wstring contents = ReadTextFile(link_from); | 678 std::wstring contents = ReadTextFile(link_from); |
679 EXPECT_EQ(bogus_content, contents); | 679 EXPECT_EQ(bogus_content, contents); |
680 | 680 |
| 681 base::PlatformFileInfo link_to_info; |
| 682 ASSERT_TRUE(file_util::GetFileInfo(link_to, &link_to_info)); |
| 683 EXPECT_FALSE(link_to_info.is_symbolic_link); |
| 684 |
| 685 base::PlatformFileInfo link_from_info; |
| 686 ASSERT_TRUE(file_util::GetFileInfo(link_from, &link_from_info)); |
| 687 EXPECT_TRUE(link_from_info.is_symbolic_link); |
| 688 |
681 FilePath result; | 689 FilePath result; |
682 ASSERT_TRUE(file_util::ReadSymbolicLink(link_from, &result)); | 690 ASSERT_TRUE(file_util::ReadSymbolicLink(link_from, &result)); |
683 EXPECT_EQ(link_to.value(), result.value()); | 691 EXPECT_EQ(link_to.value(), result.value()); |
684 | 692 |
685 // Link to a directory. | 693 // Link to a directory. |
686 link_from = temp_dir_.path().Append(FPL("from_dir")); | 694 link_from = temp_dir_.path().Append(FPL("from_dir")); |
687 link_to = temp_dir_.path().Append(FPL("to_dir")); | 695 link_to = temp_dir_.path().Append(FPL("to_dir")); |
688 ASSERT_TRUE(file_util::CreateDirectory(link_to)); | 696 ASSERT_TRUE(file_util::CreateDirectory(link_to)); |
689 ASSERT_TRUE(file_util::CreateSymbolicLink(link_to, link_from)) | 697 ASSERT_TRUE(file_util::CreateSymbolicLink(link_to, link_from)) |
690 << "Failed to create directory symlink."; | 698 << "Failed to create directory symlink."; |
(...skipping 1726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2417 file_util::VerifyPathControlledByUser( | 2425 file_util::VerifyPathControlledByUser( |
2418 base_dir_, text_file_, uid_, ok_gids_)); | 2426 base_dir_, text_file_, uid_, ok_gids_)); |
2419 EXPECT_TRUE( | 2427 EXPECT_TRUE( |
2420 file_util::VerifyPathControlledByUser( | 2428 file_util::VerifyPathControlledByUser( |
2421 sub_dir_, text_file_, uid_, ok_gids_)); | 2429 sub_dir_, text_file_, uid_, ok_gids_)); |
2422 } | 2430 } |
2423 | 2431 |
2424 #endif // defined(OS_POSIX) | 2432 #endif // defined(OS_POSIX) |
2425 | 2433 |
2426 } // namespace | 2434 } // namespace |
OLD | NEW |