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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // devices. Tick 'show disabled devices'. | 75 // devices. Tick 'show disabled devices'. |
76 // 3. You should see a 'stero mix' device - this is what your speakers output. | 76 // 3. You should see a 'stero mix' device - this is what your speakers output. |
77 // Right click > Properties. | 77 // Right click > Properties. |
78 // 4. In the Listen tab for the mix device, check the 'listen to this device' | 78 // 4. In the Listen tab for the mix device, check the 'listen to this device' |
79 // checkbox. Ensure the mix device is the default recording device. | 79 // checkbox. Ensure the mix device is the default recording device. |
80 // 5. Launch chrome and try playing a video with sound. You should see | 80 // 5. Launch chrome and try playing a video with sound. You should see |
81 // in the volume meter for the mix device. Configure the mix device to have | 81 // in the volume meter for the mix device. Configure the mix device to have |
82 // 50 / 100 in level. Also go into the playback tab, right-click Speakers, | 82 // 50 / 100 in level. Also go into the playback tab, right-click Speakers, |
83 // and set that level to 50 / 100. Otherwise you will get distortion in | 83 // and set that level to 50 / 100. Otherwise you will get distortion in |
84 // the recording. | 84 // the recording. |
85 class WebRtcAudioQualityBrowserTest : public WebRtcTestBase, | 85 class WebRtcAudioQualityBrowserTest : public WebRtcTestBase { |
86 public testing::WithParamInterface<bool> { | |
87 public: | 86 public: |
88 WebRtcAudioQualityBrowserTest() {} | 87 WebRtcAudioQualityBrowserTest() {} |
89 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 88 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
90 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. | 89 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. |
91 } | 90 } |
92 | 91 |
93 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 92 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
94 // This test expects real device handling and requires a real webcam / audio | 93 // This test expects real device handling and requires a real webcam / audio |
95 // device; it will not work with fake devices. | 94 // device; it will not work with fake devices. |
96 EXPECT_FALSE(command_line->HasSwitch( | 95 EXPECT_FALSE(command_line->HasSwitch( |
97 switches::kUseFakeDeviceForMediaStream)); | 96 switches::kUseFakeDeviceForMediaStream)); |
98 EXPECT_FALSE(command_line->HasSwitch( | 97 EXPECT_FALSE(command_line->HasSwitch( |
99 switches::kUseFakeUIForMediaStream)); | 98 switches::kUseFakeUIForMediaStream)); |
100 | |
101 bool enable_audio_track_processing = GetParam(); | |
102 if (!enable_audio_track_processing) | |
103 command_line->AppendSwitch(switches::kDisableAudioTrackProcessing); | |
104 } | 99 } |
105 | 100 |
106 void AddAudioFile(const std::string& input_file_relative_url, | 101 void AddAudioFile(const std::string& input_file_relative_url, |
107 content::WebContents* tab_contents) { | 102 content::WebContents* tab_contents) { |
108 EXPECT_EQ("ok-added", ExecuteJavascript( | 103 EXPECT_EQ("ok-added", ExecuteJavascript( |
109 "addAudioFile('" + input_file_relative_url + "')", tab_contents)); | 104 "addAudioFile('" + input_file_relative_url + "')", tab_contents)); |
110 } | 105 } |
111 | 106 |
112 void PlayAudioFile(content::WebContents* tab_contents) { | 107 void PlayAudioFile(content::WebContents* tab_contents) { |
113 EXPECT_EQ("ok-playing", ExecuteJavascript("playAudioFile()", tab_contents)); | 108 EXPECT_EQ("ok-playing", ExecuteJavascript("playAudioFile()", tab_contents)); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 // There are two tab-separated numbers on the format x.xxx, e.g. 5 chars each. | 323 // There are two tab-separated numbers on the format x.xxx, e.g. 5 chars each. |
329 std::size_t first_number_pos = anchor_pos + result_anchor.length(); | 324 std::size_t first_number_pos = anchor_pos + result_anchor.length(); |
330 *raw_mos = result.substr(first_number_pos, 5); | 325 *raw_mos = result.substr(first_number_pos, 5); |
331 EXPECT_TRUE(CanParseAsFloat(*raw_mos)) << "Failed to parse raw MOS number."; | 326 EXPECT_TRUE(CanParseAsFloat(*raw_mos)) << "Failed to parse raw MOS number."; |
332 *mos_lqo = result.substr(first_number_pos + 5 + 1, 5); | 327 *mos_lqo = result.substr(first_number_pos + 5 + 1, 5); |
333 EXPECT_TRUE(CanParseAsFloat(*mos_lqo)) << "Failed to parse MOS LQO number."; | 328 EXPECT_TRUE(CanParseAsFloat(*mos_lqo)) << "Failed to parse MOS LQO number."; |
334 | 329 |
335 return true; | 330 return true; |
336 } | 331 } |
337 | 332 |
338 static const bool kRunTestsWithFlag[] = { false, true }; | |
339 INSTANTIATE_TEST_CASE_P(WebRtcAudioQualityBrowserTests, | |
340 WebRtcAudioQualityBrowserTest, | |
341 testing::ValuesIn(kRunTestsWithFlag)); | |
342 | |
343 #if defined(OS_LINUX) || defined(OS_WIN) | 333 #if defined(OS_LINUX) || defined(OS_WIN) |
344 // Only implemented on Linux and Windows for now. | 334 // Only implemented on Linux and Windows for now. |
345 #define MAYBE_MANUAL_TestAudioQuality MANUAL_TestAudioQuality | 335 #define MAYBE_MANUAL_TestAudioQuality MANUAL_TestAudioQuality |
346 #else | 336 #else |
347 #define MAYBE_MANUAL_TestAudioQuality DISABLED_MANUAL_TestAudioQuality | 337 #define MAYBE_MANUAL_TestAudioQuality DISABLED_MANUAL_TestAudioQuality |
348 #endif | 338 #endif |
349 | 339 |
350 IN_PROC_BROWSER_TEST_P(WebRtcAudioQualityBrowserTest, | 340 IN_PROC_BROWSER_TEST_F(WebRtcAudioQualityBrowserTest, |
351 MAYBE_MANUAL_TestAudioQuality) { | 341 MAYBE_MANUAL_TestAudioQuality) { |
352 if (OnWinXp()) { | 342 if (OnWinXp()) { |
353 LOG(ERROR) << "This test is not implemented for Windows XP."; | 343 LOG(ERROR) << "This test is not implemented for Windows XP."; |
354 return; | 344 return; |
355 } | 345 } |
356 if (OnWin8()) { | 346 if (OnWin8()) { |
357 // http://crbug.com/379798. | 347 // http://crbug.com/379798. |
358 LOG(ERROR) << "Temporarily disabled for Win 8."; | 348 LOG(ERROR) << "Temporarily disabled for Win 8."; |
359 return; | 349 return; |
360 } | 350 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 test::GetReferenceFilesDir().Append(kReferenceFile); | 407 test::GetReferenceFilesDir().Append(kReferenceFile); |
418 ASSERT_TRUE(RunPesq(reference_file_in_test_dir, trimmed_recording, 16000, | 408 ASSERT_TRUE(RunPesq(reference_file_in_test_dir, trimmed_recording, 16000, |
419 &raw_mos, &mos_lqo)); | 409 &raw_mos, &mos_lqo)); |
420 | 410 |
421 perf_test::PrintResult("audio_pesq", "", "raw_mos", raw_mos, "score", true); | 411 perf_test::PrintResult("audio_pesq", "", "raw_mos", raw_mos, "score", true); |
422 perf_test::PrintResult("audio_pesq", "", "mos_lqo", mos_lqo, "score", true); | 412 perf_test::PrintResult("audio_pesq", "", "mos_lqo", mos_lqo, "score", true); |
423 | 413 |
424 EXPECT_TRUE(base::DeleteFile(recording, false)); | 414 EXPECT_TRUE(base::DeleteFile(recording, false)); |
425 EXPECT_TRUE(base::DeleteFile(trimmed_recording, false)); | 415 EXPECT_TRUE(base::DeleteFile(trimmed_recording, false)); |
426 } | 416 } |
OLD | NEW |