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/environment.h" | 6 #include "base/environment.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
10 #include "base/sync_socket.h" | 10 #include "base/sync_socket.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 audio_manager_.reset(); | 192 audio_manager_.reset(); |
193 | 193 |
194 io_thread_.reset(); | 194 io_thread_.reset(); |
195 ui_thread_.reset(); | 195 ui_thread_.reset(); |
196 } | 196 } |
197 | 197 |
198 void Create() { | 198 void Create() { |
199 EXPECT_CALL(*observer_, | 199 EXPECT_CALL(*observer_, |
200 OnSetAudioStreamStatus(_, kStreamId, "created")); | 200 OnSetAudioStreamStatus(_, kStreamId, "created")); |
201 EXPECT_CALL(*host_, OnStreamCreated(kStreamId, _)) | 201 EXPECT_CALL(*host_.get(), OnStreamCreated(kStreamId, _)) |
202 .WillOnce(QuitMessageLoop(message_loop_.get())); | 202 .WillOnce(QuitMessageLoop(message_loop_.get())); |
203 EXPECT_CALL(mirroring_manager_, | 203 EXPECT_CALL(mirroring_manager_, |
204 AddDiverter(kRenderProcessId, kRenderViewId, NotNull())) | 204 AddDiverter(kRenderProcessId, kRenderViewId, NotNull())) |
205 .RetiresOnSaturation(); | 205 .RetiresOnSaturation(); |
206 | 206 |
207 // Send a create stream message to the audio output stream and wait until | 207 // Send a create stream message to the audio output stream and wait until |
208 // we receive the created message. | 208 // we receive the created message. |
209 host_->OnCreateStream(kStreamId, | 209 host_->OnCreateStream(kStreamId, |
210 kRenderViewId, | 210 kRenderViewId, |
211 media::AudioParameters( | 211 media::AudioParameters( |
(...skipping 20 matching lines...) Expand all Loading... |
232 void Close() { | 232 void Close() { |
233 // Send a message to AudioRendererHost to tell it we want to close the | 233 // Send a message to AudioRendererHost to tell it we want to close the |
234 // stream. | 234 // stream. |
235 host_->OnCloseStream(kStreamId); | 235 host_->OnCloseStream(kStreamId); |
236 message_loop_->RunUntilIdle(); | 236 message_loop_->RunUntilIdle(); |
237 } | 237 } |
238 | 238 |
239 void Play() { | 239 void Play() { |
240 EXPECT_CALL(*observer_, | 240 EXPECT_CALL(*observer_, |
241 OnSetAudioStreamPlaying(_, kStreamId, true)); | 241 OnSetAudioStreamPlaying(_, kStreamId, true)); |
242 EXPECT_CALL(*host_, OnStreamPlaying(kStreamId)) | 242 EXPECT_CALL(*host_.get(), OnStreamPlaying(kStreamId)) |
243 .WillOnce(QuitMessageLoop(message_loop_.get())); | 243 .WillOnce(QuitMessageLoop(message_loop_.get())); |
244 | 244 |
245 host_->OnPlayStream(kStreamId); | 245 host_->OnPlayStream(kStreamId); |
246 message_loop_->Run(); | 246 message_loop_->Run(); |
247 } | 247 } |
248 | 248 |
249 void Pause() { | 249 void Pause() { |
250 EXPECT_CALL(*observer_, | 250 EXPECT_CALL(*observer_, |
251 OnSetAudioStreamPlaying(_, kStreamId, false)); | 251 OnSetAudioStreamPlaying(_, kStreamId, false)); |
252 EXPECT_CALL(*host_, OnStreamPaused(kStreamId)) | 252 EXPECT_CALL(*host_.get(), OnStreamPaused(kStreamId)) |
253 .WillOnce(QuitMessageLoop(message_loop_.get())); | 253 .WillOnce(QuitMessageLoop(message_loop_.get())); |
254 | 254 |
255 host_->OnPauseStream(kStreamId); | 255 host_->OnPauseStream(kStreamId); |
256 message_loop_->Run(); | 256 message_loop_->Run(); |
257 } | 257 } |
258 | 258 |
259 void SetVolume(double volume) { | 259 void SetVolume(double volume) { |
260 EXPECT_CALL(*observer_, | 260 EXPECT_CALL(*observer_, |
261 OnSetAudioStreamVolume(_, kStreamId, volume)); | 261 OnSetAudioStreamVolume(_, kStreamId, volume)); |
262 | 262 |
263 host_->OnSetVolume(kStreamId, volume); | 263 host_->OnSetVolume(kStreamId, volume); |
264 message_loop_->RunUntilIdle(); | 264 message_loop_->RunUntilIdle(); |
265 } | 265 } |
266 | 266 |
267 void SimulateError() { | 267 void SimulateError() { |
268 EXPECT_CALL(*observer_, | 268 EXPECT_CALL(*observer_, |
269 OnSetAudioStreamStatus(_, kStreamId, "error")); | 269 OnSetAudioStreamStatus(_, kStreamId, "error")); |
270 EXPECT_EQ(1u, host_->audio_entries_.size()) | 270 EXPECT_EQ(1u, host_->audio_entries_.size()) |
271 << "Calls Create() before calling this method"; | 271 << "Calls Create() before calling this method"; |
272 | 272 |
273 // Expect an error signal sent through IPC. | 273 // Expect an error signal sent through IPC. |
274 EXPECT_CALL(*host_, OnStreamError(kStreamId)); | 274 EXPECT_CALL(*host_.get(), OnStreamError(kStreamId)); |
275 | 275 |
276 // Simulate an error sent from the audio device. | 276 // Simulate an error sent from the audio device. |
277 host_->ReportErrorAndClose(kStreamId); | 277 host_->ReportErrorAndClose(kStreamId); |
278 SyncWithAudioThread(); | 278 SyncWithAudioThread(); |
279 | 279 |
280 // Expect the audio stream record is removed. | 280 // Expect the audio stream record is removed. |
281 EXPECT_EQ(0u, host_->audio_entries_.size()); | 281 EXPECT_EQ(0u, host_->audio_entries_.size()); |
282 } | 282 } |
283 | 283 |
284 // Called on the audio thread. | 284 // Called on the audio thread. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 TEST_F(AudioRendererHostTest, SimulateErrorAndClose) { | 375 TEST_F(AudioRendererHostTest, SimulateErrorAndClose) { |
376 Create(); | 376 Create(); |
377 Play(); | 377 Play(); |
378 SimulateError(); | 378 SimulateError(); |
379 Close(); | 379 Close(); |
380 } | 380 } |
381 | 381 |
382 // TODO(hclam): Add tests for data conversation in low latency mode. | 382 // TODO(hclam): Add tests for data conversation in low latency mode. |
383 | 383 |
384 } // namespace content | 384 } // namespace content |
OLD | NEW |