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 "content/browser/renderer_host/media/media_stream_dispatcher_host.h" | 5 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <memory> | 8 #include <memory> |
9 #include <queue> | 9 #include <queue> |
10 #include <string> | 10 #include <string> |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "content/common/media/media_stream_options.h" | 28 #include "content/common/media/media_stream_options.h" |
29 #include "content/public/browser/media_device_id.h" | 29 #include "content/public/browser/media_device_id.h" |
30 #include "content/public/common/content_switches.h" | 30 #include "content/public/common/content_switches.h" |
31 #include "content/public/test/mock_resource_context.h" | 31 #include "content/public/test/mock_resource_context.h" |
32 #include "content/public/test/test_browser_context.h" | 32 #include "content/public/test/test_browser_context.h" |
33 #include "content/public/test/test_browser_thread_bundle.h" | 33 #include "content/public/test/test_browser_thread_bundle.h" |
34 #include "content/test/test_content_browser_client.h" | 34 #include "content/test/test_content_browser_client.h" |
35 #include "content/test/test_content_client.h" | 35 #include "content/test/test_content_client.h" |
36 #include "ipc/ipc_message_macros.h" | 36 #include "ipc/ipc_message_macros.h" |
37 #include "media/audio/audio_device_description.h" | 37 #include "media/audio/audio_device_description.h" |
| 38 #include "media/audio/audio_system_impl.h" |
38 #include "media/audio/mock_audio_manager.h" | 39 #include "media/audio/mock_audio_manager.h" |
39 #include "media/base/media_switches.h" | 40 #include "media/base/media_switches.h" |
40 #include "media/capture/video/fake_video_capture_device_factory.h" | 41 #include "media/capture/video/fake_video_capture_device_factory.h" |
41 #include "net/url_request/url_request_context.h" | 42 #include "net/url_request/url_request_context.h" |
42 #include "testing/gmock/include/gmock/gmock.h" | 43 #include "testing/gmock/include/gmock/gmock.h" |
43 #include "testing/gtest/include/gtest/gtest.h" | 44 #include "testing/gtest/include/gtest/gtest.h" |
44 #include "url/gurl.h" | 45 #include "url/gurl.h" |
45 #include "url/origin.h" | 46 #include "url/origin.h" |
46 | 47 |
47 #if defined(OS_CHROMEOS) | 48 #if defined(OS_CHROMEOS) |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 }; | 229 }; |
229 | 230 |
230 class MediaStreamDispatcherHostTest : public testing::Test { | 231 class MediaStreamDispatcherHostTest : public testing::Test { |
231 public: | 232 public: |
232 MediaStreamDispatcherHostTest() | 233 MediaStreamDispatcherHostTest() |
233 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | 234 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
234 old_browser_client_(NULL), | 235 old_browser_client_(NULL), |
235 origin_(GURL("https://test.com")) { | 236 origin_(GURL("https://test.com")) { |
236 audio_manager_.reset( | 237 audio_manager_.reset( |
237 new media::MockAudioManager(base::ThreadTaskRunnerHandle::Get())); | 238 new media::MockAudioManager(base::ThreadTaskRunnerHandle::Get())); |
| 239 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get()); |
238 // Make sure we use fake devices to avoid long delays. | 240 // Make sure we use fake devices to avoid long delays. |
239 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 241 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
240 switches::kUseFakeDeviceForMediaStream); | 242 switches::kUseFakeDeviceForMediaStream); |
241 // Create our own MediaStreamManager. | 243 // Create our own MediaStreamManager. |
242 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); | 244 media_stream_manager_ = |
| 245 base::MakeUnique<MediaStreamManager>(audio_system_.get()); |
243 video_capture_device_factory_ = | 246 video_capture_device_factory_ = |
244 static_cast<media::FakeVideoCaptureDeviceFactory*>( | 247 static_cast<media::FakeVideoCaptureDeviceFactory*>( |
245 media_stream_manager_->video_capture_manager() | 248 media_stream_manager_->video_capture_manager() |
246 ->video_capture_device_factory()); | 249 ->video_capture_device_factory()); |
247 DCHECK(video_capture_device_factory_); | 250 DCHECK(video_capture_device_factory_); |
248 #if defined(OS_WIN) | 251 #if defined(OS_WIN) |
249 // Override the Video Capture Thread that MediaStreamManager constructs. | 252 // Override the Video Capture Thread that MediaStreamManager constructs. |
250 media_stream_manager_->video_capture_manager()->set_device_task_runner( | 253 media_stream_manager_->video_capture_manager()->set_device_task_runner( |
251 base::ThreadTaskRunnerHandle::Get()); | 254 base::ThreadTaskRunnerHandle::Get()); |
252 #endif | 255 #endif |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 return false; | 422 return false; |
420 } | 423 } |
421 return true; | 424 return true; |
422 } | 425 } |
423 | 426 |
424 scoped_refptr<MockMediaStreamDispatcherHost> host_; | 427 scoped_refptr<MockMediaStreamDispatcherHost> host_; |
425 std::unique_ptr<MediaStreamManager> media_stream_manager_; | 428 std::unique_ptr<MediaStreamManager> media_stream_manager_; |
426 content::TestBrowserThreadBundle thread_bundle_; | 429 content::TestBrowserThreadBundle thread_bundle_; |
427 std::unique_ptr<media::AudioManager, media::AudioManagerDeleter> | 430 std::unique_ptr<media::AudioManager, media::AudioManagerDeleter> |
428 audio_manager_; | 431 audio_manager_; |
| 432 std::unique_ptr<media::AudioSystem> audio_system_; |
429 MockMediaStreamUIProxy* stream_ui_; | 433 MockMediaStreamUIProxy* stream_ui_; |
430 ContentBrowserClient* old_browser_client_; | 434 ContentBrowserClient* old_browser_client_; |
431 std::unique_ptr<ContentClient> content_client_; | 435 std::unique_ptr<ContentClient> content_client_; |
432 content::TestBrowserContext browser_context_; | 436 content::TestBrowserContext browser_context_; |
433 media::AudioDeviceDescriptions physical_audio_devices_; | 437 media::AudioDeviceDescriptions physical_audio_devices_; |
434 media::VideoCaptureDeviceDescriptors physical_video_devices_; | 438 media::VideoCaptureDeviceDescriptors physical_video_devices_; |
435 url::Origin origin_; | 439 url::Origin origin_; |
436 media::FakeVideoCaptureDeviceFactory* video_capture_device_factory_; | 440 media::FakeVideoCaptureDeviceFactory* video_capture_device_factory_; |
437 }; | 441 }; |
438 | 442 |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 base::RunLoop run_loop; | 853 base::RunLoop run_loop; |
850 EXPECT_CALL(*host_.get(), OnDeviceStopped(kRenderId)) | 854 EXPECT_CALL(*host_.get(), OnDeviceStopped(kRenderId)) |
851 .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 855 .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
852 media_stream_manager_->media_devices_manager()->OnDevicesChanged( | 856 media_stream_manager_->media_devices_manager()->OnDevicesChanged( |
853 base::SystemMonitor::DEVTYPE_VIDEO_CAPTURE); | 857 base::SystemMonitor::DEVTYPE_VIDEO_CAPTURE); |
854 | 858 |
855 run_loop.Run(); | 859 run_loop.Run(); |
856 } | 860 } |
857 | 861 |
858 }; // namespace content | 862 }; // namespace content |
OLD | NEW |