OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/single_thread_task_runner.h" | 6 #include "base/message_loop/message_loop_proxy.h" |
7 #include "base/thread_task_runner_handle.h" | |
8 #import "media/base/mac/avfoundation_glue.h" | 7 #import "media/base/mac/avfoundation_glue.h" |
9 #include "media/base/media_switches.h" | 8 #include "media/base/media_switches.h" |
10 #include "media/video/capture/mac/video_capture_device_factory_mac.h" | 9 #include "media/video/capture/mac/video_capture_device_factory_mac.h" |
11 #include "media/video/capture/mac/video_capture_device_mac.h" | 10 #include "media/video/capture/mac/video_capture_device_mac.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
13 | 12 |
14 namespace media { | 13 namespace media { |
15 | 14 |
16 class VideoCaptureDeviceFactoryMacTest : public testing::Test { | 15 class VideoCaptureDeviceFactoryMacTest : public testing::Test { |
17 void SetUp() override { | 16 void SetUp() override { |
18 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 17 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
19 switches::kEnableAVFoundation); | 18 switches::kEnableAVFoundation); |
20 } | 19 } |
21 }; | 20 }; |
22 | 21 |
23 TEST_F(VideoCaptureDeviceFactoryMacTest, ListDevicesAVFoundation) { | 22 TEST_F(VideoCaptureDeviceFactoryMacTest, ListDevicesAVFoundation) { |
24 if (!AVFoundationGlue::IsAVFoundationSupported()) { | 23 if (!AVFoundationGlue::IsAVFoundationSupported()) { |
25 DVLOG(1) << "AVFoundation not supported, skipping test."; | 24 DVLOG(1) << "AVFoundation not supported, skipping test."; |
26 return; | 25 return; |
27 } | 26 } |
28 VideoCaptureDeviceFactoryMac video_capture_device_factory( | 27 VideoCaptureDeviceFactoryMac video_capture_device_factory( |
29 base::ThreadTaskRunnerHandle::Get()); | 28 base::MessageLoopProxy::current()); |
30 | 29 |
31 VideoCaptureDevice::Names names; | 30 VideoCaptureDevice::Names names; |
32 video_capture_device_factory.GetDeviceNames(&names); | 31 video_capture_device_factory.GetDeviceNames(&names); |
33 if (!names.size()) { | 32 if (!names.size()) { |
34 DVLOG(1) << "No camera available. Exiting test."; | 33 DVLOG(1) << "No camera available. Exiting test."; |
35 return; | 34 return; |
36 } | 35 } |
37 // There should be no blacklisted devices, i.e. QTKit. | 36 // There should be no blacklisted devices, i.e. QTKit. |
38 std::string device_vid; | 37 std::string device_vid; |
39 for (VideoCaptureDevice::Names::const_iterator it = names.begin(); | 38 for (VideoCaptureDevice::Names::const_iterator it = names.begin(); |
40 it != names.end(); ++it) { | 39 it != names.end(); ++it) { |
41 EXPECT_EQ(it->capture_api_type(), VideoCaptureDevice::Name::AVFOUNDATION); | 40 EXPECT_EQ(it->capture_api_type(), VideoCaptureDevice::Name::AVFOUNDATION); |
42 } | 41 } |
43 } | 42 } |
44 | 43 |
45 }; // namespace media | 44 }; // namespace media |
OLD | NEW |