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 c3e2876252312169d1b28736f7702f341fd8c46b..b7ca6cf153d6800a8f8d30061bdfaee9d8ce43d4 100644 |
--- a/media/capture/video/fake_video_capture_device_unittest.cc |
+++ b/media/capture/video/fake_video_capture_device_unittest.cc |
@@ -177,14 +177,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; |
@@ -214,7 +219,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_; |
@@ -250,7 +254,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); |
@@ -274,23 +278,30 @@ TEST_F(FakeVideoCaptureDeviceTest, GetDeviceSupportedFormats) { |
VideoCaptureFormats supported_formats; |
video_capture_device_factory_->GetSupportedFormats(descriptors_iterator, |
&supported_formats); |
- ASSERT_EQ(supported_formats.size(), 4u); |
- 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); |
+ ASSERT_EQ(supported_formats.size(), 5u); |
+ 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(), 96); |
+ EXPECT_EQ(supported_formats[0].frame_size.height(), 96); |
+ 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].frame_size.width(), 320); |
+ EXPECT_EQ(supported_formats[1].frame_size.height(), 240); |
+ 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].frame_size.width(), 640); |
+ EXPECT_EQ(supported_formats[2].frame_size.height(), 480); |
+ 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].frame_size.width(), 1280); |
+ EXPECT_EQ(supported_formats[3].frame_size.height(), 720); |
+ EXPECT_EQ(supported_formats[3].pixel_format, expected_format); |
EXPECT_GE(supported_formats[3].frame_rate, 20.0); |
+ EXPECT_EQ(supported_formats[4].frame_size.width(), 1920); |
+ EXPECT_EQ(supported_formats[4].frame_size.height(), 1080); |
+ EXPECT_EQ(supported_formats[4].pixel_format, expected_format); |
+ EXPECT_GE(supported_formats[4].frame_rate, 20.0); |
} |
} |
@@ -302,7 +313,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, |
@@ -411,7 +422,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_), |
@@ -441,7 +452,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); |