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 "media/capture/video/video_capture_device.h" | 5 #include "media/capture/video/video_capture_device.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 18 #include "base/test/scoped_task_environment.h" |
18 #include "base/test/test_timeouts.h" | 19 #include "base/test/test_timeouts.h" |
19 #include "base/threading/thread.h" | 20 #include "base/threading/thread.h" |
20 #include "base/threading/thread_task_runner_handle.h" | 21 #include "base/threading/thread_task_runner_handle.h" |
21 #include "build/build_config.h" | 22 #include "build/build_config.h" |
22 #include "media/base/bind_to_current_loop.h" | 23 #include "media/base/bind_to_current_loop.h" |
23 #include "media/capture/video/video_capture_device_factory.h" | 24 #include "media/capture/video/video_capture_device_factory.h" |
24 #include "media/capture/video_capture_types.h" | 25 #include "media/capture/video_capture_types.h" |
25 #include "testing/gmock/include/gmock/gmock.h" | 26 #include "testing/gmock/include/gmock/gmock.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
27 | 28 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 mojom::PhotoCapabilitiesPtr capabilities_; | 206 mojom::PhotoCapabilitiesPtr capabilities_; |
206 }; | 207 }; |
207 | 208 |
208 } // namespace | 209 } // namespace |
209 | 210 |
210 class VideoCaptureDeviceTest : public testing::TestWithParam<gfx::Size> { | 211 class VideoCaptureDeviceTest : public testing::TestWithParam<gfx::Size> { |
211 protected: | 212 protected: |
212 typedef VideoCaptureDevice::Client Client; | 213 typedef VideoCaptureDevice::Client Client; |
213 | 214 |
214 VideoCaptureDeviceTest() | 215 VideoCaptureDeviceTest() |
215 : loop_(new base::MessageLoop()), | 216 : device_descriptors_(new VideoCaptureDeviceDescriptors()), |
216 device_descriptors_(new VideoCaptureDeviceDescriptors()), | |
217 video_capture_client_(new MockVideoCaptureClient( | 217 video_capture_client_(new MockVideoCaptureClient( |
218 base::Bind(&VideoCaptureDeviceTest::OnFrameCaptured, | 218 base::Bind(&VideoCaptureDeviceTest::OnFrameCaptured, |
219 base::Unretained(this)))), | 219 base::Unretained(this)))), |
220 image_capture_client_(new MockImageCaptureClient()), | 220 image_capture_client_(new MockImageCaptureClient()), |
221 video_capture_device_factory_(VideoCaptureDeviceFactory::CreateFactory( | 221 video_capture_device_factory_(VideoCaptureDeviceFactory::CreateFactory( |
222 base::ThreadTaskRunnerHandle::Get())) {} | 222 base::ThreadTaskRunnerHandle::Get())) {} |
223 | 223 |
224 void SetUp() override { | 224 void SetUp() override { |
225 #if defined(OS_ANDROID) | 225 #if defined(OS_ANDROID) |
226 VideoCaptureDeviceAndroid::RegisterVideoCaptureDevice( | 226 VideoCaptureDeviceAndroid::RegisterVideoCaptureDevice( |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 if (it == supported_formats.end()) { | 307 if (it == supported_formats.end()) { |
308 DVLOG(1) << "Size " << size.ToString() << " is not supported."; | 308 DVLOG(1) << "Size " << size.ToString() << " is not supported."; |
309 return false; | 309 return false; |
310 } | 310 } |
311 return true; | 311 return true; |
312 } | 312 } |
313 | 313 |
314 #if defined(OS_WIN) | 314 #if defined(OS_WIN) |
315 base::win::ScopedCOMInitializer initialize_com_; | 315 base::win::ScopedCOMInitializer initialize_com_; |
316 #endif | 316 #endif |
317 const std::unique_ptr<base::MessageLoop> loop_; | 317 base::test::ScopedTaskEnvironment scoped_task_environment_; |
318 std::unique_ptr<VideoCaptureDeviceDescriptors> device_descriptors_; | 318 std::unique_ptr<VideoCaptureDeviceDescriptors> device_descriptors_; |
319 std::unique_ptr<base::RunLoop> run_loop_; | 319 std::unique_ptr<base::RunLoop> run_loop_; |
320 std::unique_ptr<MockVideoCaptureClient> video_capture_client_; | 320 std::unique_ptr<MockVideoCaptureClient> video_capture_client_; |
321 const scoped_refptr<MockImageCaptureClient> image_capture_client_; | 321 const scoped_refptr<MockImageCaptureClient> image_capture_client_; |
322 VideoCaptureFormat last_format_; | 322 VideoCaptureFormat last_format_; |
323 const std::unique_ptr<VideoCaptureDeviceFactory> | 323 const std::unique_ptr<VideoCaptureDeviceFactory> |
324 video_capture_device_factory_; | 324 video_capture_device_factory_; |
325 }; | 325 }; |
326 | 326 |
327 // Cause hangs on Windows Debug. http://crbug.com/417824 | 327 // Cause hangs on Windows Debug. http://crbug.com/417824 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 | 610 |
611 device->GetPhotoCapabilities(std::move(scoped_get_callback)); | 611 device->GetPhotoCapabilities(std::move(scoped_get_callback)); |
612 run_loop.Run(); | 612 run_loop.Run(); |
613 | 613 |
614 ASSERT_TRUE(image_capture_client_->capabilities()); | 614 ASSERT_TRUE(image_capture_client_->capabilities()); |
615 | 615 |
616 device->StopAndDeAllocate(); | 616 device->StopAndDeAllocate(); |
617 } | 617 } |
618 | 618 |
619 }; // namespace media | 619 }; // namespace media |
OLD | NEW |