Index: chrome/browser/media/chrome_webrtc_audio_quality_browsertest.cc |
diff --git a/chrome/browser/media/chrome_webrtc_audio_quality_browsertest.cc b/chrome/browser/media/chrome_webrtc_audio_quality_browsertest.cc |
index 3bce53ae1ba9b335fe2b38fd04c3220a7c90fe97..cf559b5a2e4fc38fcf2b608acebf5df5912bcdd4 100644 |
--- a/chrome/browser/media/chrome_webrtc_audio_quality_browsertest.cc |
+++ b/chrome/browser/media/chrome_webrtc_audio_quality_browsertest.cc |
@@ -54,10 +54,6 @@ |
// Test we can set up a WebRTC call and play audio through it. |
// |
-// WARNING: this test may mess with both output and input levels on your system |
-// and may cause audio to start blasting at full volume into your |
-// headphones. |
-// |
// If you're not a googler and want to run this test, you need to provide a |
// pesq binary for your platform (and sox.exe on windows). Read more on how |
// resources are managed in chrome/test/data/webrtc/resources/README. |
@@ -110,7 +106,7 @@ |
// 5. Launch chrome and try playing a video with sound. You should see |
// in the volume meter for the mix device. Configure the mix device to have |
// 50 / 100 in level. Also go into the playback tab, right-click Speakers, |
-// and set that level to 50 / 100. Otherwise you might get distortion in |
+// and set that level to 50 / 100. Otherwise you will get distortion in |
// the recording. |
class MAYBE_WebRtcAudioQualityBrowserTest : public WebRtcTestBase { |
public: |
@@ -253,7 +249,7 @@ |
base::Process recording_application_; |
}; |
-bool ForceMicrophoneLevelTo100Percent() { |
+bool ForceMicrophoneVolumeTo100Percent() { |
#if defined(OS_WIN) |
// Note: the force binary isn't in tools since it's one of our own. |
base::CommandLine command_line(test::GetReferenceFilesDir().Append( |
@@ -491,7 +487,6 @@ |
// First trim beginning and end since they are tricky for the splitter. |
base::FilePath trimmed_audio = CreateTemporaryWaveFile(); |
- // TODO(phoglund): find smarter way to do this and get rid of RemoveSilence. |
ASSERT_TRUE(RemoveSilence(to_split, trimmed_audio)); |
DVLOG(0) << "Trimmed silence: " << trimmed_audio.value() << std::endl; |
@@ -548,14 +543,24 @@ |
void ComputeAndPrintPesqResults(const base::FilePath& reference_file, |
const base::FilePath& recording, |
const std::string& perf_modifier) { |
+ base::FilePath trimmed_reference = CreateTemporaryWaveFile(); |
+ base::FilePath trimmed_recording = CreateTemporaryWaveFile(); |
+ |
+ ASSERT_TRUE(RemoveSilence(reference_file, trimmed_reference)); |
+ ASSERT_TRUE(RemoveSilence(recording, trimmed_recording)); |
+ |
std::string raw_mos; |
std::string mos_lqo; |
- ASSERT_TRUE(RunPesq(reference_file, recording, 16000, &raw_mos, &mos_lqo)); |
+ ASSERT_TRUE(RunPesq(trimmed_reference, trimmed_recording, 16000, |
+ &raw_mos, &mos_lqo)); |
perf_test::PrintResult( |
"audio_pesq", perf_modifier, "raw_mos", raw_mos, "score", true); |
perf_test::PrintResult( |
"audio_pesq", perf_modifier, "mos_lqo", mos_lqo, "score", true); |
+ |
+ EXPECT_TRUE(base::DeleteFile(trimmed_reference, false)); |
+ EXPECT_TRUE(base::DeleteFile(trimmed_recording, false)); |
} |
} // namespace |
@@ -569,7 +574,8 @@ |
// audio device is up following the getUserMedia call in the left tab. The time |
// it takes to negotiate a call isn't deterministic, but two seconds should be |
// plenty of time. Similarly, the recording time should be enough to catch the |
-// whole reference file. |
+// whole reference file. If you then silence-trim the reference file and actual |
+// file, you should end up with two time-synchronized files. |
void MAYBE_WebRtcAudioQualityBrowserTest::SetupAndRecordAudioCall( |
const base::FilePath& reference_file, |
const base::FilePath& recording, |
@@ -577,7 +583,7 @@ |
const base::TimeDelta recording_time) { |
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
ASSERT_TRUE(test::HasReferenceFilesInCheckout()); |
- ASSERT_TRUE(ForceMicrophoneLevelTo100Percent()); |
+ ASSERT_TRUE(ForceMicrophoneVolumeTo100Percent()); |
ConfigureFakeDeviceToPlayFile(reference_file); |
@@ -625,8 +631,7 @@ |
ASSERT_NO_FATAL_FAILURE(SetupAndRecordAudioCall( |
reference_file, recording, kAudioOnlyCallConstraints, |
base::TimeDelta::FromSeconds(25))); |
- ASSERT_NO_FATAL_FAILURE(ComputeAndPrintPesqResults( |
- reference_file, recording, "_getusermedia")); |
+ ComputeAndPrintPesqResults(reference_file, recording, "_getusermedia"); |
EXPECT_TRUE(base::DeleteFile(recording, false)); |
} |
@@ -641,7 +646,7 @@ |
ASSERT_TRUE(test::HasReferenceFilesInCheckout()); |
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
- ASSERT_TRUE(ForceMicrophoneLevelTo100Percent()); |
+ ASSERT_TRUE(ForceMicrophoneVolumeTo100Percent()); |
content::WebContents* left_tab = |
OpenPageWithoutGetUserMedia(kWebRtcAudioTestHtmlPage); |
@@ -671,9 +676,7 @@ |
// through WebAudio earlier). |
base::FilePath reference_file = |
test::GetReferenceFilesDir().Append(kReferenceFile); |
- ASSERT_NO_FATAL_FAILURE(ComputeAndPrintPesqResults( |
- reference_file, recording, "_webaudio")); |
- EXPECT_TRUE(base::DeleteFile(recording, false)); |
+ ComputeAndPrintPesqResults(reference_file, recording, "_webaudio"); |
} |
/** |