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

Unified Diff: media/capture/video/fake_video_capture_device_unittest.cc

Issue 2121043002: 16 bpp video stream capture, render and WebGL usage - Realsense R200 & SR300 support. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 2 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: 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);
« no previous file with comments | « media/capture/video/fake_video_capture_device_factory.cc ('k') | media/capture/video/linux/v4l2_capture_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698