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

Unified Diff: media/filters/audio_renderer_impl_unittest.cc

Issue 126793002: Add Stop() to AudioDecoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove blank lines Created 6 years, 11 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/filters/audio_renderer_impl_unittest.cc
diff --git a/media/filters/audio_renderer_impl_unittest.cc b/media/filters/audio_renderer_impl_unittest.cc
index 5adfbc499f7491f8176e71d4c801104f0fa1cf26..3e6ec2729d5c35ec52cf4f215a527df3ba38754d 100644
--- a/media/filters/audio_renderer_impl_unittest.cc
+++ b/media/filters/audio_renderer_impl_unittest.cc
@@ -46,7 +46,8 @@ class AudioRendererImplTest : public ::testing::Test {
public:
// Give the decoder some non-garbage media properties.
AudioRendererImplTest()
- : demuxer_stream_(DemuxerStream::AUDIO),
+ : needs_stop_(true),
+ demuxer_stream_(DemuxerStream::AUDIO),
decoder_(new MockAudioDecoder()) {
AudioDecoderConfig audio_config(kCodec,
kSampleFormat,
@@ -64,6 +65,9 @@ class AudioRendererImplTest : public ::testing::Test {
EXPECT_CALL(*decoder_, Reset(_))
.WillRepeatedly(Invoke(this, &AudioRendererImplTest::ResetDecoder));
+ EXPECT_CALL(*decoder_, Stop(_))
+ .WillRepeatedly(Invoke(this, &AudioRendererImplTest::StopDecoder));
+
// Set up audio properties.
EXPECT_CALL(*decoder_, bits_per_channel())
.WillRepeatedly(Return(audio_config.bits_per_channel()));
@@ -88,9 +92,11 @@ class AudioRendererImplTest : public ::testing::Test {
virtual ~AudioRendererImplTest() {
SCOPED_TRACE("~AudioRendererImplTest()");
- WaitableMessageLoopEvent event;
- renderer_->Stop(event.GetClosure());
- event.RunAndWait();
+ if (needs_stop_) {
+ WaitableMessageLoopEvent event;
+ renderer_->Stop(event.GetClosure());
+ event.RunAndWait();
+ }
}
void ExpectUnsupportedAudioDecoder() {
@@ -376,6 +382,10 @@ class AudioRendererImplTest : public ::testing::Test {
scoped_ptr<AudioRendererImpl> renderer_;
scoped_refptr<FakeAudioRendererSink> sink_;
+ // Whether or not the test needs the destructor to call Stop() on
+ // |renderer_| at destruction.
+ bool needs_stop_;
+
private:
TimeTicks GetTime() {
base::AutoLock auto_lock(lock_);
@@ -406,6 +416,10 @@ class AudioRendererImplTest : public ::testing::Test {
message_loop_.PostTask(FROM_HERE, reset_cb);
}
+ void StopDecoder(const base::Closure& stop_cb) {
+ message_loop_.PostTask(FROM_HERE, stop_cb);
+ }
+
void DeliverBuffer(AudioDecoder::Status status,
const scoped_refptr<AudioBuffer>& buffer) {
CHECK(!read_cb_.is_null());
@@ -818,10 +832,10 @@ TEST_F(AudioRendererImplTest, StopDuringFlush) {
SatisfyPendingRead(kDataSize);
- // Request a Stop() before the flush completes.
- WaitableMessageLoopEvent stop_event;
- renderer_->Stop(stop_event.GetClosure());
- stop_event.RunAndWait();
+ WaitableMessageLoopEvent event;
+ renderer_->Stop(event.GetClosure());
+ event.RunAndWait();
+ needs_stop_ = false;
}
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698