Skip to content

Commit d661e9c

Browse files
ehlemur-zzCommit bot
authored and
Commit bot
committed
WebRTC: Replace ProjectRootPath by ResourcePath
BUG=webrtc:6727 NOTRY=True Review-Url: https://codereview.webrtc.org/2513363004 Cr-Commit-Position: refs/heads/master@{#15201}
1 parent 10165ab commit d661e9c

File tree

13 files changed

+14
-166
lines changed

13 files changed

+14
-166
lines changed

data/voice_engine/audio_long16.pcm

-3.33 MB
Binary file not shown.

data/voice_engine/audio_tiny48.wav

-512 KB
Binary file not shown.

webrtc/modules/BUILD.gn

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ if (rtc_include_tests) {
138138
}
139139

140140
modules_unittests_resources = [
141-
"//data/voice_engine/audio_tiny48.wav",
142141
"//resources/att-downlink.rx",
143142
"//resources/att-uplink.rx",
144143
"//resources/audio_coding/neteq_opus.rtp",
@@ -238,6 +237,7 @@ if (rtc_include_tests) {
238237
"//resources/verizon3g-uplink.rx",
239238
"//resources/verizon4g-downlink.rx",
240239
"//resources/verizon4g-uplink.rx",
240+
"//resources/voice_engine/audio_tiny48.wav",
241241
]
242242

243243
if (is_ios) {

webrtc/modules/media_file/media_file_unittest.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class MediaFileTest : public testing::Test {
3737
TEST_F(MediaFileTest, MAYBE_StartPlayingAudioFileWithoutError) {
3838
// TODO(leozwang): Use hard coded filename here, we want to
3939
// loop through all audio files in future
40-
const std::string audio_file = webrtc::test::ProjectRootPath() +
41-
"data/voice_engine/audio_tiny48.wav";
40+
const std::string audio_file =
41+
webrtc::test::ResourcePath("voice_engine/audio_tiny48", "wav");
4242
ASSERT_EQ(0, media_file_->StartPlayingAudioFile(
4343
audio_file.c_str(),
4444
0,

webrtc/test/testsupport/fileutils.h

+2-71
Original file line numberDiff line numberDiff line change
@@ -10,57 +10,6 @@
1010

1111
#include <stdio.h>
1212

13-
// File utilities for testing purposes.
14-
//
15-
// The ProjectRootPath() method is a convenient way of getting an absolute
16-
// path to the project source tree root directory. Using this, it is easy to
17-
// refer to test resource files in a portable way.
18-
//
19-
// Notice that even if Windows platforms use backslash as path delimiter, it is
20-
// also supported to use slash, so there's no need for #ifdef checks in test
21-
// code for setting up the paths to the resource files.
22-
//
23-
// Example use:
24-
// Assume we have the following code being used in a test source file:
25-
// const std::string kInputFile = webrtc::test::ProjectRootPath() +
26-
// "test/data/voice_engine/audio_long16.wav";
27-
// // Use the kInputFile for the tests...
28-
//
29-
// Then here's some example outputs for different platforms:
30-
// Linux:
31-
// * Source tree located in /home/user/webrtc/trunk
32-
// * Test project located in /home/user/webrtc/trunk/src/testproject
33-
// * Test binary compiled as:
34-
// /home/user/webrtc/trunk/out/Debug/testproject_unittests
35-
// Then ProjectRootPath() will return /home/user/webrtc/trunk/ no matter if
36-
// the test binary is executed from standing in either of:
37-
// /home/user/webrtc/trunk
38-
// or
39-
// /home/user/webrtc/trunk/out/Debug
40-
// (or any other directory below the trunk for that matter).
41-
//
42-
// Windows:
43-
// * Source tree located in C:\Users\user\webrtc\trunk
44-
// * Test project located in C:\Users\user\webrtc\trunk\src\testproject
45-
// * Test binary compiled as:
46-
// C:\Users\user\webrtc\trunk\src\testproject\Debug\testproject_unittests.exe
47-
// Then ProjectRootPath() will return C:\Users\user\webrtc\trunk\ when the
48-
// test binary is executed from inside Visual Studio.
49-
// It will also return the same path if the test is executed from a command
50-
// prompt standing in C:\Users\user\webrtc\trunk\src\testproject\Debug
51-
//
52-
// Mac:
53-
// * Source tree located in /Users/user/webrtc/trunk
54-
// * Test project located in /Users/user/webrtc/trunk/src/testproject
55-
// * Test binary compiled as:
56-
// /Users/user/webrtc/trunk/xcodebuild/Debug/testproject_unittests
57-
// Then ProjectRootPath() will return /Users/user/webrtc/trunk/ no matter if
58-
// the test binary is executed from standing in either of:
59-
// /Users/user/webrtc/trunk
60-
// or
61-
// /Users/user/webrtc/trunk/out/Debug
62-
// (or any other directory below the trunk for that matter).
63-
6413
#ifndef WEBRTC_TEST_TESTSUPPORT_FILEUTILS_H_
6514
#define WEBRTC_TEST_TESTSUPPORT_FILEUTILS_H_
6615

@@ -73,32 +22,14 @@ namespace test {
7322
// to find the project root.
7423
extern const char* kCannotFindProjectRootDir;
7524

76-
// Finds the root dir of the project, to be able to set correct paths to
77-
// resource files used by tests.
78-
// For desktop, we assume that the project root is two levels above (i.e. the
79-
// current working directory + /../../)
80-
// For Android, it is assumed to be /sdcard/chromium_tests_root/
81-
// For iOS, the resource files are assumed to be included in the test's .app
82-
// bundle.
83-
// If the current working directory is above the project root dir, it will not
84-
// be found.
85-
//
86-
// If symbolic links occur in the path they will be resolved and the actual
87-
// directory will be returned.
88-
//
89-
// Returns the absolute path to the project root dir (usually the trunk dir)
90-
// WITH a trailing path delimiter.
91-
// If the project root is not found, the string specified by
92-
// kCannotFindProjectRootDir is returned.
93-
std::string ProjectRootPath();
94-
9525
// Creates and returns the absolute path to the output directory where log files
9626
// and other test artifacts should be put. The output directory is generally a
9727
// directory named "out" at the top-level of the project, i.e. a subfolder to
9828
// the path returned by ProjectRootPath(). The exception is Android where we use
9929
// /sdcard/ instead.
10030
//
101-
// Details described for ProjectRootPath() apply here too.
31+
// If symbolic links occur in the path they will be resolved and the actual
32+
// directory will be returned.
10233
//
10334
// Returns the path WITH a trailing path delimiter. If the project root is not
10435
// found, the current working directory ("./") is returned as a fallback.

webrtc/test/testsupport/fileutils_unittest.cc

+1-8
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,10 @@ class FileUtilsTest : public testing::Test {
5454

5555
std::string FileUtilsTest::original_working_dir_ = "";
5656

57-
// Tests that the project root path is returned for the default working
57+
// Tests that the project output dir path is returned for the default working
5858
// directory that is automatically set when the test executable is launched.
5959
// The test is not fully testing the implementation, since we cannot be sure
6060
// of where the executable was launched from.
61-
TEST_F(FileUtilsTest, ProjectRootPath) {
62-
std::string project_root = webrtc::test::ProjectRootPath();
63-
// Not very smart, but at least tests something.
64-
ASSERT_GT(project_root.length(), 0u);
65-
}
66-
67-
// Similar to the above test, but for the output dir
6861
#if defined(WEBRTC_ANDROID)
6962
#define MAYBE_OutputPathFromUnchangedWorkingDir \
7063
DISABLED_OutputPathFromUnchangedWorkingDir

webrtc/voice_engine/BUILD.gn

-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ if (rtc_include_tests) {
293293
"test/auto_test/fixtures/before_initialization_fixture.h",
294294
"test/auto_test/fixtures/before_streaming_fixture.cc",
295295
"test/auto_test/fixtures/before_streaming_fixture.h",
296-
"test/auto_test/resource_manager.cc",
297296
"test/auto_test/standard/audio_processing_test.cc",
298297
"test/auto_test/standard/codec_before_streaming_test.cc",
299298
"test/auto_test/standard/codec_test.cc",

webrtc/voice_engine/test/auto_test/fixtures/before_streaming_fixture.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88
* be found in the AUTHORS file in the root of the source tree.
99
*/
1010

11+
#include "webrtc/test/testsupport/fileutils.h"
1112
#include "webrtc/voice_engine/test/auto_test/fixtures/before_streaming_fixture.h"
1213

1314
BeforeStreamingFixture::BeforeStreamingFixture()
1415
: channel_(voe_base_->CreateChannel()),
1516
transport_(NULL) {
1617
EXPECT_GE(channel_, 0);
1718

18-
fake_microphone_input_file_ = resource_manager_.long_audio_file_path();
19-
EXPECT_FALSE(fake_microphone_input_file_.empty());
19+
fake_microphone_input_file_ =
20+
webrtc::test::ResourcePath("voice_engine/audio_long16", "pcm");
2021

2122
SetUpLocalPlayback();
2223
RestartFakeMicrophone();

webrtc/voice_engine/test/auto_test/fixtures/before_streaming_fixture.h

-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
#include <string>
1515
#include "webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h"
16-
#include "webrtc/voice_engine/test/auto_test/resource_manager.h"
1716

1817
// This fixture will, in addition to the work done by its superclasses,
1918
// create a channel and prepare playing a file through the fake microphone
@@ -26,7 +25,6 @@ class BeforeStreamingFixture : public AfterInitializationFixture {
2625

2726
protected:
2827
int channel_;
29-
ResourceManager resource_manager_;
3028
std::string fake_microphone_input_file_;
3129

3230
// Shuts off the fake microphone for this test.

webrtc/voice_engine/test/auto_test/resource_manager.cc

-28
This file was deleted.

webrtc/voice_engine/test/auto_test/resource_manager.h

-30
This file was deleted.

webrtc/voice_engine/test/auto_test/voe_standard_test.h

+3-7
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
#include <string>
1616

1717
#include "gflags/gflags.h"
18+
#include "webrtc/test/testsupport/fileutils.h"
1819
#include "webrtc/voice_engine/include/voe_audio_processing.h"
1920
#include "webrtc/voice_engine/include/voe_base.h"
2021
#include "webrtc/voice_engine/include/voe_errors.h"
2122
#include "webrtc/voice_engine/include/voe_file.h"
2223
#include "webrtc/voice_engine/include/voe_rtp_rtcp.h"
23-
#include "webrtc/voice_engine/test/auto_test/resource_manager.h"
2424
#include "webrtc/voice_engine/test/auto_test/voe_test_common.h"
2525
#include "webrtc/voice_engine/test/auto_test/voe_test_interface.h"
2626
#ifdef WEBRTC_VOICE_ENGINE_CODEC_API
@@ -118,10 +118,8 @@ class VoETestManager {
118118
int ReleaseInterfaces();
119119

120120
const char* AudioFilename() const {
121-
const std::string& result = resource_manager_.long_audio_file_path();
122-
if (result.length() == 0) {
123-
TEST_LOG("ERROR: Failed to open input file!");
124-
}
121+
const std::string& result =
122+
webrtc::test::ResourcePath("voice_engine/audio_long16", "pcm");
125123
return result.c_str();
126124
}
127125

@@ -187,8 +185,6 @@ class VoETestManager {
187185
VoEVideoSync* voe_vsync_;
188186
VoEVolumeControl* voe_volume_control_;
189187
VoEAudioProcessing* voe_apm_;
190-
191-
ResourceManager resource_manager_;
192188
};
193189

194190
} // namespace voetest

webrtc/voice_engine/test/cmd_test/voe_cmd_test.cc

+2-14
Original file line numberDiff line numberDiff line change
@@ -229,20 +229,8 @@ void RunTest(std::string out_path) {
229229
bool experimental_ns_enabled = false;
230230
bool debug_recording_started = false;
231231

232-
#if defined(WEBRTC_ANDROID)
233-
std::string resource_path = "/sdcard/";
234-
#else
235-
std::string resource_path = webrtc::test::ProjectRootPath();
236-
if (resource_path == webrtc::test::kCannotFindProjectRootDir) {
237-
printf("*** Unable to get project root directory. "
238-
"File playing may fail. ***\n");
239-
// Fall back to the current directory.
240-
resource_path = "./";
241-
} else {
242-
resource_path += "data/voice_engine/";
243-
}
244-
#endif
245-
const std::string audio_filename = resource_path + "audio_long16.pcm";
232+
const std::string audio_filename =
233+
webrtc::test::ResourcePath("voice_engine/audio_long16", "pcm");
246234

247235
const std::string play_filename = out_path + "recorded_playout.pcm";
248236
const std::string mic_filename = out_path + "recorded_mic.pcm";

0 commit comments

Comments
 (0)