Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: base/file_util_unittest.cc

Issue 22929021: Converge file_util::GetFileInfo and base::GetPlaformFileInfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nacl? Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « base/file_util_posix.cc ('k') | base/file_util_win.cc » ('j') | base/platform_file_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698