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 <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 public: | 218 public: |
219 MOCK_METHOD2( | 219 MOCK_METHOD2( |
220 OnStarted, | 220 OnStarted, |
221 void(const base::Closure& stop, | 221 void(const base::Closure& stop, |
222 const MediaStreamUIProxy::WindowIdCallback& window_id_callback)); | 222 const MediaStreamUIProxy::WindowIdCallback& window_id_callback)); |
223 }; | 223 }; |
224 | 224 |
225 class MediaStreamDispatcherHostTest : public testing::Test { | 225 class MediaStreamDispatcherHostTest : public testing::Test { |
226 public: | 226 public: |
227 MediaStreamDispatcherHostTest() | 227 MediaStreamDispatcherHostTest() |
228 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | 228 : old_browser_client_(NULL), |
229 old_browser_client_(NULL), | 229 thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
230 origin_("https://test.com") { | 230 origin_("https://test.com") { |
231 audio_manager_.reset( | 231 audio_manager_.reset( |
232 new media::MockAudioManager(base::ThreadTaskRunnerHandle::Get())); | 232 new media::MockAudioManager(base::ThreadTaskRunnerHandle::Get())); |
233 // Make sure we use fake devices to avoid long delays. | 233 // Make sure we use fake devices to avoid long delays. |
234 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 234 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
235 switches::kUseFakeDeviceForMediaStream); | 235 switches::kUseFakeDeviceForMediaStream); |
236 // Create our own MediaStreamManager. | 236 // Create our own MediaStreamManager. |
237 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); | 237 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); |
238 video_capture_device_factory_ = | 238 video_capture_device_factory_ = |
239 static_cast<media::FakeVideoCaptureDeviceFactory*>( | 239 static_cast<media::FakeVideoCaptureDeviceFactory*>( |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 // Returns true if no devices have labels, false otherwise. | 415 // Returns true if no devices have labels, false otherwise. |
416 bool DoesNotContainLabels(const StreamDeviceInfoArray& devices) { | 416 bool DoesNotContainLabels(const StreamDeviceInfoArray& devices) { |
417 for (size_t i = 0; i < devices.size(); ++i) { | 417 for (size_t i = 0; i < devices.size(); ++i) { |
418 if (!devices[i].device.name.empty()) | 418 if (!devices[i].device.name.empty()) |
419 return false; | 419 return false; |
420 } | 420 } |
421 return true; | 421 return true; |
422 } | 422 } |
423 | 423 |
424 scoped_refptr<MockMediaStreamDispatcherHost> host_; | 424 scoped_refptr<MockMediaStreamDispatcherHost> host_; |
| 425 std::unique_ptr<media::AudioManager> audio_manager_; |
425 std::unique_ptr<MediaStreamManager> media_stream_manager_; | 426 std::unique_ptr<MediaStreamManager> media_stream_manager_; |
426 content::TestBrowserThreadBundle thread_bundle_; | |
427 std::unique_ptr<media::AudioManager, media::AudioManagerDeleter> | |
428 audio_manager_; | |
429 MockMediaStreamUIProxy* stream_ui_; | 427 MockMediaStreamUIProxy* stream_ui_; |
430 ContentBrowserClient* old_browser_client_; | 428 ContentBrowserClient* old_browser_client_; |
431 std::unique_ptr<ContentClient> content_client_; | 429 std::unique_ptr<ContentClient> content_client_; |
| 430 content::TestBrowserThreadBundle thread_bundle_; |
432 content::TestBrowserContext browser_context_; | 431 content::TestBrowserContext browser_context_; |
433 media::AudioDeviceNames physical_audio_devices_; | 432 media::AudioDeviceNames physical_audio_devices_; |
434 media::VideoCaptureDevice::Names physical_video_devices_; | 433 media::VideoCaptureDevice::Names physical_video_devices_; |
435 GURL origin_; | 434 GURL origin_; |
436 media::FakeVideoCaptureDeviceFactory* video_capture_device_factory_; | 435 media::FakeVideoCaptureDeviceFactory* video_capture_device_factory_; |
437 }; | 436 }; |
438 | 437 |
439 TEST_F(MediaStreamDispatcherHostTest, GenerateStreamWithVideoOnly) { | 438 TEST_F(MediaStreamDispatcherHostTest, GenerateStreamWithVideoOnly) { |
440 StreamControls controls(false, true); | 439 StreamControls controls(false, true); |
441 | 440 |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 | 907 |
909 TEST_F(MediaStreamDispatcherHostTest, EnumerateVideoDevicesNoAccess) { | 908 TEST_F(MediaStreamDispatcherHostTest, EnumerateVideoDevicesNoAccess) { |
910 SetupFakeUI(false); | 909 SetupFakeUI(false); |
911 stream_ui_->SetCameraAccess(false); | 910 stream_ui_->SetCameraAccess(false); |
912 EnumerateDevicesAndWaitForResult(kRenderId, kPageRequestId, | 911 EnumerateDevicesAndWaitForResult(kRenderId, kPageRequestId, |
913 MEDIA_DEVICE_VIDEO_CAPTURE); | 912 MEDIA_DEVICE_VIDEO_CAPTURE); |
914 EXPECT_TRUE(DoesNotContainLabels(host_->enumerated_devices_)); | 913 EXPECT_TRUE(DoesNotContainLabels(host_->enumerated_devices_)); |
915 } | 914 } |
916 | 915 |
917 }; // namespace content | 916 }; // namespace content |
OLD | NEW |