diff --git a/data/voice_engine/audio_long16.pcm b/data/voice_engine/audio_long16.pcm deleted file mode 100644 index 853e0dfce7..0000000000 Binary files a/data/voice_engine/audio_long16.pcm and /dev/null differ diff --git a/data/voice_engine/audio_tiny48.wav b/data/voice_engine/audio_tiny48.wav deleted file mode 100644 index 8ebf11a481..0000000000 Binary files a/data/voice_engine/audio_tiny48.wav and /dev/null differ diff --git a/webrtc/modules/BUILD.gn b/webrtc/modules/BUILD.gn index a2861dd0ee..63e328dbd1 100644 --- a/webrtc/modules/BUILD.gn +++ b/webrtc/modules/BUILD.gn @@ -138,7 +138,6 @@ if (rtc_include_tests) { } modules_unittests_resources = [ - "//data/voice_engine/audio_tiny48.wav", "//resources/att-downlink.rx", "//resources/att-uplink.rx", "//resources/audio_coding/neteq_opus.rtp", @@ -238,6 +237,7 @@ if (rtc_include_tests) { "//resources/verizon3g-uplink.rx", "//resources/verizon4g-downlink.rx", "//resources/verizon4g-uplink.rx", + "//resources/voice_engine/audio_tiny48.wav", ] if (is_ios) { diff --git a/webrtc/modules/media_file/media_file_unittest.cc b/webrtc/modules/media_file/media_file_unittest.cc index cbea836fcf..5e70a5fc38 100644 --- a/webrtc/modules/media_file/media_file_unittest.cc +++ b/webrtc/modules/media_file/media_file_unittest.cc @@ -37,8 +37,8 @@ class MediaFileTest : public testing::Test { TEST_F(MediaFileTest, MAYBE_StartPlayingAudioFileWithoutError) { // TODO(leozwang): Use hard coded filename here, we want to // loop through all audio files in future - const std::string audio_file = webrtc::test::ProjectRootPath() + - "data/voice_engine/audio_tiny48.wav"; + const std::string audio_file = + webrtc::test::ResourcePath("voice_engine/audio_tiny48", "wav"); ASSERT_EQ(0, media_file_->StartPlayingAudioFile( audio_file.c_str(), 0, diff --git a/webrtc/test/testsupport/fileutils.h b/webrtc/test/testsupport/fileutils.h index 482b1874a7..2467f0c8e5 100644 --- a/webrtc/test/testsupport/fileutils.h +++ b/webrtc/test/testsupport/fileutils.h @@ -10,57 +10,6 @@ #include -// File utilities for testing purposes. -// -// The ProjectRootPath() method is a convenient way of getting an absolute -// path to the project source tree root directory. Using this, it is easy to -// refer to test resource files in a portable way. -// -// Notice that even if Windows platforms use backslash as path delimiter, it is -// also supported to use slash, so there's no need for #ifdef checks in test -// code for setting up the paths to the resource files. -// -// Example use: -// Assume we have the following code being used in a test source file: -// const std::string kInputFile = webrtc::test::ProjectRootPath() + -// "test/data/voice_engine/audio_long16.wav"; -// // Use the kInputFile for the tests... -// -// Then here's some example outputs for different platforms: -// Linux: -// * Source tree located in /home/user/webrtc/trunk -// * Test project located in /home/user/webrtc/trunk/src/testproject -// * Test binary compiled as: -// /home/user/webrtc/trunk/out/Debug/testproject_unittests -// Then ProjectRootPath() will return /home/user/webrtc/trunk/ no matter if -// the test binary is executed from standing in either of: -// /home/user/webrtc/trunk -// or -// /home/user/webrtc/trunk/out/Debug -// (or any other directory below the trunk for that matter). -// -// Windows: -// * Source tree located in C:\Users\user\webrtc\trunk -// * Test project located in C:\Users\user\webrtc\trunk\src\testproject -// * Test binary compiled as: -// C:\Users\user\webrtc\trunk\src\testproject\Debug\testproject_unittests.exe -// Then ProjectRootPath() will return C:\Users\user\webrtc\trunk\ when the -// test binary is executed from inside Visual Studio. -// It will also return the same path if the test is executed from a command -// prompt standing in C:\Users\user\webrtc\trunk\src\testproject\Debug -// -// Mac: -// * Source tree located in /Users/user/webrtc/trunk -// * Test project located in /Users/user/webrtc/trunk/src/testproject -// * Test binary compiled as: -// /Users/user/webrtc/trunk/xcodebuild/Debug/testproject_unittests -// Then ProjectRootPath() will return /Users/user/webrtc/trunk/ no matter if -// the test binary is executed from standing in either of: -// /Users/user/webrtc/trunk -// or -// /Users/user/webrtc/trunk/out/Debug -// (or any other directory below the trunk for that matter). - #ifndef WEBRTC_TEST_TESTSUPPORT_FILEUTILS_H_ #define WEBRTC_TEST_TESTSUPPORT_FILEUTILS_H_ @@ -73,32 +22,14 @@ namespace test { // to find the project root. extern const char* kCannotFindProjectRootDir; -// Finds the root dir of the project, to be able to set correct paths to -// resource files used by tests. -// For desktop, we assume that the project root is two levels above (i.e. the -// current working directory + /../../) -// For Android, it is assumed to be /sdcard/chromium_tests_root/ -// For iOS, the resource files are assumed to be included in the test's .app -// bundle. -// If the current working directory is above the project root dir, it will not -// be found. -// -// If symbolic links occur in the path they will be resolved and the actual -// directory will be returned. -// -// Returns the absolute path to the project root dir (usually the trunk dir) -// WITH a trailing path delimiter. -// If the project root is not found, the string specified by -// kCannotFindProjectRootDir is returned. -std::string ProjectRootPath(); - // Creates and returns the absolute path to the output directory where log files // and other test artifacts should be put. The output directory is generally a // directory named "out" at the top-level of the project, i.e. a subfolder to // the path returned by ProjectRootPath(). The exception is Android where we use // /sdcard/ instead. // -// Details described for ProjectRootPath() apply here too. +// If symbolic links occur in the path they will be resolved and the actual +// directory will be returned. // // Returns the path WITH a trailing path delimiter. If the project root is not // found, the current working directory ("./") is returned as a fallback. diff --git a/webrtc/test/testsupport/fileutils_unittest.cc b/webrtc/test/testsupport/fileutils_unittest.cc index b9ac913326..e6699afbc1 100644 --- a/webrtc/test/testsupport/fileutils_unittest.cc +++ b/webrtc/test/testsupport/fileutils_unittest.cc @@ -54,17 +54,10 @@ class FileUtilsTest : public testing::Test { std::string FileUtilsTest::original_working_dir_ = ""; -// Tests that the project root path is returned for the default working +// Tests that the project output dir path is returned for the default working // directory that is automatically set when the test executable is launched. // The test is not fully testing the implementation, since we cannot be sure // of where the executable was launched from. -TEST_F(FileUtilsTest, ProjectRootPath) { - std::string project_root = webrtc::test::ProjectRootPath(); - // Not very smart, but at least tests something. - ASSERT_GT(project_root.length(), 0u); -} - -// Similar to the above test, but for the output dir #if defined(WEBRTC_ANDROID) #define MAYBE_OutputPathFromUnchangedWorkingDir \ DISABLED_OutputPathFromUnchangedWorkingDir diff --git a/webrtc/voice_engine/BUILD.gn b/webrtc/voice_engine/BUILD.gn index 9a3894859c..919708e241 100644 --- a/webrtc/voice_engine/BUILD.gn +++ b/webrtc/voice_engine/BUILD.gn @@ -293,7 +293,6 @@ if (rtc_include_tests) { "test/auto_test/fixtures/before_initialization_fixture.h", "test/auto_test/fixtures/before_streaming_fixture.cc", "test/auto_test/fixtures/before_streaming_fixture.h", - "test/auto_test/resource_manager.cc", "test/auto_test/standard/audio_processing_test.cc", "test/auto_test/standard/codec_before_streaming_test.cc", "test/auto_test/standard/codec_test.cc", diff --git a/webrtc/voice_engine/test/auto_test/fixtures/before_streaming_fixture.cc b/webrtc/voice_engine/test/auto_test/fixtures/before_streaming_fixture.cc index 34e2bb0fbd..c3dba83979 100644 --- a/webrtc/voice_engine/test/auto_test/fixtures/before_streaming_fixture.cc +++ b/webrtc/voice_engine/test/auto_test/fixtures/before_streaming_fixture.cc @@ -8,6 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "webrtc/test/testsupport/fileutils.h" #include "webrtc/voice_engine/test/auto_test/fixtures/before_streaming_fixture.h" BeforeStreamingFixture::BeforeStreamingFixture() @@ -15,8 +16,8 @@ BeforeStreamingFixture::BeforeStreamingFixture() transport_(NULL) { EXPECT_GE(channel_, 0); - fake_microphone_input_file_ = resource_manager_.long_audio_file_path(); - EXPECT_FALSE(fake_microphone_input_file_.empty()); + fake_microphone_input_file_ = + webrtc::test::ResourcePath("voice_engine/audio_long16", "pcm"); SetUpLocalPlayback(); RestartFakeMicrophone(); diff --git a/webrtc/voice_engine/test/auto_test/fixtures/before_streaming_fixture.h b/webrtc/voice_engine/test/auto_test/fixtures/before_streaming_fixture.h index 1348e481a8..0ff4a06e14 100644 --- a/webrtc/voice_engine/test/auto_test/fixtures/before_streaming_fixture.h +++ b/webrtc/voice_engine/test/auto_test/fixtures/before_streaming_fixture.h @@ -13,7 +13,6 @@ #include #include "webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h" -#include "webrtc/voice_engine/test/auto_test/resource_manager.h" // This fixture will, in addition to the work done by its superclasses, // create a channel and prepare playing a file through the fake microphone @@ -26,7 +25,6 @@ class BeforeStreamingFixture : public AfterInitializationFixture { protected: int channel_; - ResourceManager resource_manager_; std::string fake_microphone_input_file_; // Shuts off the fake microphone for this test. diff --git a/webrtc/voice_engine/test/auto_test/resource_manager.cc b/webrtc/voice_engine/test/auto_test/resource_manager.cc deleted file mode 100644 index a80d71a2c8..0000000000 --- a/webrtc/voice_engine/test/auto_test/resource_manager.cc +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2012 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 "webrtc/voice_engine/test/auto_test/resource_manager.h" - -#include "webrtc/test/testsupport/fileutils.h" - -ResourceManager::ResourceManager() { - std::string filename = "audio_long16.pcm"; -#if defined(WEBRTC_ANDROID) - long_audio_file_path_ = "/sdcard/" + filename; -#else - std::string resource_path = webrtc::test::ProjectRootPath(); - if (resource_path == webrtc::test::kCannotFindProjectRootDir) { - long_audio_file_path_ = ""; - } else { - long_audio_file_path_ = - resource_path + "data/voice_engine/" + filename; - } -#endif -} diff --git a/webrtc/voice_engine/test/auto_test/resource_manager.h b/webrtc/voice_engine/test/auto_test/resource_manager.h deleted file mode 100644 index 1bb91cf497..0000000000 --- a/webrtc/voice_engine/test/auto_test/resource_manager.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2011 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. - */ - -#ifndef SRC_VOICE_ENGINE_MAIN_TEST_AUTO_TEST_RESOURCE_MANAGER_H_ -#define SRC_VOICE_ENGINE_MAIN_TEST_AUTO_TEST_RESOURCE_MANAGER_H_ - -#include - -class ResourceManager { - public: - ResourceManager(); - - // Returns the full path to a long audio file. - // Returns the empty string on failure. - const std::string& long_audio_file_path() const { - return long_audio_file_path_; - } - - private: - std::string long_audio_file_path_; -}; - -#endif // SRC_VOICE_ENGINE_MAIN_TEST_AUTO_TEST_RESOURCE_MANAGER_H_ diff --git a/webrtc/voice_engine/test/auto_test/voe_standard_test.h b/webrtc/voice_engine/test/auto_test/voe_standard_test.h index 6401cd1536..529178e212 100644 --- a/webrtc/voice_engine/test/auto_test/voe_standard_test.h +++ b/webrtc/voice_engine/test/auto_test/voe_standard_test.h @@ -15,12 +15,12 @@ #include #include "gflags/gflags.h" +#include "webrtc/test/testsupport/fileutils.h" #include "webrtc/voice_engine/include/voe_audio_processing.h" #include "webrtc/voice_engine/include/voe_base.h" #include "webrtc/voice_engine/include/voe_errors.h" #include "webrtc/voice_engine/include/voe_file.h" #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" -#include "webrtc/voice_engine/test/auto_test/resource_manager.h" #include "webrtc/voice_engine/test/auto_test/voe_test_common.h" #include "webrtc/voice_engine/test/auto_test/voe_test_interface.h" #ifdef WEBRTC_VOICE_ENGINE_CODEC_API @@ -118,10 +118,8 @@ class VoETestManager { int ReleaseInterfaces(); const char* AudioFilename() const { - const std::string& result = resource_manager_.long_audio_file_path(); - if (result.length() == 0) { - TEST_LOG("ERROR: Failed to open input file!"); - } + const std::string& result = + webrtc::test::ResourcePath("voice_engine/audio_long16", "pcm"); return result.c_str(); } @@ -187,8 +185,6 @@ class VoETestManager { VoEVideoSync* voe_vsync_; VoEVolumeControl* voe_volume_control_; VoEAudioProcessing* voe_apm_; - - ResourceManager resource_manager_; }; } // namespace voetest diff --git a/webrtc/voice_engine/test/cmd_test/voe_cmd_test.cc b/webrtc/voice_engine/test/cmd_test/voe_cmd_test.cc index edc2ecf6b2..69bb7ed5da 100644 --- a/webrtc/voice_engine/test/cmd_test/voe_cmd_test.cc +++ b/webrtc/voice_engine/test/cmd_test/voe_cmd_test.cc @@ -229,20 +229,8 @@ void RunTest(std::string out_path) { bool experimental_ns_enabled = false; bool debug_recording_started = false; -#if defined(WEBRTC_ANDROID) - std::string resource_path = "/sdcard/"; -#else - std::string resource_path = webrtc::test::ProjectRootPath(); - if (resource_path == webrtc::test::kCannotFindProjectRootDir) { - printf("*** Unable to get project root directory. " - "File playing may fail. ***\n"); - // Fall back to the current directory. - resource_path = "./"; - } else { - resource_path += "data/voice_engine/"; - } -#endif - const std::string audio_filename = resource_path + "audio_long16.pcm"; + const std::string audio_filename = + webrtc::test::ResourcePath("voice_engine/audio_long16", "pcm"); const std::string play_filename = out_path + "recorded_playout.pcm"; const std::string mic_filename = out_path + "recorded_mic.pcm";