Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc

Issue 1806313003: Pass task runners to AudioManager constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments from patch 48 Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 : old_browser_client_(NULL), 228 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
229 thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), 229 old_browser_client_(NULL),
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
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_;
426 std::unique_ptr<MediaStreamManager> media_stream_manager_; 425 std::unique_ptr<MediaStreamManager> media_stream_manager_;
426 content::TestBrowserThreadBundle thread_bundle_;
427 std::unique_ptr<media::AudioManager, media::AudioManagerDeleter>
428 audio_manager_;
427 MockMediaStreamUIProxy* stream_ui_; 429 MockMediaStreamUIProxy* stream_ui_;
428 ContentBrowserClient* old_browser_client_; 430 ContentBrowserClient* old_browser_client_;
429 std::unique_ptr<ContentClient> content_client_; 431 std::unique_ptr<ContentClient> content_client_;
430 content::TestBrowserThreadBundle thread_bundle_;
431 content::TestBrowserContext browser_context_; 432 content::TestBrowserContext browser_context_;
432 media::AudioDeviceNames physical_audio_devices_; 433 media::AudioDeviceNames physical_audio_devices_;
433 media::VideoCaptureDevice::Names physical_video_devices_; 434 media::VideoCaptureDevice::Names physical_video_devices_;
434 GURL origin_; 435 GURL origin_;
435 media::FakeVideoCaptureDeviceFactory* video_capture_device_factory_; 436 media::FakeVideoCaptureDeviceFactory* video_capture_device_factory_;
436 }; 437 };
437 438
438 TEST_F(MediaStreamDispatcherHostTest, GenerateStreamWithVideoOnly) { 439 TEST_F(MediaStreamDispatcherHostTest, GenerateStreamWithVideoOnly) {
439 StreamControls controls(false, true); 440 StreamControls controls(false, true);
440 441
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 908
908 TEST_F(MediaStreamDispatcherHostTest, EnumerateVideoDevicesNoAccess) { 909 TEST_F(MediaStreamDispatcherHostTest, EnumerateVideoDevicesNoAccess) {
909 SetupFakeUI(false); 910 SetupFakeUI(false);
910 stream_ui_->SetCameraAccess(false); 911 stream_ui_->SetCameraAccess(false);
911 EnumerateDevicesAndWaitForResult(kRenderId, kPageRequestId, 912 EnumerateDevicesAndWaitForResult(kRenderId, kPageRequestId,
912 MEDIA_DEVICE_VIDEO_CAPTURE); 913 MEDIA_DEVICE_VIDEO_CAPTURE);
913 EXPECT_TRUE(DoesNotContainLabels(host_->enumerated_devices_)); 914 EXPECT_TRUE(DoesNotContainLabels(host_->enumerated_devices_));
914 } 915 }
915 916
916 }; // namespace content 917 }; // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698