Chromium Code Reviews| Index: content/renderer/media/media_stream_dispatcher_unittest.cc |
| diff --git a/content/renderer/media/media_stream_dispatcher_unittest.cc b/content/renderer/media/media_stream_dispatcher_unittest.cc |
| index 7637e4f968b7f5f60bb0f5d959b2cee423cf479f..26debea495ab8fed3405f33675e0a9e3e91f616a 100644 |
| --- a/content/renderer/media/media_stream_dispatcher_unittest.cc |
| +++ b/content/renderer/media/media_stream_dispatcher_unittest.cc |
| @@ -12,6 +12,7 @@ |
| #include "content/public/common/media_stream_request.h" |
| #include "content/renderer/media/media_stream_dispatcher.h" |
| #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" |
| +#include "media/audio/audio_parameters.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "url/gurl.h" |
| @@ -410,4 +411,48 @@ TEST_F(MediaStreamDispatcherTest, DeviceClosed) { |
| StreamDeviceInfo::kNoId); |
| } |
| +TEST_F(MediaStreamDispatcherTest, CheckDuckingState) { |
| + scoped_ptr<MediaStreamDispatcher> dispatcher(new MediaStreamDispatcher(NULL)); |
| + scoped_ptr<MockMediaStreamDispatcherEventHandler> |
| + handler(new MockMediaStreamDispatcherEventHandler); |
| + StreamOptions components(true, false); // audio only. |
| + int ipc_request_id1 = dispatcher->next_ipc_id_; |
| + |
| + dispatcher->GenerateStream(kRequestId1, handler.get()->AsWeakPtr(), |
| + components, GURL()); |
| + EXPECT_EQ(1u, dispatcher->requests_.size()); |
| + |
| + // Ducking isn't active at this point. |
| + EXPECT_FALSE(dispatcher->IsAudioDuckingActive()); |
| + |
| + // Complete the creation of stream1 with a single audio track that has |
| + // ducking enabled. |
| + StreamDeviceInfoArray audio_device_array(1); |
| + StreamDeviceInfo& audio_device_info = audio_device_array[0]; |
| + audio_device_info.device.name = "Microphone"; |
| + audio_device_info.device.type = kAudioType; |
| + audio_device_info.session_id = kAudioSessionId; |
| + audio_device_info.device.input.effects = media::AudioParameters::DUCKING; |
|
no longer working on chromium
2014/07/08 10:42:35
do you mind adding a few lines of code to check du
tommi (sloooow) - chröme
2014/07/08 12:30:56
I think that's a good idea given my blunder in the
|
| + |
| + StreamDeviceInfoArray video_device_array; // Empty for this test. |
| + |
| + const char kStreamLabel[] = "stream1"; |
| + dispatcher->OnMessageReceived(MediaStreamMsg_StreamGenerated( |
| + kRouteId, ipc_request_id1, kStreamLabel, |
| + audio_device_array, video_device_array)); |
| + EXPECT_EQ(handler->request_id_, kRequestId1); |
| + EXPECT_EQ(0u, dispatcher->requests_.size()); |
| + |
| + // Ducking should now be reported as active. |
| + EXPECT_TRUE(dispatcher->IsAudioDuckingActive()); |
| + |
| + // Stop the device (removes the stream). |
| + dispatcher->OnMessageReceived( |
| + MediaStreamMsg_DeviceStopped(kRouteId, kStreamLabel, |
| + handler->audio_device_)); |
| + |
| + // Ducking should now be reported as inactive again. |
| + EXPECT_FALSE(dispatcher->IsAudioDuckingActive()); |
| +} |
| + |
| } // namespace content |