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

Unified Diff: media/audio/audio_output_controller_unittest.cc

Issue 8229013: Fix problem when we did not play beginning of HTML5 audio stream in low latency mode. (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
« no previous file with comments | « media/audio/audio_output_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_output_controller_unittest.cc
===================================================================
--- media/audio/audio_output_controller_unittest.cc (revision 104976)
+++ media/audio/audio_output_controller_unittest.cc (working copy)
@@ -14,6 +14,7 @@
using ::testing::_;
using ::testing::AtLeast;
+using ::testing::DoAll;
using ::testing::Exactly;
using ::testing::InvokeWithoutArgs;
using ::testing::NotNull;
@@ -54,6 +55,7 @@
MOCK_METHOD1(UpdatePendingBytes, void(uint32 bytes));
MOCK_METHOD2(Read, uint32(void* data, uint32 size));
MOCK_METHOD0(Close, void());
+ MOCK_METHOD0(DataReady, bool());
private:
DISALLOW_COPY_AND_ASSIGN(MockAudioOutputControllerSyncReader);
@@ -150,6 +152,58 @@
CloseAudioController(controller);
}
+TEST(AudioOutputControllerTest, PlayAndCloseLowLatency) {
+ if (!HasAudioOutputDevices() || IsRunningHeadless())
+ return;
+
+ MockAudioOutputControllerEventHandler event_handler;
+ base::WaitableEvent event(false, false);
+
+ // If OnCreated is called then signal the event.
+ EXPECT_CALL(event_handler, OnCreated(NotNull()))
+ .WillOnce(SignalEvent(&event));
+
+ // OnPlaying() will be called only once.
+ EXPECT_CALL(event_handler, OnPlaying(NotNull()))
+ .Times(Exactly(1));
+
+ MockAudioOutputControllerSyncReader sync_reader;
+ EXPECT_CALL(sync_reader, UpdatePendingBytes(_))
+ .Times(AtLeast(10));
+ EXPECT_CALL(sync_reader, DataReady())
+ .WillOnce(Return(false))
+ .WillOnce(Return(false))
+ .WillRepeatedly(Return(true));
+ EXPECT_CALL(sync_reader, Read(_, kHardwareBufferSize))
+ .Times(AtLeast(10))
+ .WillRepeatedly(DoAll(SignalEvent(&event),
+ Return(1)));
+ 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();
+
+ controller->Play();
+
+ // Wait until the date is requested at least 10 times.
+ for (int i = 0; i < 10; i++) {
+ event.Wait();
+ uint8 buf[1];
+ controller->EnqueueData(buf, 0);
+ }
+
+ // Now stop the controller.
+ CloseAudioController(controller);
+}
+
TEST(AudioOutputControllerTest, PlayPauseClose) {
if (!HasAudioOutputDevices() || IsRunningHeadless())
return;
« no previous file with comments | « media/audio/audio_output_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698