Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/process/launch.h" | 10 #include "base/process/launch.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 // devices. Tick 'show disabled devices'. | 82 // devices. Tick 'show disabled devices'. |
| 83 // 3. You should see a 'stero mix' device - this is what your speakers output. | 83 // 3. You should see a 'stero mix' device - this is what your speakers output. |
| 84 // Right click > Properties. | 84 // Right click > Properties. |
| 85 // 4. In the Listen tab for the mix device, check the 'listen to this device' | 85 // 4. In the Listen tab for the mix device, check the 'listen to this device' |
| 86 // checkbox. Ensure the mix device is the default recording device. | 86 // checkbox. Ensure the mix device is the default recording device. |
| 87 // 5. Launch chrome and try playing a video with sound. You should see | 87 // 5. Launch chrome and try playing a video with sound. You should see |
| 88 // in the volume meter for the mix device. Configure the mix device to have | 88 // in the volume meter for the mix device. Configure the mix device to have |
| 89 // 50 / 100 in level. Also go into the playback tab, right-click Speakers, | 89 // 50 / 100 in level. Also go into the playback tab, right-click Speakers, |
| 90 // and set that level to 50 / 100. Otherwise you will get distortion in | 90 // and set that level to 50 / 100. Otherwise you will get distortion in |
| 91 // the recording. | 91 // the recording. |
| 92 class WebRtcAudioQualityBrowserTest : public WebRtcTestBase { | 92 class WebRtcAudioQualityBrowserTest : public WebRtcTestBase, |
| 93 public testing::WithParamInterface<bool> { | |
| 93 public: | 94 public: |
| 95 WebRtcAudioQualityBrowserTest() : enable_audio_track_processing_(GetParam()) { | |
|
phoglund_chromium
2014/03/13 09:04:49
It's not necessary to store this as a member varia
no longer working on chromium
2014/03/13 09:58:08
Done.
| |
| 96 } | |
| 94 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 97 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 95 PeerConnectionServerRunner::KillAllPeerConnectionServersOnCurrentSystem(); | 98 PeerConnectionServerRunner::KillAllPeerConnectionServersOnCurrentSystem(); |
| 96 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. | 99 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. |
| 97 } | 100 } |
| 98 | 101 |
| 99 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 102 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 100 // This test expects real device handling and requires a real webcam / audio | 103 // This test expects real device handling and requires a real webcam / audio |
| 101 // device; it will not work with fake devices. | 104 // device; it will not work with fake devices. |
| 102 EXPECT_FALSE(command_line->HasSwitch( | 105 EXPECT_FALSE(command_line->HasSwitch( |
| 103 switches::kUseFakeDeviceForMediaStream)); | 106 switches::kUseFakeDeviceForMediaStream)); |
| 104 EXPECT_FALSE(command_line->HasSwitch( | 107 EXPECT_FALSE(command_line->HasSwitch( |
| 105 switches::kUseFakeUIForMediaStream)); | 108 switches::kUseFakeUIForMediaStream)); |
| 109 if (enable_audio_track_processing_) { | |
| 110 command_line->AppendSwitch(switches::kEnableAudioTrackProcessing); | |
| 111 } | |
| 106 } | 112 } |
| 107 | 113 |
| 108 bool HasAllRequiredResources() { | 114 bool HasAllRequiredResources() { |
| 109 base::FilePath reference_file = GetTestDataDir().Append(kReferenceFile); | 115 base::FilePath reference_file = GetTestDataDir().Append(kReferenceFile); |
| 110 if (!base::PathExists(reference_file)) { | 116 if (!base::PathExists(reference_file)) { |
| 111 LOG(ERROR) << "Cannot find the reference file to be used for audio " | 117 LOG(ERROR) << "Cannot find the reference file to be used for audio " |
| 112 << "quality comparison: " << reference_file.value(); | 118 << "quality comparison: " << reference_file.value(); |
| 113 return false; | 119 return false; |
| 114 } | 120 } |
| 115 return true; | 121 return true; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 140 base::FilePath CreateTemporaryWaveFile() { | 146 base::FilePath CreateTemporaryWaveFile() { |
| 141 base::FilePath filename; | 147 base::FilePath filename; |
| 142 EXPECT_TRUE(base::CreateTemporaryFile(&filename)); | 148 EXPECT_TRUE(base::CreateTemporaryFile(&filename)); |
| 143 base::FilePath wav_filename = | 149 base::FilePath wav_filename = |
| 144 filename.AddExtension(FILE_PATH_LITERAL(".wav")); | 150 filename.AddExtension(FILE_PATH_LITERAL(".wav")); |
| 145 EXPECT_TRUE(base::Move(filename, wav_filename)); | 151 EXPECT_TRUE(base::Move(filename, wav_filename)); |
| 146 return wav_filename; | 152 return wav_filename; |
| 147 } | 153 } |
| 148 | 154 |
| 149 PeerConnectionServerRunner peerconnection_server_; | 155 PeerConnectionServerRunner peerconnection_server_; |
| 156 bool enable_audio_track_processing_; | |
| 150 }; | 157 }; |
| 151 | 158 |
| 152 class AudioRecorder { | 159 class AudioRecorder { |
| 153 public: | 160 public: |
| 154 AudioRecorder(): recording_application_(base::kNullProcessHandle) {} | 161 AudioRecorder(): recording_application_(base::kNullProcessHandle) {} |
| 155 ~AudioRecorder() {} | 162 ~AudioRecorder() {} |
| 156 | 163 |
| 157 // Starts the recording program for the specified duration. Returns true | 164 // Starts the recording program for the specified duration. Returns true |
| 158 // on success. | 165 // on success. |
| 159 bool StartRecording(int duration_sec, const base::FilePath& output_file, | 166 bool StartRecording(int duration_sec, const base::FilePath& output_file, |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 // There are two tab-separated numbers on the format x.xxx, e.g. 5 chars each. | 361 // There are two tab-separated numbers on the format x.xxx, e.g. 5 chars each. |
| 355 std::size_t first_number_pos = anchor_pos + result_anchor.length(); | 362 std::size_t first_number_pos = anchor_pos + result_anchor.length(); |
| 356 *raw_mos = result.substr(first_number_pos, 5); | 363 *raw_mos = result.substr(first_number_pos, 5); |
| 357 EXPECT_TRUE(CanParseAsFloat(*raw_mos)) << "Failed to parse raw MOS number."; | 364 EXPECT_TRUE(CanParseAsFloat(*raw_mos)) << "Failed to parse raw MOS number."; |
| 358 *mos_lqo = result.substr(first_number_pos + 5 + 1, 5); | 365 *mos_lqo = result.substr(first_number_pos + 5 + 1, 5); |
| 359 EXPECT_TRUE(CanParseAsFloat(*mos_lqo)) << "Failed to parse MOS LQO number."; | 366 EXPECT_TRUE(CanParseAsFloat(*mos_lqo)) << "Failed to parse MOS LQO number."; |
| 360 | 367 |
| 361 return true; | 368 return true; |
| 362 } | 369 } |
| 363 | 370 |
| 371 static const bool kRunTestsWithFlag[] = { false, true }; | |
| 372 INSTANTIATE_TEST_CASE_P(WebRtcAudioQualityBrowserTests, | |
| 373 WebRtcAudioQualityBrowserTest, | |
| 374 testing::ValuesIn(kRunTestsWithFlag)); | |
| 375 | |
| 364 // Should be enabled for Linux, but is flaky. http://crbug.com/340197. | 376 // Should be enabled for Linux, but is flaky. http://crbug.com/340197. |
| 365 #if defined(OS_WIN) | 377 #if defined(OS_WIN) |
| 366 // Only implemented on Linux and Windows for now. | 378 // Only implemented on Linux and Windows for now. |
| 367 #define MAYBE_MANUAL_TestAudioQuality MANUAL_TestAudioQuality | 379 #define MAYBE_MANUAL_TestAudioQuality MANUAL_TestAudioQuality |
| 368 #else | 380 #else |
| 369 #define MAYBE_MANUAL_TestAudioQuality DISABLED_MANUAL_TestAudioQuality | 381 #define MAYBE_MANUAL_TestAudioQuality DISABLED_MANUAL_TestAudioQuality |
| 370 #endif | 382 #endif |
| 371 | 383 |
| 372 IN_PROC_BROWSER_TEST_F(WebRtcAudioQualityBrowserTest, | 384 IN_PROC_BROWSER_TEST_P(WebRtcAudioQualityBrowserTest, |
| 373 MAYBE_MANUAL_TestAudioQuality) { | 385 MAYBE_MANUAL_TestAudioQuality) { |
| 374 #if defined(OS_WIN) | 386 #if defined(OS_WIN) |
| 375 if (base::win::GetVersion() < base::win::VERSION_VISTA) { | 387 if (base::win::GetVersion() < base::win::VERSION_VISTA) { |
| 376 // It would take work to implement this on XP; not prioritized right now. | 388 // It would take work to implement this on XP; not prioritized right now. |
| 377 LOG(ERROR) << "This test is not implemented for Windows XP."; | 389 LOG(ERROR) << "This test is not implemented for Windows XP."; |
| 378 return; | 390 return; |
| 379 } | 391 } |
| 380 #endif | 392 #endif |
| 381 ASSERT_TRUE(HasAllRequiredResources()); | 393 ASSERT_TRUE(HasAllRequiredResources()); |
| 382 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 394 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 &raw_mos, &mos_lqo)); | 453 &raw_mos, &mos_lqo)); |
| 442 | 454 |
| 443 perf_test::PrintResult("audio_pesq", "", "raw_mos", raw_mos, "score", true); | 455 perf_test::PrintResult("audio_pesq", "", "raw_mos", raw_mos, "score", true); |
| 444 perf_test::PrintResult("audio_pesq", "", "mos_lqo", mos_lqo, "score", true); | 456 perf_test::PrintResult("audio_pesq", "", "mos_lqo", mos_lqo, "score", true); |
| 445 | 457 |
| 446 EXPECT_TRUE(base::DeleteFile(recording, false)); | 458 EXPECT_TRUE(base::DeleteFile(recording, false)); |
| 447 EXPECT_TRUE(base::DeleteFile(trimmed_recording, false)); | 459 EXPECT_TRUE(base::DeleteFile(trimmed_recording, false)); |
| 448 | 460 |
| 449 ASSERT_TRUE(peerconnection_server_.Stop()); | 461 ASSERT_TRUE(peerconnection_server_.Stop()); |
| 450 } | 462 } |
| OLD | NEW |