| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <ctime> | 7 #include <ctime> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "chrome/common/chrome_paths.h" | 29 #include "chrome/common/chrome_paths.h" |
| 30 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
| 31 #include "chrome/test/base/ui_test_utils.h" | 31 #include "chrome/test/base/ui_test_utils.h" |
| 32 #include "content/public/common/content_switches.h" | 32 #include "content/public/common/content_switches.h" |
| 33 #include "content/public/test/browser_test_utils.h" | 33 #include "content/public/test/browser_test_utils.h" |
| 34 #include "media/base/audio_parameters.h" | 34 #include "media/base/audio_parameters.h" |
| 35 #include "media/base/media_switches.h" | 35 #include "media/base/media_switches.h" |
| 36 #include "net/test/embedded_test_server/embedded_test_server.h" | 36 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 37 #include "testing/perf/perf_test.h" | 37 #include "testing/perf/perf_test.h" |
| 38 | 38 |
| 39 #if defined(OS_WIN) |
| 40 #include "base/win/windows_version.h" |
| 41 #endif |
| 42 |
| 39 namespace { | 43 namespace { |
| 40 | 44 |
| 41 static const base::FilePath::CharType kReferenceFile[] = | 45 static const base::FilePath::CharType kReferenceFile[] = |
| 42 FILE_PATH_LITERAL("speech_44kHz_16bit_stereo.wav"); | 46 FILE_PATH_LITERAL("speech_44kHz_16bit_stereo.wav"); |
| 43 | 47 |
| 44 // The javascript will load the reference file relative to its location, | 48 // The javascript will load the reference file relative to its location, |
| 45 // which is in /webrtc on the web server. The files we are looking for are in | 49 // which is in /webrtc on the web server. The files we are looking for are in |
| 46 // webrtc/resources in the chrome/test/data folder. | 50 // webrtc/resources in the chrome/test/data folder. |
| 47 static const char kReferenceFileRelativeUrl[] = | 51 static const char kReferenceFileRelativeUrl[] = |
| 48 "resources/speech_44kHz_16bit_stereo.wav"; | 52 "resources/speech_44kHz_16bit_stereo.wav"; |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 // audio device is up following the getUserMedia call in the left tab. The time | 626 // audio device is up following the getUserMedia call in the left tab. The time |
| 623 // it takes to negotiate a call isn't deterministic, but five seconds should be | 627 // it takes to negotiate a call isn't deterministic, but five seconds should be |
| 624 // plenty of time. Similarly, the recording time should be enough to catch the | 628 // plenty of time. Similarly, the recording time should be enough to catch the |
| 625 // whole reference file. If you then silence-trim the reference file and actual | 629 // whole reference file. If you then silence-trim the reference file and actual |
| 626 // file, you should end up with two time-synchronized files. | 630 // file, you should end up with two time-synchronized files. |
| 627 void MAYBE_WebRtcAudioQualityBrowserTest::SetupAndRecordAudioCall( | 631 void MAYBE_WebRtcAudioQualityBrowserTest::SetupAndRecordAudioCall( |
| 628 const base::FilePath& reference_file, | 632 const base::FilePath& reference_file, |
| 629 const base::FilePath& recording, | 633 const base::FilePath& recording, |
| 630 const std::string& constraints, | 634 const std::string& constraints, |
| 631 const base::TimeDelta recording_time) { | 635 const base::TimeDelta recording_time) { |
| 636 if (OnWin7()) { |
| 637 // http://crbug.com/677256. |
| 638 LOG(ERROR) << "This test is flaky on Windows 7."; |
| 639 return; |
| 640 } |
| 641 |
| 632 ASSERT_TRUE(embedded_test_server()->Start()); | 642 ASSERT_TRUE(embedded_test_server()->Start()); |
| 633 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); | 643 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); |
| 634 ASSERT_TRUE(ForceMicrophoneVolumeTo100Percent()); | 644 ASSERT_TRUE(ForceMicrophoneVolumeTo100Percent()); |
| 635 | 645 |
| 636 ConfigureFakeDeviceToPlayFile(reference_file); | 646 ConfigureFakeDeviceToPlayFile(reference_file); |
| 637 | 647 |
| 638 // Create a two-way call. Mute one of the receivers though; that way it will | 648 // Create a two-way call. Mute one of the receivers though; that way it will |
| 639 // be receiving audio bytes, but we will not be playing out of both elements. | 649 // be receiving audio bytes, but we will not be playing out of both elements. |
| 640 GURL test_page = embedded_test_server()->GetURL(kWebRtcAudioTestHtmlPage); | 650 GURL test_page = embedded_test_server()->GetURL(kWebRtcAudioTestHtmlPage); |
| 641 content::WebContents* left_tab = | 651 content::WebContents* left_tab = |
| (...skipping 12 matching lines...) Expand all Loading... |
| 654 | 664 |
| 655 ASSERT_TRUE(recorder.WaitForRecordingToEnd()); | 665 ASSERT_TRUE(recorder.WaitForRecordingToEnd()); |
| 656 DVLOG(0) << "Done recording to " << recording.value() << std::endl; | 666 DVLOG(0) << "Done recording to " << recording.value() << std::endl; |
| 657 | 667 |
| 658 HangUp(left_tab); | 668 HangUp(left_tab); |
| 659 } | 669 } |
| 660 | 670 |
| 661 void MAYBE_WebRtcAudioQualityBrowserTest::TestWithFakeDeviceGetUserMedia( | 671 void MAYBE_WebRtcAudioQualityBrowserTest::TestWithFakeDeviceGetUserMedia( |
| 662 const std::string& constraints, | 672 const std::string& constraints, |
| 663 const std::string& perf_modifier) { | 673 const std::string& perf_modifier) { |
| 674 if (OnWin7()) { |
| 675 // http://crbug.com/677256. |
| 676 LOG(ERROR) << "This test is flaky on Windows 7."; |
| 677 return; |
| 678 } |
| 664 if (OnWin8()) { | 679 if (OnWin8()) { |
| 665 // http://crbug.com/379798. | 680 // http://crbug.com/379798. |
| 666 LOG(ERROR) << "This test is not implemented for Windows XP/Win8."; | 681 LOG(ERROR) << "This test is not implemented for Windows XP/Win8."; |
| 667 return; | 682 return; |
| 668 } | 683 } |
| 669 | 684 |
| 670 base::FilePath reference_file = | 685 base::FilePath reference_file = |
| 671 test::GetReferenceFilesDir().Append(kReferenceFile); | 686 test::GetReferenceFilesDir().Append(kReferenceFile); |
| 672 base::FilePath recording = CreateTemporaryWaveFile(); | 687 base::FilePath recording = CreateTemporaryWaveFile(); |
| 673 | 688 |
| 674 ASSERT_NO_FATAL_FAILURE(SetupAndRecordAudioCall( | 689 ASSERT_NO_FATAL_FAILURE(SetupAndRecordAudioCall( |
| 675 reference_file, recording, constraints, | 690 reference_file, recording, constraints, |
| 676 base::TimeDelta::FromSeconds(30))); | 691 base::TimeDelta::FromSeconds(30))); |
| 677 | 692 |
| 678 ComputeAndPrintPesqResults(reference_file, recording, perf_modifier); | 693 ComputeAndPrintPesqResults(reference_file, recording, perf_modifier); |
| 679 DeleteFileUnlessTestFailed(recording, false); | 694 DeleteFileUnlessTestFailed(recording, false); |
| 680 } | 695 } |
| 681 | 696 |
| 682 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest, | 697 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest, |
| 683 MANUAL_TestCallQualityWithAudioFromFakeDevice) { | 698 MANUAL_TestCallQualityWithAudioFromFakeDevice) { |
| 684 TestWithFakeDeviceGetUserMedia(kAudioOnlyCallConstraints, "_getusermedia"); | 699 TestWithFakeDeviceGetUserMedia(kAudioOnlyCallConstraints, "_getusermedia"); |
| 685 } | 700 } |
| 686 | 701 |
| 687 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest, | 702 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest, |
| 688 MANUAL_TestCallQualityWithAudioFromWebAudio) { | 703 MANUAL_TestCallQualityWithAudioFromWebAudio) { |
| 704 if (OnWin7()) { |
| 705 // http://crbug.com/677256. |
| 706 LOG(ERROR) << "This test is flaky on Windows 7."; |
| 707 return; |
| 708 } |
| 689 if (OnWin8()) { | 709 if (OnWin8()) { |
| 690 // http://crbug.com/379798. | 710 // http://crbug.com/379798. |
| 691 LOG(ERROR) << "This test is not implemented for Windows XP/Win8."; | 711 LOG(ERROR) << "This test is not implemented for Windows XP/Win8."; |
| 692 return; | 712 return; |
| 693 } | 713 } |
| 694 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); | 714 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); |
| 695 ASSERT_TRUE(embedded_test_server()->Start()); | 715 ASSERT_TRUE(embedded_test_server()->Start()); |
| 696 | 716 |
| 697 ASSERT_TRUE(ForceMicrophoneVolumeTo100Percent()); | 717 ASSERT_TRUE(ForceMicrophoneVolumeTo100Percent()); |
| 698 | 718 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 * The test only exercises digital AGC for now. | 774 * The test only exercises digital AGC for now. |
| 755 * | 775 * |
| 756 * We record in CD format here (44.1 kHz) because that's what the fake input | 776 * We record in CD format here (44.1 kHz) because that's what the fake input |
| 757 * device currently supports, and we want to be able to compare directly. See | 777 * device currently supports, and we want to be able to compare directly. See |
| 758 * http://crbug.com/421054. | 778 * http://crbug.com/421054. |
| 759 */ | 779 */ |
| 760 void MAYBE_WebRtcAudioQualityBrowserTest::TestAutoGainControl( | 780 void MAYBE_WebRtcAudioQualityBrowserTest::TestAutoGainControl( |
| 761 const base::FilePath::StringType& reference_filename, | 781 const base::FilePath::StringType& reference_filename, |
| 762 const std::string& constraints, | 782 const std::string& constraints, |
| 763 const std::string& perf_modifier) { | 783 const std::string& perf_modifier) { |
| 784 if (OnWin7()) { |
| 785 // http://crbug.com/677256. |
| 786 LOG(ERROR) << "This test is flaky on Windows 7."; |
| 787 return; |
| 788 } |
| 764 if (OnWin8()) { | 789 if (OnWin8()) { |
| 765 // http://crbug.com/379798. | 790 // http://crbug.com/379798. |
| 766 LOG(ERROR) << "This test is not implemented for Windows XP/Win8."; | 791 LOG(ERROR) << "This test is not implemented for Windows XP/Win8."; |
| 767 return; | 792 return; |
| 768 } | 793 } |
| 769 base::FilePath reference_file = | 794 base::FilePath reference_file = |
| 770 test::GetReferenceFilesDir().Append(reference_filename); | 795 test::GetReferenceFilesDir().Append(reference_filename); |
| 771 base::FilePath recording = CreateTemporaryWaveFile(); | 796 base::FilePath recording = CreateTemporaryWaveFile(); |
| 772 | 797 |
| 773 ASSERT_NO_FATAL_FAILURE(SetupAndRecordAudioCall( | 798 ASSERT_NO_FATAL_FAILURE(SetupAndRecordAudioCall( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 794 AnalyzeSegmentsAndPrintResult( | 819 AnalyzeSegmentsAndPrintResult( |
| 795 ref_segments, actual_segments, reference_file, perf_modifier); | 820 ref_segments, actual_segments, reference_file, perf_modifier); |
| 796 | 821 |
| 797 DeleteFileUnlessTestFailed(recording, false); | 822 DeleteFileUnlessTestFailed(recording, false); |
| 798 DeleteFileUnlessTestFailed(actual_files_dir, true); | 823 DeleteFileUnlessTestFailed(actual_files_dir, true); |
| 799 } | 824 } |
| 800 | 825 |
| 801 // The AGC should apply non-zero gain here. | 826 // The AGC should apply non-zero gain here. |
| 802 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest, | 827 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest, |
| 803 MANUAL_TestAutoGainControlOnLowAudio) { | 828 MANUAL_TestAutoGainControlOnLowAudio) { |
| 829 if (OnWin7()) { |
| 830 // http://crbug.com/677256. |
| 831 LOG(ERROR) << "This test is flaky on Windows 7."; |
| 832 return; |
| 833 } |
| 804 ASSERT_NO_FATAL_FAILURE(TestAutoGainControl( | 834 ASSERT_NO_FATAL_FAILURE(TestAutoGainControl( |
| 805 kReferenceFile, kAudioOnlyCallConstraints, "_with_agc")); | 835 kReferenceFile, kAudioOnlyCallConstraints, "_with_agc")); |
| 806 } | 836 } |
| 807 | 837 |
| 808 // Since the AGC is off here there should be no gain at all. | 838 // Since the AGC is off here there should be no gain at all. |
| 809 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest, | 839 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcAudioQualityBrowserTest, |
| 810 MANUAL_TestAutoGainIsOffWithAudioProcessingOff) { | 840 MANUAL_TestAutoGainIsOffWithAudioProcessingOff) { |
| 841 if (OnWin7()) { |
| 842 // http://crbug.com/677256. |
| 843 LOG(ERROR) << "This test is flaky on Windows 7."; |
| 844 return; |
| 845 } |
| 811 const char* kAudioCallWithoutAudioProcessing = | 846 const char* kAudioCallWithoutAudioProcessing = |
| 812 "{audio: { mandatory: { echoCancellation: false } } }"; | 847 "{audio: { mandatory: { echoCancellation: false } } }"; |
| 813 ASSERT_NO_FATAL_FAILURE(TestAutoGainControl( | 848 ASSERT_NO_FATAL_FAILURE(TestAutoGainControl( |
| 814 kReferenceFile, kAudioCallWithoutAudioProcessing, "_no_agc")); | 849 kReferenceFile, kAudioCallWithoutAudioProcessing, "_no_agc")); |
| 815 } | 850 } |
| OLD | NEW |