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