OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |