OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/browser/renderer_host/media/media_devices_manager.h" | 5 #include "content/browser/renderer_host/media/media_devices_manager.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
16 #include "content/browser/renderer_host/media/video_capture_manager.h" | 16 #include "content/browser/renderer_host/media/video_capture_manager.h" |
17 #include "content/public/test/test_browser_thread_bundle.h" | 17 #include "content/public/test/test_browser_thread_bundle.h" |
18 #include "media/audio/audio_device_name.h" | 18 #include "media/audio/audio_device_name.h" |
19 #include "media/audio/audio_system_impl.h" | 19 #include "media/audio/audio_system_impl.h" |
20 #include "media/audio/fake_audio_log_factory.h" | 20 #include "media/audio/fake_audio_log_factory.h" |
21 #include "media/audio/fake_audio_manager.h" | 21 #include "media/audio/fake_audio_manager.h" |
22 #include "media/capture/video/fake_video_capture_device_factory.h" | 22 #include "media/capture/video/fake_video_capture_device_factory.h" |
| 23 #include "media/capture/video/video_capture_system_impl.h" |
23 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 | 26 |
26 using testing::_; | 27 using testing::_; |
27 using testing::SaveArg; | 28 using testing::SaveArg; |
28 | 29 |
29 namespace content { | 30 namespace content { |
30 | 31 |
31 namespace { | 32 namespace { |
32 | 33 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 void EnumerateCallback(base::RunLoop* run_loop, | 136 void EnumerateCallback(base::RunLoop* run_loop, |
136 const MediaDeviceEnumeration& result) { | 137 const MediaDeviceEnumeration& result) { |
137 MockCallback(result); | 138 MockCallback(result); |
138 run_loop->Quit(); | 139 run_loop->Quit(); |
139 } | 140 } |
140 | 141 |
141 protected: | 142 protected: |
142 void SetUp() override { | 143 void SetUp() override { |
143 audio_manager_.reset(new MockAudioManager()); | 144 audio_manager_.reset(new MockAudioManager()); |
144 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get()); | 145 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get()); |
| 146 auto video_capture_device_factory = |
| 147 base::MakeUnique<MockVideoCaptureDeviceFactory>(); |
| 148 video_capture_device_factory_ = video_capture_device_factory.get(); |
| 149 auto video_capture_system = base::MakeUnique<media::VideoCaptureSystemImpl>( |
| 150 std::move(video_capture_device_factory)); |
145 video_capture_manager_ = new VideoCaptureManager( | 151 video_capture_manager_ = new VideoCaptureManager( |
146 base::MakeUnique<media::VideoCaptureSystem>( | 152 std::move(video_capture_system), base::ThreadTaskRunnerHandle::Get()); |
147 std::unique_ptr<media::VideoCaptureDeviceFactory>( | |
148 new MockVideoCaptureDeviceFactory())), | |
149 base::ThreadTaskRunnerHandle::Get()); | |
150 video_capture_device_factory_ = static_cast<MockVideoCaptureDeviceFactory*>( | |
151 video_capture_manager_->video_capture_device_factory()); | |
152 media_devices_manager_.reset(new MediaDevicesManager( | 153 media_devices_manager_.reset(new MediaDevicesManager( |
153 audio_system_.get(), video_capture_manager_, nullptr)); | 154 audio_system_.get(), video_capture_manager_, nullptr)); |
154 } | 155 } |
155 | 156 |
156 void EnableCache(MediaDeviceType type) { | 157 void EnableCache(MediaDeviceType type) { |
157 media_devices_manager_->SetCachePolicy( | 158 media_devices_manager_->SetCachePolicy( |
158 type, MediaDevicesManager::CachePolicy::SYSTEM_MONITOR); | 159 type, MediaDevicesManager::CachePolicy::SYSTEM_MONITOR); |
159 } | 160 } |
160 | 161 |
161 // Must outlive MediaDevicesManager as ~MediaDevicesManager() verifies it's | 162 // Must outlive MediaDevicesManager as ~MediaDevicesManager() verifies it's |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 media_devices_manager_->OnDevicesChanged(base::SystemMonitor::DEVTYPE_AUDIO); | 571 media_devices_manager_->OnDevicesChanged(base::SystemMonitor::DEVTYPE_AUDIO); |
571 media_devices_manager_->OnDevicesChanged( | 572 media_devices_manager_->OnDevicesChanged( |
572 base::SystemMonitor::DEVTYPE_VIDEO_CAPTURE); | 573 base::SystemMonitor::DEVTYPE_VIDEO_CAPTURE); |
573 base::RunLoop().RunUntilIdle(); | 574 base::RunLoop().RunUntilIdle(); |
574 EXPECT_EQ(num_audio_input_devices, notification_all_audio_input.size()); | 575 EXPECT_EQ(num_audio_input_devices, notification_all_audio_input.size()); |
575 EXPECT_EQ(num_video_input_devices, notification_all_video_input.size()); | 576 EXPECT_EQ(num_video_input_devices, notification_all_video_input.size()); |
576 EXPECT_EQ(num_audio_output_devices, notification_all_audio_output.size()); | 577 EXPECT_EQ(num_audio_output_devices, notification_all_audio_output.size()); |
577 } | 578 } |
578 | 579 |
579 } // namespace content | 580 } // namespace content |
OLD | NEW |