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
This commit is contained in:
henrike@webrtc.org
2013-07-08 14:55:23 +00:00
parent 1932fe1865
commit 34773d9b6b
5 changed files with 79 additions and 33 deletions

View File

@ -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 @@ bool FileExists(std::string& file_name) {
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 ProjectRootPath() {
}
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() {