| Index: media/filters/video_frame_stream_unittest.cc
|
| diff --git a/media/filters/video_frame_stream_unittest.cc b/media/filters/video_frame_stream_unittest.cc
|
| index e45c90355304b868c42a378f9001aa22481772bf..729bea718c6f39cd996d1138ebd4823a88356d69 100644
|
| --- a/media/filters/video_frame_stream_unittest.cc
|
| +++ b/media/filters/video_frame_stream_unittest.cc
|
| @@ -31,18 +31,21 @@ static const gfx::Size kNaturalSize(320, 240);
|
| class VideoFrameStreamTest : public testing::TestWithParam<bool> {
|
| public:
|
| VideoFrameStreamTest()
|
| - : video_frame_stream_(new VideoFrameStream(
|
| - message_loop_.message_loop_proxy(),
|
| - base::Bind(&VideoFrameStreamTest::SetDecryptorReadyCallback,
|
| - base::Unretained(this)))),
|
| - video_config_(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, kVideoFormat,
|
| + : video_config_(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, kVideoFormat,
|
| kCodedSize, kVisibleRect, kNaturalSize, NULL, 0,
|
| GetParam()),
|
| demuxer_stream_(new StrictMock<MockDemuxerStream>()),
|
| decryptor_(new NiceMock<MockDecryptor>()),
|
| decoder_(new StrictMock<MockVideoDecoder>()),
|
| is_initialized_(false) {
|
| - decoders_.push_back(decoder_);
|
| + ScopedVector<VideoDecoder> decoders;
|
| + decoders.push_back(decoder_);
|
| +
|
| + video_frame_stream_ = new VideoFrameStream(
|
| + message_loop_.message_loop_proxy(),
|
| + decoders.Pass(),
|
| + base::Bind(&VideoFrameStreamTest::SetDecryptorReadyCallback,
|
| + base::Unretained(this)));
|
|
|
| EXPECT_CALL(*demuxer_stream_, type())
|
| .WillRepeatedly(Return(DemuxerStream::VIDEO));
|
| @@ -88,7 +91,6 @@ class VideoFrameStreamTest : public testing::TestWithParam<bool> {
|
| .WillOnce(SaveArg<1>(&decoder_init_cb_));
|
| video_frame_stream_->Initialize(
|
| demuxer_stream_,
|
| - decoders_,
|
| base::Bind(&VideoFrameStreamTest::OnStatistics, base::Unretained(this)),
|
| base::Bind(&VideoFrameStreamTest::OnInitialized,
|
| base::Unretained(this)));
|
| @@ -101,6 +103,10 @@ class VideoFrameStreamTest : public testing::TestWithParam<bool> {
|
| base::ResetAndReturn(&decoder_init_cb_).Run(
|
| success ? PIPELINE_OK : DECODER_ERROR_NOT_SUPPORTED);
|
| message_loop_.RunUntilIdle();
|
| +
|
| + // Failed initialization will delete unused decoders.
|
| + if (!success)
|
| + decoder_ = NULL;
|
| }
|
|
|
| void EnterPendingReadFrameState() {
|
| @@ -135,9 +141,11 @@ class VideoFrameStreamTest : public testing::TestWithParam<bool> {
|
| void EnterPendingStopState() {
|
| // If initialization failed, we won't call VideoDecoder::Stop() during
|
| // the stopping process.
|
| - EXPECT_CALL(*decoder_, Stop(_))
|
| - .Times(AtMost(1))
|
| - .WillRepeatedly(SaveArg<0>(&decoder_stop_cb_));
|
| + if (decoder_) {
|
| + EXPECT_CALL(*decoder_, Stop(_))
|
| + .WillRepeatedly(SaveArg<0>(&decoder_stop_cb_));
|
| + }
|
| +
|
| EXPECT_CALL(*this, OnStopped())
|
| .WillOnce(Assign(&is_initialized_, false));
|
| video_frame_stream_->Stop(base::Bind(&VideoFrameStreamTest::OnStopped,
|
| @@ -188,8 +196,7 @@ class VideoFrameStreamTest : public testing::TestWithParam<bool> {
|
| // Use NiceMock since we don't care about most of calls on the decryptor, e.g.
|
| // RegisterNewKeyCB().
|
| scoped_ptr<NiceMock<MockDecryptor> > decryptor_;
|
| - scoped_refptr<StrictMock<MockVideoDecoder> > decoder_;
|
| - VideoFrameStream::VideoDecoderList decoders_;
|
| + StrictMock<MockVideoDecoder>* decoder_; // Owned by |video_frame_stream_|.
|
|
|
| // Callbacks to simulate pending decoder operations.
|
| PipelineStatusCB decoder_init_cb_;
|
|
|