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