| 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/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg | 39 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg |
| 40 #elif defined(OS_WIN) | 40 #elif defined(OS_WIN) |
| 41 #define MAYBE_AllocateBadSize AllocateBadSize | 41 #define MAYBE_AllocateBadSize AllocateBadSize |
| 42 #define MAYBE_CaptureMjpeg CaptureMjpeg | 42 #define MAYBE_CaptureMjpeg CaptureMjpeg |
| 43 #elif defined(OS_ANDROID) | 43 #elif defined(OS_ANDROID) |
| 44 // TODO(wjia): enable those tests on Android. | 44 // TODO(wjia): enable those tests on Android. |
| 45 // On Android, native camera (JAVA) delivers frames on UI thread which is the | 45 // On Android, native camera (JAVA) delivers frames on UI thread which is the |
| 46 // main thread for tests. This results in no frame received by | 46 // main thread for tests. This results in no frame received by |
| 47 // VideoCaptureAndroid. | 47 // VideoCaptureAndroid. |
| 48 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize | 48 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize |
| 49 #define ReAllocateCamera DISABLED_ReAllocateCamera | |
| 50 #define DeAllocateCameraWhileRunning DISABLED_DeAllocateCameraWhileRunning | 49 #define DeAllocateCameraWhileRunning DISABLED_DeAllocateCameraWhileRunning |
| 51 #define DeAllocateCameraWhileRunning DISABLED_DeAllocateCameraWhileRunning | 50 #define DeAllocateCameraWhileRunning DISABLED_DeAllocateCameraWhileRunning |
| 52 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg | 51 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg |
| 53 #else | 52 #else |
| 54 #define MAYBE_AllocateBadSize AllocateBadSize | 53 #define MAYBE_AllocateBadSize AllocateBadSize |
| 55 #define MAYBE_CaptureMjpeg CaptureMjpeg | 54 #define MAYBE_CaptureMjpeg CaptureMjpeg |
| 56 #endif | 55 #endif |
| 57 | 56 |
| 58 using ::testing::_; | 57 using ::testing::_; |
| 59 using ::testing::SaveArg; | 58 using ::testing::SaveArg; |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 // Get captured video frames. | 321 // Get captured video frames. |
| 323 WaitForCapturedFrame(); | 322 WaitForCapturedFrame(); |
| 324 EXPECT_EQ(last_format().frame_size.width(), width); | 323 EXPECT_EQ(last_format().frame_size.width(), width); |
| 325 EXPECT_EQ(last_format().frame_size.height(), height); | 324 EXPECT_EQ(last_format().frame_size.height(), height); |
| 326 if (last_format().pixel_format != PIXEL_FORMAT_MJPEG) | 325 if (last_format().pixel_format != PIXEL_FORMAT_MJPEG) |
| 327 EXPECT_EQ(size.GetArea(), last_format().frame_size.GetArea()); | 326 EXPECT_EQ(size.GetArea(), last_format().frame_size.GetArea()); |
| 328 device->StopAndDeAllocate(); | 327 device->StopAndDeAllocate(); |
| 329 } | 328 } |
| 330 | 329 |
| 331 #if !defined(OS_ANDROID) | 330 #if !defined(OS_ANDROID) |
| 332 INSTANTIATE_TEST_CASE_P(MAYBE_VideoCaptureDeviceTests, | 331 INSTANTIATE_TEST_CASE_P(VideoCaptureDeviceTests, |
| 333 VideoCaptureDeviceTest, | 332 VideoCaptureDeviceTest, |
| 334 testing::ValuesIn(kCaptureSizes)); | 333 testing::ValuesIn(kCaptureSizes)); |
| 335 #endif | 334 #endif |
| 336 | 335 |
| 337 TEST_F(VideoCaptureDeviceTest, MAYBE_AllocateBadSize) { | 336 TEST_F(VideoCaptureDeviceTest, MAYBE_AllocateBadSize) { |
| 338 names_ = EnumerateDevices(); | 337 names_ = EnumerateDevices(); |
| 339 if (names_->empty()) { | 338 if (names_->empty()) { |
| 340 DVLOG(1) << "No camera available. Exiting test."; | 339 DVLOG(1) << "No camera available. Exiting test."; |
| 341 return; | 340 return; |
| 342 } | 341 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 354 PIXEL_FORMAT_I420; | 353 PIXEL_FORMAT_I420; |
| 355 device->AllocateAndStart(capture_params, client_.Pass()); | 354 device->AllocateAndStart(capture_params, client_.Pass()); |
| 356 WaitForCapturedFrame(); | 355 WaitForCapturedFrame(); |
| 357 device->StopAndDeAllocate(); | 356 device->StopAndDeAllocate(); |
| 358 EXPECT_EQ(last_format().frame_size.width(), input_size.width()); | 357 EXPECT_EQ(last_format().frame_size.width(), input_size.width()); |
| 359 EXPECT_EQ(last_format().frame_size.height(), input_size.height()); | 358 EXPECT_EQ(last_format().frame_size.height(), input_size.height()); |
| 360 if (last_format().pixel_format != PIXEL_FORMAT_MJPEG) | 359 if (last_format().pixel_format != PIXEL_FORMAT_MJPEG) |
| 361 EXPECT_EQ(input_size.GetArea(), last_format().frame_size.GetArea()); | 360 EXPECT_EQ(input_size.GetArea(), last_format().frame_size.GetArea()); |
| 362 } | 361 } |
| 363 | 362 |
| 364 // Cause hangs on Windows Debug. http://crbug.com/417824 | 363 // Cause hangs on Windows, Linux. Fails Android. http://crbug.com/417824 |
| 365 #if defined(OS_WIN) && !defined(NDEBUG) | 364 TEST_F(VideoCaptureDeviceTest, DISABLED_ReAllocateCamera) { |
| 366 #define MAYBE_ReAllocateCamera DISABLED_ReAllocateCamera | |
| 367 #else | |
| 368 #define MAYBE_ReAllocateCamera ReAllocateCamera | |
| 369 #endif | |
| 370 | |
| 371 TEST_F(VideoCaptureDeviceTest, MAYBE_ReAllocateCamera) { | |
| 372 names_ = EnumerateDevices(); | 365 names_ = EnumerateDevices(); |
| 373 if (names_->empty()) { | 366 if (names_->empty()) { |
| 374 DVLOG(1) << "No camera available. Exiting test."; | 367 DVLOG(1) << "No camera available. Exiting test."; |
| 375 return; | 368 return; |
| 376 } | 369 } |
| 377 | 370 |
| 378 // First, do a number of very fast device start/stops. | 371 // First, do a number of very fast device start/stops. |
| 379 for (int i = 0; i <= 5; i++) { | 372 for (int i = 0; i <= 5; i++) { |
| 380 ResetWithNewClient(); | 373 ResetWithNewClient(); |
| 381 scoped_ptr<VideoCaptureDevice> device( | 374 scoped_ptr<VideoCaptureDevice> device( |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 // GetDeviceSupportedFormats(). | 464 // GetDeviceSupportedFormats(). |
| 472 scoped_ptr<VideoCaptureDevice::Name> name = | 465 scoped_ptr<VideoCaptureDevice::Name> name = |
| 473 GetFirstDeviceNameSupportingPixelFormat(PIXEL_FORMAT_MAX); | 466 GetFirstDeviceNameSupportingPixelFormat(PIXEL_FORMAT_MAX); |
| 474 // Verify no camera returned for PIXEL_FORMAT_MAX. Nothing else | 467 // Verify no camera returned for PIXEL_FORMAT_MAX. Nothing else |
| 475 // to test here | 468 // to test here |
| 476 // since we cannot forecast the hardware capabilities. | 469 // since we cannot forecast the hardware capabilities. |
| 477 ASSERT_FALSE(name); | 470 ASSERT_FALSE(name); |
| 478 } | 471 } |
| 479 | 472 |
| 480 }; // namespace media | 473 }; // namespace media |
| OLD | NEW |