Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(938)

Unified Diff: content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc

Issue 235353002: Extract VideoCaptureDeviceFactory out of VideoCaptureDevice and use for File and FakeVCD. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 65f26180b1dd3e1129efa3b8e3a92ae3b0657ed3..32995257787e434da347f0f7da6a97a1937c7362 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
@@ -13,6 +13,7 @@
#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/media_stream_ui_proxy.h"
+#include "content/browser/renderer_host/media/video_capture_manager.h"
#include "content/common/media/media_stream_messages.h"
#include "content/common/media/media_stream_options.h"
#include "content/public/browser/media_device_id.h"
@@ -23,7 +24,7 @@
#include "content/test/test_content_client.h"
#include "ipc/ipc_message_macros.h"
#include "media/audio/mock_audio_manager.h"
-#include "media/video/capture/fake_video_capture_device.h"
+#include "media/video/capture/fake_video_capture_device_factory.h"
#include "net/url_request/url_request_context.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -219,7 +220,15 @@ class MediaStreamDispatcherHostTest : public testing::Test {
// Create our own MediaStreamManager.
media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get()));
// Make sure we use fake devices to avoid long delays.
- media_stream_manager_->UseFakeDevice();
+ media_stream_manager_->UseFakeVideoDevice(
+ scoped_ptr<media::VideoCaptureDeviceFactory>(
+ new media::FakeVideoCaptureDeviceFactory()));
+ video_capture_device_factory_ =
+ static_cast<media::FakeVideoCaptureDeviceFactory*>(
+ media_stream_manager_->video_capture_manager()
+ ->video_capture_device_factory());
+ DCHECK(video_capture_device_factory_);
+ media_stream_manager_->UseFakeAudioDevice();
host_ = new MockMediaStreamDispatcherHost(
browser_context_.GetResourceContext()->GetMediaDeviceIDSalt(),
@@ -236,7 +245,7 @@ class MediaStreamDispatcherHostTest : public testing::Test {
}
virtual void SetUp() OVERRIDE {
- media::FakeVideoCaptureDevice::GetDeviceNames(&physical_video_devices_);
+ video_capture_device_factory_->GetDeviceNames(&physical_video_devices_);
ASSERT_GT(physical_video_devices_.size(), 0u);
audio_manager_->GetAudioInputDeviceNames(&physical_audio_devices_);
@@ -386,6 +395,7 @@ class MediaStreamDispatcherHostTest : public testing::Test {
media::AudioDeviceNames physical_audio_devices_;
media::VideoCaptureDevice::Names physical_video_devices_;
GURL origin_;
+ media::FakeVideoCaptureDeviceFactory* video_capture_device_factory_;
};
TEST_F(MediaStreamDispatcherHostTest, GenerateStreamWithVideoOnly) {
@@ -671,8 +681,8 @@ TEST_F(MediaStreamDispatcherHostTest,
TEST_F(MediaStreamDispatcherHostTest, GenerateStreamsNoAvailableVideoDevice) {
size_t number_of_fake_devices = physical_video_devices_.size();
- media::FakeVideoCaptureDevice::SetNumberOfFakeDevices(0);
- media::FakeVideoCaptureDevice::GetDeviceNames(&physical_video_devices_);
+ video_capture_device_factory_->set_number_of_devices(0);
+ video_capture_device_factory_->GetDeviceNames(&physical_video_devices_);
StreamOptions options(true, true);
SetupFakeUI(false);
@@ -680,7 +690,7 @@ TEST_F(MediaStreamDispatcherHostTest, GenerateStreamsNoAvailableVideoDevice) {
MEDIA_DEVICE_NO_HARDWARE);
// Reset the number of fake devices for next test.
- media::FakeVideoCaptureDevice::SetNumberOfFakeDevices(number_of_fake_devices);
+ video_capture_device_factory_->set_number_of_devices(number_of_fake_devices);
}
// Test that if a OnStopStreamDevice message is received for a device that has
@@ -831,7 +841,7 @@ TEST_F(MediaStreamDispatcherHostTest, VideoDeviceUnplugged) {
EXPECT_EQ(host_->audio_devices_.size(), 1u);
EXPECT_EQ(host_->video_devices_.size(), 1u);
- media::FakeVideoCaptureDevice::SetNumberOfFakeDevices(0);
+ video_capture_device_factory_->set_number_of_devices(0);
base::RunLoop run_loop;
EXPECT_CALL(*host_.get(), OnDeviceStopped(kRenderId))
@@ -841,7 +851,7 @@ TEST_F(MediaStreamDispatcherHostTest, VideoDeviceUnplugged) {
run_loop.Run();
- media::FakeVideoCaptureDevice::SetNumberOfFakeDevices(number_of_fake_devices);
+ video_capture_device_factory_->set_number_of_devices(number_of_fake_devices);
}
TEST_F(MediaStreamDispatcherHostTest, EnumerateAudioDevices) {

Powered by Google App Engine
This is Rietveld 408576698