summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkjellander@webrtc.org <kjellander@webrtc.org>2014-11-05 06:28:50 +0000
committerkjellander@webrtc.org <kjellander@webrtc.org>2014-11-05 06:28:50 +0000
commit048258f276d094723d301a09329bb06b303c5259 (patch)
tree727e99060336192aa648a2268952824b1fc244f0
parent20b2dc6bfbfc84cbdcbc733314704fdcc5f9f700 (diff)
downloadwebrtc-048258f276d094723d301a09329bb06b303c5259.tar.gz
Restore old behavior for Android in fileutils.cc
From r7014 the Android APK tests are designed to be build from a standalone WebRTC checkout instead of a Chromium checkout. Because of that, the special handling for both cases can be removed. I also don't think we need to use the base::android::GetExternalStorageDirectory() method since all devices has a symlink at /sdcard that points to /storage/emulated/legacy on the Android device. This essentially reverts the changes in https://webrtc-codereview.appspot.com/1754005/ plus some minor changes. BUG=webrtc:3741 TEST=Locally running test_support_unittests APK test on an Android device using: CHECKOUT_SOURCE_ROOT=`pwd` build/android/test_runner.py gtest -s test_support_unittests --verbose --isolate-file-path=webrtc/test/test_support_unittests.isolate R=henrike@webrtc.org Review URL: https://webrtc-codereview.appspot.com/15329004 git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@7632 4adac7df-926f-26a2-2b94-8c16560cd09d
-rw-r--r--test/BUILD.gn3
-rw-r--r--test/test.gyp16
-rw-r--r--test/testsupport/android/root_path_android.cc26
-rw-r--r--test/testsupport/android/root_path_android_chromium.cc34
-rw-r--r--test/testsupport/fileutils.cc39
-rw-r--r--test/testsupport/fileutils_unittest.cc7
6 files changed, 20 insertions, 105 deletions
diff --git a/test/BUILD.gn b/test/BUILD.gn
index db17c31e..870404e7 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -67,10 +67,7 @@ source_set("test_support") {
]
if (is_android) {
- sources += [ "testsupport/android/root_path_android_chromium.cc" ]
deps += [ "//base:base" ]
- } else {
- sources += [ "testsupport/android/root_path_android.cc" ]
}
configs += [ "..:common_config" ]
diff --git a/test/test.gyp b/test/test.gyp
index 5c959b9e..7aba2f57 100644
--- a/test/test.gyp
+++ b/test/test.gyp
@@ -98,8 +98,6 @@
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
],
'sources': [
- 'testsupport/android/root_path_android.cc',
- 'testsupport/android/root_path_android_chromium.cc',
'testsupport/fileutils.cc',
'testsupport/fileutils.h',
'testsupport/frame_reader.cc',
@@ -117,20 +115,6 @@
'testsupport/trace_to_stderr.cc',
'testsupport/trace_to_stderr.h',
],
- 'conditions': [
- ['OS=="android"', {
- 'dependencies': [
- '<(DEPTH)/base/base.gyp:base',
- ],
- 'sources!': [
- 'testsupport/android/root_path_android.cc',
- ],
- }, {
- 'sources!': [
- 'testsupport/android/root_path_android_chromium.cc',
- ],
- }],
- ],
},
{
# Depend on this target when you want to have test_support but also the
diff --git a/test/testsupport/android/root_path_android.cc b/test/testsupport/android/root_path_android.cc
deleted file mode 100644
index 6eca5f57..00000000
--- a/test/testsupport/android/root_path_android.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#include <string>
-
-namespace webrtc {
-namespace test {
-
-static const char* kRootDirName = "/sdcard/";
-std::string ProjectRootPathAndroid() {
- return kRootDirName;
-}
-
-std::string OutputPathAndroid() {
- return kRootDirName;
-}
-
-} // namespace test
-} // namespace webrtc
diff --git a/test/testsupport/android/root_path_android_chromium.cc b/test/testsupport/android/root_path_android_chromium.cc
deleted file mode 100644
index f8e65f4f..00000000
--- a/test/testsupport/android/root_path_android_chromium.cc
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "base/android/path_utils.h"
-#include "base/files/file_path.h"
-
-namespace webrtc {
-namespace test {
-
-std::string OutputPathImpl();
-
-// This file is only compiled when running WebRTC tests in a Chromium workspace.
-// The Android testing framework will push files relative to the root path of
-// the Chromium workspace. The root path for webrtc is one directory up from
-// trunk/webrtc (in standalone) or src/third_party/webrtc (in Chromium).
-std::string ProjectRootPathAndroid() {
- base::FilePath root_path;
- base::android::GetExternalStorageDirectory(&root_path);
- return root_path.value() + "/";
-}
-
-std::string OutputPathAndroid() {
- return OutputPathImpl();
-}
-
-} // namespace test
-} // namespace webrtc
diff --git a/test/testsupport/fileutils.cc b/test/testsupport/fileutils.cc
index a3e66201..36ca391c 100644
--- a/test/testsupport/fileutils.cc
+++ b/test/testsupport/fileutils.cc
@@ -50,15 +50,15 @@ const char* kPathDelimiter = "/";
#endif
#ifdef WEBRTC_ANDROID
-const char* kResourcesDirName = "resources";
+const char* kRootDirName = "/sdcard/";
#else
// The file we're looking for to identify the project root dir.
const char* kProjectRootFileName = "DEPS";
-const char* kResourcesDirName = "resources";
+const char* kOutputDirName = "out";
+const char* kFallbackPath = "./";
#endif
+const char* kResourcesDirName = "resources";
-const char* kFallbackPath = "./";
-const char* kOutputDirName = "out";
char relative_dir_path[FILENAME_MAX];
bool relative_dir_path_set = false;
@@ -66,9 +66,6 @@ bool relative_dir_path_set = false;
const char* kCannotFindProjectRootDir = "ERROR_CANNOT_FIND_PROJECT_ROOT_DIR";
-std::string OutputPathAndroid();
-std::string ProjectRootPathAndroid();
-
void SetExecutablePath(const std::string& path) {
std::string working_dir = WorkingDir();
std::string temp_path = path;
@@ -95,30 +92,18 @@ 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 (!CreateDir(path)) {
- return kFallbackPath;
- }
- return path + kPathDelimiter;
-}
-
#ifdef WEBRTC_ANDROID
std::string ProjectRootPath() {
- return ProjectRootPathAndroid();
+ return kRootDirName;
}
std::string OutputPath() {
- return OutputPathAndroid();
+ return kRootDirName;
}
std::string WorkingDir() {
- return ProjectRootPath();
+ return kRootDirName;
}
#else // WEBRTC_ANDROID
@@ -148,7 +133,15 @@ std::string ProjectRootPath() {
}
std::string OutputPath() {
- return OutputPathImpl();
+ std::string path = ProjectRootPath();
+ if (path == kCannotFindProjectRootDir) {
+ return kFallbackPath;
+ }
+ path += kOutputDirName;
+ if (!CreateDir(path)) {
+ return kFallbackPath;
+ }
+ return path + kPathDelimiter;
}
std::string WorkingDir() {
diff --git a/test/testsupport/fileutils_unittest.cc b/test/testsupport/fileutils_unittest.cc
index 114f1083..dff7f224 100644
--- a/test/testsupport/fileutils_unittest.cc
+++ b/test/testsupport/fileutils_unittest.cc
@@ -66,7 +66,7 @@ TEST_F(FileUtilsTest, ProjectRootPath) {
}
// Similar to the above test, but for the output dir
-TEST_F(FileUtilsTest, OutputPathFromUnchangedWorkingDir) {
+TEST_F(FileUtilsTest, DISABLED_ON_ANDROID(OutputPathFromUnchangedWorkingDir)) {
std::string path = webrtc::test::OutputPath();
std::string expected_end = "out";
expected_end = kPathDelimiter + expected_end + kPathDelimiter;
@@ -80,10 +80,11 @@ TEST_F(FileUtilsTest, DISABLED_ON_ANDROID(OutputPathFromRootWorkingDir)) {
ASSERT_EQ("./", webrtc::test::OutputPath());
}
-TEST_F(FileUtilsTest, DISABLED_ON_ANDROID(TempFilename)) {
+TEST_F(FileUtilsTest, TempFilename) {
std::string temp_filename = webrtc::test::TempFilename(
webrtc::test::OutputPath(), "TempFilenameTest");
- ASSERT_TRUE(webrtc::test::FileExists(temp_filename));
+ ASSERT_TRUE(webrtc::test::FileExists(temp_filename))
+ << "Couldn't find file: " << temp_filename;
remove(temp_filename.c_str());
}