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/test/webrtc_audio_device_test.h" | 5 #include "content/test/webrtc_audio_device_test.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // Main parts are inspired by the RenderViewFakeResourcesTest. | 133 // Main parts are inspired by the RenderViewFakeResourcesTest. |
134 // Note that, the IPC part is not utilized in this test. | 134 // Note that, the IPC part is not utilized in this test. |
135 saved_content_renderer_.reset( | 135 saved_content_renderer_.reset( |
136 new ReplaceContentClientRenderer(&content_renderer_client_)); | 136 new ReplaceContentClientRenderer(&content_renderer_client_)); |
137 mock_process_.reset(new WebRTCMockRenderProcess()); | 137 mock_process_.reset(new WebRTCMockRenderProcess()); |
138 ui_thread_.reset( | 138 ui_thread_.reset( |
139 new TestBrowserThread(BrowserThread::UI, base::MessageLoop::current())); | 139 new TestBrowserThread(BrowserThread::UI, base::MessageLoop::current())); |
140 | 140 |
141 // Construct the resource context on the UI thread. | 141 // Construct the resource context on the UI thread. |
142 resource_context_.reset(new MockRTCResourceContext); | 142 resource_context_.reset(new MockRTCResourceContext); |
| 143 audio_manager_.reset(media::AudioManager::Create()); |
| 144 mirroring_manager_.reset(new AudioMirroringManager()); |
143 | 145 |
144 static const char kThreadName[] = "RenderThread"; | 146 static const char kThreadName[] = "RenderThread"; |
145 ChildProcess::current()->io_message_loop()->PostTask(FROM_HERE, | 147 ChildProcess::current()->io_message_loop()->PostTask(FROM_HERE, |
146 base::Bind(&WebRTCAudioDeviceTest::InitializeIOThread, | 148 base::Bind(&WebRTCAudioDeviceTest::InitializeIOThread, |
147 base::Unretained(this), kThreadName)); | 149 base::Unretained(this), kThreadName)); |
148 WaitForIOThreadCompletion(); | 150 WaitForIOThreadCompletion(); |
149 | 151 |
150 sandbox_was_enabled_ = | 152 sandbox_was_enabled_ = |
151 RendererWebKitPlatformSupportImpl::SetSandboxEnabledForTesting(false); | 153 RendererWebKitPlatformSupportImpl::SetSandboxEnabledForTesting(false); |
152 render_thread_ = new RenderThreadImpl(kThreadName); | 154 render_thread_ = new RenderThreadImpl(kThreadName); |
(...skipping 21 matching lines...) Expand all Loading... |
174 WaitForAudioManagerCompletion(); | 176 WaitForAudioManagerCompletion(); |
175 | 177 |
176 ChildProcess::current()->io_message_loop()->PostTask(FROM_HERE, | 178 ChildProcess::current()->io_message_loop()->PostTask(FROM_HERE, |
177 base::Bind(&WebRTCAudioDeviceTest::UninitializeIOThread, | 179 base::Bind(&WebRTCAudioDeviceTest::UninitializeIOThread, |
178 base::Unretained((this)))); | 180 base::Unretained((this)))); |
179 WaitForIOThreadCompletion(); | 181 WaitForIOThreadCompletion(); |
180 mock_process_.reset(); | 182 mock_process_.reset(); |
181 media_stream_manager_.reset(); | 183 media_stream_manager_.reset(); |
182 mirroring_manager_.reset(); | 184 mirroring_manager_.reset(); |
183 audio_manager_.reset(); | 185 audio_manager_.reset(); |
| 186 |
184 RendererWebKitPlatformSupportImpl::SetSandboxEnabledForTesting( | 187 RendererWebKitPlatformSupportImpl::SetSandboxEnabledForTesting( |
185 sandbox_was_enabled_); | 188 sandbox_was_enabled_); |
186 } | 189 } |
187 | 190 |
188 bool WebRTCAudioDeviceTest::Send(IPC::Message* message) { | 191 bool WebRTCAudioDeviceTest::Send(IPC::Message* message) { |
189 return channel_->Send(message); | 192 return channel_->Send(message); |
190 } | 193 } |
191 | 194 |
192 void WebRTCAudioDeviceTest::SetAudioHardwareConfig( | 195 void WebRTCAudioDeviceTest::SetAudioHardwareConfig( |
193 media::AudioHardwareConfig* hardware_config) { | 196 media::AudioHardwareConfig* hardware_config) { |
(...skipping 10 matching lines...) Expand all Loading... |
204 // Set the current thread as the IO thread. | 207 // Set the current thread as the IO thread. |
205 io_thread_.reset( | 208 io_thread_.reset( |
206 new TestBrowserThread(BrowserThread::IO, base::MessageLoop::current())); | 209 new TestBrowserThread(BrowserThread::IO, base::MessageLoop::current())); |
207 | 210 |
208 // Populate our resource context. | 211 // Populate our resource context. |
209 test_request_context_.reset(new net::TestURLRequestContext()); | 212 test_request_context_.reset(new net::TestURLRequestContext()); |
210 MockRTCResourceContext* resource_context = | 213 MockRTCResourceContext* resource_context = |
211 static_cast<MockRTCResourceContext*>(resource_context_.get()); | 214 static_cast<MockRTCResourceContext*>(resource_context_.get()); |
212 resource_context->set_request_context(test_request_context_.get()); | 215 resource_context->set_request_context(test_request_context_.get()); |
213 media_internals_.reset(new MockMediaInternals()); | 216 media_internals_.reset(new MockMediaInternals()); |
214 | |
215 // Create our own AudioManager, AudioMirroringManager and MediaStreamManager. | |
216 audio_manager_.reset(media::AudioManager::Create()); | |
217 mirroring_manager_.reset(new AudioMirroringManager()); | |
218 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); | 217 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); |
219 | 218 |
220 has_input_devices_ = audio_manager_->HasAudioInputDevices(); | 219 has_input_devices_ = audio_manager_->HasAudioInputDevices(); |
221 has_output_devices_ = audio_manager_->HasAudioOutputDevices(); | 220 has_output_devices_ = audio_manager_->HasAudioOutputDevices(); |
222 | 221 |
223 // Create an IPC channel that handles incoming messages on the IO thread. | 222 // Create an IPC channel that handles incoming messages on the IO thread. |
224 CreateChannel(thread_name); | 223 CreateChannel(thread_name); |
225 } | 224 } |
226 | 225 |
227 void WebRTCAudioDeviceTest::UninitializeIOThread() { | 226 void WebRTCAudioDeviceTest::UninitializeIOThread() { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) { | 356 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) { |
358 return network_->ReceivedRTPPacket(channel, data, len); | 357 return network_->ReceivedRTPPacket(channel, data, len); |
359 } | 358 } |
360 | 359 |
361 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data, | 360 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data, |
362 int len) { | 361 int len) { |
363 return network_->ReceivedRTCPPacket(channel, data, len); | 362 return network_->ReceivedRTCPPacket(channel, data, len); |
364 } | 363 } |
365 | 364 |
366 } // namespace content | 365 } // namespace content |
OLD | NEW |