| Index: media/capture/video/fake_video_capture_device_unittest.cc
|
| diff --git a/media/capture/video/fake_video_capture_device_unittest.cc b/media/capture/video/fake_video_capture_device_unittest.cc
|
| index 8830c7dc1213fc4604b5becefc9632464a66e9f3..2bd0ea97e7adf209dc39a267345ca1913f17150a 100644
|
| --- a/media/capture/video/fake_video_capture_device_unittest.cc
|
| +++ b/media/capture/video/fake_video_capture_device_unittest.cc
|
| @@ -178,14 +178,19 @@ class FakeVideoCaptureDeviceBase : public ::testing::Test {
|
| protected:
|
| FakeVideoCaptureDeviceBase()
|
| : loop_(new base::MessageLoop()),
|
| - client_(new MockClient(
|
| - base::Bind(&FakeVideoCaptureDeviceBase::OnFrameCaptured,
|
| - base::Unretained(this)))),
|
| device_enumeration_listener_(new DeviceEnumerationListener()),
|
| image_capture_client_(new ImageCaptureClient()),
|
| video_capture_device_factory_(new FakeVideoCaptureDeviceFactory()) {}
|
|
|
| - void SetUp() override { EXPECT_CALL(*client_, OnError(_, _)).Times(0); }
|
| + void SetUp() override {}
|
| +
|
| + std::unique_ptr<MockClient> CreateClient() {
|
| + std::unique_ptr<MockClient> client = std::unique_ptr<MockClient>(
|
| + new MockClient(base::Bind(&FakeVideoCaptureDeviceBase::OnFrameCaptured,
|
| + base::Unretained(this))));
|
| + EXPECT_CALL(*client, OnError(_, _)).Times(0);
|
| + return client;
|
| + }
|
|
|
| void OnFrameCaptured(const VideoCaptureFormat& format) {
|
| last_format_ = format;
|
| @@ -215,7 +220,6 @@ class FakeVideoCaptureDeviceBase : public ::testing::Test {
|
| VideoCaptureDeviceDescriptors descriptors_;
|
| const std::unique_ptr<base::MessageLoop> loop_;
|
| std::unique_ptr<base::RunLoop> run_loop_;
|
| - std::unique_ptr<MockClient> client_;
|
| const scoped_refptr<DeviceEnumerationListener> device_enumeration_listener_;
|
| const scoped_refptr<ImageCaptureClient> image_capture_client_;
|
| VideoCaptureFormat last_format_;
|
| @@ -251,7 +255,7 @@ TEST_P(FakeVideoCaptureDeviceTest, CaptureUsing) {
|
| VideoCaptureParams capture_params;
|
| capture_params.requested_format.frame_size.SetSize(640, 480);
|
| capture_params.requested_format.frame_rate = testing::get<1>(GetParam());
|
| - device->AllocateAndStart(capture_params, std::move(client_));
|
| + device->AllocateAndStart(capture_params, CreateClient());
|
|
|
| WaitForCapturedFrame();
|
| EXPECT_EQ(last_format().frame_size.width(), 640);
|
| @@ -276,21 +280,24 @@ TEST_F(FakeVideoCaptureDeviceTest, GetDeviceSupportedFormats) {
|
| video_capture_device_factory_->GetSupportedFormats(descriptors_iterator,
|
| &supported_formats);
|
| ASSERT_EQ(supported_formats.size(), 4u);
|
| + const std::string device_id = descriptors_iterator.device_id;
|
| + VideoPixelFormat expected_format =
|
| + (device_id == "/dev/video1") ? PIXEL_FORMAT_Y16 : PIXEL_FORMAT_I420;
|
| EXPECT_EQ(supported_formats[0].frame_size.width(), 320);
|
| EXPECT_EQ(supported_formats[0].frame_size.height(), 240);
|
| - EXPECT_EQ(supported_formats[0].pixel_format, PIXEL_FORMAT_I420);
|
| + EXPECT_EQ(supported_formats[0].pixel_format, expected_format);
|
| EXPECT_GE(supported_formats[0].frame_rate, 20.0);
|
| EXPECT_EQ(supported_formats[1].frame_size.width(), 640);
|
| EXPECT_EQ(supported_formats[1].frame_size.height(), 480);
|
| - EXPECT_EQ(supported_formats[1].pixel_format, PIXEL_FORMAT_I420);
|
| + EXPECT_EQ(supported_formats[1].pixel_format, expected_format);
|
| EXPECT_GE(supported_formats[1].frame_rate, 20.0);
|
| EXPECT_EQ(supported_formats[2].frame_size.width(), 1280);
|
| EXPECT_EQ(supported_formats[2].frame_size.height(), 720);
|
| - EXPECT_EQ(supported_formats[2].pixel_format, PIXEL_FORMAT_I420);
|
| + EXPECT_EQ(supported_formats[2].pixel_format, expected_format);
|
| EXPECT_GE(supported_formats[2].frame_rate, 20.0);
|
| EXPECT_EQ(supported_formats[3].frame_size.width(), 1920);
|
| EXPECT_EQ(supported_formats[3].frame_size.height(), 1080);
|
| - EXPECT_EQ(supported_formats[3].pixel_format, PIXEL_FORMAT_I420);
|
| + EXPECT_EQ(supported_formats[3].pixel_format, expected_format);
|
| EXPECT_GE(supported_formats[3].frame_rate, 20.0);
|
| }
|
| }
|
| @@ -303,7 +310,7 @@ TEST_F(FakeVideoCaptureDeviceTest, GetAndSetCapabilities) {
|
| VideoCaptureParams capture_params;
|
| capture_params.requested_format.frame_size.SetSize(640, 480);
|
| capture_params.requested_format.frame_rate = 30.0;
|
| - device->AllocateAndStart(capture_params, std::move(client_));
|
| + device->AllocateAndStart(capture_params, CreateClient());
|
|
|
| VideoCaptureDevice::GetPhotoCapabilitiesCallback scoped_get_callback(
|
| base::Bind(&ImageCaptureClient::DoOnGetPhotoCapabilities,
|
| @@ -390,7 +397,7 @@ TEST_F(FakeVideoCaptureDeviceTest, TakePhoto) {
|
| VideoCaptureParams capture_params;
|
| capture_params.requested_format.frame_size.SetSize(640, 480);
|
| capture_params.requested_format.frame_rate = 30.0;
|
| - device->AllocateAndStart(capture_params, std::move(client_));
|
| + device->AllocateAndStart(capture_params, CreateClient());
|
|
|
| VideoCaptureDevice::TakePhotoCallback scoped_callback(
|
| base::Bind(&ImageCaptureClient::DoOnPhotoTaken, image_capture_client_),
|
| @@ -420,7 +427,7 @@ TEST_P(FakeVideoCaptureDeviceCommandLineTest, FrameRate) {
|
| VideoCaptureParams capture_params;
|
| capture_params.requested_format.frame_size.SetSize(1280, 720);
|
| capture_params.requested_format.frame_rate = GetParam().fps;
|
| - device->AllocateAndStart(capture_params, std::move(client_));
|
| + device->AllocateAndStart(capture_params, CreateClient());
|
|
|
| WaitForCapturedFrame();
|
| EXPECT_EQ(last_format().frame_size.width(), 1280);
|
|
|