Chromium Code Reviews| Index: media/audio/audio_output_device_unittest.cc |
| diff --git a/media/audio/audio_output_device_unittest.cc b/media/audio/audio_output_device_unittest.cc |
| index 3952cf38d128f304beba5d0bfc4590f2f0719aa0..11576734c608d77338fab44ff58948071474d02a 100644 |
| --- a/media/audio/audio_output_device_unittest.cc |
| +++ b/media/audio/audio_output_device_unittest.cc |
| @@ -100,14 +100,14 @@ class AudioOutputDeviceTest |
| : default_audio_parameters_(AudioParameters::AUDIO_PCM_LINEAR, |
| CHANNEL_LAYOUT_STEREO, |
| 48000, 16, 1024), |
| - audio_device_(new AudioOutputDevice( |
| - &audio_output_ipc_, io_loop_.message_loop_proxy())), |
| synchronized_io_(GetParam()), |
| input_channels_(synchronized_io_ ? 2 : 0) { |
| } |
| ~AudioOutputDeviceTest() {} |
| + void Construct(); |
| + void Destruct(); |
| void Initialize(); |
| void StartAudioDevice(); |
| void CreateStream(); |
| @@ -157,6 +157,20 @@ int AudioOutputDeviceTest::CalculateMemorySize() { |
| return TotalSharedMemorySizeInBytes(io_buffer_size); |
| } |
| +void AudioOutputDeviceTest::Construct() { |
| + EXPECT_CALL(audio_output_ipc_, AddDelegate(_)) |
| + .WillOnce(Return(kStreamId)); |
| + |
| + audio_device_ = new AudioOutputDevice( |
| + &audio_output_ipc_, io_loop_.message_loop_proxy()); |
| +} |
| + |
| +void AudioOutputDeviceTest::Destruct() { |
| + EXPECT_CALL(audio_output_ipc_, RemoveDelegate(kStreamId)); |
| + |
| + audio_device_ = NULL; |
| +} |
| + |
| void AudioOutputDeviceTest::Initialize() { |
| if (synchronized_io_) { |
| audio_device_->InitializeIO(default_audio_parameters_, |
| @@ -172,8 +186,6 @@ void AudioOutputDeviceTest::Initialize() { |
| void AudioOutputDeviceTest::StartAudioDevice() { |
| audio_device_->Start(); |
| - EXPECT_CALL(audio_output_ipc_, AddDelegate(audio_device_.get())) |
| - .WillOnce(Return(kStreamId)); |
| EXPECT_CALL(audio_output_ipc_, CreateStream(kStreamId, _, _)); |
| io_loop_.RunUntilIdle(); |
| @@ -245,35 +257,41 @@ void AudioOutputDeviceTest::StopAudioDevice() { |
| audio_device_->Stop(); |
| EXPECT_CALL(audio_output_ipc_, CloseStream(kStreamId)); |
| - EXPECT_CALL(audio_output_ipc_, RemoveDelegate(kStreamId)); |
| io_loop_.RunUntilIdle(); |
| } |
| TEST_P(AudioOutputDeviceTest, Initialize) { |
| + Construct(); |
|
DaleCurtis
2012/11/28 19:29:50
just do this in setUp() and tearDown() instead of
miu
2012/11/28 20:59:03
Done. I also moved the call to Initialize() into
|
| Initialize(); |
| + Destruct(); |
| } |
| // Calls Start() followed by an immediate Stop() and check for the basic message |
| // filter messages being sent in that case. |
| TEST_P(AudioOutputDeviceTest, StartStop) { |
| + Construct(); |
| Initialize(); |
| StartAudioDevice(); |
| StopAudioDevice(); |
| + Destruct(); |
| } |
| // AudioOutputDevice supports multiple start/stop sequences. |
| TEST_P(AudioOutputDeviceTest, StartStopStartStop) { |
| + Construct(); |
| Initialize(); |
| StartAudioDevice(); |
| StopAudioDevice(); |
| StartAudioDevice(); |
| StopAudioDevice(); |
| + Destruct(); |
| } |
| // Simulate receiving OnStreamCreated() prior to processing ShutDownOnIOThread() |
| // on the IO loop. |
| TEST_P(AudioOutputDeviceTest, StopBeforeRender) { |
| + Construct(); |
| Initialize(); |
| StartAudioDevice(); |
| @@ -283,18 +301,21 @@ TEST_P(AudioOutputDeviceTest, StopBeforeRender) { |
| // Expect us to shutdown IPC but not to render anything despite the stream |
| // getting created. |
| EXPECT_CALL(audio_output_ipc_, CloseStream(kStreamId)); |
| - EXPECT_CALL(audio_output_ipc_, RemoveDelegate(kStreamId)); |
| CreateStream(); |
| + |
| + Destruct(); |
| } |
| // Full test with output only. |
| TEST_P(AudioOutputDeviceTest, CreateStream) { |
| + Construct(); |
| Initialize(); |
| StartAudioDevice(); |
| ExpectRenderCallback(); |
| CreateStream(); |
| WaitUntilRenderCallback(); |
| StopAudioDevice(); |
| + Destruct(); |
| } |
| INSTANTIATE_TEST_CASE_P(Render, AudioOutputDeviceTest, Values(false)); |