summaryrefslogtreecommitdiffstats
path: root/base/test
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-07 22:57:11 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-07 22:57:11 +0000
commit92be8eb69a70860ef270e598dac0c11cb1b4dac4 (patch)
treea2a64311b75b91daddd89cd2c2236c5651b2cb94 /base/test
parent5cc45528290be46f831148d0fcb75ce971dae476 (diff)
downloadchromium_src-92be8eb69a70860ef270e598dac0c11cb1b4dac4.zip
chromium_src-92be8eb69a70860ef270e598dac0c11cb1b4dac4.tar.gz
chromium_src-92be8eb69a70860ef270e598dac0c11cb1b4dac4.tar.bz2
Move the rest of test_file_util to base namespace.
R=rvargas@chromium.org Review URL: https://codereview.chromium.org/444163003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288158 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/test')
-rw-r--r--base/test/run_all_unittests.cc2
-rw-r--r--base/test/test_file_util.h39
-rw-r--r--base/test/test_file_util_android.cc8
-rw-r--r--base/test/test_file_util_posix.cc18
-rw-r--r--base/test/test_file_util_win.cc18
5 files changed, 32 insertions, 53 deletions
diff --git a/base/test/run_all_unittests.cc b/base/test/run_all_unittests.cc
index 3b5ebfe..93cb8cb 100644
--- a/base/test/run_all_unittests.cc
+++ b/base/test/run_all_unittests.cc
@@ -30,7 +30,7 @@ int RunTestSuite(int argc, char** argv) {
int main(int argc, char** argv) {
#if defined(OS_ANDROID)
JNIEnv* env = base::android::AttachCurrentThread();
- file_util::RegisterContentUriTestUtils(env);
+ base::RegisterContentUriTestUtils(env);
#else
base::AtExitManager at_exit;
#endif
diff --git a/base/test/test_file_util.h b/base/test/test_file_util.h
index 295fb85..27197f2 100644
--- a/base/test/test_file_util.h
+++ b/base/test/test_file_util.h
@@ -47,39 +47,34 @@ bool VolumeSupportsADS(const FilePath& path);
bool HasInternetZoneIdentifier(const FilePath& full_path);
#endif // defined(OS_WIN)
-} // namespace base
-
-// TODO(brettw) move all of this to the base namespace.
-namespace file_util {
-
// For testing, make the file unreadable or unwritable.
// In POSIX, this does not apply to the root user.
-bool MakeFileUnreadable(const base::FilePath& path) WARN_UNUSED_RESULT;
-bool MakeFileUnwritable(const base::FilePath& path) WARN_UNUSED_RESULT;
-
-#if defined(OS_ANDROID)
-// Register the ContentUriTestUrils JNI bindings.
-bool RegisterContentUriTestUtils(JNIEnv* env);
-
-// Insert an image file into the MediaStore, and retrieve the content URI for
-// testing purpose.
-base::FilePath InsertImageIntoMediaStore(const base::FilePath& path);
-#endif // defined(OS_ANDROID)
+bool MakeFileUnreadable(const FilePath& path) WARN_UNUSED_RESULT;
+bool MakeFileUnwritable(const FilePath& path) WARN_UNUSED_RESULT;
// Saves the current permissions for a path, and restores it on destruction.
-class PermissionRestorer {
+class FilePermissionRestorer {
public:
- explicit PermissionRestorer(const base::FilePath& path);
- ~PermissionRestorer();
+ explicit FilePermissionRestorer(const FilePath& path);
+ ~FilePermissionRestorer();
private:
- const base::FilePath path_;
+ const FilePath path_;
void* info_; // The opaque stored permission information.
size_t length_; // The length of the stored permission information.
- DISALLOW_COPY_AND_ASSIGN(PermissionRestorer);
+ DISALLOW_COPY_AND_ASSIGN(FilePermissionRestorer);
};
-} // namespace file_util
+#if defined(OS_ANDROID)
+// Register the ContentUriTestUrils JNI bindings.
+bool RegisterContentUriTestUtils(JNIEnv* env);
+
+// Insert an image file into the MediaStore, and retrieve the content URI for
+// testing purpose.
+FilePath InsertImageIntoMediaStore(const FilePath& path);
+#endif // defined(OS_ANDROID)
+
+} // namespace base
#endif // BASE_TEST_TEST_FILE_UTIL_H_
diff --git a/base/test/test_file_util_android.cc b/base/test/test_file_util_android.cc
index c17f669..b8fd50c 100644
--- a/base/test/test_file_util_android.cc
+++ b/base/test/test_file_util_android.cc
@@ -9,13 +9,13 @@
#include "base/files/file_path.h"
#include "jni/ContentUriTestUtils_jni.h"
-namespace file_util {
+namespace base {
bool RegisterContentUriTestUtils(JNIEnv* env) {
return RegisterNativesImpl(env);
}
-base::FilePath InsertImageIntoMediaStore(const base::FilePath& path) {
+FilePath InsertImageIntoMediaStore(const FilePath& path) {
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jstring> j_path =
base::android::ConvertUTF8ToJavaString(env, path.value());
@@ -23,7 +23,7 @@ base::FilePath InsertImageIntoMediaStore(const base::FilePath& path) {
Java_ContentUriTestUtils_insertImageIntoMediaStore(
env, base::android::GetApplicationContext(), j_path.obj());
std::string uri = base::android::ConvertJavaStringToUTF8(j_uri);
- return base::FilePath(uri);
+ return FilePath(uri);
}
-} // namespace file_util
+} // namespace base
diff --git a/base/test/test_file_util_posix.cc b/base/test/test_file_util_posix.cc
index 0350ccc..cbcabd6 100644
--- a/base/test/test_file_util_posix.cc
+++ b/base/test/test_file_util_posix.cc
@@ -85,32 +85,24 @@ bool EvictFileFromSystemCache(const FilePath& file) {
}
#endif
-} // namespace base
-
-namespace file_util {
-
-using base::DenyFilePermission;
-using base::GetPermissionInfo;
-using base::RestorePermissionInfo;
-
-bool MakeFileUnreadable(const base::FilePath& path) {
+bool MakeFileUnreadable(const FilePath& path) {
return DenyFilePermission(path, S_IRUSR | S_IRGRP | S_IROTH);
}
-bool MakeFileUnwritable(const base::FilePath& path) {
+bool MakeFileUnwritable(const FilePath& path) {
return DenyFilePermission(path, S_IWUSR | S_IWGRP | S_IWOTH);
}
-PermissionRestorer::PermissionRestorer(const base::FilePath& path)
+FilePermissionRestorer::FilePermissionRestorer(const FilePath& path)
: path_(path), info_(NULL), length_(0) {
info_ = GetPermissionInfo(path_, &length_);
DCHECK(info_ != NULL);
DCHECK_NE(0u, length_);
}
-PermissionRestorer::~PermissionRestorer() {
+FilePermissionRestorer::~FilePermissionRestorer() {
if (!RestorePermissionInfo(path_, info_, length_))
NOTREACHED();
}
-} // namespace file_util
+} // namespace base
diff --git a/base/test/test_file_util_win.cc b/base/test/test_file_util_win.cc
index 0b7a0c6..2656e31 100644
--- a/base/test/test_file_util_win.cc
+++ b/base/test/test_file_util_win.cc
@@ -259,32 +259,24 @@ bool HasInternetZoneIdentifier(const FilePath& full_path) {
}
}
-} // namespace base
-
-namespace file_util {
-
-using base::DenyFilePermission;
-using base::GetPermissionInfo;
-using base::RestorePermissionInfo;
-
-bool MakeFileUnreadable(const base::FilePath& path) {
+bool MakeFileUnreadable(const FilePath& path) {
return DenyFilePermission(path, GENERIC_READ);
}
-bool MakeFileUnwritable(const base::FilePath& path) {
+bool MakeFileUnwritable(const FilePath& path) {
return DenyFilePermission(path, GENERIC_WRITE);
}
-PermissionRestorer::PermissionRestorer(const base::FilePath& path)
+FilePermissionRestorer::FilePermissionRestorer(const FilePath& path)
: path_(path), info_(NULL), length_(0) {
info_ = GetPermissionInfo(path_, &length_);
DCHECK(info_ != NULL);
DCHECK_NE(0u, length_);
}
-PermissionRestorer::~PermissionRestorer() {
+FilePermissionRestorer::~FilePermissionRestorer() {
if (!RestorePermissionInfo(path_, info_, length_))
NOTREACHED();
}
-} // namespace file_util
+} // namespace base