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

Side by Side Diff: media/video/capture/video_capture_device_unittest.cc

Issue 91343002: Added supported formats caching to VideoCaptureManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mad formatting corrected in certain files. Created 7 years 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
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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 EXPECT_EQ(last_format().pixel_format, PIXEL_FORMAT_MJPEG); 362 EXPECT_EQ(last_format().pixel_format, PIXEL_FORMAT_MJPEG);
363 device->StopAndDeAllocate(); 363 device->StopAndDeAllocate();
364 } 364 }
365 365
366 TEST_F(VideoCaptureDeviceTest, GetDeviceSupportedFormats) { 366 TEST_F(VideoCaptureDeviceTest, GetDeviceSupportedFormats) {
367 VideoCaptureDevice::GetDeviceNames(&names_); 367 VideoCaptureDevice::GetDeviceNames(&names_);
368 if (!names_.size()) { 368 if (!names_.size()) {
369 DVLOG(1) << "No camera available. Exiting test."; 369 DVLOG(1) << "No camera available. Exiting test.";
370 return; 370 return;
371 } 371 }
372 VideoCaptureCapabilities capture_capabilities; 372 VideoCaptureFormats supported_formats;
373 VideoCaptureDevice::Names::iterator names_iterator; 373 VideoCaptureDevice::Names::iterator names_iterator;
374 for (names_iterator = names_.begin(); names_iterator != names_.end(); 374 for (names_iterator = names_.begin(); names_iterator != names_.end();
375 ++names_iterator) { 375 ++names_iterator) {
376 VideoCaptureDevice::GetDeviceSupportedFormats(*names_iterator, 376 VideoCaptureDevice::GetDeviceSupportedFormats(*names_iterator,
377 &capture_capabilities); 377 &supported_formats);
378 // Nothing to test here since we cannot forecast the hardware capabilities. 378 // Nothing to test here since we cannot forecast the hardware capabilities.
379 } 379 }
380 } 380 }
381 381
382 TEST_F(VideoCaptureDeviceTest, FakeCaptureVariableResolution) { 382 TEST_F(VideoCaptureDeviceTest, FakeCaptureVariableResolution) {
383 VideoCaptureDevice::Names names; 383 VideoCaptureDevice::Names names;
384 384
385 FakeVideoCaptureDevice::GetDeviceNames(&names); 385 FakeVideoCaptureDevice::GetDeviceNames(&names);
386 VideoCaptureParams capture_params; 386 VideoCaptureParams capture_params;
387 capture_params.requested_format.frame_size.SetSize(640, 480); 387 capture_params.requested_format.frame_size.SetSize(640, 480);
(...skipping 18 matching lines...) Expand all
406 for (int i = 0; i < action_count; ++i) { 406 for (int i = 0; i < action_count; ++i) {
407 WaitForCapturedFrame(); 407 WaitForCapturedFrame();
408 } 408 }
409 device->StopAndDeAllocate(); 409 device->StopAndDeAllocate();
410 } 410 }
411 411
412 TEST_F(VideoCaptureDeviceTest, FakeGetDeviceSupportedFormats) { 412 TEST_F(VideoCaptureDeviceTest, FakeGetDeviceSupportedFormats) {
413 VideoCaptureDevice::Names names; 413 VideoCaptureDevice::Names names;
414 FakeVideoCaptureDevice::GetDeviceNames(&names); 414 FakeVideoCaptureDevice::GetDeviceNames(&names);
415 415
416 VideoCaptureCapabilities capture_capabilities; 416 VideoCaptureFormats supported_formats;
417 VideoCaptureDevice::Names::iterator names_iterator; 417 VideoCaptureDevice::Names::iterator names_iterator;
418 418
419 for (names_iterator = names.begin(); names_iterator != names.end(); 419 for (names_iterator = names.begin(); names_iterator != names.end();
420 ++names_iterator) { 420 ++names_iterator) {
421 FakeVideoCaptureDevice::GetDeviceSupportedFormats(*names_iterator, 421 FakeVideoCaptureDevice::GetDeviceSupportedFormats(*names_iterator,
422 &capture_capabilities); 422 &supported_formats);
423 EXPECT_GE(capture_capabilities.size(), 1u); 423 EXPECT_EQ(supported_formats.size(), 2u);
424 EXPECT_EQ(capture_capabilities[0].supported_format.frame_size.width(), 640); 424 EXPECT_EQ(supported_formats[0].frame_size.width(), 640);
425 EXPECT_EQ(capture_capabilities[0].supported_format.frame_size.height(), 425 EXPECT_EQ(supported_formats[0].frame_size.height(), 480);
426 480); 426 EXPECT_EQ(supported_formats[0].pixel_format, media::PIXEL_FORMAT_I420);
427 EXPECT_EQ(capture_capabilities[0].supported_format.pixel_format, 427 EXPECT_GE(supported_formats[0].frame_rate, 20);
428 media::PIXEL_FORMAT_I420); 428 EXPECT_EQ(supported_formats[1].frame_size.width(), 320);
429 EXPECT_GE(capture_capabilities[0].supported_format.frame_rate, 20); 429 EXPECT_EQ(supported_formats[1].frame_size.height(), 240);
430 EXPECT_EQ(supported_formats[1].pixel_format, media::PIXEL_FORMAT_I420);
431 EXPECT_GE(supported_formats[1].frame_rate, 20);
430 } 432 }
431 } 433 }
432 434
433 }; // namespace media 435 }; // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698