Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(554)

Unified Diff: media/audio/audio_input_controller_unittest.cc

Issue 7129057: Fix bug when unplugging an audio input device whilst using speech input. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Removed unnecessary includes Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..d7ce4db7e523cbb10192230287ed42e0865e9526 100644
--- a/media/audio/audio_input_controller_unittest.cc
+++ b/media/audio/audio_input_controller_unittest.cc
@@ -92,13 +92,60 @@ TEST(AudioInputControllerTest, RecordAndClose) {
event.Wait();
event.Reset();
- // Play and then wait for the event to be signaled.
+ // Record and then wait for the event to be signaled.
controller->Record();
event.Wait();
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();
+
+ // Record and then wait for the event to be signaled.
+ controller->Record();
+ event.Wait();
+ event.Reset();
+
+ // Wait for the stream to be stopped.
+ AudioInputStream* stream = controller->stream();
+ 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.

Powered by Google App Engine
This is Rietveld 408576698