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

Unified Diff: media/audio/audio_output_proxy_unittest.cc

Issue 10958020: Don't fallback if we've successfully opened a stream previously. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments w/o state machine. Created 8 years, 3 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_proxy_unittest.cc
diff --git a/media/audio/audio_output_proxy_unittest.cc b/media/audio/audio_output_proxy_unittest.cc
index 131feba19e3550889300f1250ac8eccedd71797b..fcf52cbb92ec27df828d861dbb659e169fed59f4 100644
--- a/media/audio/audio_output_proxy_unittest.cc
+++ b/media/audio/audio_output_proxy_unittest.cc
@@ -867,4 +867,77 @@ TEST_F(AudioOutputResamplerTest, LowLatencyFallbackFailed) {
WaitForCloseTimer(kTestCloseDelayMs);
}
+// Simulate an eventual OpenStream() failure; i.e. successful OpenStream() calls
+// eventually followed by one which fails; root cause of http://crbug.com/150619
+TEST_F(AudioOutputResamplerTest, LowLatencyOpenEventuallyFails) {
tommi (sloooow) - chröme 2012/09/21 08:46:27 nice!
henrika (OOO until Aug 14) 2012/09/21 09:27:40 +1
+ MockAudioOutputStream stream1(params_);
+ MockAudioOutputStream stream2(params_);
+ MockAudioOutputStream stream3(params_);
+
+ // Setup the mock such that all three streams are successfully created.
+ EXPECT_CALL(manager(), MakeAudioOutputStream(_))
+ .WillOnce(Return(&stream1))
+ .WillOnce(Return(&stream2))
+ .WillOnce(Return(&stream3))
+ .WillRepeatedly(Return(static_cast<AudioOutputStream*>(NULL)));
+
+ // Stream1 should be able to successfully open and start.
+ EXPECT_CALL(stream1, Open())
+ .WillOnce(Return(true));
+ EXPECT_CALL(stream1, Close())
+ .Times(1);
+ EXPECT_CALL(stream1, SetVolume(_))
+ .Times(1);
+
+ // Stream2 should also be able to successfully open and start.
+ EXPECT_CALL(stream2, Open())
+ .WillOnce(Return(true));
+ EXPECT_CALL(stream2, Close())
+ .Times(1);
+ EXPECT_CALL(stream2, SetVolume(_))
+ .Times(1);
+
+ // Stream3 should fail on Open() (yet still be closed since
+ // MakeAudioOutputStream returned a valid AudioOutputStream object).
+ EXPECT_CALL(stream3, Open())
+ .WillOnce(Return(false));
+ EXPECT_CALL(stream3, Close())
+ .Times(1);
+
+ // Open and start the first proxy and stream.
+ AudioOutputProxy* proxy1 = new AudioOutputProxy(resampler_);
+ EXPECT_TRUE(proxy1->Open());
+ proxy1->Start(&callback_);
+ OnStart();
+
+ // Open and start the second proxy and stream.
+ AudioOutputProxy* proxy2 = new AudioOutputProxy(resampler_);
+ EXPECT_TRUE(proxy2->Open());
+ proxy2->Start(&callback_);
+ OnStart();
+
+ // Attempt to open the third stream which should fail.
+ AudioOutputProxy* proxy3 = new AudioOutputProxy(resampler_);
+ EXPECT_FALSE(proxy3->Open());
+
+ // Perform the required Stop()/Close() shutdown dance for each proxy. Under
+ // the hood each proxy should correctly call CloseStream() if OpenStream()
+ // succeeded or not.
+ proxy3->Stop();
+ proxy3->Close();
+ proxy2->Stop();
+ proxy2->Close();
+ proxy1->Stop();
+ proxy1->Close();
+
+ // Wait for all of the messages to fly and then verify stream behavior.
+ WaitForCloseTimer(kTestCloseDelayMs);
+ EXPECT_TRUE(stream1.stop_called());
+ EXPECT_TRUE(stream1.start_called());
+ EXPECT_TRUE(stream2.stop_called());
+ EXPECT_TRUE(stream2.start_called());
+ EXPECT_FALSE(stream3.stop_called());
+ EXPECT_FALSE(stream3.start_called());
+}
+
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698