diff --git a/webrtc/test/BUILD.gn b/webrtc/test/BUILD.gn index db17c31e4..870404e7a 100644 --- a/webrtc/test/BUILD.gn +++ b/webrtc/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/webrtc/test/test.gyp b/webrtc/test/test.gyp index 5c959b9ea..7aba2f573 100644 --- a/webrtc/test/test.gyp +++ b/webrtc/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/webrtc/test/testsupport/android/root_path_android.cc b/webrtc/test/testsupport/android/root_path_android.cc deleted file mode 100644 index 6eca5f57a..000000000 --- a/webrtc/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 - -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/webrtc/test/testsupport/android/root_path_android_chromium.cc b/webrtc/test/testsupport/android/root_path_android_chromium.cc deleted file mode 100644 index f8e65f4fd..000000000 --- a/webrtc/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/webrtc/test/testsupport/fileutils.cc b/webrtc/test/testsupport/fileutils.cc index a3e66201f..36ca391c4 100644 --- a/webrtc/test/testsupport/fileutils.cc +++ b/webrtc/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"; -#endif - -const char* kFallbackPath = "./"; const char* kOutputDirName = "out"; +const char* kFallbackPath = "./"; +#endif +const char* kResourcesDirName = "resources"; + 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/webrtc/test/testsupport/fileutils_unittest.cc b/webrtc/test/testsupport/fileutils_unittest.cc index 114f10835..dff7f2249 100644 --- a/webrtc/test/testsupport/fileutils_unittest.cc +++ b/webrtc/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()); }