mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
WebRTC: Replace ProjectRootPath by ResourcePath
BUG=webrtc:6727 NOTRY=True Review-Url: https://codereview.webrtc.org/2513363004 Cr-Commit-Position: refs/heads/master@{#15201}
This commit is contained in:
parent
10165ab8e7
commit
d661e9c354
13 changed files with 14 additions and 166 deletions
Binary file not shown.
Binary file not shown.
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -10,57 +10,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
// 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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
#include <string>
|
||||
#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.
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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 <string>
|
||||
|
||||
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_
|
|
@ -15,12 +15,12 @@
|
|||
#include <string>
|
||||
|
||||
#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
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Reference in a new issue