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

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

Issue 2697033006: Switching MediaStreamManager from using AudioManager to AudioSystem (Closed)
Patch Set: weak pointers removed Created 3 years, 9 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 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_dispatcher_host.h" 5 #include "content/browser/renderer_host/media/media_devices_dispatcher_host.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <queue> 10 #include <queue>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
19 #include "base/threading/thread_task_runner_handle.h" 19 #include "base/threading/thread_task_runner_handle.h"
20 #include "content/browser/renderer_host/media/media_stream_manager.h" 20 #include "content/browser/renderer_host/media/media_stream_manager.h"
21 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" 21 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h"
22 #include "content/browser/renderer_host/media/video_capture_manager.h" 22 #include "content/browser/renderer_host/media/video_capture_manager.h"
23 #include "content/public/browser/media_device_id.h" 23 #include "content/public/browser/media_device_id.h"
24 #include "content/public/test/mock_resource_context.h" 24 #include "content/public/test/mock_resource_context.h"
25 #include "content/public/test/test_browser_context.h" 25 #include "content/public/test/test_browser_context.h"
26 #include "content/public/test/test_browser_thread_bundle.h" 26 #include "content/public/test/test_browser_thread_bundle.h"
27 #include "media/audio/audio_device_description.h" 27 #include "media/audio/audio_device_description.h"
28 #include "media/audio/audio_system_impl.h"
28 #include "media/audio/mock_audio_manager.h" 29 #include "media/audio/mock_audio_manager.h"
29 #include "media/base/media_switches.h" 30 #include "media/base/media_switches.h"
30 #include "media/capture/video/fake_video_capture_device_factory.h" 31 #include "media/capture/video/fake_video_capture_device_factory.h"
31 #include "mojo/public/cpp/bindings/binding.h" 32 #include "mojo/public/cpp/bindings/binding.h"
32 #include "testing/gmock/include/gmock/gmock.h" 33 #include "testing/gmock/include/gmock/gmock.h"
33 #include "testing/gtest/include/gtest/gtest.h" 34 #include "testing/gtest/include/gtest/gtest.h"
34 #include "url/origin.h" 35 #include "url/origin.h"
35 36
36 using testing::_; 37 using testing::_;
37 using testing::SaveArg; 38 using testing::SaveArg;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 MediaDevicesDispatcherHostTest() 75 MediaDevicesDispatcherHostTest()
75 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), 76 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
76 origin_(GURL("https://test.com")) { 77 origin_(GURL("https://test.com")) {
77 // Make sure we use fake devices to avoid long delays. 78 // Make sure we use fake devices to avoid long delays.
78 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 79 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
79 switches::kUseFakeDeviceForMediaStream, 80 switches::kUseFakeDeviceForMediaStream,
80 base::StringPrintf("device-count=%zu, video-input-default-id=%s", 81 base::StringPrintf("device-count=%zu, video-input-default-id=%s",
81 kNumFakeVideoDevices, kDefaultVideoDeviceID)); 82 kNumFakeVideoDevices, kDefaultVideoDeviceID));
82 audio_manager_.reset( 83 audio_manager_.reset(
83 new media::MockAudioManager(base::ThreadTaskRunnerHandle::Get())); 84 new media::MockAudioManager(base::ThreadTaskRunnerHandle::Get()));
84 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); 85 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get());
86 media_stream_manager_ =
87 base::MakeUnique<MediaStreamManager>(audio_system_.get());
85 88
86 MockResourceContext* mock_resource_context = 89 MockResourceContext* mock_resource_context =
87 static_cast<MockResourceContext*>( 90 static_cast<MockResourceContext*>(
88 browser_context_.GetResourceContext()); 91 browser_context_.GetResourceContext());
89 92
90 host_ = base::MakeUnique<MediaDevicesDispatcherHost>( 93 host_ = base::MakeUnique<MediaDevicesDispatcherHost>(
91 kProcessId, kRenderId, mock_resource_context->GetMediaDeviceIDSalt(), 94 kProcessId, kRenderId, mock_resource_context->GetMediaDeviceIDSalt(),
92 media_stream_manager_.get()); 95 media_stream_manager_.get());
93 } 96 }
94 97
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 // The order of these members is important on teardown: 282 // The order of these members is important on teardown:
280 // MediaDevicesDispatcherHost expects to be destroyed on the IO thread while 283 // MediaDevicesDispatcherHost expects to be destroyed on the IO thread while
281 // MediaStreamManager expects to be destroyed after the IO thread has been 284 // MediaStreamManager expects to be destroyed after the IO thread has been
282 // uninitialized. 285 // uninitialized.
283 std::unique_ptr<MediaStreamManager> media_stream_manager_; 286 std::unique_ptr<MediaStreamManager> media_stream_manager_;
284 content::TestBrowserThreadBundle thread_bundle_; 287 content::TestBrowserThreadBundle thread_bundle_;
285 std::unique_ptr<MediaDevicesDispatcherHost> host_; 288 std::unique_ptr<MediaDevicesDispatcherHost> host_;
286 289
287 std::unique_ptr<media::AudioManager, media::AudioManagerDeleter> 290 std::unique_ptr<media::AudioManager, media::AudioManagerDeleter>
288 audio_manager_; 291 audio_manager_;
292 std::unique_ptr<media::AudioSystem> audio_system_;
289 content::TestBrowserContext browser_context_; 293 content::TestBrowserContext browser_context_;
290 MediaDeviceEnumeration physical_devices_; 294 MediaDeviceEnumeration physical_devices_;
291 url::Origin origin_; 295 url::Origin origin_;
292 296
293 std::vector<MediaDeviceInfoArray> enumerated_devices_; 297 std::vector<MediaDeviceInfoArray> enumerated_devices_;
294 }; 298 };
295 299
296 TEST_F(MediaDevicesDispatcherHostTest, EnumerateAudioInputDevices) { 300 TEST_F(MediaDevicesDispatcherHostTest, EnumerateAudioInputDevices) {
297 EnumerateDevicesAndWaitForResult(true, false, false); 301 EnumerateDevicesAndWaitForResult(true, false, false);
298 EXPECT_TRUE(DoesContainLabels(enumerated_devices_)); 302 EXPECT_TRUE(DoesContainLabels(enumerated_devices_));
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 // On Windows, the underlying MediaStreamManager uses a separate thread for 382 // On Windows, the underlying MediaStreamManager uses a separate thread for
379 // video capture which must be flushed to guarantee that the callback bound to 383 // video capture which must be flushed to guarantee that the callback bound to
380 // GetVIdeoInputCapabilities above is invoked before the end of this test's 384 // GetVIdeoInputCapabilities above is invoked before the end of this test's
381 // body. 385 // body.
382 media_stream_manager_->FlushVideoCaptureThreadForTesting(); 386 media_stream_manager_->FlushVideoCaptureThreadForTesting();
383 base::RunLoop().RunUntilIdle(); 387 base::RunLoop().RunUntilIdle();
384 #endif 388 #endif
385 } 389 }
386 390
387 }; // namespace content 391 }; // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698