Chromium Code Reviews| Index: content/renderer/media/media_stream_audio_processor_unittest.cc |
| diff --git a/content/renderer/media/media_stream_audio_processor_unittest.cc b/content/renderer/media/media_stream_audio_processor_unittest.cc |
| index cf6a5a6bf385d4e21a0fdc8af72a25e9ad0e7a3b..5cbfcae1bc7278a733d98fd95c79b2490b4cac79 100644 |
| --- a/content/renderer/media/media_stream_audio_processor_unittest.cc |
| +++ b/content/renderer/media/media_stream_audio_processor_unittest.cc |
| @@ -199,6 +199,16 @@ class MediaStreamAudioProcessorTest : public ::testing::Test { |
| #endif |
| } |
| + bool GetAec3ConfigState(MediaStreamAudioProcessor* audio_processor) { |
| + DCHECK(audio_processor); |
| + if (!audio_processor->audio_processing_) { |
| + ADD_FAILURE() << "AudioProcessing object missing where it shouldn't be"; |
| + return false; |
| + } |
| + return audio_processor->audio_processing_->GetConfig() |
| + .echo_canceller3.enabled; |
| + } |
| + |
| base::MessageLoop main_thread_message_loop_; |
| media::AudioParameters params_; |
| MediaStreamDevice::AudioDeviceParameters input_device_params_; |
| @@ -592,4 +602,51 @@ TEST_F(MediaStreamAudioProcessorTest, MAYBE_TestWithKeyboardMicChannel) { |
| audio_processor->Stop(); |
| } |
| +// Test that the OnAec3Enable method has the desired effect on the APM config. |
| +TEST_F(MediaStreamAudioProcessorTest, TestAec3Switch) { |
|
Henrik Grunell
2017/04/10 17:08:40
Great tests.
Interesting that no test has a Initi
hlundin-chromium
2017/04/11 09:19:37
Acknowledged.
|
| + MockConstraintFactory constraint_factory; |
| + scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( |
| + new WebRtcAudioDeviceImpl()); |
| + scoped_refptr<MediaStreamAudioProcessor> audio_processor( |
| + new rtc::RefCountedObject<MediaStreamAudioProcessor>( |
| + constraint_factory.CreateWebMediaConstraints(), input_device_params_, |
| + webrtc_audio_device.get())); |
| + |
| + audio_processor->OnAec3Enable(true); |
| + EXPECT_TRUE(GetAec3ConfigState(audio_processor.get())); |
| + |
| + audio_processor->OnAec3Enable(false); |
| + EXPECT_FALSE(GetAec3ConfigState(audio_processor.get())); |
| + |
| + // Stop |audio_processor| so that it removes itself from |
| + // |webrtc_audio_device| and clears its pointer to it. |
| + audio_processor->Stop(); |
| +} |
| + |
| +// Same test as above, but when AEC is disabled in the constrants. The expected |
| +// outcome is that AEC3 should be disabled in all cases. |
| +TEST_F(MediaStreamAudioProcessorTest, TestAec3Switch_AecOff) { |
| + MockConstraintFactory constraint_factory; |
| + // Disable the AEC. |
| + constraint_factory.DisableAecAudioConstraints(); |
| + scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( |
| + new WebRtcAudioDeviceImpl()); |
| + scoped_refptr<MediaStreamAudioProcessor> audio_processor( |
| + new rtc::RefCountedObject<MediaStreamAudioProcessor>( |
| + constraint_factory.CreateWebMediaConstraints(), input_device_params_, |
| + webrtc_audio_device.get())); |
| + |
| + EXPECT_FALSE(GetAec3ConfigState(audio_processor.get())); |
| + |
| + audio_processor->OnAec3Enable(true); |
| + EXPECT_FALSE(GetAec3ConfigState(audio_processor.get())); |
| + |
| + audio_processor->OnAec3Enable(false); |
| + EXPECT_FALSE(GetAec3ConfigState(audio_processor.get())); |
| + |
| + // Stop |audio_processor| so that it removes itself from |
| + // |webrtc_audio_device| and clears its pointer to it. |
| + audio_processor->Stop(); |
| +} |
| + |
| } // namespace content |