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

Unified Diff: media/filters/decrypting_video_decoder_unittest.cc

Issue 16274005: Separate DemuxerStream and VideoDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win64 Created 7 years, 5 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
« no previous file with comments | « media/filters/decrypting_video_decoder.cc ('k') | media/filters/fake_demuxer_stream.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/decrypting_video_decoder_unittest.cc
diff --git a/media/filters/decrypting_video_decoder_unittest.cc b/media/filters/decrypting_video_decoder_unittest.cc
index 27d4e5383ecb5823e8fb21460ad55cba704b626b..9d86b4d61592fd19f287a3de055b8df40a6c7b40 100644
--- a/media/filters/decrypting_video_decoder_unittest.cc
+++ b/media/filters/decrypting_video_decoder_unittest.cc
@@ -46,10 +46,6 @@ static scoped_refptr<DecoderBuffer> CreateFakeEncryptedBuffer() {
// times across multiple test files. Sadly we can't use static for them.
namespace {
-ACTION_P(ReturnBuffer, buffer) {
- arg0.Run(buffer.get() ? DemuxerStream::kOk : DemuxerStream::kAborted, buffer);
-}
-
ACTION_P(RunCallbackIfNotNull, param) {
if (!arg0.is_null())
arg0.Run(param);
@@ -74,7 +70,6 @@ class DecryptingVideoDecoderTest : public testing::Test {
&DecryptingVideoDecoderTest::RequestDecryptorNotification,
base::Unretained(this)))),
decryptor_(new StrictMock<MockDecryptor>()),
- demuxer_(new StrictMock<MockDemuxerStream>(DemuxerStream::VIDEO)),
encrypted_buffer_(CreateFakeEncryptedBuffer()),
decoded_video_frame_(VideoFrame::CreateBlackFrame(
TestVideoConfig::NormalCodedSize())),
@@ -90,8 +85,7 @@ class DecryptingVideoDecoderTest : public testing::Test {
void InitializeAndExpectStatus(const VideoDecoderConfig& config,
PipelineStatus status) {
- demuxer_->set_video_decoder_config(config);
- decoder_->Initialize(demuxer_.get(), NewExpectedStatusCB(status),
+ decoder_->Initialize(config, NewExpectedStatusCB(status),
base::Bind(&MockStatisticsCB::OnStatistics,
base::Unretained(&statistics_cb_)));
message_loop_.RunUntilIdle();
@@ -112,6 +106,7 @@ class DecryptingVideoDecoderTest : public testing::Test {
}
void ReadAndExpectFrameReadyWith(
+ const scoped_refptr<DecoderBuffer>& buffer,
VideoDecoder::Status status,
const scoped_refptr<VideoFrame>& video_frame) {
if (status != VideoDecoder::kOk)
@@ -121,68 +116,55 @@ class DecryptingVideoDecoderTest : public testing::Test {
else
EXPECT_CALL(*this, FrameReady(status, video_frame));
- decoder_->Read(base::Bind(&DecryptingVideoDecoderTest::FrameReady,
- base::Unretained(this)));
+ decoder_->Decode(buffer,
+ base::Bind(&DecryptingVideoDecoderTest::FrameReady,
+ base::Unretained(this)));
message_loop_.RunUntilIdle();
}
// Sets up expectations and actions to put DecryptingVideoDecoder in an
// active normal decoding state.
void EnterNormalDecodingState() {
- EXPECT_CALL(*demuxer_, Read(_))
- .WillOnce(ReturnBuffer(encrypted_buffer_))
- .WillRepeatedly(ReturnBuffer(DecoderBuffer::CreateEOSBuffer()));
EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _))
.WillOnce(RunCallback<1>(Decryptor::kSuccess, decoded_video_frame_))
.WillRepeatedly(RunCallback<1>(Decryptor::kNeedMoreData,
scoped_refptr<VideoFrame>()));
EXPECT_CALL(statistics_cb_, OnStatistics(_));
- ReadAndExpectFrameReadyWith(VideoDecoder::kOk, decoded_video_frame_);
+ ReadAndExpectFrameReadyWith(
+ encrypted_buffer_, VideoDecoder::kOk, decoded_video_frame_);
}
// Sets up expectations and actions to put DecryptingVideoDecoder in an end
// of stream state. This function must be called after
// EnterNormalDecodingState() to work.
void EnterEndOfStreamState() {
- ReadAndExpectFrameReadyWith(VideoDecoder::kOk, end_of_stream_video_frame_);
- }
-
- // Make the read callback pending by saving and not firing it.
- void EnterPendingReadState() {
- EXPECT_TRUE(pending_demuxer_read_cb_.is_null());
- EXPECT_CALL(*demuxer_, Read(_))
- .WillOnce(SaveArg<0>(&pending_demuxer_read_cb_));
- decoder_->Read(base::Bind(&DecryptingVideoDecoderTest::FrameReady,
- base::Unretained(this)));
- message_loop_.RunUntilIdle();
- // Make sure the Read() on the decoder triggers a Read() on the demuxer.
- EXPECT_FALSE(pending_demuxer_read_cb_.is_null());
+ ReadAndExpectFrameReadyWith(DecoderBuffer::CreateEOSBuffer(),
+ VideoDecoder::kOk,
+ end_of_stream_video_frame_);
}
// Make the video decode callback pending by saving and not firing it.
void EnterPendingDecodeState() {
EXPECT_TRUE(pending_video_decode_cb_.is_null());
- EXPECT_CALL(*demuxer_, Read(_))
- .WillRepeatedly(ReturnBuffer(encrypted_buffer_));
EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(encrypted_buffer_, _))
.WillOnce(SaveArg<1>(&pending_video_decode_cb_));
- decoder_->Read(base::Bind(&DecryptingVideoDecoderTest::FrameReady,
- base::Unretained(this)));
+ decoder_->Decode(encrypted_buffer_,
+ base::Bind(&DecryptingVideoDecoderTest::FrameReady,
+ base::Unretained(this)));
message_loop_.RunUntilIdle();
- // Make sure the Read() on the decoder triggers a DecryptAndDecode() on the
- // decryptor.
+ // Make sure the Decode() on the decoder triggers a DecryptAndDecode() on
+ // the decryptor.
EXPECT_FALSE(pending_video_decode_cb_.is_null());
}
void EnterWaitingForKeyState() {
- EXPECT_CALL(*demuxer_, Read(_))
- .WillRepeatedly(ReturnBuffer(encrypted_buffer_));
EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _))
.WillRepeatedly(RunCallback<1>(Decryptor::kNoKey, null_video_frame_));
- decoder_->Read(base::Bind(&DecryptingVideoDecoderTest::FrameReady,
- base::Unretained(this)));
+ decoder_->Decode(encrypted_buffer_,
+ base::Bind(&DecryptingVideoDecoderTest::FrameReady,
+ base::Unretained(this)));
message_loop_.RunUntilIdle();
}
@@ -232,15 +214,13 @@ class DecryptingVideoDecoderTest : public testing::Test {
base::MessageLoop message_loop_;
scoped_ptr<DecryptingVideoDecoder> decoder_;
scoped_ptr<StrictMock<MockDecryptor> > decryptor_;
- scoped_ptr<StrictMock<MockDemuxerStream> > demuxer_;
MockStatisticsCB statistics_cb_;
- DemuxerStream::ReadCB pending_demuxer_read_cb_;
Decryptor::DecoderInitCB pending_init_cb_;
Decryptor::NewKeyCB key_added_cb_;
Decryptor::VideoDecodeCB pending_video_decode_cb_;
- // Constant buffer/frames to be returned by the |demuxer_| and |decryptor_|.
+ // Constant buffer/frames.
scoped_refptr<DecoderBuffer> encrypted_buffer_;
scoped_refptr<VideoFrame> decoded_video_frame_;
scoped_refptr<VideoFrame> null_video_frame_;
@@ -300,16 +280,16 @@ TEST_F(DecryptingVideoDecoderTest, DecryptAndDecode_Normal) {
TEST_F(DecryptingVideoDecoderTest, DecryptAndDecode_DecodeError) {
Initialize();
- EXPECT_CALL(*demuxer_, Read(_))
- .WillRepeatedly(ReturnBuffer(encrypted_buffer_));
EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _))
.WillRepeatedly(RunCallback<1>(Decryptor::kError,
- scoped_refptr<VideoFrame>(NULL)));
+ scoped_refptr<VideoFrame>(NULL)));
- ReadAndExpectFrameReadyWith(VideoDecoder::kDecodeError, null_video_frame_);
+ ReadAndExpectFrameReadyWith(
+ encrypted_buffer_, VideoDecoder::kDecodeError, null_video_frame_);
// After a decode error occurred, all following read returns kDecodeError.
- ReadAndExpectFrameReadyWith(VideoDecoder::kDecodeError, null_video_frame_);
+ ReadAndExpectFrameReadyWith(
+ encrypted_buffer_, VideoDecoder::kDecodeError, null_video_frame_);
}
// Test the case where the decryptor returns kNeedMoreData to ask for more
@@ -317,9 +297,6 @@ TEST_F(DecryptingVideoDecoderTest, DecryptAndDecode_DecodeError) {
TEST_F(DecryptingVideoDecoderTest, DecryptAndDecode_NeedMoreData) {
Initialize();
- EXPECT_CALL(*demuxer_, Read(_))
- .Times(2)
- .WillRepeatedly(ReturnBuffer(encrypted_buffer_));
EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _))
.WillOnce(RunCallback<1>(Decryptor::kNeedMoreData,
scoped_refptr<VideoFrame>()))
@@ -328,7 +305,10 @@ TEST_F(DecryptingVideoDecoderTest, DecryptAndDecode_NeedMoreData) {
EXPECT_CALL(statistics_cb_, OnStatistics(_))
.Times(2);
- ReadAndExpectFrameReadyWith(VideoDecoder::kOk, decoded_video_frame_);
+ ReadAndExpectFrameReadyWith(
+ encrypted_buffer_, VideoDecoder::kNotEnoughData, decoded_video_frame_);
+ ReadAndExpectFrameReadyWith(
+ encrypted_buffer_, VideoDecoder::kOk, decoded_video_frame_);
}
// Test the case where the decryptor receives end-of-stream buffer.
@@ -338,17 +318,6 @@ TEST_F(DecryptingVideoDecoderTest, DecryptAndDecode_EndOfStream) {
EnterEndOfStreamState();
}
-// Test aborted read on the demuxer stream.
-TEST_F(DecryptingVideoDecoderTest, DemuxerRead_Aborted) {
- Initialize();
-
- // ReturnBuffer() with NULL triggers aborted demuxer read.
- EXPECT_CALL(*demuxer_, Read(_))
- .WillOnce(ReturnBuffer(scoped_refptr<DecoderBuffer>()));
-
- ReadAndExpectFrameReadyWith(VideoDecoder::kOk, null_video_frame_);
-}
-
// Test the case where the a key is added when the decryptor is in
// kWaitingForKey state.
TEST_F(DecryptingVideoDecoderTest, KeyAdded_DuringWaitingForKey) {
@@ -398,35 +367,6 @@ TEST_F(DecryptingVideoDecoderTest, Reset_DuringIdleAfterDecodedOneFrame) {
Reset();
}
-// Test resetting when the decoder is in kPendingDemuxerRead state and the read
-// callback is returned with kOk.
-TEST_F(DecryptingVideoDecoderTest, Reset_DuringDemuxerRead_Ok) {
- Initialize();
- EnterPendingReadState();
-
- EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull()));
-
- Reset();
- base::ResetAndReturn(&pending_demuxer_read_cb_).Run(DemuxerStream::kOk,
- encrypted_buffer_);
- message_loop_.RunUntilIdle();
-}
-
-// Test resetting when the decoder is in kPendingDemuxerRead state and the read
-// callback is returned with kAborted.
-TEST_F(DecryptingVideoDecoderTest, Reset_DuringDemuxerRead_Aborted) {
- Initialize();
- EnterPendingReadState();
-
- // Make sure we get a NULL video frame returned.
- EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull()));
-
- Reset();
- base::ResetAndReturn(&pending_demuxer_read_cb_).Run(DemuxerStream::kAborted,
- NULL);
- message_loop_.RunUntilIdle();
-}
-
// Test resetting when the decoder is in kPendingDecode state.
TEST_F(DecryptingVideoDecoderTest, Reset_DuringPendingDecode) {
Initialize();
@@ -466,11 +406,10 @@ TEST_F(DecryptingVideoDecoderTest, Reset_AfterReset) {
// Test stopping when the decoder is in kDecryptorRequested state.
TEST_F(DecryptingVideoDecoderTest, Stop_DuringDecryptorRequested) {
- demuxer_->set_video_decoder_config(TestVideoConfig::NormalEncrypted());
DecryptorReadyCB decryptor_ready_cb;
EXPECT_CALL(*this, RequestDecryptorNotification(_))
.WillOnce(SaveArg<0>(&decryptor_ready_cb));
- decoder_->Initialize(demuxer_.get(),
+ decoder_->Initialize(TestVideoConfig::NormalEncrypted(),
NewExpectedStatusCB(DECODER_ERROR_NOT_SUPPORTED),
base::Bind(&MockStatisticsCB::OnStatistics,
base::Unretained(&statistics_cb_)));
@@ -513,19 +452,6 @@ TEST_F(DecryptingVideoDecoderTest, Stop_DuringIdleAfterDecodedOneFrame) {
Stop();
}
-// Test stopping when the decoder is in kPendingDemuxerRead state.
-TEST_F(DecryptingVideoDecoderTest, Stop_DuringPendingDemuxerRead) {
- Initialize();
- EnterPendingReadState();
-
- EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull()));
-
- Stop();
- base::ResetAndReturn(&pending_demuxer_read_cb_).Run(DemuxerStream::kOk,
- encrypted_buffer_);
- message_loop_.RunUntilIdle();
-}
-
// Test stopping when the decoder is in kPendingDecode state.
TEST_F(DecryptingVideoDecoderTest, Stop_DuringPendingDecode) {
Initialize();
« no previous file with comments | « media/filters/decrypting_video_decoder.cc ('k') | media/filters/fake_demuxer_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698