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

Unified Diff: media/audio/sounds/audio_stream_handler_unittest.cc

Issue 1453233002: Improve input handling for WaveAudioHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Update FileSource Created 5 years, 1 month 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/sounds/audio_stream_handler_unittest.cc
diff --git a/media/audio/sounds/audio_stream_handler_unittest.cc b/media/audio/sounds/audio_stream_handler_unittest.cc
index 234ac9d16a919abe4b66b7b1651303599098e047..5393162065c3029055ef0e85fda716b4de6a865b 100644
--- a/media/audio/sounds/audio_stream_handler_unittest.cc
+++ b/media/audio/sounds/audio_stream_handler_unittest.cc
@@ -63,6 +63,9 @@ TEST_F(AudioStreamHandlerTest, Play) {
SetObserverForTesting(&observer);
ASSERT_TRUE(audio_stream_handler()->IsInitialized());
+ EXPECT_EQ(base::TimeDelta::FromMicroseconds(20u),
+ audio_stream_handler()->duration());
+
ASSERT_TRUE(audio_stream_handler()->Play());
run_loop.Run();
@@ -83,6 +86,8 @@ TEST_F(AudioStreamHandlerTest, ConsecutivePlayRequests) {
SetAudioSourceForTesting(&source);
ASSERT_TRUE(audio_stream_handler()->IsInitialized());
+ EXPECT_EQ(base::TimeDelta::FromMicroseconds(20u),
+ audio_stream_handler()->duration());
ASSERT_TRUE(audio_stream_handler()->Play());
base::MessageLoop::current()->PostDelayedTask(
@@ -105,4 +110,16 @@ TEST_F(AudioStreamHandlerTest, ConsecutivePlayRequests) {
ASSERT_EQ(1, observer.num_stop_requests());
}
+TEST_F(AudioStreamHandlerTest, BadWavDataDoesNotInitialize) {
+ // The class members and SetUp() will be ignored for this test. Create a
+ // handler on the stack with some bad WAV data.
+ AudioStreamHandler handler("RIFF1234WAVEjunkjunkjunkjunk");
+ EXPECT_FALSE(handler.IsInitialized());
+ EXPECT_FALSE(handler.Play());
+ EXPECT_EQ(base::TimeDelta(), handler.duration());
+
+ // Call Stop() to ensure that there is no crash.
+ handler.Stop();
+}
+
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698