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

Side by Side 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: perkj@'s nits Created 7 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 unified diff | Download patch
« no previous file with comments | « media/video/capture/video_capture_device.h ('k') | media/video/capture/video_capture_types.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 0, 402 0,
403 false, 403 false,
404 ConstantResolutionVideoCaptureDevice); 404 ConstantResolutionVideoCaptureDevice);
405 device->AllocateAndStart(capture_format, client_.PassAs<Client>()); 405 device->AllocateAndStart(capture_format, client_.PassAs<Client>());
406 // Get captured video frames. 406 // Get captured video frames.
407 WaitForCapturedFrame(); 407 WaitForCapturedFrame();
408 EXPECT_EQ(rx_capability.color, PIXEL_FORMAT_MJPEG); 408 EXPECT_EQ(rx_capability.color, PIXEL_FORMAT_MJPEG);
409 device->StopAndDeAllocate(); 409 device->StopAndDeAllocate();
410 } 410 }
411 411
412 TEST_F(VideoCaptureDeviceTest, GetDeviceSupportedFormats) {
413 VideoCaptureDevice::GetDeviceNames(&names_);
414 if (!names_.size()) {
415 DVLOG(1) << "No camera available. Exiting test.";
416 return;
417 }
418 VideoCaptureCapabilities capture_formats;
419 VideoCaptureDevice::Names::iterator names_iterator;
420 for (names_iterator = names_.begin(); names_iterator != names_.end();
421 ++names_iterator) {
422 VideoCaptureDevice::GetDeviceSupportedFormats(*names_iterator,
423 &capture_formats);
424 // Nothing to test here since we cannot forecast the hardware capabilities.
425 }
426 }
427
412 TEST_F(VideoCaptureDeviceTest, FakeCaptureVariableResolution) { 428 TEST_F(VideoCaptureDeviceTest, FakeCaptureVariableResolution) {
413 VideoCaptureDevice::Names names; 429 VideoCaptureDevice::Names names;
414 430
415 FakeVideoCaptureDevice::GetDeviceNames(&names); 431 FakeVideoCaptureDevice::GetDeviceNames(&names);
416 media::VideoCaptureCapability capture_format; 432 media::VideoCaptureCapability capture_format;
417 capture_format.width = 640; 433 capture_format.width = 640;
418 capture_format.height = 480; 434 capture_format.height = 480;
419 capture_format.frame_rate = 30; 435 capture_format.frame_rate = 30;
420 capture_format.frame_size_type = media::VariableResolutionVideoCaptureDevice; 436 capture_format.frame_size_type = media::VariableResolutionVideoCaptureDevice;
421 437
(...skipping 18 matching lines...) Expand all
440 // The amount of times the OnFrameInfoChanged gets called depends on how often 456 // The amount of times the OnFrameInfoChanged gets called depends on how often
441 // FakeDevice is supposed to change and what is its actual frame rate. 457 // FakeDevice is supposed to change and what is its actual frame rate.
442 // We set TimeWait to 200 action timeouts and this should be enough for at 458 // We set TimeWait to 200 action timeouts and this should be enough for at
443 // least action_count/kFakeCaptureCapabilityChangePeriod calls. 459 // least action_count/kFakeCaptureCapabilityChangePeriod calls.
444 for (int i = 0; i < action_count; ++i) { 460 for (int i = 0; i < action_count; ++i) {
445 WaitForCapturedFrame(); 461 WaitForCapturedFrame();
446 } 462 }
447 device->StopAndDeAllocate(); 463 device->StopAndDeAllocate();
448 } 464 }
449 465
466 TEST_F(VideoCaptureDeviceTest, FakeGetDeviceSupportedFormats) {
467 VideoCaptureDevice::Names names;
468 FakeVideoCaptureDevice::GetDeviceNames(&names);
469
470 VideoCaptureCapabilities capture_formats;
471 VideoCaptureDevice::Names::iterator names_iterator;
472
473 for (names_iterator = names.begin(); names_iterator != names.end();
474 ++names_iterator) {
475 FakeVideoCaptureDevice::GetDeviceSupportedFormats(*names_iterator,
476 &capture_formats);
477 EXPECT_GE(capture_formats.size(), 1u);
478 EXPECT_EQ(capture_formats[0].width, 640);
479 EXPECT_EQ(capture_formats[0].height, 480);
480 EXPECT_EQ(capture_formats[0].color, media::PIXEL_FORMAT_I420);
481 EXPECT_GE(capture_formats[0].frame_rate, 20);
482 }
483 }
484
450 }; // namespace media 485 }; // namespace media
OLDNEW
« no previous file with comments | « media/video/capture/video_capture_device.h ('k') | media/video/capture/video_capture_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698