summaryrefslogtreecommitdiffstats
path: root/base/test
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-17 05:07:23 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-17 05:07:23 +0000
commit023ad6abe4b833b9478992176b13b5a073895cdc (patch)
tree2f73c09690e0ccd85fff810c7db4404a5245aeca /base/test
parent9e784dabf6278e848f081c7c24137ef8cc03671b (diff)
downloadchromium_src-023ad6abe4b833b9478992176b13b5a073895cdc.zip
chromium_src-023ad6abe4b833b9478992176b13b5a073895cdc.tar.gz
chromium_src-023ad6abe4b833b9478992176b13b5a073895cdc.tar.bz2
Replace FilePath with base::FilePath.
This is im preparation for removing the 'using" in file_path.h Review URL: https://codereview.chromium.org/12286020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@183021 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/test')
-rw-r--r--base/test/scoped_path_override.cc2
-rw-r--r--base/test/test_file_util_linux.cc2
-rw-r--r--base/test/test_file_util_mac.cc2
-rw-r--r--base/test/test_file_util_posix.cc33
-rw-r--r--base/test/test_file_util_win.cc39
-rw-r--r--base/test/test_shortcut_win.cc17
-rw-r--r--base/test/test_suite.cc4
-rw-r--r--base/test/test_support_android.cc4
8 files changed, 53 insertions, 50 deletions
diff --git a/base/test/scoped_path_override.cc b/base/test/scoped_path_override.cc
index bb38c7f..495ba2f 100644
--- a/base/test/scoped_path_override.cc
+++ b/base/test/scoped_path_override.cc
@@ -16,7 +16,7 @@ ScopedPathOverride::ScopedPathOverride(int key) : key_(key) {
CHECK(result);
}
-ScopedPathOverride::ScopedPathOverride(int key, const FilePath& dir)
+ScopedPathOverride::ScopedPathOverride(int key, const base::FilePath& dir)
: key_(key) {
bool result = PathService::Override(key, dir);
CHECK(result);
diff --git a/base/test/test_file_util_linux.cc b/base/test/test_file_util_linux.cc
index 993750e..958fa81 100644
--- a/base/test/test_file_util_linux.cc
+++ b/base/test/test_file_util_linux.cc
@@ -13,7 +13,7 @@
namespace file_util {
-bool EvictFileFromSystemCache(const FilePath& file) {
+bool EvictFileFromSystemCache(const base::FilePath& file) {
int fd = open(file.value().c_str(), O_RDONLY);
if (fd < 0)
return false;
diff --git a/base/test/test_file_util_mac.cc b/base/test/test_file_util_mac.cc
index 7145e51..b52b39c 100644
--- a/base/test/test_file_util_mac.cc
+++ b/base/test/test_file_util_mac.cc
@@ -11,7 +11,7 @@
namespace file_util {
-bool EvictFileFromSystemCache(const FilePath& file) {
+bool EvictFileFromSystemCache(const base::FilePath& file) {
// There aren't any really direct ways to purge a file from the UBC. From
// talking with Amit Singh, the safest is to mmap the file with MAP_FILE (the
// default) + MAP_SHARED, then do an msync to invalidate the memory. The next
diff --git a/base/test/test_file_util_posix.cc b/base/test/test_file_util_posix.cc
index 5ebf3353..f538bc1 100644
--- a/base/test/test_file_util_posix.cc
+++ b/base/test/test_file_util_posix.cc
@@ -22,7 +22,7 @@ namespace file_util {
namespace {
// Deny |permission| on the file |path|.
-bool DenyFilePermission(const FilePath& path, mode_t permission) {
+bool DenyFilePermission(const base::FilePath& path, mode_t permission) {
struct stat stat_buf;
if (stat(path.value().c_str(), &stat_buf) != 0)
return false;
@@ -35,7 +35,7 @@ bool DenyFilePermission(const FilePath& path, mode_t permission) {
// Gets a blob indicating the permission information for |path|.
// |length| is the length of the blob. Zero on failure.
// Returns the blob pointer, or NULL on failure.
-void* GetPermissionInfo(const FilePath& path, size_t* length) {
+void* GetPermissionInfo(const base::FilePath& path, size_t* length) {
DCHECK(length);
*length = 0;
@@ -55,7 +55,8 @@ void* GetPermissionInfo(const FilePath& path, size_t* length) {
// |info| is the pointer to the blob.
// |length| is the length of the blob.
// Either |info| or |length| may be NULL/0, in which case nothing happens.
-bool RestorePermissionInfo(const FilePath& path, void* info, size_t length) {
+bool RestorePermissionInfo(const base::FilePath& path,
+ void* info, size_t length) {
if (!info || (length == 0))
return false;
@@ -71,15 +72,15 @@ bool RestorePermissionInfo(const FilePath& path, void* info, size_t length) {
} // namespace
-bool DieFileDie(const FilePath& file, bool recurse) {
+bool DieFileDie(const base::FilePath& file, bool recurse) {
// There is no need to workaround Windows problems on POSIX.
// Just pass-through.
return file_util::Delete(file, recurse);
}
// Mostly a verbatim copy of CopyDirectory
-bool CopyRecursiveDirNoCache(const FilePath& source_dir,
- const FilePath& dest_dir) {
+bool CopyRecursiveDirNoCache(const base::FilePath& source_dir,
+ const base::FilePath& dest_dir) {
char top_dir[PATH_MAX];
if (base::strlcpy(top_dir, source_dir.value().c_str(),
arraysize(top_dir)) >= arraysize(top_dir)) {
@@ -87,7 +88,7 @@ bool CopyRecursiveDirNoCache(const FilePath& source_dir,
}
// This function does not properly handle destinations within the source
- FilePath real_to_path = dest_dir;
+ base::FilePath real_to_path = dest_dir;
if (PathExists(real_to_path)) {
if (!AbsolutePath(&real_to_path))
return false;
@@ -107,7 +108,7 @@ bool CopyRecursiveDirNoCache(const FilePath& source_dir,
// dest_dir may not exist yet, start the loop with dest_dir
FileEnumerator::FindInfo info;
- FilePath current = source_dir;
+ base::FilePath current = source_dir;
if (stat(source_dir.value().c_str(), &info.stat) < 0) {
DLOG(ERROR) << "CopyRecursiveDirNoCache() couldn't stat source directory: "
<< source_dir.value() << " errno = " << errno;
@@ -123,7 +124,7 @@ bool CopyRecursiveDirNoCache(const FilePath& source_dir,
DCHECK_EQ('/', suffix[0]);
suffix.erase(0, 1);
}
- const FilePath target_path = dest_dir.Append(suffix);
+ const base::FilePath target_path = dest_dir.Append(suffix);
if (S_ISDIR(info.stat.st_mode)) {
if (mkdir(target_path.value().c_str(), info.stat.st_mode & 01777) != 0 &&
@@ -154,29 +155,29 @@ bool CopyRecursiveDirNoCache(const FilePath& source_dir,
}
#if !defined(OS_LINUX) && !defined(OS_MACOSX)
-bool EvictFileFromSystemCache(const FilePath& file) {
+bool EvictFileFromSystemCache(const base::FilePath& file) {
// There doesn't seem to be a POSIX way to cool the disk cache.
NOTIMPLEMENTED();
return false;
}
#endif
-std::wstring FilePathAsWString(const FilePath& path) {
+std::wstring FilePathAsWString(const base::FilePath& path) {
return UTF8ToWide(path.value());
}
-FilePath WStringAsFilePath(const std::wstring& path) {
- return FilePath(WideToUTF8(path));
+base::FilePath WStringAsFilePath(const std::wstring& path) {
+ return base::FilePath(WideToUTF8(path));
}
-bool MakeFileUnreadable(const FilePath& path) {
+bool MakeFileUnreadable(const base::FilePath& path) {
return DenyFilePermission(path, S_IRUSR | S_IRGRP | S_IROTH);
}
-bool MakeFileUnwritable(const FilePath& path) {
+bool MakeFileUnwritable(const base::FilePath& path) {
return DenyFilePermission(path, S_IWUSR | S_IWGRP | S_IWOTH);
}
-PermissionRestorer::PermissionRestorer(const FilePath& path)
+PermissionRestorer::PermissionRestorer(const base::FilePath& path)
: path_(path), info_(NULL), length_(0) {
info_ = GetPermissionInfo(path_, &length_);
DCHECK(info_ != NULL);
diff --git a/base/test/test_file_util_win.cc b/base/test/test_file_util_win.cc
index daaa414..9b234e3 100644
--- a/base/test/test_file_util_win.cc
+++ b/base/test/test_file_util_win.cc
@@ -29,7 +29,7 @@ struct PermissionInfo {
};
// Deny |permission| on the file |path|, for the current user.
-bool DenyFilePermission(const FilePath& path, DWORD permission) {
+bool DenyFilePermission(const base::FilePath& path, DWORD permission) {
PACL old_dacl;
PSECURITY_DESCRIPTOR security_descriptor;
if (GetNamedSecurityInfo(const_cast<wchar_t*>(path.value().c_str()),
@@ -67,7 +67,7 @@ bool DenyFilePermission(const FilePath& path, DWORD permission) {
// Gets a blob indicating the permission information for |path|.
// |length| is the length of the blob. Zero on failure.
// Returns the blob pointer, or NULL on failure.
-void* GetPermissionInfo(const FilePath& path, size_t* length) {
+void* GetPermissionInfo(const base::FilePath& path, size_t* length) {
DCHECK(length != NULL);
*length = 0;
PACL dacl = NULL;
@@ -93,7 +93,8 @@ void* GetPermissionInfo(const FilePath& path, size_t* length) {
// |info| is the pointer to the blob.
// |length| is the length of the blob.
// Either |info| or |length| may be NULL/0, in which case nothing happens.
-bool RestorePermissionInfo(const FilePath& path, void* info, size_t length) {
+bool RestorePermissionInfo(const base::FilePath& path,
+ void* info, size_t length) {
if (!info || !length)
return false;
@@ -112,7 +113,7 @@ bool RestorePermissionInfo(const FilePath& path, void* info, size_t length) {
} // namespace
-bool DieFileDie(const FilePath& file, bool recurse) {
+bool DieFileDie(const base::FilePath& file, bool recurse) {
// It turns out that to not induce flakiness a long timeout is needed.
const int kIterations = 25;
const base::TimeDelta kTimeout = base::TimeDelta::FromSeconds(10) /
@@ -132,7 +133,7 @@ bool DieFileDie(const FilePath& file, bool recurse) {
return false;
}
-bool EvictFileFromSystemCache(const FilePath& file) {
+bool EvictFileFromSystemCache(const base::FilePath& file) {
// Request exclusive access to the file and overwrite it with no buffering.
base::win::ScopedHandle file_handle(
CreateFile(file.value().c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL,
@@ -217,8 +218,8 @@ bool EvictFileFromSystemCache(const FilePath& file) {
// Like CopyFileNoCache but recursively copies all files and subdirectories
// in the given input directory to the output directory.
-bool CopyRecursiveDirNoCache(const FilePath& source_dir,
- const FilePath& dest_dir) {
+bool CopyRecursiveDirNoCache(const base::FilePath& source_dir,
+ const base::FilePath& dest_dir) {
// Try to create the directory if it doesn't already exist.
if (!CreateDirectory(dest_dir)) {
if (GetLastError() != ERROR_ALREADY_EXISTS)
@@ -227,7 +228,7 @@ bool CopyRecursiveDirNoCache(const FilePath& source_dir,
std::vector<std::wstring> files_copied;
- FilePath src(source_dir.AppendASCII("*"));
+ base::FilePath src(source_dir.AppendASCII("*"));
WIN32_FIND_DATA fd;
HANDLE fh = FindFirstFile(src.value().c_str(), &fd);
@@ -239,8 +240,8 @@ bool CopyRecursiveDirNoCache(const FilePath& source_dir,
if (cur_file == L"." || cur_file == L"..")
continue; // Skip these special entries.
- FilePath cur_source_path = source_dir.Append(cur_file);
- FilePath cur_dest_path = dest_dir.Append(cur_file);
+ base::FilePath cur_source_path = source_dir.Append(cur_file);
+ base::FilePath cur_dest_path = dest_dir.Append(cur_file);
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
// Recursively copy a subdirectory. We stripped "." and ".." already.
@@ -270,7 +271,7 @@ bool CopyRecursiveDirNoCache(const FilePath& source_dir,
// Checks if the volume supports Alternate Data Streams. This is required for
// the Zone Identifier implementation.
-bool VolumeSupportsADS(const FilePath& path) {
+bool VolumeSupportsADS(const base::FilePath& path) {
wchar_t drive[MAX_PATH] = {0};
wcscpy_s(drive, MAX_PATH, path.value().c_str());
@@ -290,8 +291,8 @@ bool VolumeSupportsADS(const FilePath& path) {
// Return whether the ZoneIdentifier is correctly set to "Internet" (3)
// Only returns a valid result when called from same process as the
// one that (was supposed to have) set the zone identifier.
-bool HasInternetZoneIdentifier(const FilePath& full_path) {
- FilePath zone_path(full_path.value() + L":Zone.Identifier");
+bool HasInternetZoneIdentifier(const base::FilePath& full_path) {
+ base::FilePath zone_path(full_path.value() + L":Zone.Identifier");
std::string zone_path_contents;
if (!file_util::ReadFileToString(zone_path, &zone_path_contents))
return false;
@@ -313,22 +314,22 @@ bool HasInternetZoneIdentifier(const FilePath& full_path) {
}
}
-std::wstring FilePathAsWString(const FilePath& path) {
+std::wstring FilePathAsWString(const base::FilePath& path) {
return path.value();
}
-FilePath WStringAsFilePath(const std::wstring& path) {
- return FilePath(path);
+base::FilePath WStringAsFilePath(const std::wstring& path) {
+ return base::FilePath(path);
}
-bool MakeFileUnreadable(const FilePath& path) {
+bool MakeFileUnreadable(const base::FilePath& path) {
return DenyFilePermission(path, GENERIC_READ);
}
-bool MakeFileUnwritable(const FilePath& path) {
+bool MakeFileUnwritable(const base::FilePath& path) {
return DenyFilePermission(path, GENERIC_WRITE);
}
-PermissionRestorer::PermissionRestorer(const FilePath& path)
+PermissionRestorer::PermissionRestorer(const base::FilePath& path)
: path_(path), info_(NULL), length_(0) {
info_ = GetPermissionInfo(path_, &length_);
DCHECK(info_ != NULL);
diff --git a/base/test/test_shortcut_win.cc b/base/test/test_shortcut_win.cc
index 8339172..1a0d280 100644
--- a/base/test/test_shortcut_win.cc
+++ b/base/test/test_shortcut_win.cc
@@ -23,8 +23,8 @@ namespace {
// Validates |actual_path|'s LongPathName case-insensitively matches
// |expected_path|'s LongPathName.
-void ValidatePathsAreEqual(const FilePath& expected_path,
- const FilePath& actual_path) {
+void ValidatePathsAreEqual(const base::FilePath& expected_path,
+ const base::FilePath& actual_path) {
wchar_t long_expected_path_chars[MAX_PATH] = {0};
wchar_t long_actual_path_chars[MAX_PATH] = {0};
@@ -43,8 +43,8 @@ void ValidatePathsAreEqual(const FilePath& expected_path,
actual_path.value().c_str(), long_actual_path_chars, MAX_PATH))
<< "Failed to get LongPathName of " << actual_path.value();
- FilePath long_expected_path(long_expected_path_chars);
- FilePath long_actual_path(long_actual_path_chars);
+ base::FilePath long_expected_path(long_expected_path_chars);
+ base::FilePath long_actual_path(long_actual_path_chars);
EXPECT_FALSE(long_expected_path.empty());
EXPECT_FALSE(long_actual_path.empty());
@@ -53,7 +53,7 @@ void ValidatePathsAreEqual(const FilePath& expected_path,
} // namespace
-void ValidateShortcut(const FilePath& shortcut_path,
+void ValidateShortcut(const base::FilePath& shortcut_path,
const ShortcutProperties& properties) {
ScopedComPtr<IShellLink> i_shell_link;
ScopedComPtr<IPersistFile> i_persist_file;
@@ -87,13 +87,14 @@ void ValidateShortcut(const FilePath& shortcut_path,
if (properties.options & ShortcutProperties::PROPERTIES_TARGET) {
EXPECT_TRUE(SUCCEEDED(
i_shell_link->GetPath(read_target, MAX_PATH, NULL, SLGP_SHORTPATH)));
- ValidatePathsAreEqual(properties.target, FilePath(read_target));
+ ValidatePathsAreEqual(properties.target, base::FilePath(read_target));
}
if (properties.options & ShortcutProperties::PROPERTIES_WORKING_DIR) {
EXPECT_TRUE(SUCCEEDED(
i_shell_link->GetWorkingDirectory(read_working_dir, MAX_PATH)));
- ValidatePathsAreEqual(properties.working_dir, FilePath(read_working_dir));
+ ValidatePathsAreEqual(properties.working_dir,
+ base::FilePath(read_working_dir));
}
if (properties.options & ShortcutProperties::PROPERTIES_ARGUMENTS) {
@@ -111,7 +112,7 @@ void ValidateShortcut(const FilePath& shortcut_path,
if (properties.options & ShortcutProperties::PROPERTIES_ICON) {
EXPECT_TRUE(SUCCEEDED(
i_shell_link->GetIconLocation(read_icon, MAX_PATH, &read_icon_index)));
- ValidatePathsAreEqual(properties.icon, FilePath(read_icon));
+ ValidatePathsAreEqual(properties.icon, base::FilePath(read_icon));
EXPECT_EQ(properties.icon_index, read_icon_index);
}
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc
index c5c3368..cd7875b 100644
--- a/base/test/test_suite.cc
+++ b/base/test/test_suite.cc
@@ -210,9 +210,9 @@ void TestSuite::Initialize() {
InitAndroidTest();
#else
// Initialize logging.
- FilePath exe;
+ base::FilePath exe;
PathService::Get(base::FILE_EXE, &exe);
- FilePath log_filename = exe.ReplaceExtension(FILE_PATH_LITERAL("log"));
+ base::FilePath log_filename = exe.ReplaceExtension(FILE_PATH_LITERAL("log"));
logging::InitLogging(
log_filename.value().c_str(),
logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG,
diff --git a/base/test/test_support_android.cc b/base/test/test_support_android.cc
index e38a897..b87c073 100644
--- a/base/test/test_support_android.cc
+++ b/base/test/test_support_android.cc
@@ -139,7 +139,7 @@ base::MessagePump* CreateMessagePumpForUIStub() {
};
// Provides the test path for DIR_MODULE and DIR_ANDROID_APP_DATA.
-bool GetTestProviderPath(int key, FilePath* result) {
+bool GetTestProviderPath(int key, base::FilePath* result) {
switch (key) {
case base::DIR_MODULE: {
return base::android::GetExternalStorageDirectory(result);
@@ -154,7 +154,7 @@ bool GetTestProviderPath(int key, FilePath* result) {
}
void InitPathProvider(int key) {
- FilePath path;
+ base::FilePath path;
// If failed to override the key, that means the way has not been registered.
if (GetTestProviderPath(key, &path) && !PathService::Override(key, path))
PathService::RegisterProvider(&GetTestProviderPath, key, key + 1);