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 1742b9fb51eea638ff43b4fc7faf3b6f93aba613..011285c68c21020b259de7559d0448a07df6b447 100644 |
--- a/media/video/capture/video_capture_device_unittest.cc |
+++ b/media/video/capture/video_capture_device_unittest.cc |
@@ -128,6 +128,32 @@ class VideoCaptureDeviceTest : public testing::Test { |
const VideoCaptureFormat& last_format() const { return last_format_; } |
+ scoped_ptr<VideoCaptureDevice::Name> GetRquestedPixelFormatDeviceName( |
Ami GONE FROM CHROMIUM
2014/04/07 17:14:17
typo: GetRquestedPixelFormatDeviceName
Ami GONE FROM CHROMIUM
2014/04/07 17:14:17
This function's name is a bit convoluted, and "req
yuli
2014/04/08 07:42:54
Done.
|
+ const VideoPixelFormat& requested_pixel_format) { |
+ VideoCaptureDevice::GetDeviceNames(&names_); |
+ if (!names_.size()) { |
+ DVLOG(1) << "No camera available."; |
+ return scoped_ptr<VideoCaptureDevice::Name>(); |
+ } |
+ VideoCaptureFormats supported_formats; |
+ VideoCaptureDevice::Names::iterator names_iterator; |
+ for (names_iterator = names_.begin(); names_iterator != names_.end(); |
+ ++names_iterator) { |
+ VideoCaptureDevice::GetDeviceSupportedFormats(*names_iterator, |
Ami GONE FROM CHROMIUM
2014/04/07 17:14:17
This doesn't specify that it clears its output arg
yuli
2014/04/08 07:42:54
Done.
|
+ &supported_formats); |
+ VideoCaptureFormats::iterator formats_iterator; |
+ for (formats_iterator = supported_formats.begin(); |
+ formats_iterator != supported_formats.end(); ++formats_iterator) { |
+ if (formats_iterator->pixel_format == requested_pixel_format) { |
+ return scoped_ptr<VideoCaptureDevice::Name>( |
+ new VideoCaptureDevice::Name(*names_iterator)); |
+ } |
+ } |
+ } |
+ DVLOG(1) << "No camera can capture the requested pixel format."; |
Ami GONE FROM CHROMIUM
2014/04/07 17:14:17
DVLOG(1) << "No camera can capture " << requested_
yuli
2014/04/08 07:42:54
Done.
|
+ return scoped_ptr<VideoCaptureDevice::Name>(); |
+ } |
+ |
#if defined(OS_WIN) |
base::win::ScopedCOMInitializer initialize_com_; |
#endif |
@@ -332,13 +358,13 @@ TEST_F(VideoCaptureDeviceTest, FakeCapture) { |
// Start the camera in 720p to capture MJPEG instead of a raw format. |
TEST_F(VideoCaptureDeviceTest, MAYBE_CaptureMjpeg) { |
- VideoCaptureDevice::GetDeviceNames(&names_); |
- if (!names_.size()) { |
- DVLOG(1) << "No camera available. Exiting test."; |
+ scoped_ptr<VideoCaptureDevice::Name> name = GetRquestedPixelFormatDeviceName( |
+ PIXEL_FORMAT_MJPEG); |
+ if (name.get() == NULL) { |
+ DVLOG(1) << "No camera supports MJPEG format. Exiting test."; |
return; |
} |
- scoped_ptr<VideoCaptureDevice> device( |
- VideoCaptureDevice::Create(names_.front())); |
+ scoped_ptr<VideoCaptureDevice> device(VideoCaptureDevice::Create(*name)); |
ASSERT_TRUE(device.get() != NULL); |
EXPECT_CALL(*client_, OnErr()) |
@@ -359,19 +385,13 @@ TEST_F(VideoCaptureDeviceTest, MAYBE_CaptureMjpeg) { |
} |
TEST_F(VideoCaptureDeviceTest, GetDeviceSupportedFormats) { |
- VideoCaptureDevice::GetDeviceNames(&names_); |
- if (!names_.size()) { |
- DVLOG(1) << "No camera available. Exiting test."; |
- return; |
- } |
- VideoCaptureFormats supported_formats; |
- VideoCaptureDevice::Names::iterator names_iterator; |
- for (names_iterator = names_.begin(); names_iterator != names_.end(); |
- ++names_iterator) { |
- VideoCaptureDevice::GetDeviceSupportedFormats(*names_iterator, |
- &supported_formats); |
- // Nothing to test here since we cannot forecast the hardware capabilities. |
- } |
+ // Use PIXEL_FORMAT_MAX to iterate all device names for testing |
+ // GetDeviceSupportedFormats(). |
+ scoped_ptr<VideoCaptureDevice::Name> name = GetRquestedPixelFormatDeviceName( |
+ PIXEL_FORMAT_MAX); |
+ // Verify no camera returned for PIXEL_FORMAT_MAX. Nothing else to test here |
+ // since we cannot forecast the hardware capabilities. |
+ ASSERT_TRUE(name.get() == NULL); |
} |
TEST_F(VideoCaptureDeviceTest, FakeCaptureVariableResolution) { |