Chromium Code Reviews| Index: content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc |
| diff --git a/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc b/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc |
| index eb56bd9802f317e91d37b0df0fc657be1bdae144..77fac5b1665e55a1d260739f8bf8b388a8d98c3b 100644 |
| --- a/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc |
| +++ b/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc |
| @@ -7,7 +7,6 @@ |
| #include "base/bind.h" |
| #include "base/message_loop.h" |
| #include "content/browser/browser_thread_impl.h" |
| -#include "content/browser/renderer_host/media/audio_input_device_manager.h" |
| #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h" |
| #include "content/browser/renderer_host/media/media_stream_manager.h" |
| #include "content/browser/renderer_host/media/mock_media_observer.h" |
| @@ -62,6 +61,15 @@ class MockMediaStreamDispatcherHost : public MediaStreamDispatcherHost, |
| components, |
| GURL()); |
| } |
| + void OnGenerateStreamForDevice(int page_request_id, |
| + const StreamOptions& components, |
| + const std::string& device_id) { |
| + MediaStreamDispatcherHost::OnGenerateStreamForDevice(kRenderId, |
| + page_request_id, |
| + components, |
| + device_id, |
| + GURL()); |
| + } |
| void OnStopGeneratedStream(const std::string& label) { |
| MediaStreamDispatcherHost::OnStopGeneratedStream(kRenderId, label); |
| } |
| @@ -172,13 +180,8 @@ class MediaStreamDispatcherHostTest : public testing::Test { |
| // Create our own MediaStreamManager. |
| audio_manager_.reset(media::AudioManager::Create()); |
| - scoped_refptr<media_stream::AudioInputDeviceManager> |
| - audio_input_device_manager( |
| - new media_stream::AudioInputDeviceManager(audio_manager_.get())); |
| - scoped_refptr<media_stream::VideoCaptureManager> video_capture_manager( |
| - new media_stream::VideoCaptureManager()); |
| - media_stream_manager_.reset(new media_stream::MediaStreamManager( |
| - audio_input_device_manager, video_capture_manager)); |
| + media_stream_manager_.reset( |
| + new media_stream::MediaStreamManager(audio_manager_.get())); |
| // Make sure we use fake devices to avoid long delays. |
| media_stream_manager_->UseFakeDevice(); |
| @@ -240,6 +243,32 @@ TEST_F(MediaStreamDispatcherHostTest, GenerateStream) { |
| EXPECT_EQ(host_->NumberOfStreams(), 0u); |
| } |
| +TEST_F(MediaStreamDispatcherHostTest, GenerateStreamForDevice) { |
|
no longer working on chromium
2012/09/10 09:11:04
+1, thanks for adding the unittest
|
| + static const char kDeviceId[] = "/dev/video0"; |
| + |
| + StreamOptions options(content::MEDIA_NO_SERVICE, |
| + content::MEDIA_DEVICE_VIDEO_CAPTURE); |
| + |
| + EXPECT_CALL(*host_, GetMediaObserver()) |
| + .WillRepeatedly(Return(media_observer_.get())); |
| + EXPECT_CALL(*host_, OnStreamGenerated(kRenderId, kPageRequestId, 0, 1)); |
| + host_->OnGenerateStreamForDevice(kPageRequestId, options, kDeviceId); |
| + |
| + EXPECT_CALL(*media_observer_.get(), OnCaptureDevicesOpened(_, _, _)); |
| + EXPECT_CALL(*media_observer_.get(), OnCaptureDevicesClosed(_, _, _)); |
| + |
| + WaitForResult(); |
| + |
| + std::string label = host_->label_; |
|
no longer working on chromium
2012/09/10 09:11:04
nit, fix the indentation.
miu
2012/09/10 21:24:38
Done.
|
| + |
| + EXPECT_EQ(0u, host_->audio_devices_.size()); |
| + EXPECT_EQ(1u, host_->video_devices_.size()); |
| + EXPECT_EQ(1u, host_->NumberOfStreams()); |
| + |
| + host_->OnStopGeneratedStream(label); |
| + EXPECT_EQ(0u, host_->NumberOfStreams()); |
| +} |
| + |
| TEST_F(MediaStreamDispatcherHostTest, GenerateThreeStreams) { |
| // This test opens three video capture devices. Two fake devices exists and it |
| // is expected the last call to |Open()| will open the first device again, but |
| @@ -330,7 +359,8 @@ TEST_F(MediaStreamDispatcherHostTest, FailDevice) { |
| EXPECT_CALL(*host_, OnVideoDeviceFailed(kRenderId, 0)); |
| int session_id = host_->video_devices_[0].session_id; |
| - media_stream_manager_->video_capture_manager()->Error(session_id); |
| + media_stream_manager_->GetVideoCaptureManager( |
| + content::MEDIA_DEVICE_VIDEO_CAPTURE)->Error(session_id); |
| WaitForResult(); |
| EXPECT_EQ(host_->video_devices_.size(), 0u); |
| EXPECT_EQ(host_->NumberOfStreams(), 1u); |