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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/sync_socket.h" | 9 #include "base/sync_socket.h" |
| 10 #include "content/browser/browser_message_filter_peer.h" |
10 #include "content/browser/media/capture/audio_mirroring_manager.h" | 11 #include "content/browser/media/capture/audio_mirroring_manager.h" |
11 #include "content/browser/media/media_internals.h" | 12 #include "content/browser/media/media_internals.h" |
12 #include "content/browser/renderer_host/media/audio_input_device_manager.h" | 13 #include "content/browser/renderer_host/media/audio_input_device_manager.h" |
13 #include "content/browser/renderer_host/media/audio_renderer_host.h" | 14 #include "content/browser/renderer_host/media/audio_renderer_host.h" |
14 #include "content/browser/renderer_host/media/media_stream_manager.h" | 15 #include "content/browser/renderer_host/media/media_stream_manager.h" |
15 #include "content/common/media/audio_messages.h" | 16 #include "content/common/media/audio_messages.h" |
16 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
17 #include "content/public/test/test_browser_thread_bundle.h" | 18 #include "content/public/test/test_browser_thread_bundle.h" |
18 #include "ipc/ipc_message_utils.h" | 19 #include "ipc/ipc_message_utils.h" |
19 #include "media/audio/audio_manager.h" | 20 #include "media/audio/audio_manager.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 audio_manager_.reset(media::AudioManager::CreateForTesting()); | 160 audio_manager_.reset(media::AudioManager::CreateForTesting()); |
160 CommandLine::ForCurrentProcess()->AppendSwitch( | 161 CommandLine::ForCurrentProcess()->AppendSwitch( |
161 switches::kUseFakeDeviceForMediaStream); | 162 switches::kUseFakeDeviceForMediaStream); |
162 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); | 163 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); |
163 host_ = new MockAudioRendererHost(audio_manager_.get(), | 164 host_ = new MockAudioRendererHost(audio_manager_.get(), |
164 &mirroring_manager_, | 165 &mirroring_manager_, |
165 MediaInternals::GetInstance(), | 166 MediaInternals::GetInstance(), |
166 media_stream_manager_.get()); | 167 media_stream_manager_.get()); |
167 | 168 |
168 // Simulate IPC channel connected. | 169 // Simulate IPC channel connected. |
169 host_->set_peer_pid_for_testing(base::GetCurrentProcId()); | 170 host_peer_.reset(new BrowserMessageFilterPeer(base::GetCurrentProcId())); |
| 171 host_->OnFilterAddedToHost(host_peer_.get()); |
170 } | 172 } |
171 | 173 |
172 virtual ~AudioRendererHostTest() { | 174 virtual ~AudioRendererHostTest() { |
173 // Simulate closing the IPC channel and give the audio thread time to close | 175 // Simulate closing the IPC channel and give the audio thread time to close |
174 // the underlying streams. | 176 // the underlying streams. |
175 host_->OnChannelClosing(); | 177 host_->OnSenderClosing(); |
176 SyncWithAudioThread(); | 178 SyncWithAudioThread(); |
177 | 179 |
178 // Release the reference to the mock object. The object will be destructed | 180 // Release the reference to the mock object. The object will be destructed |
179 // on message_loop_. | 181 // on message_loop_. |
180 host_ = NULL; | 182 host_ = NULL; |
181 } | 183 } |
182 | 184 |
183 protected: | 185 protected: |
184 void Create(bool unified_stream) { | 186 void Create(bool unified_stream) { |
185 EXPECT_CALL(*host_.get(), OnStreamCreated(kStreamId, _)); | 187 EXPECT_CALL(*host_.get(), OnStreamCreated(kStreamId, _)); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 } | 277 } |
276 | 278 |
277 private: | 279 private: |
278 // MediaStreamManager uses a DestructionObserver, so it must outlive the | 280 // MediaStreamManager uses a DestructionObserver, so it must outlive the |
279 // TestBrowserThreadBundle. | 281 // TestBrowserThreadBundle. |
280 scoped_ptr<MediaStreamManager> media_stream_manager_; | 282 scoped_ptr<MediaStreamManager> media_stream_manager_; |
281 TestBrowserThreadBundle thread_bundle_; | 283 TestBrowserThreadBundle thread_bundle_; |
282 scoped_ptr<media::AudioManager> audio_manager_; | 284 scoped_ptr<media::AudioManager> audio_manager_; |
283 MockAudioMirroringManager mirroring_manager_; | 285 MockAudioMirroringManager mirroring_manager_; |
284 scoped_refptr<MockAudioRendererHost> host_; | 286 scoped_refptr<MockAudioRendererHost> host_; |
| 287 scoped_ptr<BrowserMessageFilterPeer> host_peer_; |
285 | 288 |
286 DISALLOW_COPY_AND_ASSIGN(AudioRendererHostTest); | 289 DISALLOW_COPY_AND_ASSIGN(AudioRendererHostTest); |
287 }; | 290 }; |
288 | 291 |
289 TEST_F(AudioRendererHostTest, CreateAndClose) { | 292 TEST_F(AudioRendererHostTest, CreateAndClose) { |
290 Create(false); | 293 Create(false); |
291 Close(); | 294 Close(); |
292 } | 295 } |
293 | 296 |
294 // Simulate the case where a stream is not properly closed. | 297 // Simulate the case where a stream is not properly closed. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } | 350 } |
348 | 351 |
349 TEST_F(AudioRendererHostTest, CreateUnifiedStreamAndClose) { | 352 TEST_F(AudioRendererHostTest, CreateUnifiedStreamAndClose) { |
350 Create(true); | 353 Create(true); |
351 Close(); | 354 Close(); |
352 } | 355 } |
353 | 356 |
354 // TODO(hclam): Add tests for data conversation in low latency mode. | 357 // TODO(hclam): Add tests for data conversation in low latency mode. |
355 | 358 |
356 } // namespace content | 359 } // namespace content |
OLD | NEW |