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 6cf58e15a3a11d68780db3c01efd3878176c6740..53e2a46738b7b72eee58355f94a9c6196ca6e4fa 100644 |
--- a/media/capture/video/fake_video_capture_device_unittest.cc |
+++ b/media/capture/video/fake_video_capture_device_unittest.cc |
@@ -179,14 +179,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; |
@@ -216,7 +221,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_; |
@@ -252,7 +256,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); |
@@ -277,21 +281,27 @@ 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 |
+ : (device_id == "/dev/video2") |
+ ? PIXEL_FORMAT_Y8 |
+ : 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); |
} |
} |
@@ -304,7 +314,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, |
@@ -381,7 +391,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_), |
@@ -411,7 +421,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); |