Index: media/filters/ffmpeg_audio_decoder_unittest.cc |
diff --git a/media/filters/ffmpeg_audio_decoder_unittest.cc b/media/filters/ffmpeg_audio_decoder_unittest.cc |
index ccd30aa6cc74b201680fc1b06aff16ee9ad1c155..b47cd059fc89765d9187bf2cbd16c5aadfffa84f 100644 |
--- a/media/filters/ffmpeg_audio_decoder_unittest.cc |
+++ b/media/filters/ffmpeg_audio_decoder_unittest.cc |
@@ -29,7 +29,8 @@ class FFmpegAudioDecoderTest : public testing::Test { |
: decoder_(new FFmpegAudioDecoder(message_loop_.message_loop_proxy(), |
LogCB())), |
pending_decode_(false), |
- pending_reset_(false) { |
+ pending_reset_(false), |
+ last_decode_status_(AudioDecoder::kOk) { |
FFmpegGlue::InitializeFFmpeg(); |
vorbis_extradata_ = ReadTestDataFile("vorbis-extradata"); |
@@ -69,7 +70,9 @@ class FFmpegAudioDecoderTest : public testing::Test { |
vorbis_extradata_->data_size(), |
false); // Not encrypted. |
decoder_->Initialize(config, |
- NewExpectedStatusCB(PIPELINE_OK)); |
+ NewExpectedStatusCB(PIPELINE_OK), |
+ base::Bind(&FFmpegAudioDecoderTest::OnDecoderOutput, |
+ base::Unretained(this))); |
base::RunLoop().RunUntilIdle(); |
} |
@@ -77,7 +80,7 @@ class FFmpegAudioDecoderTest : public testing::Test { |
base::RunLoop().RunUntilIdle(); |
} |
- void Decode() { |
+ void Decode(AudioDecoder::Status expected_status) { |
pending_decode_ = true; |
scoped_refptr<DecoderBuffer> buffer(encoded_audio_.front()); |
encoded_audio_.pop_front(); |
@@ -85,6 +88,8 @@ class FFmpegAudioDecoderTest : public testing::Test { |
base::Bind(&FFmpegAudioDecoderTest::DecodeFinished, |
base::Unretained(this))); |
base::RunLoop().RunUntilIdle(); |
+ EXPECT_FALSE(pending_decode_); |
+ EXPECT_EQ(expected_status, last_decode_status_); |
} |
void Reset() { |
@@ -99,27 +104,17 @@ class FFmpegAudioDecoderTest : public testing::Test { |
base::RunLoop().RunUntilIdle(); |
} |
- void DecodeFinished(AudioDecoder::Status status, |
- const scoped_refptr<AudioBuffer>& buffer) { |
- EXPECT_TRUE(pending_decode_); |
- pending_decode_ = false; |
- |
- if (status == AudioDecoder::kNotEnoughData) { |
- EXPECT_TRUE(buffer.get() == NULL); |
- Decode(); |
- return; |
- } |
- |
+ void OnDecoderOutput(const scoped_refptr<AudioBuffer>& buffer) { |
+ LOG(ERROR) << "Outp"; |
xhwang
2014/06/05 21:53:50
rm
Sergey Ulanov
2014/06/06 22:49:40
Done.
|
decoded_audio_.push_back(buffer); |
+ } |
- // If we hit a NULL buffer or have a pending reset, we expect an abort. |
- if (buffer.get() == NULL || pending_reset_) { |
- EXPECT_TRUE(buffer.get() == NULL); |
- EXPECT_EQ(status, AudioDecoder::kAborted); |
- return; |
- } |
+ void DecodeFinished(AudioDecoder::Status status) { |
+ LOG(ERROR) << "Finished"; |
xhwang
2014/06/05 21:53:50
rm
Sergey Ulanov
2014/06/06 22:49:40
Done.
|
+ EXPECT_TRUE(pending_decode_); |
+ pending_decode_ = false; |
- EXPECT_EQ(status, AudioDecoder::kOk); |
+ last_decode_status_ = status; |
} |
void ResetFinished() { |
@@ -151,6 +146,7 @@ class FFmpegAudioDecoderTest : public testing::Test { |
std::deque<scoped_refptr<DecoderBuffer> > encoded_audio_; |
std::deque<scoped_refptr<AudioBuffer> > decoded_audio_; |
+ AudioDecoder::Status last_decode_status_; |
}; |
TEST_F(FFmpegAudioDecoderTest, Initialize) { |
@@ -169,9 +165,10 @@ TEST_F(FFmpegAudioDecoderTest, ProduceAudioSamples) { |
// |
// This will should result in the demuxer receiving three reads for two |
// requests to produce audio samples. |
- Decode(); |
- Decode(); |
- Decode(); |
+ Decode(AudioDecoder::kOk); |
+ Decode(AudioDecoder::kOk); |
+ Decode(AudioDecoder::kOk); |
+ Decode(AudioDecoder::kOk); |
ASSERT_EQ(3u, decoded_audio_.size()); |
ExpectDecodedAudio(0, 0, 2902); |
@@ -179,8 +176,8 @@ TEST_F(FFmpegAudioDecoderTest, ProduceAudioSamples) { |
ExpectDecodedAudio(2, 15963, 23219); |
// Call one more time to trigger EOS. |
- Decode(); |
- ASSERT_EQ(4u, decoded_audio_.size()); |
+ Decode(AudioDecoder::kOk); |
+ ASSERT_EQ(5u, decoded_audio_.size()); |
ExpectEndOfStream(3); |
Stop(); |
} |
@@ -188,28 +185,26 @@ TEST_F(FFmpegAudioDecoderTest, ProduceAudioSamples) { |
TEST_F(FFmpegAudioDecoderTest, DecodeAbort) { |
encoded_audio_.clear(); |
encoded_audio_.push_back(NULL); |
- Decode(); |
- |
- EXPECT_EQ(decoded_audio_.size(), 1u); |
- EXPECT_TRUE(decoded_audio_[0].get() == NULL); |
+ Decode(AudioDecoder::kAborted); |
xhwang
2014/06/05 21:53:50
This is probably obsolete. Now DemuxerStream will
Sergey Ulanov
2014/06/06 22:49:40
Done.
|
+ EXPECT_TRUE(decoded_audio_.empty()); |
Stop(); |
} |
TEST_F(FFmpegAudioDecoderTest, PendingDecode_Stop) { |
- Decode(); |
+ Decode(AudioDecoder::kOk); |
Stop(); |
SatisfyPendingDecode(); |
} |
TEST_F(FFmpegAudioDecoderTest, PendingDecode_Reset) { |
- Decode(); |
+ Decode(AudioDecoder::kOk); |
Reset(); |
SatisfyPendingDecode(); |
Stop(); |
} |
TEST_F(FFmpegAudioDecoderTest, PendingDecode_ResetStop) { |
- Decode(); |
+ Decode(AudioDecoder::kOk); |
Reset(); |
Stop(); |
SatisfyPendingDecode(); |