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

Unified Diff: media/audio/audio_output_controller_unittest.cc

Issue 8371013: Harden audio output controller making it safe to call Pause() before (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 9 years, 2 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_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;
« media/audio/audio_output_controller.cc ('K') | « media/audio/audio_output_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698