Chromium Code Reviews| Index: media/audio/audio_output_controller_unittest.cc |
| =================================================================== |
| --- media/audio/audio_output_controller_unittest.cc (revision 106670) |
| +++ media/audio/audio_output_controller_unittest.cc (working copy) |
| @@ -258,6 +258,58 @@ |
| CloseAudioController(controller); |
| } |
| +TEST(AudioOutputControllerTest, PlayPauseCloseLowLatency) { |
| + if (!HasAudioOutputDevices() || IsRunningHeadless()) |
| + return; |
| + |
| + MockAudioOutputControllerEventHandler event_handler; |
| + base::WaitableEvent event(false, false); |
| + base::WaitableEvent pause_event(false, false); |
| + |
| + // If OnCreated is called then signal the event. |
| + EXPECT_CALL(event_handler, OnCreated(NotNull())) |
| + .Times(Exactly(1)) |
|
acolwell GONE FROM CHROMIUM
2011/10/24 03:47:15
I don't think you need the Times(Exactly(1)). I be
enal1
2011/10/24 16:28:29
Done.
|
| + .WillOnce(InvokeWithoutArgs(&event, &base::WaitableEvent::Signal)); |
| + |
| + // OnPlaying() will be called only once. |
| + EXPECT_CALL(event_handler, OnPlaying(NotNull())) |
| + .Times(Exactly(1)); |
|
acolwell GONE FROM CHROMIUM
2011/10/24 03:47:15
ditto
enal1
2011/10/24 16:28:29
Done.
|
| + |
| + MockAudioOutputControllerSyncReader sync_reader; |
| + EXPECT_CALL(sync_reader, UpdatePendingBytes(_)) |
| + .Times(AtLeast(2)); |
| + EXPECT_CALL(sync_reader, DataReady()) |
| + .WillOnce(Return(false)) |
| + .WillOnce(Return(false)) |
| + .WillRepeatedly(Return(true)); |
| + EXPECT_CALL(sync_reader, Read(_, kHardwareBufferSize)) |
| + .WillRepeatedly(DoAll(SignalEvent(&event), |
| + Return(4))); |
| + EXPECT_CALL(event_handler, OnPaused(NotNull())) |
| + .Times(Exactly(1)) |
|
acolwell GONE FROM CHROMIUM
2011/10/24 03:47:15
ditto
enal1
2011/10/24 16:28:29
Done.
|
| + .WillOnce(InvokeWithoutArgs(&pause_event, &base::WaitableEvent::Signal)); |
| + EXPECT_CALL(sync_reader, Close()); |
| + |
| + AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, |
| + kSampleRate, kBitsPerSample, kSamplesPerPacket); |
| + scoped_refptr<AudioOutputController> controller = |
| + AudioOutputController::CreateLowLatency(&event_handler, |
| + params, |
| + &sync_reader); |
| + ASSERT_TRUE(controller.get()); |
| + |
| + // Wait for OnCreated() to be called. |
| + event.Wait(); |
| + |
| + ASSERT_FALSE(pause_event.IsSignaled()); |
| + controller->Play(); |
| + controller->Pause(); |
| + pause_event.Wait(); |
| + |
| + // Now stop the controller. |
| + CloseAudioController(controller); |
| +} |
| + |
| TEST(AudioOutputControllerTest, PlayPausePlay) { |
| if (!HasAudioOutputDevices() || IsRunningHeadless()) |
| return; |