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

Side by Side Diff: base/file_util_unittest.cc

Issue 13165005: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge, fixes Created 7 years, 7 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>
11 #include <tchar.h> 11 #include <tchar.h>
12 #include <winioctl.h> 12 #include <winioctl.h>
13 #endif 13 #endif
14 14
15 #include <algorithm> 15 #include <algorithm>
16 #include <fstream> 16 #include <fstream>
17 #include <set> 17 #include <set>
18 18
19 #include "base/base_paths.h" 19 #include "base/base_paths.h"
20 #include "base/file_util.h" 20 #include "base/file_util.h"
21 #include "base/files/file_enumerator.h"
21 #include "base/files/file_path.h" 22 #include "base/files/file_path.h"
22 #include "base/files/scoped_temp_dir.h" 23 #include "base/files/scoped_temp_dir.h"
23 #include "base/path_service.h" 24 #include "base/path_service.h"
24 #include "base/test/test_file_util.h" 25 #include "base/test/test_file_util.h"
25 #include "base/threading/platform_thread.h" 26 #include "base/threading/platform_thread.h"
26 #include "base/utf_string_conversions.h" 27 #include "base/utf_string_conversions.h"
27 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
28 #include "testing/platform_test.h" 29 #include "testing/platform_test.h"
29 30
30 #if defined(OS_WIN) 31 #if defined(OS_WIN)
31 #include "base/win/scoped_handle.h" 32 #include "base/win/scoped_handle.h"
32 #endif 33 #endif
33 34
34 // This macro helps avoid wrapped lines in the test structs. 35 // This macro helps avoid wrapped lines in the test structs.
35 #define FPL(x) FILE_PATH_LITERAL(x) 36 #define FPL(x) FILE_PATH_LITERAL(x)
36 37
38 using base::FileEnumerator;
37 using base::FilePath; 39 using base::FilePath;
38 40
39 namespace { 41 namespace {
40 42
41 // To test that file_util::Normalize FilePath() deals with NTFS reparse points 43 // To test that file_util::Normalize FilePath() deals with NTFS reparse points
42 // correctly, we need functions to create and delete reparse points. 44 // correctly, we need functions to create and delete reparse points.
43 #if defined(OS_WIN) 45 #if defined(OS_WIN)
44 typedef struct _REPARSE_DATA_BUFFER { 46 typedef struct _REPARSE_DATA_BUFFER {
45 ULONG ReparseTag; 47 ULONG ReparseTag;
46 USHORT ReparseDataLength; 48 USHORT ReparseDataLength;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 ASSERT_TRUE(file_util::GetPosixFilePermissions(path, &mode)); 129 ASSERT_TRUE(file_util::GetPosixFilePermissions(path, &mode));
128 mode |= mode_bits_to_set; 130 mode |= mode_bits_to_set;
129 mode &= ~mode_bits_to_clear; 131 mode &= ~mode_bits_to_clear;
130 ASSERT_TRUE(file_util::SetPosixFilePermissions(path, mode)); 132 ASSERT_TRUE(file_util::SetPosixFilePermissions(path, mode));
131 } 133 }
132 #endif // defined(OS_POSIX) 134 #endif // defined(OS_POSIX)
133 135
134 const wchar_t bogus_content[] = L"I'm cannon fodder."; 136 const wchar_t bogus_content[] = L"I'm cannon fodder.";
135 137
136 const int FILES_AND_DIRECTORIES = 138 const int FILES_AND_DIRECTORIES =
137 file_util::FileEnumerator::FILES | file_util::FileEnumerator::DIRECTORIES; 139 FileEnumerator::FILES | FileEnumerator::DIRECTORIES;
138 140
139 // file_util winds up using autoreleased objects on the Mac, so this needs 141 // file_util winds up using autoreleased objects on the Mac, so this needs
140 // to be a PlatformTest 142 // to be a PlatformTest
141 class FileUtilTest : public PlatformTest { 143 class FileUtilTest : public PlatformTest {
142 protected: 144 protected:
143 virtual void SetUp() OVERRIDE { 145 virtual void SetUp() OVERRIDE {
144 PlatformTest::SetUp(); 146 PlatformTest::SetUp();
145 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 147 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
146 } 148 }
147 149
148 base::ScopedTempDir temp_dir_; 150 base::ScopedTempDir temp_dir_;
149 }; 151 };
150 152
151 // Collects all the results from the given file enumerator, and provides an 153 // Collects all the results from the given file enumerator, and provides an
152 // interface to query whether a given file is present. 154 // interface to query whether a given file is present.
153 class FindResultCollector { 155 class FindResultCollector {
154 public: 156 public:
155 explicit FindResultCollector(file_util::FileEnumerator& enumerator) { 157 explicit FindResultCollector(FileEnumerator& enumerator) {
156 FilePath cur_file; 158 FilePath cur_file;
157 while (!(cur_file = enumerator.Next()).value().empty()) { 159 while (!(cur_file = enumerator.Next()).value().empty()) {
158 FilePath::StringType path = cur_file.value(); 160 FilePath::StringType path = cur_file.value();
159 // The file should not be returned twice. 161 // The file should not be returned twice.
160 EXPECT_TRUE(files_.end() == files_.find(path)) 162 EXPECT_TRUE(files_.end() == files_.find(path))
161 << "Same file returned twice"; 163 << "Same file returned twice";
162 164
163 // Save for later. 165 // Save for later.
164 files_.insert(path); 166 files_.insert(path);
165 } 167 }
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 EXPECT_TRUE(file_util::GetPosixFilePermissions(subdir_path, &mode)); 912 EXPECT_TRUE(file_util::GetPosixFilePermissions(subdir_path, &mode));
911 EXPECT_EQ(file_util::FILE_PERMISSION_USER_MASK, 913 EXPECT_EQ(file_util::FILE_PERMISSION_USER_MASK,
912 mode & file_util::FILE_PERMISSION_USER_MASK); 914 mode & file_util::FILE_PERMISSION_USER_MASK);
913 915
914 // Get rid of the permissions from the directory. 916 // Get rid of the permissions from the directory.
915 EXPECT_TRUE(file_util::SetPosixFilePermissions(subdir_path, 0u)); 917 EXPECT_TRUE(file_util::SetPosixFilePermissions(subdir_path, 0u));
916 EXPECT_TRUE(file_util::GetPosixFilePermissions(subdir_path, &mode)); 918 EXPECT_TRUE(file_util::GetPosixFilePermissions(subdir_path, &mode));
917 EXPECT_FALSE(mode & file_util::FILE_PERMISSION_USER_MASK); 919 EXPECT_FALSE(mode & file_util::FILE_PERMISSION_USER_MASK);
918 920
919 // Make sure the file in the directory can't be enumerated. 921 // Make sure the file in the directory can't be enumerated.
920 file_util::FileEnumerator f1(subdir_path, true, 922 FileEnumerator f1(subdir_path, true, FileEnumerator::FILES);
921 file_util::FileEnumerator::FILES);
922 EXPECT_TRUE(file_util::PathExists(subdir_path)); 923 EXPECT_TRUE(file_util::PathExists(subdir_path));
923 FindResultCollector c1(f1); 924 FindResultCollector c1(f1);
924 EXPECT_EQ(c1.size(), 0); 925 EXPECT_EQ(c1.size(), 0);
925 EXPECT_FALSE(file_util::GetPosixFilePermissions(file_name, &mode)); 926 EXPECT_FALSE(file_util::GetPosixFilePermissions(file_name, &mode));
926 927
927 // Give the permissions to the directory. 928 // Give the permissions to the directory.
928 EXPECT_TRUE(file_util::SetPosixFilePermissions( 929 EXPECT_TRUE(file_util::SetPosixFilePermissions(
929 subdir_path, 930 subdir_path,
930 file_util::FILE_PERMISSION_USER_MASK)); 931 file_util::FILE_PERMISSION_USER_MASK));
931 EXPECT_TRUE(file_util::GetPosixFilePermissions(subdir_path, &mode)); 932 EXPECT_TRUE(file_util::GetPosixFilePermissions(subdir_path, &mode));
932 EXPECT_EQ(file_util::FILE_PERMISSION_USER_MASK, 933 EXPECT_EQ(file_util::FILE_PERMISSION_USER_MASK,
933 mode & file_util::FILE_PERMISSION_USER_MASK); 934 mode & file_util::FILE_PERMISSION_USER_MASK);
934 935
935 // Make sure the file in the directory can be enumerated. 936 // Make sure the file in the directory can be enumerated.
936 file_util::FileEnumerator f2(subdir_path, true, 937 FileEnumerator f2(subdir_path, true, FileEnumerator::FILES);
937 file_util::FileEnumerator::FILES);
938 FindResultCollector c2(f2); 938 FindResultCollector c2(f2);
939 EXPECT_TRUE(c2.HasFile(file_name)); 939 EXPECT_TRUE(c2.HasFile(file_name));
940 EXPECT_EQ(c2.size(), 1); 940 EXPECT_EQ(c2.size(), 1);
941 941
942 // Delete the file. 942 // Delete the file.
943 EXPECT_TRUE(file_util::Delete(subdir_path, true)); 943 EXPECT_TRUE(file_util::Delete(subdir_path, true));
944 EXPECT_FALSE(file_util::PathExists(subdir_path)); 944 EXPECT_FALSE(file_util::PathExists(subdir_path));
945 } 945 }
946 946
947 #endif // defined(OS_POSIX) 947 #endif // defined(OS_POSIX)
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
1817 CreateTextFile(test_path, L"test file"); 1817 CreateTextFile(test_path, L"test file");
1818 EXPECT_TRUE(file_util::PathExists(test_path)); 1818 EXPECT_TRUE(file_util::PathExists(test_path));
1819 EXPECT_FALSE(file_util::DirectoryExists(test_path)); 1819 EXPECT_FALSE(file_util::DirectoryExists(test_path));
1820 EXPECT_TRUE(file_util::Delete(test_path, false)); 1820 EXPECT_TRUE(file_util::Delete(test_path, false));
1821 1821
1822 EXPECT_TRUE(file_util::Delete(test_root, true)); 1822 EXPECT_TRUE(file_util::Delete(test_root, true));
1823 } 1823 }
1824 1824
1825 TEST_F(FileUtilTest, FileEnumeratorTest) { 1825 TEST_F(FileUtilTest, FileEnumeratorTest) {
1826 // Test an empty directory. 1826 // Test an empty directory.
1827 file_util::FileEnumerator f0(temp_dir_.path(), true, FILES_AND_DIRECTORIES); 1827 FileEnumerator f0(temp_dir_.path(), true, FILES_AND_DIRECTORIES);
1828 EXPECT_EQ(f0.Next().value(), FILE_PATH_LITERAL("")); 1828 EXPECT_EQ(f0.Next().value(), FILE_PATH_LITERAL(""));
1829 EXPECT_EQ(f0.Next().value(), FILE_PATH_LITERAL("")); 1829 EXPECT_EQ(f0.Next().value(), FILE_PATH_LITERAL(""));
1830 1830
1831 // Test an empty directory, non-recursively, including "..". 1831 // Test an empty directory, non-recursively, including "..".
1832 file_util::FileEnumerator f0_dotdot(temp_dir_.path(), false, 1832 FileEnumerator f0_dotdot(temp_dir_.path(), false,
1833 FILES_AND_DIRECTORIES | file_util::FileEnumerator::INCLUDE_DOT_DOT); 1833 FILES_AND_DIRECTORIES | FileEnumerator::INCLUDE_DOT_DOT);
1834 EXPECT_EQ(temp_dir_.path().Append(FILE_PATH_LITERAL("..")).value(), 1834 EXPECT_EQ(temp_dir_.path().Append(FILE_PATH_LITERAL("..")).value(),
1835 f0_dotdot.Next().value()); 1835 f0_dotdot.Next().value());
1836 EXPECT_EQ(FILE_PATH_LITERAL(""), 1836 EXPECT_EQ(FILE_PATH_LITERAL(""),
1837 f0_dotdot.Next().value()); 1837 f0_dotdot.Next().value());
1838 1838
1839 // create the directories 1839 // create the directories
1840 FilePath dir1 = temp_dir_.path().Append(FILE_PATH_LITERAL("dir1")); 1840 FilePath dir1 = temp_dir_.path().Append(FILE_PATH_LITERAL("dir1"));
1841 EXPECT_TRUE(file_util::CreateDirectory(dir1)); 1841 EXPECT_TRUE(file_util::CreateDirectory(dir1));
1842 FilePath dir2 = temp_dir_.path().Append(FILE_PATH_LITERAL("dir2")); 1842 FilePath dir2 = temp_dir_.path().Append(FILE_PATH_LITERAL("dir2"));
1843 EXPECT_TRUE(file_util::CreateDirectory(dir2)); 1843 EXPECT_TRUE(file_util::CreateDirectory(dir2));
1844 FilePath dir2inner = dir2.Append(FILE_PATH_LITERAL("inner")); 1844 FilePath dir2inner = dir2.Append(FILE_PATH_LITERAL("inner"));
1845 EXPECT_TRUE(file_util::CreateDirectory(dir2inner)); 1845 EXPECT_TRUE(file_util::CreateDirectory(dir2inner));
1846 1846
1847 // create the files 1847 // create the files
1848 FilePath dir2file = dir2.Append(FILE_PATH_LITERAL("dir2file.txt")); 1848 FilePath dir2file = dir2.Append(FILE_PATH_LITERAL("dir2file.txt"));
1849 CreateTextFile(dir2file, std::wstring()); 1849 CreateTextFile(dir2file, std::wstring());
1850 FilePath dir2innerfile = dir2inner.Append(FILE_PATH_LITERAL("innerfile.txt")); 1850 FilePath dir2innerfile = dir2inner.Append(FILE_PATH_LITERAL("innerfile.txt"));
1851 CreateTextFile(dir2innerfile, std::wstring()); 1851 CreateTextFile(dir2innerfile, std::wstring());
1852 FilePath file1 = temp_dir_.path().Append(FILE_PATH_LITERAL("file1.txt")); 1852 FilePath file1 = temp_dir_.path().Append(FILE_PATH_LITERAL("file1.txt"));
1853 CreateTextFile(file1, std::wstring()); 1853 CreateTextFile(file1, std::wstring());
1854 FilePath file2_rel = dir2.Append(FilePath::kParentDirectory) 1854 FilePath file2_rel = dir2.Append(FilePath::kParentDirectory)
1855 .Append(FILE_PATH_LITERAL("file2.txt")); 1855 .Append(FILE_PATH_LITERAL("file2.txt"));
1856 CreateTextFile(file2_rel, std::wstring()); 1856 CreateTextFile(file2_rel, std::wstring());
1857 FilePath file2_abs = temp_dir_.path().Append(FILE_PATH_LITERAL("file2.txt")); 1857 FilePath file2_abs = temp_dir_.path().Append(FILE_PATH_LITERAL("file2.txt"));
1858 1858
1859 // Only enumerate files. 1859 // Only enumerate files.
1860 file_util::FileEnumerator f1(temp_dir_.path(), true, 1860 FileEnumerator f1(temp_dir_.path(), true, FileEnumerator::FILES);
1861 file_util::FileEnumerator::FILES);
1862 FindResultCollector c1(f1); 1861 FindResultCollector c1(f1);
1863 EXPECT_TRUE(c1.HasFile(file1)); 1862 EXPECT_TRUE(c1.HasFile(file1));
1864 EXPECT_TRUE(c1.HasFile(file2_abs)); 1863 EXPECT_TRUE(c1.HasFile(file2_abs));
1865 EXPECT_TRUE(c1.HasFile(dir2file)); 1864 EXPECT_TRUE(c1.HasFile(dir2file));
1866 EXPECT_TRUE(c1.HasFile(dir2innerfile)); 1865 EXPECT_TRUE(c1.HasFile(dir2innerfile));
1867 EXPECT_EQ(c1.size(), 4); 1866 EXPECT_EQ(c1.size(), 4);
1868 1867
1869 // Only enumerate directories. 1868 // Only enumerate directories.
1870 file_util::FileEnumerator f2(temp_dir_.path(), true, 1869 FileEnumerator f2(temp_dir_.path(), true, FileEnumerator::DIRECTORIES);
1871 file_util::FileEnumerator::DIRECTORIES);
1872 FindResultCollector c2(f2); 1870 FindResultCollector c2(f2);
1873 EXPECT_TRUE(c2.HasFile(dir1)); 1871 EXPECT_TRUE(c2.HasFile(dir1));
1874 EXPECT_TRUE(c2.HasFile(dir2)); 1872 EXPECT_TRUE(c2.HasFile(dir2));
1875 EXPECT_TRUE(c2.HasFile(dir2inner)); 1873 EXPECT_TRUE(c2.HasFile(dir2inner));
1876 EXPECT_EQ(c2.size(), 3); 1874 EXPECT_EQ(c2.size(), 3);
1877 1875
1878 // Only enumerate directories non-recursively. 1876 // Only enumerate directories non-recursively.
1879 file_util::FileEnumerator f2_non_recursive( 1877 FileEnumerator f2_non_recursive(
1880 temp_dir_.path(), false, file_util::FileEnumerator::DIRECTORIES); 1878 temp_dir_.path(), false, FileEnumerator::DIRECTORIES);
1881 FindResultCollector c2_non_recursive(f2_non_recursive); 1879 FindResultCollector c2_non_recursive(f2_non_recursive);
1882 EXPECT_TRUE(c2_non_recursive.HasFile(dir1)); 1880 EXPECT_TRUE(c2_non_recursive.HasFile(dir1));
1883 EXPECT_TRUE(c2_non_recursive.HasFile(dir2)); 1881 EXPECT_TRUE(c2_non_recursive.HasFile(dir2));
1884 EXPECT_EQ(c2_non_recursive.size(), 2); 1882 EXPECT_EQ(c2_non_recursive.size(), 2);
1885 1883
1886 // Only enumerate directories, non-recursively, including "..". 1884 // Only enumerate directories, non-recursively, including "..".
1887 file_util::FileEnumerator f2_dotdot(temp_dir_.path(), false, 1885 FileEnumerator f2_dotdot(temp_dir_.path(), false,
1888 file_util::FileEnumerator::DIRECTORIES | 1886 FileEnumerator::DIRECTORIES |
1889 file_util::FileEnumerator::INCLUDE_DOT_DOT); 1887 FileEnumerator::INCLUDE_DOT_DOT);
1890 FindResultCollector c2_dotdot(f2_dotdot); 1888 FindResultCollector c2_dotdot(f2_dotdot);
1891 EXPECT_TRUE(c2_dotdot.HasFile(dir1)); 1889 EXPECT_TRUE(c2_dotdot.HasFile(dir1));
1892 EXPECT_TRUE(c2_dotdot.HasFile(dir2)); 1890 EXPECT_TRUE(c2_dotdot.HasFile(dir2));
1893 EXPECT_TRUE(c2_dotdot.HasFile( 1891 EXPECT_TRUE(c2_dotdot.HasFile(
1894 temp_dir_.path().Append(FILE_PATH_LITERAL("..")))); 1892 temp_dir_.path().Append(FILE_PATH_LITERAL(".."))));
1895 EXPECT_EQ(c2_dotdot.size(), 3); 1893 EXPECT_EQ(c2_dotdot.size(), 3);
1896 1894
1897 // Enumerate files and directories. 1895 // Enumerate files and directories.
1898 file_util::FileEnumerator f3(temp_dir_.path(), true, FILES_AND_DIRECTORIES); 1896 FileEnumerator f3(temp_dir_.path(), true, FILES_AND_DIRECTORIES);
1899 FindResultCollector c3(f3); 1897 FindResultCollector c3(f3);
1900 EXPECT_TRUE(c3.HasFile(dir1)); 1898 EXPECT_TRUE(c3.HasFile(dir1));
1901 EXPECT_TRUE(c3.HasFile(dir2)); 1899 EXPECT_TRUE(c3.HasFile(dir2));
1902 EXPECT_TRUE(c3.HasFile(file1)); 1900 EXPECT_TRUE(c3.HasFile(file1));
1903 EXPECT_TRUE(c3.HasFile(file2_abs)); 1901 EXPECT_TRUE(c3.HasFile(file2_abs));
1904 EXPECT_TRUE(c3.HasFile(dir2file)); 1902 EXPECT_TRUE(c3.HasFile(dir2file));
1905 EXPECT_TRUE(c3.HasFile(dir2inner)); 1903 EXPECT_TRUE(c3.HasFile(dir2inner));
1906 EXPECT_TRUE(c3.HasFile(dir2innerfile)); 1904 EXPECT_TRUE(c3.HasFile(dir2innerfile));
1907 EXPECT_EQ(c3.size(), 7); 1905 EXPECT_EQ(c3.size(), 7);
1908 1906
1909 // Non-recursive operation. 1907 // Non-recursive operation.
1910 file_util::FileEnumerator f4(temp_dir_.path(), false, FILES_AND_DIRECTORIES); 1908 FileEnumerator f4(temp_dir_.path(), false, FILES_AND_DIRECTORIES);
1911 FindResultCollector c4(f4); 1909 FindResultCollector c4(f4);
1912 EXPECT_TRUE(c4.HasFile(dir2)); 1910 EXPECT_TRUE(c4.HasFile(dir2));
1913 EXPECT_TRUE(c4.HasFile(dir2)); 1911 EXPECT_TRUE(c4.HasFile(dir2));
1914 EXPECT_TRUE(c4.HasFile(file1)); 1912 EXPECT_TRUE(c4.HasFile(file1));
1915 EXPECT_TRUE(c4.HasFile(file2_abs)); 1913 EXPECT_TRUE(c4.HasFile(file2_abs));
1916 EXPECT_EQ(c4.size(), 4); 1914 EXPECT_EQ(c4.size(), 4);
1917 1915
1918 // Enumerate with a pattern. 1916 // Enumerate with a pattern.
1919 file_util::FileEnumerator f5(temp_dir_.path(), true, FILES_AND_DIRECTORIES, 1917 FileEnumerator f5(temp_dir_.path(), true, FILES_AND_DIRECTORIES,
1920 FILE_PATH_LITERAL("dir*")); 1918 FILE_PATH_LITERAL("dir*"));
1921 FindResultCollector c5(f5); 1919 FindResultCollector c5(f5);
1922 EXPECT_TRUE(c5.HasFile(dir1)); 1920 EXPECT_TRUE(c5.HasFile(dir1));
1923 EXPECT_TRUE(c5.HasFile(dir2)); 1921 EXPECT_TRUE(c5.HasFile(dir2));
1924 EXPECT_TRUE(c5.HasFile(dir2file)); 1922 EXPECT_TRUE(c5.HasFile(dir2file));
1925 EXPECT_TRUE(c5.HasFile(dir2inner)); 1923 EXPECT_TRUE(c5.HasFile(dir2inner));
1926 EXPECT_TRUE(c5.HasFile(dir2innerfile)); 1924 EXPECT_TRUE(c5.HasFile(dir2innerfile));
1927 EXPECT_EQ(c5.size(), 5); 1925 EXPECT_EQ(c5.size(), 5);
1928 1926
1929 // Make sure the destructor closes the find handle while in the middle of a 1927 // Make sure the destructor closes the find handle while in the middle of a
1930 // query to allow TearDown to delete the directory. 1928 // query to allow TearDown to delete the directory.
1931 file_util::FileEnumerator f6(temp_dir_.path(), true, FILES_AND_DIRECTORIES); 1929 FileEnumerator f6(temp_dir_.path(), true, FILES_AND_DIRECTORIES);
1932 EXPECT_FALSE(f6.Next().value().empty()); // Should have found something 1930 EXPECT_FALSE(f6.Next().value().empty()); // Should have found something
1933 // (we don't care what). 1931 // (we don't care what).
1934 } 1932 }
1935 1933
1936 TEST_F(FileUtilTest, AppendToFile) { 1934 TEST_F(FileUtilTest, AppendToFile) {
1937 FilePath data_dir = 1935 FilePath data_dir =
1938 temp_dir_.path().Append(FILE_PATH_LITERAL("FilePathTest")); 1936 temp_dir_.path().Append(FILE_PATH_LITERAL("FilePathTest"));
1939 1937
1940 // Create a fresh, empty copy of this directory. 1938 // Create a fresh, empty copy of this directory.
1941 if (file_util::PathExists(data_dir)) { 1939 if (file_util::PathExists(data_dir)) {
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
2378 file_util::VerifyPathControlledByUser( 2376 file_util::VerifyPathControlledByUser(
2379 base_dir_, text_file_, uid_, ok_gids_)); 2377 base_dir_, text_file_, uid_, ok_gids_));
2380 EXPECT_TRUE( 2378 EXPECT_TRUE(
2381 file_util::VerifyPathControlledByUser( 2379 file_util::VerifyPathControlledByUser(
2382 sub_dir_, text_file_, uid_, ok_gids_)); 2380 sub_dir_, text_file_, uid_, ok_gids_));
2383 } 2381 }
2384 2382
2385 #endif // defined(OS_POSIX) 2383 #endif // defined(OS_POSIX)
2386 2384
2387 } // namespace 2385 } // 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