#include "base/files/file_enumerator.h"
#include <string>
#include <utility>
#include <vector>
#include "base/containers/circular_deque.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/logging.h"
#include "build/build_config.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
ElementsAre;
IsEmpty;
UnorderedElementsAre;
namespace base {
namespace {
const FilePath::StringType kEmptyPattern;
const std::vector<FileEnumerator::FolderSearchPolicy> kFolderSearchPolicies{ … };
struct TestFile { … };
struct TestDirectory { … };
void CheckModificationTime(const FileEnumerator::FileInfo& actual,
Time expected_last_modified_time) { … }
void CheckFileAgainstInfo(const FileEnumerator::FileInfo& actual,
TestFile& expected) { … }
void CheckDirectoryAgainstInfo(const FileEnumerator::FileInfo& actual,
TestDirectory& expected) { … }
circular_deque<FilePath> RunEnumerator(
const FilePath& root_path,
bool recursive,
int file_type,
const FilePath::StringType& pattern,
FileEnumerator::FolderSearchPolicy folder_search_policy) { … }
bool CreateDummyFile(const FilePath& path) { … }
bool GetFileInfo(const FilePath& file_path, File::Info& info) { … }
void SetUpTestFiles(const ScopedTempDir& temp_dir,
std::vector<TestFile>& files) { … }
}
TEST(FileEnumerator, NotExistingPath) { … }
TEST(FileEnumerator, EmptyFolder) { … }
TEST(FileEnumerator, SingleFileInFolderForFileSearch) { … }
TEST(FileEnumerator, SingleFileInFolderForDirSearch) { … }
TEST(FileEnumerator, SingleFileInFolderWithFiltering) { … }
TEST(FileEnumerator, TwoFilesInFolder) { … }
TEST(FileEnumerator, SingleFolderInFolderForFileSearch) { … }
TEST(FileEnumerator, SingleFolderInFolderForDirSearch) { … }
TEST(FileEnumerator, TwoFoldersInFolder) { … }
TEST(FileEnumerator, FolderAndFileInFolder) { … }
TEST(FileEnumerator, FilesInParentFolderAlwaysFirst) { … }
TEST(FileEnumerator, FileInSubfolder) { … }
TEST(FileEnumerator, FilesInSubfoldersWithFiltering) { … }
TEST(FileEnumerator, InvalidDirectory) { … }
#if BUILDFLAG(IS_POSIX)
TEST(FileEnumerator, SymLinkLoops) { … }
#endif
TEST(FileEnumerator, GetInfo) { … }
TEST(FileEnumerator, GetInfoRecursive) { … }
#if BUILDFLAG(IS_FUCHSIA)
#elif BUILDFLAG(IS_WIN)
#else
TEST(FileEnumerator, GetInfoDotDot) { … }
#endif
TEST(FileEnumerator, OnlyName) { … }
struct FileEnumeratorForEachTestCase { … };
class FileEnumeratorForEachTest
: public ::testing::TestWithParam<FileEnumeratorForEachTestCase> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(FileEnumeratorForEachTest, TestCases) { … }
}