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

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

Issue 24079003: Add VideoCaptureDevice::GetDeviceSupportedFormats to interface + implementation for Linux and Fake (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed inexistent video_capture_device_dummy; also removed from media.gyp targets. Created 7 years, 3 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/video/capture/video_capture_device_unittest.cc
diff --git a/media/video/capture/video_capture_device_unittest.cc b/media/video/capture/video_capture_device_unittest.cc
index 586060f169fdac71b838effc7e976607e8f528ae..234e04ae5bb66efe3c5cf041832153fe150e4bcd 100644
--- a/media/video/capture/video_capture_device_unittest.cc
+++ b/media/video/capture/video_capture_device_unittest.cc
@@ -68,6 +68,8 @@ class MockFrameObserver : public media::VideoCaptureDevice::EventHandler {
MOCK_METHOD0(OnErr, void());
MOCK_METHOD1(OnFrameInfo, void(const VideoCaptureCapability&));
MOCK_METHOD1(OnFrameInfoChanged, void(const VideoCaptureCapability&));
+ MOCK_METHOD1(OnDeviceSupportedFormatsEnumerated,
+ void(const VideoCaptureFormats& formats));
explicit MockFrameObserver(
base::Closure frame_cb)
@@ -121,6 +123,7 @@ class VideoCaptureDeviceTest : public testing::Test {
#endif
scoped_ptr<MockFrameObserver> frame_observer_;
VideoCaptureDevice::Names names_;
+ VideoCaptureFormats capture_formats_;
scoped_ptr<base::MessageLoop> loop_;
};
@@ -270,7 +273,7 @@ TEST_F(VideoCaptureDeviceTest, ReAllocateCamera) {
// The device (if it is an async implementation) may or may not get as far
// as the OnFrameInfo() step; we're intentionally not going to wait for it
// to get that far.
- ON_CALL(*frame_observer, OnFrameInfo(_));
+ EXPECT_CALL(*frame_observer, OnFrameInfo(_)).Times(AnyNumber());
device->AllocateAndStart(requested_format,
frame_observer.PassAs<EventHandler>());
device->StopAndDeAllocate();
@@ -450,4 +453,23 @@ TEST_F(VideoCaptureDeviceTest, FakeCaptureVariableResolution) {
device->StopAndDeAllocate();
}
+TEST_F(VideoCaptureDeviceTest, GetDeviceSupportedFormats) {
+ VideoCaptureDevice::Names names;
+
+ FakeVideoCaptureDevice::GetDeviceNames(&names);
+ scoped_ptr<VideoCaptureDevice> device(
+ FakeVideoCaptureDevice::Create(names.front()));
+ ASSERT_TRUE(device.get() != NULL);
+ EXPECT_CALL(*frame_observer_, OnDeviceSupportedFormatsEnumerated(_))
+ .Times(1)
+ .WillOnce(SaveArg<0>(&capture_formats_));
+ device->GetDeviceSupportedFormats(frame_observer_.PassAs<EventHandler>());
+
+ EXPECT_GE(capture_formats_.size(), 1u);
+ EXPECT_EQ(capture_formats_[0].width, 640);
+ EXPECT_EQ(capture_formats_[0].height, 480);
+ EXPECT_EQ(capture_formats_[0].color, media::PIXEL_FORMAT_I420);
+ EXPECT_GE(capture_formats_[0].frame_rate, 20);
+}
+
}; // namespace media

Powered by Google App Engine
This is Rietveld 408576698