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/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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize | 50 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize |
51 #define ReAllocateCamera DISABLED_ReAllocateCamera | 51 #define ReAllocateCamera DISABLED_ReAllocateCamera |
52 #define DeAllocateCameraWhileRunning DISABLED_DeAllocateCameraWhileRunning | 52 #define DeAllocateCameraWhileRunning DISABLED_DeAllocateCameraWhileRunning |
53 #define DeAllocateCameraWhileRunning DISABLED_DeAllocateCameraWhileRunning | 53 #define DeAllocateCameraWhileRunning DISABLED_DeAllocateCameraWhileRunning |
54 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg | 54 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg |
55 #else | 55 #else |
56 #define MAYBE_AllocateBadSize AllocateBadSize | 56 #define MAYBE_AllocateBadSize AllocateBadSize |
57 #define MAYBE_CaptureMjpeg CaptureMjpeg | 57 #define MAYBE_CaptureMjpeg CaptureMjpeg |
58 #endif | 58 #endif |
59 | 59 |
60 // Cause hangs on Windows Debug. http://crbug.com/417824 | |
61 #if defined(OS_WIN) && defined(_DEBUG) | |
miu
2014/09/29 20:13:19
Should be:
#if defined(OS_WIN) && !defined(NDEB
| |
62 #define MAYBE_OpenInvalidDevice DISABLED_OpenInvalidDevice | |
63 #define MAYBE_ReAllocateCamera DISABLED_ReAllocateCamera | |
64 #else | |
65 #define MAYBE_OpenInvalidDevice OpenInvalidDevice | |
66 #define MAYBE_ReAllocateCamera ReAllocateCamera | |
67 #endif | |
68 | |
60 using ::testing::_; | 69 using ::testing::_; |
61 using ::testing::SaveArg; | 70 using ::testing::SaveArg; |
62 | 71 |
63 namespace media { | 72 namespace media { |
64 | 73 |
65 class MockClient : public media::VideoCaptureDevice::Client { | 74 class MockClient : public media::VideoCaptureDevice::Client { |
66 public: | 75 public: |
67 MOCK_METHOD2(ReserveOutputBuffer, | 76 MOCK_METHOD2(ReserveOutputBuffer, |
68 scoped_refptr<Buffer>(media::VideoFrame::Format format, | 77 scoped_refptr<Buffer>(media::VideoFrame::Format format, |
69 const gfx::Size& dimensions)); | 78 const gfx::Size& dimensions)); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 #endif | 203 #endif |
195 scoped_ptr<VideoCaptureDevice::Names> names_; | 204 scoped_ptr<VideoCaptureDevice::Names> names_; |
196 scoped_ptr<base::MessageLoop> loop_; | 205 scoped_ptr<base::MessageLoop> loop_; |
197 scoped_ptr<base::RunLoop> run_loop_; | 206 scoped_ptr<base::RunLoop> run_loop_; |
198 scoped_ptr<MockClient> client_; | 207 scoped_ptr<MockClient> client_; |
199 scoped_refptr<DeviceEnumerationListener> device_enumeration_listener_; | 208 scoped_refptr<DeviceEnumerationListener> device_enumeration_listener_; |
200 VideoCaptureFormat last_format_; | 209 VideoCaptureFormat last_format_; |
201 scoped_ptr<VideoCaptureDeviceFactory> video_capture_device_factory_; | 210 scoped_ptr<VideoCaptureDeviceFactory> video_capture_device_factory_; |
202 }; | 211 }; |
203 | 212 |
204 TEST_F(VideoCaptureDeviceTest, OpenInvalidDevice) { | 213 TEST_F(VideoCaptureDeviceTest, MAYBE_OpenInvalidDevice) { |
205 #if defined(OS_WIN) | 214 #if defined(OS_WIN) |
206 VideoCaptureDevice::Name::CaptureApiType api_type = | 215 VideoCaptureDevice::Name::CaptureApiType api_type = |
207 VideoCaptureDeviceFactoryWin::PlatformSupportsMediaFoundation() | 216 VideoCaptureDeviceFactoryWin::PlatformSupportsMediaFoundation() |
208 ? VideoCaptureDevice::Name::MEDIA_FOUNDATION | 217 ? VideoCaptureDevice::Name::MEDIA_FOUNDATION |
209 : VideoCaptureDevice::Name::DIRECT_SHOW; | 218 : VideoCaptureDevice::Name::DIRECT_SHOW; |
210 VideoCaptureDevice::Name device_name("jibberish", "jibberish", api_type); | 219 VideoCaptureDevice::Name device_name("jibberish", "jibberish", api_type); |
211 #elif defined(OS_MACOSX) | 220 #elif defined(OS_MACOSX) |
212 VideoCaptureDevice::Name device_name("jibberish", "jibberish", | 221 VideoCaptureDevice::Name device_name("jibberish", "jibberish", |
213 VideoCaptureDeviceFactoryMac::PlatformSupportsAVFoundation() | 222 VideoCaptureDeviceFactoryMac::PlatformSupportsAVFoundation() |
214 ? VideoCaptureDevice::Name::AVFOUNDATION | 223 ? VideoCaptureDevice::Name::AVFOUNDATION |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
306 capture_params.requested_format.frame_size.SetSize(637, 472); | 315 capture_params.requested_format.frame_size.SetSize(637, 472); |
307 capture_params.requested_format.frame_rate = 35; | 316 capture_params.requested_format.frame_rate = 35; |
308 capture_params.requested_format.pixel_format = PIXEL_FORMAT_I420; | 317 capture_params.requested_format.pixel_format = PIXEL_FORMAT_I420; |
309 device->AllocateAndStart(capture_params, client_.PassAs<Client>()); | 318 device->AllocateAndStart(capture_params, client_.PassAs<Client>()); |
310 WaitForCapturedFrame(); | 319 WaitForCapturedFrame(); |
311 device->StopAndDeAllocate(); | 320 device->StopAndDeAllocate(); |
312 EXPECT_EQ(last_format().frame_size.width(), 640); | 321 EXPECT_EQ(last_format().frame_size.width(), 640); |
313 EXPECT_EQ(last_format().frame_size.height(), 480); | 322 EXPECT_EQ(last_format().frame_size.height(), 480); |
314 } | 323 } |
315 | 324 |
316 TEST_F(VideoCaptureDeviceTest, ReAllocateCamera) { | 325 TEST_F(VideoCaptureDeviceTest, MAYBE_ReAllocateCamera) { |
317 names_ = EnumerateDevices(); | 326 names_ = EnumerateDevices(); |
318 if (!names_->size()) { | 327 if (!names_->size()) { |
319 DVLOG(1) << "No camera available. Exiting test."; | 328 DVLOG(1) << "No camera available. Exiting test."; |
320 return; | 329 return; |
321 } | 330 } |
322 | 331 |
323 // First, do a number of very fast device start/stops. | 332 // First, do a number of very fast device start/stops. |
324 for (int i = 0; i <= 5; i++) { | 333 for (int i = 0; i <= 5; i++) { |
325 ResetWithNewClient(); | 334 ResetWithNewClient(); |
326 scoped_ptr<VideoCaptureDevice> device( | 335 scoped_ptr<VideoCaptureDevice> device( |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
415 // Use PIXEL_FORMAT_MAX to iterate all device names for testing | 424 // Use PIXEL_FORMAT_MAX to iterate all device names for testing |
416 // GetDeviceSupportedFormats(). | 425 // GetDeviceSupportedFormats(). |
417 scoped_ptr<VideoCaptureDevice::Name> name = | 426 scoped_ptr<VideoCaptureDevice::Name> name = |
418 GetFirstDeviceNameSupportingPixelFormat(PIXEL_FORMAT_MAX); | 427 GetFirstDeviceNameSupportingPixelFormat(PIXEL_FORMAT_MAX); |
419 // Verify no camera returned for PIXEL_FORMAT_MAX. Nothing else to test here | 428 // Verify no camera returned for PIXEL_FORMAT_MAX. Nothing else to test here |
420 // since we cannot forecast the hardware capabilities. | 429 // since we cannot forecast the hardware capabilities. |
421 ASSERT_FALSE(name); | 430 ASSERT_FALSE(name); |
422 } | 431 } |
423 | 432 |
424 }; // namespace media | 433 }; // namespace media |
OLD | NEW |