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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 #endif | 194 #endif |
195 scoped_ptr<VideoCaptureDevice::Names> names_; | 195 scoped_ptr<VideoCaptureDevice::Names> names_; |
196 scoped_ptr<base::MessageLoop> loop_; | 196 scoped_ptr<base::MessageLoop> loop_; |
197 scoped_ptr<base::RunLoop> run_loop_; | 197 scoped_ptr<base::RunLoop> run_loop_; |
198 scoped_ptr<MockClient> client_; | 198 scoped_ptr<MockClient> client_; |
199 scoped_refptr<DeviceEnumerationListener> device_enumeration_listener_; | 199 scoped_refptr<DeviceEnumerationListener> device_enumeration_listener_; |
200 VideoCaptureFormat last_format_; | 200 VideoCaptureFormat last_format_; |
201 scoped_ptr<VideoCaptureDeviceFactory> video_capture_device_factory_; | 201 scoped_ptr<VideoCaptureDeviceFactory> video_capture_device_factory_; |
202 }; | 202 }; |
203 | 203 |
204 TEST_F(VideoCaptureDeviceTest, OpenInvalidDevice) { | 204 // Cause hangs on Windows Debug. http://crbug.com/417824 |
| 205 #if defined(OS_WIN) && !defined(NDEBUG) |
| 206 #define MAYBE_OpenInvalidDevice DISABLED_OpenInvalidDevice |
| 207 #else |
| 208 #define MAYBE_OpenInvalidDevice OpenInvalidDevice |
| 209 #endif |
| 210 |
| 211 TEST_F(VideoCaptureDeviceTest, MAYBE_OpenInvalidDevice) { |
205 #if defined(OS_WIN) | 212 #if defined(OS_WIN) |
206 VideoCaptureDevice::Name::CaptureApiType api_type = | 213 VideoCaptureDevice::Name::CaptureApiType api_type = |
207 VideoCaptureDeviceFactoryWin::PlatformSupportsMediaFoundation() | 214 VideoCaptureDeviceFactoryWin::PlatformSupportsMediaFoundation() |
208 ? VideoCaptureDevice::Name::MEDIA_FOUNDATION | 215 ? VideoCaptureDevice::Name::MEDIA_FOUNDATION |
209 : VideoCaptureDevice::Name::DIRECT_SHOW; | 216 : VideoCaptureDevice::Name::DIRECT_SHOW; |
210 VideoCaptureDevice::Name device_name("jibberish", "jibberish", api_type); | 217 VideoCaptureDevice::Name device_name("jibberish", "jibberish", api_type); |
211 #elif defined(OS_MACOSX) | 218 #elif defined(OS_MACOSX) |
212 VideoCaptureDevice::Name device_name("jibberish", "jibberish", | 219 VideoCaptureDevice::Name device_name("jibberish", "jibberish", |
213 VideoCaptureDeviceFactoryMac::PlatformSupportsAVFoundation() | 220 VideoCaptureDeviceFactoryMac::PlatformSupportsAVFoundation() |
214 ? VideoCaptureDevice::Name::AVFOUNDATION | 221 ? 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); | 313 capture_params.requested_format.frame_size.SetSize(637, 472); |
307 capture_params.requested_format.frame_rate = 35; | 314 capture_params.requested_format.frame_rate = 35; |
308 capture_params.requested_format.pixel_format = PIXEL_FORMAT_I420; | 315 capture_params.requested_format.pixel_format = PIXEL_FORMAT_I420; |
309 device->AllocateAndStart(capture_params, client_.PassAs<Client>()); | 316 device->AllocateAndStart(capture_params, client_.PassAs<Client>()); |
310 WaitForCapturedFrame(); | 317 WaitForCapturedFrame(); |
311 device->StopAndDeAllocate(); | 318 device->StopAndDeAllocate(); |
312 EXPECT_EQ(last_format().frame_size.width(), 640); | 319 EXPECT_EQ(last_format().frame_size.width(), 640); |
313 EXPECT_EQ(last_format().frame_size.height(), 480); | 320 EXPECT_EQ(last_format().frame_size.height(), 480); |
314 } | 321 } |
315 | 322 |
316 TEST_F(VideoCaptureDeviceTest, ReAllocateCamera) { | 323 // Cause hangs on Windows Debug. http://crbug.com/417824 |
| 324 #if defined(OS_WIN) && !defined(NDEBUG) |
| 325 #define MAYBE_ReAllocateCamera DISABLED_ReAllocateCamera |
| 326 #else |
| 327 #define MAYBE_ReAllocateCamera ReAllocateCamera |
| 328 #endif |
| 329 |
| 330 TEST_F(VideoCaptureDeviceTest, MAYBE_ReAllocateCamera) { |
317 names_ = EnumerateDevices(); | 331 names_ = EnumerateDevices(); |
318 if (!names_->size()) { | 332 if (!names_->size()) { |
319 DVLOG(1) << "No camera available. Exiting test."; | 333 DVLOG(1) << "No camera available. Exiting test."; |
320 return; | 334 return; |
321 } | 335 } |
322 | 336 |
323 // First, do a number of very fast device start/stops. | 337 // First, do a number of very fast device start/stops. |
324 for (int i = 0; i <= 5; i++) { | 338 for (int i = 0; i <= 5; i++) { |
325 ResetWithNewClient(); | 339 ResetWithNewClient(); |
326 scoped_ptr<VideoCaptureDevice> device( | 340 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 | 429 // Use PIXEL_FORMAT_MAX to iterate all device names for testing |
416 // GetDeviceSupportedFormats(). | 430 // GetDeviceSupportedFormats(). |
417 scoped_ptr<VideoCaptureDevice::Name> name = | 431 scoped_ptr<VideoCaptureDevice::Name> name = |
418 GetFirstDeviceNameSupportingPixelFormat(PIXEL_FORMAT_MAX); | 432 GetFirstDeviceNameSupportingPixelFormat(PIXEL_FORMAT_MAX); |
419 // Verify no camera returned for PIXEL_FORMAT_MAX. Nothing else to test here | 433 // Verify no camera returned for PIXEL_FORMAT_MAX. Nothing else to test here |
420 // since we cannot forecast the hardware capabilities. | 434 // since we cannot forecast the hardware capabilities. |
421 ASSERT_FALSE(name); | 435 ASSERT_FALSE(name); |
422 } | 436 } |
423 | 437 |
424 }; // namespace media | 438 }; // namespace media |
OLD | NEW |