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

Side by Side Diff: content/browser/renderer_host/media/audio_input_renderer_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/audio_input_renderer_host.h" 5 #include "content/browser/renderer_host/media/audio_input_renderer_host.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "content/browser/bad_message.h" 15 #include "content/browser/bad_message.h"
16 #include "content/browser/media/capture/audio_mirroring_manager.h" 16 #include "content/browser/media/capture/audio_mirroring_manager.h"
17 #include "content/browser/renderer_host/media/audio_input_device_manager.h" 17 #include "content/browser/renderer_host/media/audio_input_device_manager.h"
18 #include "content/browser/renderer_host/media/media_stream_manager.h" 18 #include "content/browser/renderer_host/media/media_stream_manager.h"
19 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" 19 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 #include "content/public/common/content_switches.h" 21 #include "content/public/common/content_switches.h"
22 #include "content/public/test/mock_render_process_host.h" 22 #include "content/public/test/mock_render_process_host.h"
23 #include "content/public/test/test_browser_context.h" 23 #include "content/public/test/test_browser_context.h"
24 #include "content/public/test/test_browser_thread.h" 24 #include "content/public/test/test_browser_thread.h"
25 #include "content/public/test/test_browser_thread_bundle.h" 25 #include "content/public/test/test_browser_thread_bundle.h"
26 #include "media/audio/audio_device_description.h" 26 #include "media/audio/audio_device_description.h"
27 #include "media/audio/audio_system_impl.h"
27 #include "media/audio/fake_audio_log_factory.h" 28 #include "media/audio/fake_audio_log_factory.h"
28 #include "media/audio/fake_audio_manager.h" 29 #include "media/audio/fake_audio_manager.h"
29 #include "media/base/media_switches.h" 30 #include "media/base/media_switches.h"
30 #include "testing/gmock/include/gmock/gmock.h" 31 #include "testing/gmock/include/gmock/gmock.h"
31 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
32 #include "url/gurl.h" 33 #include "url/gurl.h"
33 #include "url/origin.h" 34 #include "url/origin.h"
34 35
35 using ::media::AudioInputController; 36 using ::media::AudioInputController;
36 using ::testing::_; 37 using ::testing::_;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 class AudioInputRendererHostTest : public testing::Test { 260 class AudioInputRendererHostTest : public testing::Test {
260 public: 261 public:
261 AudioInputRendererHostTest() { 262 AudioInputRendererHostTest() {
262 base::CommandLine* flags = base::CommandLine::ForCurrentProcess(); 263 base::CommandLine* flags = base::CommandLine::ForCurrentProcess();
263 flags->AppendSwitch(switches::kUseFakeDeviceForMediaStream); 264 flags->AppendSwitch(switches::kUseFakeDeviceForMediaStream);
264 flags->AppendSwitch(switches::kUseFakeUIForMediaStream); 265 flags->AppendSwitch(switches::kUseFakeUIForMediaStream);
265 266
266 audio_manager_.reset(new media::FakeAudioManager( 267 audio_manager_.reset(new media::FakeAudioManager(
267 base::ThreadTaskRunnerHandle::Get(), 268 base::ThreadTaskRunnerHandle::Get(),
268 base::ThreadTaskRunnerHandle::Get(), &log_factory_)); 269 base::ThreadTaskRunnerHandle::Get(), &log_factory_));
270 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get());
269 media_stream_manager_ = 271 media_stream_manager_ =
270 base::MakeUnique<MediaStreamManager>(audio_manager_.get()); 272 base::MakeUnique<MediaStreamManager>(audio_system_.get());
271 airh_ = new AudioInputRendererHostWithInterception( 273 airh_ = new AudioInputRendererHostWithInterception(
272 kRenderProcessId, kRendererPid, media::AudioManager::Get(), 274 kRenderProcessId, kRendererPid, media::AudioManager::Get(),
273 media_stream_manager_.get(), AudioMirroringManager::GetInstance(), 275 media_stream_manager_.get(), AudioMirroringManager::GetInstance(),
274 nullptr, &renderer_); 276 nullptr, &renderer_);
275 } 277 }
276 278
277 ~AudioInputRendererHostTest() override { 279 ~AudioInputRendererHostTest() override {
278 airh_->OnChannelClosing(); 280 airh_->OnChannelClosing();
279 base::RunLoop().RunUntilIdle(); 281 base::RunLoop().RunUntilIdle();
280 } 282 }
(...skipping 27 matching lines...) Expand all
308 base::Unretained(&id))); 310 base::Unretained(&id)));
309 base::RunLoop().RunUntilIdle(); 311 base::RunLoop().RunUntilIdle();
310 return id; 312 return id;
311 } 313 }
312 314
313 media::FakeAudioLogFactory log_factory_; 315 media::FakeAudioLogFactory log_factory_;
314 StrictMock<MockControllerFactory> controller_factory_; 316 StrictMock<MockControllerFactory> controller_factory_;
315 std::unique_ptr<MediaStreamManager> media_stream_manager_; 317 std::unique_ptr<MediaStreamManager> media_stream_manager_;
316 TestBrowserThreadBundle thread_bundle_; 318 TestBrowserThreadBundle thread_bundle_;
317 media::ScopedAudioManagerPtr audio_manager_; 319 media::ScopedAudioManagerPtr audio_manager_;
320 std::unique_ptr<media::AudioSystem> audio_system_;
318 StrictMock<MockRenderer> renderer_; 321 StrictMock<MockRenderer> renderer_;
319 scoped_refptr<AudioInputRendererHost> airh_; 322 scoped_refptr<AudioInputRendererHost> airh_;
320 323
321 private: 324 private:
322 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHostTest); 325 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHostTest);
323 }; 326 };
324 327
325 // Checks that a controller is created and a reply is sent when creating a 328 // Checks that a controller is created and a reply is sent when creating a
326 // stream. 329 // stream.
327 TEST_F(AudioInputRendererHostTest, CreateWithDefaultDevice) { 330 TEST_F(AudioInputRendererHostTest, CreateWithDefaultDevice) {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 EXPECT_CALL(controller_factory_, ControllerCreated()); 558 EXPECT_CALL(controller_factory_, ControllerCreated());
556 559
557 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream( 560 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream(
558 kStreamId, kRenderFrameId, session_id, DefaultConfig())); 561 kStreamId, kRenderFrameId, session_id, DefaultConfig()));
559 base::RunLoop().RunUntilIdle(); 562 base::RunLoop().RunUntilIdle();
560 563
561 EXPECT_CALL(*controller_factory_.controller(0), Close(_)); 564 EXPECT_CALL(*controller_factory_.controller(0), Close(_));
562 } 565 }
563 566
564 } // namespace content 567 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698