Index: content/test/webrtc_audio_device_test.cc |
=================================================================== |
--- content/test/webrtc_audio_device_test.cc (revision 225900) |
+++ content/test/webrtc_audio_device_test.cc (working copy) |
@@ -77,6 +77,61 @@ |
DISALLOW_COPY_AND_ASSIGN(WebRTCMockRenderProcess); |
}; |
+class TestAudioRendererHost : public AudioRendererHost { |
+ public: |
+ TestAudioRendererHost( |
+ int render_process_id, |
+ media::AudioManager* audio_manager, |
+ AudioMirroringManager* mirroring_manager, |
+ MediaInternals* media_internals, |
+ MediaStreamManager* media_stream_manager, |
+ IPC::Channel* channel) |
+ : AudioRendererHost(render_process_id, audio_manager, mirroring_manager, |
+ media_internals, media_stream_manager), |
+ channel_(channel) {} |
+ virtual bool Send(IPC::Message* message) OVERRIDE { |
+ if (channel_) |
+ return channel_->Send(message); |
+ return false; |
+ } |
+ void ResetChannel() { |
+ channel_ = NULL; |
+ } |
+ |
+ protected: |
+ virtual ~TestAudioRendererHost() {} |
+ |
+ private: |
+ IPC::Channel* channel_; |
+}; |
+ |
+class TestAudioInputRendererHost : public AudioInputRendererHost { |
+ public: |
+ TestAudioInputRendererHost( |
+ media::AudioManager* audio_manager, |
+ MediaStreamManager* media_stream_manager, |
+ AudioMirroringManager* audio_mirroring_manager, |
+ media::UserInputMonitor* user_input_monitor, |
+ IPC::Channel* channel) |
+ : AudioInputRendererHost(audio_manager, media_stream_manager, |
+ audio_mirroring_manager, user_input_monitor), |
+ channel_(channel) {} |
+ virtual bool Send(IPC::Message* message) OVERRIDE { |
+ if (channel_) |
+ return channel_->Send(message); |
+ return false; |
+ } |
+ void ResetChannel() { |
+ channel_ = NULL; |
+ } |
+ |
+ protected: |
+ virtual ~TestAudioInputRendererHost() {} |
+ |
+ private: |
+ IPC::Channel* channel_; |
+}; |
+ |
// Utility scoped class to replace the global content client's renderer for the |
// duration of the test. |
class ReplaceContentClientRenderer { |
@@ -258,24 +313,23 @@ |
void MAYBE_WebRTCAudioDeviceTest::CreateChannel(const char* name) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+ channel_.reset(new IPC::Channel(name, IPC::Channel::MODE_SERVER, this)); |
+ ASSERT_TRUE(channel_->Connect()); |
+ |
static const int kRenderProcessId = 1; |
- audio_render_host_ = new AudioRendererHost( |
+ audio_render_host_ = new TestAudioRendererHost( |
kRenderProcessId, audio_manager_.get(), mirroring_manager_.get(), |
- media_internals_.get(), media_stream_manager_.get()); |
- audio_render_host_->OnChannelConnected(base::GetCurrentProcId()); |
+ media_internals_.get(), media_stream_manager_.get(), channel_.get()); |
+ audio_render_host_->set_peer_pid_for_testing(base::GetCurrentProcId()); |
audio_input_renderer_host_ = |
- new AudioInputRendererHost(audio_manager_.get(), |
- media_stream_manager_.get(), |
- mirroring_manager_.get(), |
- NULL); |
- audio_input_renderer_host_->OnChannelConnected(base::GetCurrentProcId()); |
- |
- channel_.reset(new IPC::Channel(name, IPC::Channel::MODE_SERVER, this)); |
- ASSERT_TRUE(channel_->Connect()); |
- |
- audio_render_host_->OnFilterAdded(channel_.get()); |
- audio_input_renderer_host_->OnFilterAdded(channel_.get()); |
+ new TestAudioInputRendererHost(audio_manager_.get(), |
+ media_stream_manager_.get(), |
+ mirroring_manager_.get(), |
+ NULL, |
+ channel_.get()); |
+ audio_input_renderer_host_->set_peer_pid_for_testing( |
+ base::GetCurrentProcId()); |
} |
void MAYBE_WebRTCAudioDeviceTest::DestroyChannel() { |
@@ -284,6 +338,8 @@ |
audio_render_host_->OnFilterRemoved(); |
audio_input_renderer_host_->OnChannelClosing(); |
audio_input_renderer_host_->OnFilterRemoved(); |
+ audio_render_host_->ResetChannel(); |
+ audio_input_renderer_host_->ResetChannel(); |
channel_.reset(); |
audio_render_host_ = NULL; |
audio_input_renderer_host_ = NULL; |