| Index: media/video/capture/fake_video_capture_device_unittest.cc
|
| diff --git a/media/video/capture/fake_video_capture_device_unittest.cc b/media/video/capture/fake_video_capture_device_unittest.cc
|
| index 929f5ecddbf3e24984703c64587b32b8e9a915ff..c3b38e97d290d41d45203d2dff40d58cc150a148 100644
|
| --- a/media/video/capture/fake_video_capture_device_unittest.cc
|
| +++ b/media/video/capture/fake_video_capture_device_unittest.cc
|
| @@ -15,6 +15,7 @@
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| using ::testing::_;
|
| +using ::testing::SaveArg;
|
|
|
| namespace media {
|
|
|
| @@ -53,6 +54,17 @@ class MockClient : public media::VideoCaptureDevice::Client {
|
| base::Callback<void(const VideoCaptureFormat&)> frame_cb_;
|
| };
|
|
|
| +class DeviceEnumerationListener :
|
| + public base::RefCounted<DeviceEnumerationListener> {
|
| + public:
|
| + MOCK_METHOD1(OnEnumeratedDevicesCallback,
|
| + void(const media::VideoCaptureDevice::Names& names));
|
| +
|
| + private:
|
| + friend class base::RefCounted<DeviceEnumerationListener>;
|
| + virtual ~DeviceEnumerationListener() {}
|
| +};
|
| +
|
| class FakeVideoCaptureDeviceTest : public testing::Test {
|
| protected:
|
| typedef media::VideoCaptureDevice::Client Client;
|
| @@ -62,7 +74,9 @@ class FakeVideoCaptureDeviceTest : public testing::Test {
|
| client_(new MockClient(
|
| base::Bind(&FakeVideoCaptureDeviceTest::OnFrameCaptured,
|
| base::Unretained(this)))),
|
| - video_capture_device_factory_(new FakeVideoCaptureDeviceFactory()) {}
|
| + video_capture_device_factory_(new FakeVideoCaptureDeviceFactory()) {
|
| + device_enumeration_listener_ = new DeviceEnumerationListener();
|
| + }
|
|
|
| virtual void SetUp() {
|
| }
|
| @@ -77,12 +91,23 @@ class FakeVideoCaptureDeviceTest : public testing::Test {
|
| run_loop_->Run();
|
| }
|
|
|
| + void EnumerateDevices(VideoCaptureDevice::Names* device_names) {
|
| + EXPECT_CALL(*device_enumeration_listener_, OnEnumeratedDevicesCallback(_))
|
| + .WillOnce(SaveArg<0>(device_names));
|
| +
|
| + video_capture_device_factory_->EnumerateDeviceNames(
|
| + base::Bind(&DeviceEnumerationListener::OnEnumeratedDevicesCallback,
|
| + device_enumeration_listener_));
|
| + base::MessageLoop::current()->RunUntilIdle();
|
| + }
|
| +
|
| const VideoCaptureFormat& last_format() const { return last_format_; }
|
|
|
| VideoCaptureDevice::Names names_;
|
| scoped_ptr<base::MessageLoop> loop_;
|
| scoped_ptr<base::RunLoop> run_loop_;
|
| scoped_ptr<MockClient> client_;
|
| + scoped_refptr<DeviceEnumerationListener> device_enumeration_listener_;
|
| VideoCaptureFormat last_format_;
|
| scoped_ptr<VideoCaptureDeviceFactory> video_capture_device_factory_;
|
| };
|
| @@ -90,13 +115,12 @@ class FakeVideoCaptureDeviceTest : public testing::Test {
|
| TEST_F(FakeVideoCaptureDeviceTest, Capture) {
|
| VideoCaptureDevice::Names names;
|
|
|
| - video_capture_device_factory_->GetDeviceNames(&names);
|
| + EnumerateDevices(&names);
|
|
|
| ASSERT_GT(static_cast<int>(names.size()), 0);
|
|
|
| scoped_ptr<VideoCaptureDevice> device(
|
| - video_capture_device_factory_->Create(
|
| - base::MessageLoopProxy::current(), names.front()));
|
| + video_capture_device_factory_->Create(names.front()));
|
| ASSERT_TRUE(device);
|
|
|
| EXPECT_CALL(*client_, OnErr()).Times(0);
|
| @@ -116,7 +140,7 @@ TEST_F(FakeVideoCaptureDeviceTest, Capture) {
|
|
|
| TEST_F(FakeVideoCaptureDeviceTest, GetDeviceSupportedFormats) {
|
| VideoCaptureDevice::Names names;
|
| - video_capture_device_factory_->GetDeviceNames(&names);
|
| + EnumerateDevices(&names);
|
|
|
| VideoCaptureFormats supported_formats;
|
| VideoCaptureDevice::Names::iterator names_iterator;
|
| @@ -144,7 +168,7 @@ TEST_F(FakeVideoCaptureDeviceTest, GetDeviceSupportedFormats) {
|
| TEST_F(FakeVideoCaptureDeviceTest, CaptureVariableResolution) {
|
| VideoCaptureDevice::Names names;
|
|
|
| - video_capture_device_factory_->GetDeviceNames(&names);
|
| + EnumerateDevices(&names);
|
| VideoCaptureParams capture_params;
|
| capture_params.requested_format.frame_size.SetSize(640, 480);
|
| capture_params.requested_format.frame_rate = 30;
|
| @@ -154,8 +178,7 @@ TEST_F(FakeVideoCaptureDeviceTest, CaptureVariableResolution) {
|
| ASSERT_GT(static_cast<int>(names.size()), 0);
|
|
|
| scoped_ptr<VideoCaptureDevice> device(
|
| - video_capture_device_factory_->Create(
|
| - base::MessageLoopProxy::current(), names.front()));
|
| + video_capture_device_factory_->Create(names.front()));
|
| ASSERT_TRUE(device);
|
|
|
| // Configure the FakeVideoCaptureDevice to use all its formats as roster.
|
|
|