Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: chrome/browser/media/chrome_webrtc_audio_quality_browsertest.cc

Issue 934793002: Made WebRTC AQ test two-way, adjusted volume on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@threading_fake_device
Patch Set: Also re-enabling test on mac (since this patch fixes that test) Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/data/webrtc/peerconnection.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <ctime> 5 #include <ctime>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_enumerator.h" 8 #include "base/files/file_enumerator.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 content::WebContents* tab = 148 content::WebContents* tab =
149 browser()->tab_strip_model()->GetActiveWebContents(); 149 browser()->tab_strip_model()->GetActiveWebContents();
150 150
151 // Prepare the peer connections manually in this test since we don't add 151 // Prepare the peer connections manually in this test since we don't add
152 // getUserMedia-derived media streams in this test like the other tests. 152 // getUserMedia-derived media streams in this test like the other tests.
153 EXPECT_EQ("ok-peerconnection-created", 153 EXPECT_EQ("ok-peerconnection-created",
154 ExecuteJavascript("preparePeerConnection()", tab)); 154 ExecuteJavascript("preparePeerConnection()", tab));
155 return tab; 155 return tab;
156 } 156 }
157 157
158 void MuteMediaElement(const std::string& element_id,
159 content::WebContents* tab_contents) {
160 EXPECT_EQ("ok-muted", ExecuteJavascript(
161 "setMediaElementMuted('" + element_id + "', true)", tab_contents));
162 }
163
158 protected: 164 protected:
159 void TestAutoGainControl(const base::FilePath::StringType& reference_filename, 165 void TestAutoGainControl(const base::FilePath::StringType& reference_filename,
160 const std::string& constraints, 166 const std::string& constraints,
161 const std::string& perf_modifier); 167 const std::string& perf_modifier);
162 void SetupAndRecordAudioCall(const base::FilePath& reference_file, 168 void SetupAndRecordAudioCall(const base::FilePath& reference_file,
163 const base::FilePath& recording, 169 const base::FilePath& recording,
164 const std::string& constraints, 170 const std::string& constraints,
165 const base::TimeDelta recording_time); 171 const base::TimeDelta recording_time);
166 }; 172 };
167 173
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 if (!base::GetAppOutput(command_line, &result)) { 265 if (!base::GetAppOutput(command_line, &result)) {
260 LOG(ERROR) << "Failed to set source volume: output was " << result; 266 LOG(ERROR) << "Failed to set source volume: output was " << result;
261 return false; 267 return false;
262 } 268 }
263 #elif defined(OS_MACOSX) 269 #elif defined(OS_MACOSX)
264 base::CommandLine command_line( 270 base::CommandLine command_line(
265 base::FilePath(FILE_PATH_LITERAL("osascript"))); 271 base::FilePath(FILE_PATH_LITERAL("osascript")));
266 command_line.AppendArg("-e"); 272 command_line.AppendArg("-e");
267 command_line.AppendArg("set volume input volume 100"); 273 command_line.AppendArg("set volume input volume 100");
268 command_line.AppendArg("-e"); 274 command_line.AppendArg("-e");
269 command_line.AppendArg("set volume output volume 100"); 275 command_line.AppendArg("set volume output volume 85");
270 276
271 std::string result; 277 std::string result;
272 if (!base::GetAppOutput(command_line, &result)) { 278 if (!base::GetAppOutput(command_line, &result)) {
273 LOG(ERROR) << "Failed to set source volume: output was " << result; 279 LOG(ERROR) << "Failed to set source volume: output was " << result;
274 return false; 280 return false;
275 } 281 }
276 #else 282 #else
277 // Just force the volume of, say the first 5 devices. A machine will rarely 283 // Just force the volume of, say the first 5 devices. A machine will rarely
278 // have more input sources than that. This is way easier than finding the 284 // have more input sources than that. This is way easier than finding the
279 // input device we happen to be using. 285 // input device we happen to be using.
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 "audio_pesq", perf_modifier, "raw_mos", raw_mos, "score", true); 564 "audio_pesq", perf_modifier, "raw_mos", raw_mos, "score", true);
559 perf_test::PrintResult( 565 perf_test::PrintResult(
560 "audio_pesq", perf_modifier, "mos_lqo", mos_lqo, "score", true); 566 "audio_pesq", perf_modifier, "mos_lqo", mos_lqo, "score", true);
561 567
562 EXPECT_TRUE(base::DeleteFile(trimmed_reference, false)); 568 EXPECT_TRUE(base::DeleteFile(trimmed_reference, false));
563 EXPECT_TRUE(base::DeleteFile(trimmed_recording, false)); 569 EXPECT_TRUE(base::DeleteFile(trimmed_recording, false));
564 } 570 }
565 571
566 } // namespace 572 } // namespace
567 573
568 // Sets up a one-way WebRTC call and records its output to |recording|, using 574 // Sets up a two-way WebRTC call and records its output to |recording|, using
569 // getUserMedia. 575 // getUserMedia.
570 // 576 //
571 // |reference_file| should have at least two seconds of silence in the 577 // |reference_file| should have at least two seconds of silence in the
572 // beginning: otherwise all the reference audio will not be picked up by the 578 // beginning: otherwise all the reference audio will not be picked up by the
573 // recording. Note that the reference file will start playing as soon as the 579 // recording. Note that the reference file will start playing as soon as the
574 // audio device is up following the getUserMedia call in the left tab. The time 580 // audio device is up following the getUserMedia call in the left tab. The time
575 // it takes to negotiate a call isn't deterministic, but two seconds should be 581 // it takes to negotiate a call isn't deterministic, but two seconds should be
576 // plenty of time. Similarly, the recording time should be enough to catch the 582 // plenty of time. Similarly, the recording time should be enough to catch the
577 // whole reference file. If you then silence-trim the reference file and actual 583 // whole reference file. If you then silence-trim the reference file and actual
578 // file, you should end up with two time-synchronized files. 584 // file, you should end up with two time-synchronized files.
579 void MAYBE_WebRtcAudioQualityBrowserTest::SetupAndRecordAudioCall( 585 void MAYBE_WebRtcAudioQualityBrowserTest::SetupAndRecordAudioCall(
580 const base::FilePath& reference_file, 586 const base::FilePath& reference_file,
581 const base::FilePath& recording, 587 const base::FilePath& recording,
582 const std::string& constraints, 588 const std::string& constraints,
583 const base::TimeDelta recording_time) { 589 const base::TimeDelta recording_time) {
584 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 590 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
585 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); 591 ASSERT_TRUE(test::HasReferenceFilesInCheckout());
586 ASSERT_TRUE(ForceMicrophoneVolumeTo100Percent()); 592 ASSERT_TRUE(ForceMicrophoneVolumeTo100Percent());
587 593
588 ConfigureFakeDeviceToPlayFile(reference_file); 594 ConfigureFakeDeviceToPlayFile(reference_file);
589 595
590 // Create a one-way call. 596 // Create a two-way call. Mute one of the receivers though; that way it will
597 // be receiving audio bytes, but we will not be playing out of both elements.
591 GURL test_page = embedded_test_server()->GetURL(kWebRtcAudioTestHtmlPage); 598 GURL test_page = embedded_test_server()->GetURL(kWebRtcAudioTestHtmlPage);
592 content::WebContents* left_tab = 599 content::WebContents* left_tab =
593 OpenPageAndGetUserMediaInNewTabWithConstraints(test_page, constraints); 600 OpenPageAndGetUserMediaInNewTabWithConstraints(test_page, constraints);
594 SetupPeerconnectionWithLocalStream(left_tab); 601 SetupPeerconnectionWithLocalStream(left_tab);
602 MuteMediaElement("remote-view", left_tab);
595 603
596 content::WebContents* right_tab = 604 content::WebContents* right_tab =
597 OpenPageWithoutGetUserMedia(kWebRtcAudioTestHtmlPage); 605 OpenPageAndGetUserMediaInNewTabWithConstraints(test_page, constraints);
606 SetupPeerconnectionWithLocalStream(right_tab);
598 607
599 AudioRecorder recorder; 608 AudioRecorder recorder;
600 ASSERT_TRUE(recorder.StartRecording(recording_time, recording)); 609 ASSERT_TRUE(recorder.StartRecording(recording_time, recording));
601 610
602 NegotiateCall(left_tab, right_tab); 611 NegotiateCall(left_tab, right_tab);
603 612
604 ASSERT_TRUE(recorder.WaitForRecordingToEnd()); 613 ASSERT_TRUE(recorder.WaitForRecordingToEnd());
605 DVLOG(0) << "Done recording to " << recording.value() << std::endl; 614 DVLOG(0) << "Done recording to " << recording.value() << std::endl;
606 615
607 HangUp(left_tab); 616 HangUp(left_tab);
608 } 617 }
609 618
610 #if defined(OS_MACOSX)
611 // Broken on Mac for some reason: http://crbug.com/446859.
612 #define MAYBE_MANUAL_TestCallQualityWithAudioFromFakeDevice \
613 DISABLED_MANUAL_TestCallQualityWithAudioFromFakeDevice
614 #else
615 #define MAYBE_MANUAL_TestCallQualityWithAudioFromFakeDevice \
616 MANUAL_TestCallQualityWithAudioFromFakeDevice
617 #endif
618
619 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest, 619 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest,
620 MAYBE_MANUAL_TestCallQualityWithAudioFromFakeDevice) { 620 MANUAL_TestCallQualityWithAudioFromFakeDevice) {
621 if (OnWinXp() || OnWin8()) { 621 if (OnWinXp() || OnWin8()) {
622 // http://crbug.com/379798. 622 // http://crbug.com/379798.
623 LOG(ERROR) << "This test is not implemented for Windows XP/Win8."; 623 LOG(ERROR) << "This test is not implemented for Windows XP/Win8.";
624 return; 624 return;
625 } 625 }
626 626
627 base::FilePath reference_file = 627 base::FilePath reference_file =
628 test::GetReferenceFilesDir().Append(kReferenceFile); 628 test::GetReferenceFilesDir().Append(kReferenceFile);
629 base::FilePath recording = CreateTemporaryWaveFile(); 629 base::FilePath recording = CreateTemporaryWaveFile();
630 630
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 #endif 774 #endif
775 775
776 // Since the AGC is off here there should be no gain at all. 776 // Since the AGC is off here there should be no gain at all.
777 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest, 777 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest,
778 MAYBE_MANUAL_TestAutoGainIsOffWithAudioProcessingOff) { 778 MAYBE_MANUAL_TestAutoGainIsOffWithAudioProcessingOff) {
779 const char* kAudioCallWithoutAudioProcessing = 779 const char* kAudioCallWithoutAudioProcessing =
780 "{audio: { mandatory: { echoCancellation: false } } }"; 780 "{audio: { mandatory: { echoCancellation: false } } }";
781 ASSERT_NO_FATAL_FAILURE(TestAutoGainControl( 781 ASSERT_NO_FATAL_FAILURE(TestAutoGainControl(
782 kReferenceFile, kAudioCallWithoutAudioProcessing, "_no_agc")); 782 kReferenceFile, kAudioCallWithoutAudioProcessing, "_no_agc"));
783 } 783 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/webrtc/peerconnection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698