Chromium Code Reviews| Index: media/audio/audio_input_controller_unittest.cc |
| diff --git a/media/audio/audio_input_controller_unittest.cc b/media/audio/audio_input_controller_unittest.cc |
| index 6a62871d26d4c1ee9f837cf91e05585a38ab0f0e..a220d369e35c0a224b4ad58283506a11ad7523de 100644 |
| --- a/media/audio/audio_input_controller_unittest.cc |
| +++ b/media/audio/audio_input_controller_unittest.cc |
| @@ -99,6 +99,53 @@ TEST(AudioInputControllerTest, RecordAndClose) { |
| controller->Close(); |
| } |
| +// Test that the AudioInputController reports an error when the input stream |
| +// stops without an OnClose callback. |
| +TEST(AudioInputControllerTest, RecordAndError) { |
| + MockAudioInputControllerEventHandler event_handler; |
| + base::WaitableEvent event(false, false); |
| + int count = 0; |
| + |
| + // If OnCreated is called then signal the event. |
| + EXPECT_CALL(event_handler, OnCreated(NotNull())) |
| + .WillOnce(InvokeWithoutArgs(&event, &base::WaitableEvent::Signal)); |
| + |
| + // OnRecording() will be called only once. |
| + EXPECT_CALL(event_handler, OnRecording(NotNull())) |
| + .Times(Exactly(1)); |
| + |
| + // If OnData is called enough then signal the event. |
| + EXPECT_CALL(event_handler, OnData(NotNull(), NotNull(), _)) |
| + .Times(AtLeast(10)) |
| + .WillRepeatedly(CheckCountAndSignalEvent(&count, 10, &event)); |
| + |
| + // OnError will be called after the data stream stops. |
| + EXPECT_CALL(event_handler, OnError(NotNull(), 0)) |
| + .WillOnce(InvokeWithoutArgs(&event, &base::WaitableEvent::Signal)); |
| + |
| + AudioParameters params(AudioParameters::AUDIO_MOCK, kChannelLayout, |
| + kSampleRate, kBitsPerSample, kSamplesPerPacket); |
| + scoped_refptr<AudioInputController> controller = |
| + AudioInputController::Create(&event_handler, params); |
| + ASSERT_TRUE(controller.get()); |
| + |
| + // Wait for OnCreated() to be called. |
| + event.Wait(); |
| + event.Reset(); |
| + |
| + // Play and then wait for the event to be signaled. |
|
Satish
2011/06/14 14:28:04
Change 'Play' to 'Record'
allanwoj
2011/06/14 15:03:12
Done.
|
| + controller->Record(); |
| + event.Wait(); |
| + event.Reset(); |
| + |
| + // Wait for the stream to be stopped. |
| + AudioInputStream* stream = controller->getAudioInputStream(); |
| + stream->Stop(); |
| + event.Wait(); |
| + |
| + controller->Close(); |
| +} |
| + |
| // Test that AudioInputController rejects insanely large packet sizes. |
| TEST(AudioInputControllerTest, SamplesPerPacketTooLarge) { |
| // Create an audio device with a very large packet size. |