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

Unified Diff: base/file_util_unittest.cc

Issue 13247008: base: Extract FileEnumerator out of file_util.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: file_enumerator_posix.cc should not compile on win Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/file_util_posix.cc ('k') | base/file_util_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util_unittest.cc
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index b90565420db51a89d52b18f97d996c9ec940dee0..f360f9007c70955b9a3be1780608f836fdffd648 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -36,7 +36,7 @@
using base::FilePath;
-namespace {
+namespace file_util {
// To test that file_util::Normalize FilePath() deals with NTFS reparse points
// correctly, we need functions to create and delete reparse points.
@@ -133,8 +133,8 @@ void ChangePosixFilePermissions(const FilePath& path,
const wchar_t bogus_content[] = L"I'm cannon fodder.";
-const int FILES_AND_DIRECTORIES =
- file_util::FileEnumerator::FILES | file_util::FileEnumerator::DIRECTORIES;
+const int FILES_AND_DIRECTORIES = FileEnumerator::FILES |
+ FileEnumerator::DIRECTORIES;
// file_util winds up using autoreleased objects on the Mac, so this needs
// to be a PlatformTest
@@ -152,7 +152,7 @@ class FileUtilTest : public PlatformTest {
// interface to query whether a given file is present.
class FindResultCollector {
public:
- explicit FindResultCollector(file_util::FileEnumerator& enumerator) {
+ explicit FindResultCollector(FileEnumerator& enumerator) {
FilePath cur_file;
while (!(cur_file = enumerator.Next()).value().empty()) {
FilePath::StringType path = cur_file.value();
@@ -946,8 +946,7 @@ TEST_F(FileUtilTest, ChangeDirectoryPermissionsAndEnumerate) {
EXPECT_FALSE(mode & file_util::FILE_PERMISSION_USER_MASK);
// Make sure the file in the directory can't be enumerated.
- file_util::FileEnumerator f1(subdir_path, true,
- file_util::FileEnumerator::FILES);
+ FileEnumerator f1(subdir_path, true, FileEnumerator::FILES);
EXPECT_TRUE(file_util::PathExists(subdir_path));
FindResultCollector c1(f1);
EXPECT_EQ(c1.size(), 0);
@@ -962,8 +961,7 @@ TEST_F(FileUtilTest, ChangeDirectoryPermissionsAndEnumerate) {
mode & file_util::FILE_PERMISSION_USER_MASK);
// Make sure the file in the directory can be enumerated.
- file_util::FileEnumerator f2(subdir_path, true,
- file_util::FileEnumerator::FILES);
+ FileEnumerator f2(subdir_path, true, FileEnumerator::FILES);
FindResultCollector c2(f2);
EXPECT_TRUE(c2.HasFile(file_name));
EXPECT_EQ(c2.size(), 1);
@@ -1857,13 +1855,13 @@ TEST_F(FileUtilTest, DetectDirectoryTest) {
TEST_F(FileUtilTest, FileEnumeratorTest) {
// Test an empty directory.
- file_util::FileEnumerator f0(temp_dir_.path(), true, FILES_AND_DIRECTORIES);
+ FileEnumerator f0(temp_dir_.path(), true, FILES_AND_DIRECTORIES);
EXPECT_EQ(f0.Next().value(), FILE_PATH_LITERAL(""));
EXPECT_EQ(f0.Next().value(), FILE_PATH_LITERAL(""));
// Test an empty directory, non-recursively, including "..".
- file_util::FileEnumerator f0_dotdot(temp_dir_.path(), false,
- FILES_AND_DIRECTORIES | file_util::FileEnumerator::INCLUDE_DOT_DOT);
+ FileEnumerator f0_dotdot(temp_dir_.path(), false,
+ FILES_AND_DIRECTORIES | FileEnumerator::INCLUDE_DOT_DOT);
EXPECT_EQ(temp_dir_.path().Append(FILE_PATH_LITERAL("..")).value(),
f0_dotdot.Next().value());
EXPECT_EQ(FILE_PATH_LITERAL(""),
@@ -1891,8 +1889,7 @@ TEST_F(FileUtilTest, FileEnumeratorTest) {
FilePath file2_abs = temp_dir_.path().Append(FILE_PATH_LITERAL("file2.txt"));
// Only enumerate files.
- file_util::FileEnumerator f1(temp_dir_.path(), true,
- file_util::FileEnumerator::FILES);
+ FileEnumerator f1(temp_dir_.path(), true, FileEnumerator::FILES);
FindResultCollector c1(f1);
EXPECT_TRUE(c1.HasFile(file1));
EXPECT_TRUE(c1.HasFile(file2_abs));
@@ -1901,8 +1898,7 @@ TEST_F(FileUtilTest, FileEnumeratorTest) {
EXPECT_EQ(c1.size(), 4);
// Only enumerate directories.
- file_util::FileEnumerator f2(temp_dir_.path(), true,
- file_util::FileEnumerator::DIRECTORIES);
+ FileEnumerator f2(temp_dir_.path(), true, FileEnumerator::DIRECTORIES);
FindResultCollector c2(f2);
EXPECT_TRUE(c2.HasFile(dir1));
EXPECT_TRUE(c2.HasFile(dir2));
@@ -1910,17 +1906,17 @@ TEST_F(FileUtilTest, FileEnumeratorTest) {
EXPECT_EQ(c2.size(), 3);
// Only enumerate directories non-recursively.
- file_util::FileEnumerator f2_non_recursive(
- temp_dir_.path(), false, file_util::FileEnumerator::DIRECTORIES);
+ FileEnumerator f2_non_recursive(temp_dir_.path(), false,
+ FileEnumerator::DIRECTORIES);
FindResultCollector c2_non_recursive(f2_non_recursive);
EXPECT_TRUE(c2_non_recursive.HasFile(dir1));
EXPECT_TRUE(c2_non_recursive.HasFile(dir2));
EXPECT_EQ(c2_non_recursive.size(), 2);
// Only enumerate directories, non-recursively, including "..".
- file_util::FileEnumerator f2_dotdot(temp_dir_.path(), false,
- file_util::FileEnumerator::DIRECTORIES |
- file_util::FileEnumerator::INCLUDE_DOT_DOT);
+ FileEnumerator f2_dotdot(temp_dir_.path(), false,
+ FileEnumerator::DIRECTORIES |
+ FileEnumerator::INCLUDE_DOT_DOT);
FindResultCollector c2_dotdot(f2_dotdot);
EXPECT_TRUE(c2_dotdot.HasFile(dir1));
EXPECT_TRUE(c2_dotdot.HasFile(dir2));
@@ -1929,7 +1925,7 @@ TEST_F(FileUtilTest, FileEnumeratorTest) {
EXPECT_EQ(c2_dotdot.size(), 3);
// Enumerate files and directories.
- file_util::FileEnumerator f3(temp_dir_.path(), true, FILES_AND_DIRECTORIES);
+ FileEnumerator f3(temp_dir_.path(), true, FILES_AND_DIRECTORIES);
FindResultCollector c3(f3);
EXPECT_TRUE(c3.HasFile(dir1));
EXPECT_TRUE(c3.HasFile(dir2));
@@ -1941,7 +1937,7 @@ TEST_F(FileUtilTest, FileEnumeratorTest) {
EXPECT_EQ(c3.size(), 7);
// Non-recursive operation.
- file_util::FileEnumerator f4(temp_dir_.path(), false, FILES_AND_DIRECTORIES);
+ FileEnumerator f4(temp_dir_.path(), false, FILES_AND_DIRECTORIES);
FindResultCollector c4(f4);
EXPECT_TRUE(c4.HasFile(dir2));
EXPECT_TRUE(c4.HasFile(dir2));
@@ -1950,7 +1946,7 @@ TEST_F(FileUtilTest, FileEnumeratorTest) {
EXPECT_EQ(c4.size(), 4);
// Enumerate with a pattern.
- file_util::FileEnumerator f5(temp_dir_.path(), true, FILES_AND_DIRECTORIES,
+ FileEnumerator f5(temp_dir_.path(), true, FILES_AND_DIRECTORIES,
FILE_PATH_LITERAL("dir*"));
FindResultCollector c5(f5);
EXPECT_TRUE(c5.HasFile(dir1));
@@ -1962,7 +1958,7 @@ TEST_F(FileUtilTest, FileEnumeratorTest) {
// Make sure the destructor closes the find handle while in the middle of a
// query to allow TearDown to delete the directory.
- file_util::FileEnumerator f6(temp_dir_.path(), true, FILES_AND_DIRECTORIES);
+ FileEnumerator f6(temp_dir_.path(), true, FILES_AND_DIRECTORIES);
EXPECT_FALSE(f6.Next().value().empty()); // Should have found something
// (we don't care what).
}
@@ -2462,4 +2458,4 @@ TEST_F(VerifyPathControlledByUserTest, WriteBitChecks) {
#endif // defined(OS_POSIX)
-} // namespace
+} // namespace file_util
« 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