Unreverts revert: Makes it possible to find files used by some unit tests when running them as Chrome native tests.
TBR=andrew@webrtc.org
BUG=N/A
Review URL: https://webrtc-codereview.appspot.com/1754005
git-svn-id: http://webrtc.googlecode.com/svn/trunk@4303 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/test/testsupport/fileutils.cc b/webrtc/test/testsupport/fileutils.cc
index 61e4bcf..84945ff 100644
--- a/webrtc/test/testsupport/fileutils.cc
+++ b/webrtc/test/testsupport/fileutils.cc
@@ -31,28 +31,33 @@
namespace webrtc {
namespace test {
+namespace {
+
#ifdef WIN32
-static const char* kPathDelimiter = "\\";
+const char* kPathDelimiter = "\\";
#else
-static const char* kPathDelimiter = "/";
+const char* kPathDelimiter = "/";
#endif
#ifdef WEBRTC_ANDROID
-static const char* kRootDirName = "/sdcard/";
-static const char* kResourcesDirName = "resources";
+const char* kResourcesDirName = "resources";
#else
// The file we're looking for to identify the project root dir.
-static const char* kProjectRootFileName = "DEPS";
-static const char* kOutputDirName = "out";
-static const char* kFallbackPath = "./";
-static const char* kResourcesDirName = "resources";
+const char* kProjectRootFileName = "DEPS";
+const char* kResourcesDirName = "resources";
#endif
-const char* kCannotFindProjectRootDir = "ERROR_CANNOT_FIND_PROJECT_ROOT_DIR";
-namespace {
+const char* kFallbackPath = "./";
+const char* kOutputDirName = "out";
char relative_dir_path[FILENAME_MAX];
bool relative_dir_path_set = false;
-}
+
+} // namespace
+
+const char* kCannotFindProjectRootDir = "ERROR_CANNOT_FIND_PROJECT_ROOT_DIR";
+
+std::string OutputPathAndroid();
+std::string ProjectRoothPathAndroid();
void SetExecutablePath(const std::string& path) {
std::string working_dir = WorkingDir();
@@ -73,18 +78,30 @@
return stat(file_name.c_str(), &file_info) == 0;
}
+std::string OutputPathImpl() {
+ std::string path = ProjectRootPath();
+ if (path == kCannotFindProjectRootDir) {
+ return kFallbackPath;
+ }
+ path += kOutputDirName;
+ if (!CreateDirectory(path)) {
+ return kFallbackPath;
+ }
+ return path + kPathDelimiter;
+}
+
#ifdef WEBRTC_ANDROID
std::string ProjectRootPath() {
- return kRootDirName;
+ return ProjectRoothPathAndroid();
}
std::string OutputPath() {
- return kRootDirName;
+ return OutputPathAndroid();
}
std::string WorkingDir() {
- return kRootDirName;
+ return ProjectRootPath();
}
#else // WEBRTC_ANDROID
@@ -114,15 +131,7 @@
}
std::string OutputPath() {
- std::string path = ProjectRootPath();
- if (path == kCannotFindProjectRootDir) {
- return kFallbackPath;
- }
- path += kOutputDirName;
- if (!CreateDirectory(path)) {
- return kFallbackPath;
- }
- return path + kPathDelimiter;
+ return OutputPathImpl();
}
std::string WorkingDir() {