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

Side by Side Diff: base/file_util_unittest.cc

Issue 19052005: Move PathIsWritable, DirectoryExists, ContentsEqual, and TextContentsEqual to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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
« no previous file with comments | « base/file_util_posix.cc ('k') | base/file_util_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 17 matching lines...) Expand all
28 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
29 #include "testing/platform_test.h" 29 #include "testing/platform_test.h"
30 30
31 #if defined(OS_WIN) 31 #if defined(OS_WIN)
32 #include "base/win/scoped_handle.h" 32 #include "base/win/scoped_handle.h"
33 #endif 33 #endif
34 34
35 // This macro helps avoid wrapped lines in the test structs. 35 // This macro helps avoid wrapped lines in the test structs.
36 #define FPL(x) FILE_PATH_LITERAL(x) 36 #define FPL(x) FILE_PATH_LITERAL(x)
37 37
38 using base::DirectoryExists;
38 using base::FileEnumerator; 39 using base::FileEnumerator;
39 using base::FilePath; 40 using base::FilePath;
41 using base::PathIsWritable;
42 using base::TextContentsEqual;
40 43
41 namespace { 44 namespace {
42 45
43 // To test that file_util::Normalize FilePath() deals with NTFS reparse points 46 // To test that file_util::Normalize FilePath() deals with NTFS reparse points
44 // correctly, we need functions to create and delete reparse points. 47 // correctly, we need functions to create and delete reparse points.
45 #if defined(OS_WIN) 48 #if defined(OS_WIN)
46 typedef struct _REPARSE_DATA_BUFFER { 49 typedef struct _REPARSE_DATA_BUFFER {
47 ULONG ReparseTag; 50 ULONG ReparseTag;
48 USHORT ReparseDataLength; 51 USHORT ReparseDataLength;
49 USHORT Reserved; 52 USHORT Reserved;
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 858
856 // Write file. 859 // Write file.
857 EXPECT_EQ(static_cast<int>(kData.length()), 860 EXPECT_EQ(static_cast<int>(kData.length()),
858 file_util::WriteFile(file_name, kData.data(), kData.length())); 861 file_util::WriteFile(file_name, kData.data(), kData.length()));
859 EXPECT_TRUE(base::PathExists(file_name)); 862 EXPECT_TRUE(base::PathExists(file_name));
860 863
861 // Make sure the file is writable. 864 // Make sure the file is writable.
862 int mode = 0; 865 int mode = 0;
863 EXPECT_TRUE(file_util::GetPosixFilePermissions(file_name, &mode)); 866 EXPECT_TRUE(file_util::GetPosixFilePermissions(file_name, &mode));
864 EXPECT_TRUE(mode & file_util::FILE_PERMISSION_WRITE_BY_USER); 867 EXPECT_TRUE(mode & file_util::FILE_PERMISSION_WRITE_BY_USER);
865 EXPECT_TRUE(file_util::PathIsWritable(file_name)); 868 EXPECT_TRUE(PathIsWritable(file_name));
866 869
867 // Get rid of the write permission. 870 // Get rid of the write permission.
868 EXPECT_TRUE(file_util::SetPosixFilePermissions(file_name, 0u)); 871 EXPECT_TRUE(file_util::SetPosixFilePermissions(file_name, 0u));
869 EXPECT_TRUE(file_util::GetPosixFilePermissions(file_name, &mode)); 872 EXPECT_TRUE(file_util::GetPosixFilePermissions(file_name, &mode));
870 EXPECT_FALSE(mode & file_util::FILE_PERMISSION_WRITE_BY_USER); 873 EXPECT_FALSE(mode & file_util::FILE_PERMISSION_WRITE_BY_USER);
871 // Make sure the file can't be write. 874 // Make sure the file can't be write.
872 EXPECT_EQ(-1, 875 EXPECT_EQ(-1,
873 file_util::WriteFile(file_name, kData.data(), kData.length())); 876 file_util::WriteFile(file_name, kData.data(), kData.length()));
874 EXPECT_FALSE(file_util::PathIsWritable(file_name)); 877 EXPECT_FALSE(PathIsWritable(file_name));
875 878
876 // Give read permission. 879 // Give read permission.
877 EXPECT_TRUE(file_util::SetPosixFilePermissions( 880 EXPECT_TRUE(file_util::SetPosixFilePermissions(
878 file_name, 881 file_name,
879 file_util::FILE_PERMISSION_WRITE_BY_USER)); 882 file_util::FILE_PERMISSION_WRITE_BY_USER));
880 EXPECT_TRUE(file_util::GetPosixFilePermissions(file_name, &mode)); 883 EXPECT_TRUE(file_util::GetPosixFilePermissions(file_name, &mode));
881 EXPECT_TRUE(mode & file_util::FILE_PERMISSION_WRITE_BY_USER); 884 EXPECT_TRUE(mode & file_util::FILE_PERMISSION_WRITE_BY_USER);
882 // Make sure the file can be write. 885 // Make sure the file can be write.
883 EXPECT_EQ(static_cast<int>(kData.length()), 886 EXPECT_EQ(static_cast<int>(kData.length()),
884 file_util::WriteFile(file_name, kData.data(), kData.length())); 887 file_util::WriteFile(file_name, kData.data(), kData.length()));
885 EXPECT_TRUE(file_util::PathIsWritable(file_name)); 888 EXPECT_TRUE(PathIsWritable(file_name));
886 889
887 // Delete the file. 890 // Delete the file.
888 EXPECT_TRUE(base::Delete(file_name, false)); 891 EXPECT_TRUE(base::Delete(file_name, false));
889 EXPECT_FALSE(base::PathExists(file_name)); 892 EXPECT_FALSE(base::PathExists(file_name));
890 } 893 }
891 894
892 TEST_F(FileUtilTest, ChangeDirectoryPermissionsAndEnumerate) { 895 TEST_F(FileUtilTest, ChangeDirectoryPermissionsAndEnumerate) {
893 // Create a directory path. 896 // Create a directory path.
894 FilePath subdir_path = 897 FilePath subdir_path =
895 temp_dir_.path().Append(FPL("PermissionTest1")); 898 temp_dir_.path().Append(FPL("PermissionTest1"));
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 data_dir.Append(FILE_PATH_LITERAL("empty2.txt")); 1553 data_dir.Append(FILE_PATH_LITERAL("empty2.txt"));
1551 FilePath shortened_file = 1554 FilePath shortened_file =
1552 data_dir.Append(FILE_PATH_LITERAL("shortened.txt")); 1555 data_dir.Append(FILE_PATH_LITERAL("shortened.txt"));
1553 FilePath binary_file = 1556 FilePath binary_file =
1554 data_dir.Append(FILE_PATH_LITERAL("binary_file.bin")); 1557 data_dir.Append(FILE_PATH_LITERAL("binary_file.bin"));
1555 FilePath binary_file_same = 1558 FilePath binary_file_same =
1556 data_dir.Append(FILE_PATH_LITERAL("binary_file_same.bin")); 1559 data_dir.Append(FILE_PATH_LITERAL("binary_file_same.bin"));
1557 FilePath binary_file_diff = 1560 FilePath binary_file_diff =
1558 data_dir.Append(FILE_PATH_LITERAL("binary_file_diff.bin")); 1561 data_dir.Append(FILE_PATH_LITERAL("binary_file_diff.bin"));
1559 1562
1560 EXPECT_TRUE(file_util::ContentsEqual(original_file, original_file)); 1563 EXPECT_TRUE(ContentsEqual(original_file, original_file));
1561 EXPECT_TRUE(file_util::ContentsEqual(original_file, same_file)); 1564 EXPECT_TRUE(ContentsEqual(original_file, same_file));
1562 EXPECT_FALSE(file_util::ContentsEqual(original_file, same_length_file)); 1565 EXPECT_FALSE(ContentsEqual(original_file, same_length_file));
1563 EXPECT_FALSE(file_util::ContentsEqual(original_file, different_file)); 1566 EXPECT_FALSE(ContentsEqual(original_file, different_file));
1564 EXPECT_FALSE(file_util::ContentsEqual( 1567 EXPECT_FALSE(ContentsEqual(FilePath(FILE_PATH_LITERAL("bogusname")),
1565 FilePath(FILE_PATH_LITERAL("bogusname")), 1568 FilePath(FILE_PATH_LITERAL("bogusname"))));
1566 FilePath(FILE_PATH_LITERAL("bogusname")))); 1569 EXPECT_FALSE(ContentsEqual(original_file, different_first_file));
1567 EXPECT_FALSE(file_util::ContentsEqual(original_file, different_first_file)); 1570 EXPECT_FALSE(ContentsEqual(original_file, different_last_file));
1568 EXPECT_FALSE(file_util::ContentsEqual(original_file, different_last_file)); 1571 EXPECT_TRUE(ContentsEqual(empty1_file, empty2_file));
1569 EXPECT_TRUE(file_util::ContentsEqual(empty1_file, empty2_file)); 1572 EXPECT_FALSE(ContentsEqual(original_file, shortened_file));
1570 EXPECT_FALSE(file_util::ContentsEqual(original_file, shortened_file)); 1573 EXPECT_FALSE(ContentsEqual(shortened_file, original_file));
1571 EXPECT_FALSE(file_util::ContentsEqual(shortened_file, original_file)); 1574 EXPECT_TRUE(ContentsEqual(binary_file, binary_file_same));
1572 EXPECT_TRUE(file_util::ContentsEqual(binary_file, binary_file_same)); 1575 EXPECT_FALSE(ContentsEqual(binary_file, binary_file_diff));
1573 EXPECT_FALSE(file_util::ContentsEqual(binary_file, binary_file_diff));
1574 } 1576 }
1575 1577
1576 TEST_F(ReadOnlyFileUtilTest, TextContentsEqual) { 1578 TEST_F(ReadOnlyFileUtilTest, TextContentsEqual) {
1577 FilePath data_dir; 1579 FilePath data_dir;
1578 ASSERT_TRUE(PathService::Get(base::DIR_TEST_DATA, &data_dir)); 1580 ASSERT_TRUE(PathService::Get(base::DIR_TEST_DATA, &data_dir));
1579 data_dir = data_dir.AppendASCII("file_util"); 1581 data_dir = data_dir.AppendASCII("file_util");
1580 ASSERT_TRUE(base::PathExists(data_dir)); 1582 ASSERT_TRUE(base::PathExists(data_dir));
1581 1583
1582 FilePath original_file = 1584 FilePath original_file =
1583 data_dir.Append(FILE_PATH_LITERAL("original.txt")); 1585 data_dir.Append(FILE_PATH_LITERAL("original.txt"));
(...skipping 15 matching lines...) Expand all
1599 data_dir.Append(FILE_PATH_LITERAL("first2.txt")); 1601 data_dir.Append(FILE_PATH_LITERAL("first2.txt"));
1600 FilePath empty1_file = 1602 FilePath empty1_file =
1601 data_dir.Append(FILE_PATH_LITERAL("empty1.txt")); 1603 data_dir.Append(FILE_PATH_LITERAL("empty1.txt"));
1602 FilePath empty2_file = 1604 FilePath empty2_file =
1603 data_dir.Append(FILE_PATH_LITERAL("empty2.txt")); 1605 data_dir.Append(FILE_PATH_LITERAL("empty2.txt"));
1604 FilePath blank_line_file = 1606 FilePath blank_line_file =
1605 data_dir.Append(FILE_PATH_LITERAL("blank_line.txt")); 1607 data_dir.Append(FILE_PATH_LITERAL("blank_line.txt"));
1606 FilePath blank_line_crlf_file = 1608 FilePath blank_line_crlf_file =
1607 data_dir.Append(FILE_PATH_LITERAL("blank_line_crlf.txt")); 1609 data_dir.Append(FILE_PATH_LITERAL("blank_line_crlf.txt"));
1608 1610
1609 EXPECT_TRUE(file_util::TextContentsEqual(original_file, same_file)); 1611 EXPECT_TRUE(TextContentsEqual(original_file, same_file));
1610 EXPECT_TRUE(file_util::TextContentsEqual(original_file, crlf_file)); 1612 EXPECT_TRUE(TextContentsEqual(original_file, crlf_file));
1611 EXPECT_FALSE(file_util::TextContentsEqual(original_file, shortened_file)); 1613 EXPECT_FALSE(TextContentsEqual(original_file, shortened_file));
1612 EXPECT_FALSE(file_util::TextContentsEqual(original_file, different_file)); 1614 EXPECT_FALSE(TextContentsEqual(original_file, different_file));
1613 EXPECT_FALSE(file_util::TextContentsEqual(original_file, 1615 EXPECT_FALSE(TextContentsEqual(original_file, different_first_file));
1614 different_first_file)); 1616 EXPECT_FALSE(TextContentsEqual(original_file, different_last_file));
1615 EXPECT_FALSE(file_util::TextContentsEqual(original_file, 1617 EXPECT_FALSE(TextContentsEqual(first1_file, first2_file));
1616 different_last_file)); 1618 EXPECT_TRUE(TextContentsEqual(empty1_file, empty2_file));
1617 EXPECT_FALSE(file_util::TextContentsEqual(first1_file, first2_file)); 1619 EXPECT_FALSE(TextContentsEqual(original_file, empty1_file));
1618 EXPECT_TRUE(file_util::TextContentsEqual(empty1_file, empty2_file)); 1620 EXPECT_TRUE(TextContentsEqual(blank_line_file, blank_line_crlf_file));
1619 EXPECT_FALSE(file_util::TextContentsEqual(original_file, empty1_file));
1620 EXPECT_TRUE(file_util::TextContentsEqual(blank_line_file,
1621 blank_line_crlf_file));
1622 } 1621 }
1623 1622
1624 // We don't need equivalent functionality outside of Windows. 1623 // We don't need equivalent functionality outside of Windows.
1625 #if defined(OS_WIN) 1624 #if defined(OS_WIN)
1626 TEST_F(FileUtilTest, CopyAndDeleteDirectoryTest) { 1625 TEST_F(FileUtilTest, CopyAndDeleteDirectoryTest) {
1627 // Create a directory 1626 // Create a directory
1628 FilePath dir_name_from = 1627 FilePath dir_name_from =
1629 temp_dir_.path().Append(FILE_PATH_LITERAL("CopyAndDelete_From_Subdir")); 1628 temp_dir_.path().Append(FILE_PATH_LITERAL("CopyAndDelete_From_Subdir"));
1630 file_util::CreateDirectory(dir_name_from); 1629 file_util::CreateDirectory(dir_name_from);
1631 ASSERT_TRUE(base::PathExists(dir_name_from)); 1630 ASSERT_TRUE(base::PathExists(dir_name_from));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 ::_tputenv_s(kTmpKey, _T("")); 1680 ::_tputenv_s(kTmpKey, _T(""));
1682 } 1681 }
1683 } 1682 }
1684 #endif // OS_WIN 1683 #endif // OS_WIN
1685 1684
1686 TEST_F(FileUtilTest, CreateTemporaryFileTest) { 1685 TEST_F(FileUtilTest, CreateTemporaryFileTest) {
1687 FilePath temp_files[3]; 1686 FilePath temp_files[3];
1688 for (int i = 0; i < 3; i++) { 1687 for (int i = 0; i < 3; i++) {
1689 ASSERT_TRUE(file_util::CreateTemporaryFile(&(temp_files[i]))); 1688 ASSERT_TRUE(file_util::CreateTemporaryFile(&(temp_files[i])));
1690 EXPECT_TRUE(base::PathExists(temp_files[i])); 1689 EXPECT_TRUE(base::PathExists(temp_files[i]));
1691 EXPECT_FALSE(file_util::DirectoryExists(temp_files[i])); 1690 EXPECT_FALSE(DirectoryExists(temp_files[i]));
1692 } 1691 }
1693 for (int i = 0; i < 3; i++) 1692 for (int i = 0; i < 3; i++)
1694 EXPECT_FALSE(temp_files[i] == temp_files[(i+1)%3]); 1693 EXPECT_FALSE(temp_files[i] == temp_files[(i+1)%3]);
1695 for (int i = 0; i < 3; i++) 1694 for (int i = 0; i < 3; i++)
1696 EXPECT_TRUE(base::Delete(temp_files[i], false)); 1695 EXPECT_TRUE(base::Delete(temp_files[i], false));
1697 } 1696 }
1698 1697
1699 TEST_F(FileUtilTest, CreateAndOpenTemporaryFileTest) { 1698 TEST_F(FileUtilTest, CreateAndOpenTemporaryFileTest) {
1700 FilePath names[3]; 1699 FilePath names[3];
1701 FILE* fps[3]; 1700 FILE* fps[3];
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1735 FILE_PATH_LITERAL("CreateNewTemporaryDirInDirTest"), 1734 FILE_PATH_LITERAL("CreateNewTemporaryDirInDirTest"),
1736 &new_dir)); 1735 &new_dir));
1737 EXPECT_TRUE(base::PathExists(new_dir)); 1736 EXPECT_TRUE(base::PathExists(new_dir));
1738 EXPECT_TRUE(temp_dir_.path().IsParent(new_dir)); 1737 EXPECT_TRUE(temp_dir_.path().IsParent(new_dir));
1739 EXPECT_TRUE(base::Delete(new_dir, false)); 1738 EXPECT_TRUE(base::Delete(new_dir, false));
1740 } 1739 }
1741 1740
1742 TEST_F(FileUtilTest, GetShmemTempDirTest) { 1741 TEST_F(FileUtilTest, GetShmemTempDirTest) {
1743 FilePath dir; 1742 FilePath dir;
1744 EXPECT_TRUE(file_util::GetShmemTempDir(&dir, false)); 1743 EXPECT_TRUE(file_util::GetShmemTempDir(&dir, false));
1745 EXPECT_TRUE(file_util::DirectoryExists(dir)); 1744 EXPECT_TRUE(DirectoryExists(dir));
1746 } 1745 }
1747 1746
1748 TEST_F(FileUtilTest, CreateDirectoryTest) { 1747 TEST_F(FileUtilTest, CreateDirectoryTest) {
1749 FilePath test_root = 1748 FilePath test_root =
1750 temp_dir_.path().Append(FILE_PATH_LITERAL("create_directory_test")); 1749 temp_dir_.path().Append(FILE_PATH_LITERAL("create_directory_test"));
1751 #if defined(OS_WIN) 1750 #if defined(OS_WIN)
1752 FilePath test_path = 1751 FilePath test_path =
1753 test_root.Append(FILE_PATH_LITERAL("dir\\tree\\likely\\doesnt\\exist\\")); 1752 test_root.Append(FILE_PATH_LITERAL("dir\\tree\\likely\\doesnt\\exist\\"));
1754 #elif defined(OS_POSIX) 1753 #elif defined(OS_POSIX)
1755 FilePath test_path = 1754 FilePath test_path =
(...skipping 13 matching lines...) Expand all
1769 EXPECT_TRUE(base::PathExists(test_path)); 1768 EXPECT_TRUE(base::PathExists(test_path));
1770 EXPECT_FALSE(file_util::CreateDirectory(test_path)); 1769 EXPECT_FALSE(file_util::CreateDirectory(test_path));
1771 1770
1772 EXPECT_TRUE(base::Delete(test_root, true)); 1771 EXPECT_TRUE(base::Delete(test_root, true));
1773 EXPECT_FALSE(base::PathExists(test_root)); 1772 EXPECT_FALSE(base::PathExists(test_root));
1774 EXPECT_FALSE(base::PathExists(test_path)); 1773 EXPECT_FALSE(base::PathExists(test_path));
1775 1774
1776 // Verify assumptions made by the Windows implementation: 1775 // Verify assumptions made by the Windows implementation:
1777 // 1. The current directory always exists. 1776 // 1. The current directory always exists.
1778 // 2. The root directory always exists. 1777 // 2. The root directory always exists.
1779 ASSERT_TRUE(file_util::DirectoryExists( 1778 ASSERT_TRUE(DirectoryExists(FilePath(FilePath::kCurrentDirectory)));
1780 FilePath(FilePath::kCurrentDirectory)));
1781 FilePath top_level = test_root; 1779 FilePath top_level = test_root;
1782 while (top_level != top_level.DirName()) { 1780 while (top_level != top_level.DirName()) {
1783 top_level = top_level.DirName(); 1781 top_level = top_level.DirName();
1784 } 1782 }
1785 ASSERT_TRUE(file_util::DirectoryExists(top_level)); 1783 ASSERT_TRUE(DirectoryExists(top_level));
1786 1784
1787 // Given these assumptions hold, it should be safe to 1785 // Given these assumptions hold, it should be safe to
1788 // test that "creating" these directories succeeds. 1786 // test that "creating" these directories succeeds.
1789 EXPECT_TRUE(file_util::CreateDirectory( 1787 EXPECT_TRUE(file_util::CreateDirectory(
1790 FilePath(FilePath::kCurrentDirectory))); 1788 FilePath(FilePath::kCurrentDirectory)));
1791 EXPECT_TRUE(file_util::CreateDirectory(top_level)); 1789 EXPECT_TRUE(file_util::CreateDirectory(top_level));
1792 1790
1793 #if defined(OS_WIN) 1791 #if defined(OS_WIN)
1794 FilePath invalid_drive(FILE_PATH_LITERAL("o:\\")); 1792 FilePath invalid_drive(FILE_PATH_LITERAL("o:\\"));
1795 FilePath invalid_path = 1793 FilePath invalid_path =
1796 invalid_drive.Append(FILE_PATH_LITERAL("some\\inaccessible\\dir")); 1794 invalid_drive.Append(FILE_PATH_LITERAL("some\\inaccessible\\dir"));
1797 if (!base::PathExists(invalid_drive)) { 1795 if (!base::PathExists(invalid_drive)) {
1798 EXPECT_FALSE(file_util::CreateDirectory(invalid_path)); 1796 EXPECT_FALSE(file_util::CreateDirectory(invalid_path));
1799 } 1797 }
1800 #endif 1798 #endif
1801 } 1799 }
1802 1800
1803 TEST_F(FileUtilTest, DetectDirectoryTest) { 1801 TEST_F(FileUtilTest, DetectDirectoryTest) {
1804 // Check a directory 1802 // Check a directory
1805 FilePath test_root = 1803 FilePath test_root =
1806 temp_dir_.path().Append(FILE_PATH_LITERAL("detect_directory_test")); 1804 temp_dir_.path().Append(FILE_PATH_LITERAL("detect_directory_test"));
1807 EXPECT_FALSE(base::PathExists(test_root)); 1805 EXPECT_FALSE(base::PathExists(test_root));
1808 EXPECT_TRUE(file_util::CreateDirectory(test_root)); 1806 EXPECT_TRUE(file_util::CreateDirectory(test_root));
1809 EXPECT_TRUE(base::PathExists(test_root)); 1807 EXPECT_TRUE(base::PathExists(test_root));
1810 EXPECT_TRUE(file_util::DirectoryExists(test_root)); 1808 EXPECT_TRUE(DirectoryExists(test_root));
1811 // Check a file 1809 // Check a file
1812 FilePath test_path = 1810 FilePath test_path =
1813 test_root.Append(FILE_PATH_LITERAL("foobar.txt")); 1811 test_root.Append(FILE_PATH_LITERAL("foobar.txt"));
1814 EXPECT_FALSE(base::PathExists(test_path)); 1812 EXPECT_FALSE(base::PathExists(test_path));
1815 CreateTextFile(test_path, L"test file"); 1813 CreateTextFile(test_path, L"test file");
1816 EXPECT_TRUE(base::PathExists(test_path)); 1814 EXPECT_TRUE(base::PathExists(test_path));
1817 EXPECT_FALSE(file_util::DirectoryExists(test_path)); 1815 EXPECT_FALSE(DirectoryExists(test_path));
1818 EXPECT_TRUE(base::Delete(test_path, false)); 1816 EXPECT_TRUE(base::Delete(test_path, false));
1819 1817
1820 EXPECT_TRUE(base::Delete(test_root, true)); 1818 EXPECT_TRUE(base::Delete(test_root, true));
1821 } 1819 }
1822 1820
1823 TEST_F(FileUtilTest, FileEnumeratorTest) { 1821 TEST_F(FileUtilTest, FileEnumeratorTest) {
1824 // Test an empty directory. 1822 // Test an empty directory.
1825 FileEnumerator f0(temp_dir_.path(), true, FILES_AND_DIRECTORIES); 1823 FileEnumerator f0(temp_dir_.path(), true, FILES_AND_DIRECTORIES);
1826 EXPECT_EQ(f0.Next().value(), FILE_PATH_LITERAL("")); 1824 EXPECT_EQ(f0.Next().value(), FILE_PATH_LITERAL(""));
1827 EXPECT_EQ(f0.Next().value(), FILE_PATH_LITERAL("")); 1825 EXPECT_EQ(f0.Next().value(), FILE_PATH_LITERAL(""));
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
2374 file_util::VerifyPathControlledByUser( 2372 file_util::VerifyPathControlledByUser(
2375 base_dir_, text_file_, uid_, ok_gids_)); 2373 base_dir_, text_file_, uid_, ok_gids_));
2376 EXPECT_TRUE( 2374 EXPECT_TRUE(
2377 file_util::VerifyPathControlledByUser( 2375 file_util::VerifyPathControlledByUser(
2378 sub_dir_, text_file_, uid_, ok_gids_)); 2376 sub_dir_, text_file_, uid_, ok_gids_));
2379 } 2377 }
2380 2378
2381 #endif // defined(OS_POSIX) 2379 #endif // defined(OS_POSIX)
2382 2380
2383 } // namespace 2381 } // namespace
OLDNEW
« no previous file with comments | « base/file_util_posix.cc ('k') | base/file_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698