Commit c0d56727 authored by Olga Sharonova's avatar Olga Sharonova Committed by Commit Bot

Fix fake audio setup in WebRTC audio perf tests.

Change them to set up switches::kUseFileForFakeAudioCapture in
SetUpCommandLine(), so that it can be propagated to the audio process.

Bug: 850936
Change-Id: Ia6cccc01d2b5fa7545abe8cb1554d72c33146566
Reviewed-on: https://chromium-review.googlesource.com/1122857Reviewed-by: default avatarHenrik Boström <hbos@chromium.org>
Commit-Queue: Olga Sharonova <olka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572142}
parent 2a3b0cc9
...@@ -66,14 +66,6 @@ const int kMaxAgcSegmentDiffMs = ...@@ -66,14 +66,6 @@ const int kMaxAgcSegmentDiffMs =
200; 200;
#endif #endif
// Temporarily disabled on Win (https://crbug.com/850936).
#if defined(OS_LINUX) || defined(OS_MACOSX)
#define MAYBE_WebRtcAudioQualityBrowserTest WebRtcAudioQualityBrowserTest
#else
// Not implemented on Android, ChromeOS etc.
#define MAYBE_WebRtcAudioQualityBrowserTest DISABLED_WebRtcAudioQualityBrowserTest
#endif
} // namespace } // namespace
// Test we can set up a WebRTC call and play audio through it. // Test we can set up a WebRTC call and play audio through it.
...@@ -135,9 +127,9 @@ const int kMaxAgcSegmentDiffMs = ...@@ -135,9 +127,9 @@ const int kMaxAgcSegmentDiffMs =
// 50 / 100 in level. Also go into the playback tab, right-click Speakers, // 50 / 100 in level. Also go into the playback tab, right-click Speakers,
// and set that level to 50 / 100. Otherwise you will get distortion in // and set that level to 50 / 100. Otherwise you will get distortion in
// the recording. // the recording.
class MAYBE_WebRtcAudioQualityBrowserTest : public WebRtcTestBase { class WebRtcAudioQualityBrowserTest : public WebRtcTestBase {
public: public:
MAYBE_WebRtcAudioQualityBrowserTest() {} WebRtcAudioQualityBrowserTest() {}
void SetUpInProcessBrowserTestFixture() override { void SetUpInProcessBrowserTestFixture() override {
DetectErrorsInJavaScript(); // Look for errors in our rather complex js. DetectErrorsInJavaScript(); // Look for errors in our rather complex js.
} }
...@@ -161,6 +153,9 @@ class MAYBE_WebRtcAudioQualityBrowserTest : public WebRtcTestBase { ...@@ -161,6 +153,9 @@ class MAYBE_WebRtcAudioQualityBrowserTest : public WebRtcTestBase {
// Add loopback interface such that there is always connectivity. // Add loopback interface such that there is always connectivity.
command_line->AppendSwitch(switches::kAllowLoopbackInPeerConnection); command_line->AppendSwitch(switches::kAllowLoopbackInPeerConnection);
reference_file_ = test::GetReferenceFilesDir().Append(kReferenceFile);
ConfigureFakeDeviceToPlayFile(reference_file_);
} }
void ConfigureFakeDeviceToPlayFile(const base::FilePath& wav_file_path) { void ConfigureFakeDeviceToPlayFile(const base::FilePath& wav_file_path) {
...@@ -498,17 +493,18 @@ class MAYBE_WebRtcAudioQualityBrowserTest : public WebRtcTestBase { ...@@ -498,17 +493,18 @@ class MAYBE_WebRtcAudioQualityBrowserTest : public WebRtcTestBase {
} }
protected: protected:
void TestAutoGainControl(const base::FilePath::StringType& reference_filename, void TestAutoGainControl(const std::string& constraints,
const std::string& constraints,
const std::string& perf_modifier); const std::string& perf_modifier);
void SetupAndRecordAudioCall(const base::FilePath& reference_file, void SetupAndRecordAudioCall(const base::FilePath& recording,
const base::FilePath& recording,
const std::string& constraints, const std::string& constraints,
const base::TimeDelta recording_time); const base::TimeDelta recording_time);
void TestWithFakeDeviceGetUserMedia(const std::string& constraints, void TestWithFakeDeviceGetUserMedia(const std::string& constraints,
const std::string& perf_modifier); const std::string& perf_modifier);
const base::FilePath& reference_file() { return reference_file_; }
private: private:
base::FilePath reference_file_;
base::FilePath wav_dump_path_; base::FilePath wav_dump_path_;
}; };
...@@ -654,8 +650,7 @@ bool ForceMicrophoneVolumeTo100Percent() { ...@@ -654,8 +650,7 @@ bool ForceMicrophoneVolumeTo100Percent() {
// plenty of time. Similarly, the recording time should be enough to catch the // plenty of time. Similarly, the recording time should be enough to catch the
// whole reference file. If you then silence-trim the reference file and actual // whole reference file. If you then silence-trim the reference file and actual
// file, you should end up with two time-synchronized files. // file, you should end up with two time-synchronized files.
void MAYBE_WebRtcAudioQualityBrowserTest::SetupAndRecordAudioCall( void WebRtcAudioQualityBrowserTest::SetupAndRecordAudioCall(
const base::FilePath& reference_file,
const base::FilePath& recording, const base::FilePath& recording,
const std::string& constraints, const std::string& constraints,
const base::TimeDelta recording_time) { const base::TimeDelta recording_time) {
...@@ -663,8 +658,6 @@ void MAYBE_WebRtcAudioQualityBrowserTest::SetupAndRecordAudioCall( ...@@ -663,8 +658,6 @@ void MAYBE_WebRtcAudioQualityBrowserTest::SetupAndRecordAudioCall(
ASSERT_TRUE(test::HasReferenceFilesInCheckout()); ASSERT_TRUE(test::HasReferenceFilesInCheckout());
ASSERT_TRUE(ForceMicrophoneVolumeTo100Percent()); ASSERT_TRUE(ForceMicrophoneVolumeTo100Percent());
ConfigureFakeDeviceToPlayFile(reference_file);
// Create a two-way call. Mute one of the receivers though; that way it will // Create a two-way call. Mute one of the receivers though; that way it will
// be receiving audio bytes, but we will not be playing out of both elements. // be receiving audio bytes, but we will not be playing out of both elements.
GURL test_page = embedded_test_server()->GetURL(kWebRtcAudioTestHtmlPage); GURL test_page = embedded_test_server()->GetURL(kWebRtcAudioTestHtmlPage);
...@@ -688,7 +681,7 @@ void MAYBE_WebRtcAudioQualityBrowserTest::SetupAndRecordAudioCall( ...@@ -688,7 +681,7 @@ void MAYBE_WebRtcAudioQualityBrowserTest::SetupAndRecordAudioCall(
HangUp(left_tab); HangUp(left_tab);
} }
void MAYBE_WebRtcAudioQualityBrowserTest::TestWithFakeDeviceGetUserMedia( void WebRtcAudioQualityBrowserTest::TestWithFakeDeviceGetUserMedia(
const std::string& constraints, const std::string& constraints,
const std::string& perf_modifier) { const std::string& perf_modifier) {
if (OnWin8OrHigher()) { if (OnWin8OrHigher()) {
...@@ -697,25 +690,22 @@ void MAYBE_WebRtcAudioQualityBrowserTest::TestWithFakeDeviceGetUserMedia( ...@@ -697,25 +690,22 @@ void MAYBE_WebRtcAudioQualityBrowserTest::TestWithFakeDeviceGetUserMedia(
return; return;
} }
base::FilePath reference_file =
test::GetReferenceFilesDir().Append(kReferenceFile);
base::FilePath recording = CreateTemporaryWaveFile(); base::FilePath recording = CreateTemporaryWaveFile();
ASSERT_NO_FATAL_FAILURE(SetupAndRecordAudioCall( ASSERT_NO_FATAL_FAILURE(SetupAndRecordAudioCall(
reference_file, recording, constraints, recording, constraints, base::TimeDelta::FromSeconds(30)));
base::TimeDelta::FromSeconds(30)));
ComputeAndPrintPesqResults(reference_file, recording, perf_modifier); ComputeAndPrintPesqResults(reference_file(), recording, perf_modifier);
DeleteFileUnlessTestFailed(recording, false); DeleteFileUnlessTestFailed(recording, false);
} }
IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest, IN_PROC_BROWSER_TEST_F(WebRtcAudioQualityBrowserTest,
MANUAL_TestCallQualityWithAudioFromFakeDevice) { MANUAL_TestCallQualityWithAudioFromFakeDevice) {
base::ScopedAllowBlockingForTesting allow_blocking; base::ScopedAllowBlockingForTesting allow_blocking;
TestWithFakeDeviceGetUserMedia(kAudioOnlyCallConstraints, "_getusermedia"); TestWithFakeDeviceGetUserMedia(kAudioOnlyCallConstraints, "_getusermedia");
} }
IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest, IN_PROC_BROWSER_TEST_F(WebRtcAudioQualityBrowserTest,
MANUAL_TestCallQualityWithAudioFromWebAudio) { MANUAL_TestCallQualityWithAudioFromWebAudio) {
base::ScopedAllowBlockingForTesting allow_blocking; base::ScopedAllowBlockingForTesting allow_blocking;
if (OnWin8OrHigher()) { if (OnWin8OrHigher()) {
...@@ -754,9 +744,7 @@ IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest, ...@@ -754,9 +744,7 @@ IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest,
// Compare with the reference file on disk (this is the same file we played // Compare with the reference file on disk (this is the same file we played
// through WebAudio earlier). // through WebAudio earlier).
base::FilePath reference_file = ComputeAndPrintPesqResults(reference_file(), recording, "_webaudio");
test::GetReferenceFilesDir().Append(kReferenceFile);
ComputeAndPrintPesqResults(reference_file, recording, "_webaudio");
DeleteFileUnlessTestFailed(recording, false); DeleteFileUnlessTestFailed(recording, false);
} }
...@@ -791,8 +779,7 @@ IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest, ...@@ -791,8 +779,7 @@ IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest,
* device currently supports, and we want to be able to compare directly. See * device currently supports, and we want to be able to compare directly. See
* http://crbug.com/421054. * http://crbug.com/421054.
*/ */
void MAYBE_WebRtcAudioQualityBrowserTest::TestAutoGainControl( void WebRtcAudioQualityBrowserTest::TestAutoGainControl(
const base::FilePath::StringType& reference_filename,
const std::string& constraints, const std::string& constraints,
const std::string& perf_modifier) { const std::string& perf_modifier) {
if (OnWin8OrHigher()) { if (OnWin8OrHigher()) {
...@@ -800,18 +787,15 @@ void MAYBE_WebRtcAudioQualityBrowserTest::TestAutoGainControl( ...@@ -800,18 +787,15 @@ void MAYBE_WebRtcAudioQualityBrowserTest::TestAutoGainControl(
LOG(ERROR) << "This test is not implemented for Win8 or higher."; LOG(ERROR) << "This test is not implemented for Win8 or higher.";
return; return;
} }
base::FilePath reference_file =
test::GetReferenceFilesDir().Append(reference_filename);
base::FilePath recording = CreateTemporaryWaveFile(); base::FilePath recording = CreateTemporaryWaveFile();
ASSERT_NO_FATAL_FAILURE(SetupAndRecordAudioCall( ASSERT_NO_FATAL_FAILURE(SetupAndRecordAudioCall(
reference_file, recording, constraints, recording, constraints, base::TimeDelta::FromSeconds(30)));
base::TimeDelta::FromSeconds(30)));
base::ScopedTempDir split_ref_files; base::ScopedTempDir split_ref_files;
ASSERT_TRUE(split_ref_files.CreateUniqueTempDirUnderPath(wav_dump_path_)); ASSERT_TRUE(split_ref_files.CreateUniqueTempDirUnderPath(wav_dump_path_));
ASSERT_NO_FATAL_FAILURE( ASSERT_NO_FATAL_FAILURE(
SplitFileOnSilenceIntoDir(reference_file, split_ref_files.GetPath())); SplitFileOnSilenceIntoDir(reference_file(), split_ref_files.GetPath()));
std::vector<base::FilePath> ref_segments = std::vector<base::FilePath> ref_segments =
ListWavFilesInDir(split_ref_files.GetPath()); ListWavFilesInDir(split_ref_files.GetPath());
...@@ -825,30 +809,30 @@ void MAYBE_WebRtcAudioQualityBrowserTest::TestAutoGainControl( ...@@ -825,30 +809,30 @@ void MAYBE_WebRtcAudioQualityBrowserTest::TestAutoGainControl(
std::vector<base::FilePath> actual_segments = std::vector<base::FilePath> actual_segments =
ListWavFilesInDir(actual_files_dir); ListWavFilesInDir(actual_files_dir);
AnalyzeSegmentsAndPrintResult( AnalyzeSegmentsAndPrintResult(ref_segments, actual_segments, reference_file(),
ref_segments, actual_segments, reference_file, perf_modifier); perf_modifier);
DeleteFileUnlessTestFailed(recording, false); DeleteFileUnlessTestFailed(recording, false);
DeleteFileUnlessTestFailed(actual_files_dir, true); DeleteFileUnlessTestFailed(actual_files_dir, true);
} }
// The AGC should apply non-zero gain here. // The AGC should apply non-zero gain here.
IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest, IN_PROC_BROWSER_TEST_F(WebRtcAudioQualityBrowserTest,
MANUAL_TestAutoGainControlOnLowAudio) { MANUAL_TestAutoGainControlOnLowAudio) {
base::ScopedAllowBlockingForTesting allow_blocking; base::ScopedAllowBlockingForTesting allow_blocking;
// Disables AEC, but leaves AGC on. // Disables AEC, but leaves AGC on.
const char* kAudioCallWithoutEchoCancellation = const char* kAudioCallWithoutEchoCancellation =
"{audio: { mandatory: { googEchoCancellation: false } } }"; "{audio: { mandatory: { googEchoCancellation: false } } }";
ASSERT_NO_FATAL_FAILURE(TestAutoGainControl( ASSERT_NO_FATAL_FAILURE(
kReferenceFile, kAudioCallWithoutEchoCancellation, "_with_agc")); TestAutoGainControl(kAudioCallWithoutEchoCancellation, "_with_agc"));
} }
// Since the AGC is off here there should be no gain at all. // Since the AGC is off here there should be no gain at all.
IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest, IN_PROC_BROWSER_TEST_F(WebRtcAudioQualityBrowserTest,
MANUAL_TestAutoGainIsOffWithAudioProcessingOff) { MANUAL_TestAutoGainIsOffWithAudioProcessingOff) {
base::ScopedAllowBlockingForTesting allow_blocking; base::ScopedAllowBlockingForTesting allow_blocking;
const char* kAudioCallWithoutAudioProcessing = const char* kAudioCallWithoutAudioProcessing =
"{audio: { mandatory: { echoCancellation: false } } }"; "{audio: { mandatory: { echoCancellation: false } } }";
ASSERT_NO_FATAL_FAILURE(TestAutoGainControl( ASSERT_NO_FATAL_FAILURE(
kReferenceFile, kAudioCallWithoutAudioProcessing, "_no_agc")); TestAutoGainControl(kAudioCallWithoutAudioProcessing, "_no_agc"));
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment