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

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

Issue 227613005: Fix CaptureMjpeg test may fail on devices that cannot capture MJPEG. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698