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" |
11 #include "base/test/test_timeouts.h" | 11 #include "base/test/test_timeouts.h" |
12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
14 #include "media/base/video_capture_types.h" | 14 #include "media/base/video_capture_types.h" |
15 #include "media/video/capture/video_capture_device.h" | 15 #include "media/video/capture/video_capture_device.h" |
16 #include "media/video/capture/video_capture_device_factory.h" | 16 #include "media/video/capture/video_capture_device_factory.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
20 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
21 #include "base/win/scoped_com_initializer.h" | 21 #include "base/win/scoped_com_initializer.h" |
22 #include "media/video/capture/win/video_capture_device_factory_win.h" | 22 #include "media/video/capture/win/video_capture_device_factory_win.h" |
23 #endif | 23 #endif |
24 | 24 |
25 #if defined(OS_MACOSX) | 25 #if defined(OS_MACOSX) |
| 26 #include "media/base/mac/avfoundation_glue.h" |
26 #include "media/video/capture/mac/video_capture_device_factory_mac.h" | 27 #include "media/video/capture/mac/video_capture_device_factory_mac.h" |
27 #endif | 28 #endif |
28 | 29 |
29 #if defined(OS_ANDROID) | 30 #if defined(OS_ANDROID) |
30 #include "base/android/jni_android.h" | 31 #include "base/android/jni_android.h" |
31 #include "media/video/capture/android/video_capture_device_android.h" | 32 #include "media/video/capture/android/video_capture_device_android.h" |
32 #endif | 33 #endif |
33 | 34 |
34 #if defined(OS_MACOSX) | 35 #if defined(OS_MACOSX) |
35 // Mac/QTKit will always give you the size you ask for and this case will fail. | 36 // Mac/QTKit will always give you the size you ask for and this case will fail. |
(...skipping 15 matching lines...) Expand all Loading... |
51 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg | 52 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg |
52 #else | 53 #else |
53 #define MAYBE_AllocateBadSize AllocateBadSize | 54 #define MAYBE_AllocateBadSize AllocateBadSize |
54 #define MAYBE_CaptureMjpeg CaptureMjpeg | 55 #define MAYBE_CaptureMjpeg CaptureMjpeg |
55 #endif | 56 #endif |
56 | 57 |
57 using ::testing::_; | 58 using ::testing::_; |
58 using ::testing::SaveArg; | 59 using ::testing::SaveArg; |
59 | 60 |
60 namespace media { | 61 namespace media { |
61 | |
62 namespace { | 62 namespace { |
63 | 63 |
64 static const gfx::Size kCaptureSizes[] = { | 64 static const gfx::Size kCaptureSizes[] = { |
65 gfx::Size(640, 480), | 65 gfx::Size(640, 480), |
66 gfx::Size(1280, 720) | 66 gfx::Size(1280, 720) |
67 }; | 67 }; |
68 | 68 |
69 class MockClient : public VideoCaptureDevice::Client { | 69 class MockClient : public VideoCaptureDevice::Client { |
70 public: | 70 public: |
71 MOCK_METHOD9(OnIncomingCapturedYuvData, | 71 MOCK_METHOD9(OnIncomingCapturedYuvData, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 video_capture_device_factory_(VideoCaptureDeviceFactory::CreateFactory( | 149 video_capture_device_factory_(VideoCaptureDeviceFactory::CreateFactory( |
150 base::ThreadTaskRunnerHandle::Get())) { | 150 base::ThreadTaskRunnerHandle::Get())) { |
151 device_enumeration_listener_ = new DeviceEnumerationListener(); | 151 device_enumeration_listener_ = new DeviceEnumerationListener(); |
152 } | 152 } |
153 | 153 |
154 void SetUp() override { | 154 void SetUp() override { |
155 #if defined(OS_ANDROID) | 155 #if defined(OS_ANDROID) |
156 VideoCaptureDeviceAndroid::RegisterVideoCaptureDevice( | 156 VideoCaptureDeviceAndroid::RegisterVideoCaptureDevice( |
157 base::android::AttachCurrentThread()); | 157 base::android::AttachCurrentThread()); |
158 #endif | 158 #endif |
| 159 #if defined(OS_MACOSX) |
| 160 AVFoundationGlue::InitializeAVFoundation(); |
| 161 #endif |
159 EXPECT_CALL(*client_, OnIncomingCapturedYuvData(_,_,_,_,_,_,_,_,_)) | 162 EXPECT_CALL(*client_, OnIncomingCapturedYuvData(_,_,_,_,_,_,_,_,_)) |
160 .Times(0); | 163 .Times(0); |
161 EXPECT_CALL(*client_, DoReserveOutputBuffer()).Times(0); | 164 EXPECT_CALL(*client_, DoReserveOutputBuffer()).Times(0); |
162 EXPECT_CALL(*client_, DoOnIncomingCapturedBuffer()).Times(0); | 165 EXPECT_CALL(*client_, DoOnIncomingCapturedBuffer()).Times(0); |
163 EXPECT_CALL(*client_, DoOnIncomingCapturedVideoFrame()).Times(0); | 166 EXPECT_CALL(*client_, DoOnIncomingCapturedVideoFrame()).Times(0); |
164 } | 167 } |
165 | 168 |
166 void ResetWithNewClient() { | 169 void ResetWithNewClient() { |
167 client_.reset(new MockClient(base::Bind( | 170 client_.reset(new MockClient(base::Bind( |
168 &VideoCaptureDeviceTest::OnFrameCaptured, base::Unretained(this)))); | 171 &VideoCaptureDeviceTest::OnFrameCaptured, base::Unretained(this)))); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 // Use PIXEL_FORMAT_MAX to iterate all device names for testing | 467 // Use PIXEL_FORMAT_MAX to iterate all device names for testing |
465 // GetDeviceSupportedFormats(). | 468 // GetDeviceSupportedFormats(). |
466 scoped_ptr<VideoCaptureDevice::Name> name = | 469 scoped_ptr<VideoCaptureDevice::Name> name = |
467 GetFirstDeviceNameSupportingPixelFormat(PIXEL_FORMAT_MAX); | 470 GetFirstDeviceNameSupportingPixelFormat(PIXEL_FORMAT_MAX); |
468 // Verify no camera returned for PIXEL_FORMAT_MAX. Nothing else to test here | 471 // Verify no camera returned for PIXEL_FORMAT_MAX. Nothing else to test here |
469 // since we cannot forecast the hardware capabilities. | 472 // since we cannot forecast the hardware capabilities. |
470 ASSERT_FALSE(name); | 473 ASSERT_FALSE(name); |
471 } | 474 } |
472 | 475 |
473 }; // namespace media | 476 }; // namespace media |
OLD | NEW |