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 ba938a6d019adcf101f9d03f4df938520dff8d2b..f5fc436c4f7272a389d3a2d5935108172039add9 100644 |
| --- a/content/renderer/media/media_stream_audio_processor_unittest.cc |
| +++ b/content/renderer/media/media_stream_audio_processor_unittest.cc |
| @@ -11,6 +11,7 @@ |
| #include "content/public/common/content_switches.h" |
| #include "content/public/common/media_stream_request.h" |
| #include "content/renderer/media/media_stream_audio_processor.h" |
| +#include "content/renderer/media/media_stream_audio_processor_options.h" |
| #include "content/renderer/media/mock_media_constraint_factory.h" |
| #include "media/audio/audio_parameters.h" |
| #include "media/base/audio_bus.h" |
| @@ -153,13 +154,13 @@ class MediaStreamAudioProcessorTest : public ::testing::Test { |
| TEST_F(MediaStreamAudioProcessorTest, WithoutAudioProcessing) { |
| // Setup the audio processor without enabling the flag. |
| - blink::WebMediaConstraints constraints; |
| + MockMediaConstraintFactory constraint_factory; |
| scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( |
| new WebRtcAudioDeviceImpl()); |
| scoped_refptr<MediaStreamAudioProcessor> audio_processor( |
| new talk_base::RefCountedObject<MediaStreamAudioProcessor>( |
| - constraints, 0, MEDIA_DEVICE_AUDIO_CAPTURE, |
| - webrtc_audio_device.get())); |
| + constraint_factory.CreateWebMediaConstraints(), 0, |
| + MEDIA_DEVICE_AUDIO_CAPTURE, webrtc_audio_device.get())); |
| EXPECT_FALSE(audio_processor->has_audio_processing()); |
| audio_processor->OnCaptureFormatChanged(params_); |
| @@ -176,13 +177,13 @@ TEST_F(MediaStreamAudioProcessorTest, WithAudioProcessing) { |
| // Setup the audio processor with the flag enabled. |
| CommandLine::ForCurrentProcess()->AppendSwitch( |
| switches::kEnableAudioTrackProcessing); |
| - blink::WebMediaConstraints constraints; |
| + MockMediaConstraintFactory constraint_factory; |
| scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( |
| new WebRtcAudioDeviceImpl()); |
| scoped_refptr<MediaStreamAudioProcessor> audio_processor( |
| new talk_base::RefCountedObject<MediaStreamAudioProcessor>( |
| - constraints, 0, MEDIA_DEVICE_AUDIO_CAPTURE, |
| - webrtc_audio_device.get())); |
| + constraint_factory.CreateWebMediaConstraints(), 0, |
| + MEDIA_DEVICE_AUDIO_CAPTURE, webrtc_audio_device.get())); |
| EXPECT_TRUE(audio_processor->has_audio_processing()); |
| audio_processor->OnCaptureFormatChanged(params_); |
| VerifyDefaultComponents(audio_processor); |
| @@ -200,14 +201,14 @@ TEST_F(MediaStreamAudioProcessorTest, VerifyTabCaptureWithoutAudioProcessing) { |
| // Setup the audio processor with enabling the flag. |
| CommandLine::ForCurrentProcess()->AppendSwitch( |
| switches::kEnableAudioTrackProcessing); |
| - blink::WebMediaConstraints constraints; |
| + MockMediaConstraintFactory constraint_factory; |
| scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( |
| new WebRtcAudioDeviceImpl()); |
| // Create MediaStreamAudioProcessor instance for MEDIA_TAB_AUDIO_CAPTURE type. |
| scoped_refptr<MediaStreamAudioProcessor> audio_processor( |
| new talk_base::RefCountedObject<MediaStreamAudioProcessor>( |
| - constraints, 0, MEDIA_TAB_AUDIO_CAPTURE, |
| - webrtc_audio_device.get())); |
| + constraint_factory.CreateWebMediaConstraints(), 0, |
| + MEDIA_TAB_AUDIO_CAPTURE, webrtc_audio_device.get())); |
| EXPECT_FALSE(audio_processor->has_audio_processing()); |
| audio_processor->OnCaptureFormatChanged(params_); |
| @@ -219,8 +220,8 @@ TEST_F(MediaStreamAudioProcessorTest, VerifyTabCaptureWithoutAudioProcessing) { |
| // Create MediaStreamAudioProcessor instance for MEDIA_LOOPBACK_AUDIO_CAPTURE. |
| audio_processor = |
| new talk_base::RefCountedObject<MediaStreamAudioProcessor>( |
| - constraints, 0, MEDIA_LOOPBACK_AUDIO_CAPTURE, |
| - webrtc_audio_device.get()); |
| + constraint_factory.CreateWebMediaConstraints(), 0, |
| + MEDIA_LOOPBACK_AUDIO_CAPTURE, webrtc_audio_device.get()); |
| EXPECT_FALSE(audio_processor->has_audio_processing()); |
| // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives |
| @@ -254,4 +255,52 @@ TEST_F(MediaStreamAudioProcessorTest, TurnOffDefaultConstraints) { |
| audio_processor = NULL; |
| } |
| +TEST_F(MediaStreamAudioProcessorTest, VerifyConstraints) { |
| + // Setup the audio processor with enabling the flag. |
| + CommandLine::ForCurrentProcess()->AppendSwitch( |
| + switches::kEnableAudioTrackProcessing); |
| + |
| + static const char* kDefaultAudioConstraints[] = { |
| + kEchoCancellation, |
|
tommi (sloooow) - chröme
2014/04/08 10:49:30
fix indent
no longer working on chromium
2014/04/11 08:56:30
Done.
|
| + kGoogEchoCancellation, |
| + kGoogExperimentalEchoCancellation, |
| + kGoogAutoGainControl, |
| + kGoogExperimentalAutoGainControl, |
| + kGoogNoiseSuppression, |
| + kGoogExperimentalNoiseSuppression, |
| + kGoogHighpassFilter, |
| + kGoogTypingNoiseDetection, |
| + kGoogAudioMirroring |
| + }; |
| + |
| + // Verify mandatory constraints. |
| + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kDefaultAudioConstraints); ++i) { |
| + MockMediaConstraintFactory constraint_factory; |
| + constraint_factory.AddMandatory(kDefaultAudioConstraints[i], false); |
|
tommi (sloooow) - chröme
2014/04/08 10:49:30
looks like you're exchanging bool for what used to
no longer working on chromium
2014/04/11 08:56:30
MockMediaConstraintFactory::AddMandatory takes int
|
| + blink::WebMediaConstraints constraints = |
| + constraint_factory.CreateWebMediaConstraints(); |
| + EXPECT_FALSE(GetPropertyFromConstraints(constraints, |
| + kDefaultAudioConstraints[i], |
| + 0, MEDIA_DEVICE_AUDIO_CAPTURE)); |
| + } |
| + |
| + // Verify optional constraints. |
| + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kDefaultAudioConstraints); ++i) { |
| + MockMediaConstraintFactory constraint_factory; |
| + constraint_factory.AddOptional(kDefaultAudioConstraints[i], false); |
| + blink::WebMediaConstraints constraints = |
| + constraint_factory.CreateWebMediaConstraints(); |
| + EXPECT_FALSE(GetPropertyFromConstraints(constraints, |
| + kDefaultAudioConstraints[i], |
| + 0, MEDIA_DEVICE_AUDIO_CAPTURE)); |
| + } |
| + |
| + // Verify echo cancellation is off when platform aec effect is on. |
| + MockMediaConstraintFactory constraint_factory; |
| + EXPECT_FALSE(GetPropertyFromConstraints( |
| + constraint_factory.CreateWebMediaConstraints(), |
| + kGoogEchoCancellation, |
| + media::AudioParameters::ECHO_CANCELLER, MEDIA_DEVICE_AUDIO_CAPTURE)); |
| +} |
| + |
|
perkj_chrome
2014/04/08 10:28:12
Add test to see that gum fail if an unsupported ma
no longer working on chromium
2014/04/11 08:56:30
Done.
|
| } // namespace content |