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

Unified Diff: media/filters/decrypting_audio_decoder_unittest.cc

Issue 11342031: Add DecryptingDemuxerStream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: resolve ddorwin's comments Created 8 years, 1 month 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/decrypting_audio_decoder_unittest.cc
diff --git a/media/filters/decrypting_audio_decoder_unittest.cc b/media/filters/decrypting_audio_decoder_unittest.cc
index 24e9eba876b5edee1847fa56425acb2e51b9e010..cbb1a5f75d40a39d65498da7a6e50fb3b77f510a 100644
--- a/media/filters/decrypting_audio_decoder_unittest.cc
+++ b/media/filters/decrypting_audio_decoder_unittest.cc
@@ -21,7 +21,6 @@
using ::testing::_;
using ::testing::AtMost;
-using ::testing::Invoke;
using ::testing::IsNull;
using ::testing::ReturnRef;
using ::testing::SaveArg;
@@ -72,7 +71,7 @@ MATCHER(IsEndOfStream, "end of stream") {
class DecryptingAudioDecoderTest : public testing::Test {
public:
DecryptingAudioDecoderTest()
- : decoder_(new StrictMock<DecryptingAudioDecoder>(
+ : decoder_(new DecryptingAudioDecoder(
base::Bind(&Identity<scoped_refptr<base::MessageLoopProxy> >,
message_loop_.message_loop_proxy()),
base::Bind(
@@ -84,10 +83,10 @@ class DecryptingAudioDecoderTest : public testing::Test {
decoded_frame_(NULL),
end_of_stream_frame_(new DataBuffer(0)),
decoded_frame_list_() {
- // TODO(xhwang): Fix this after DataBuffer(data, size) is public.
- scoped_refptr<DataBuffer> buffer = new DataBuffer(kFakeAudioFrameSize);
- buffer->SetDataSize(kFakeAudioFrameSize);
- decoded_frame_ = buffer;
+ scoped_refptr<DataBuffer> data_buffer = new DataBuffer(kFakeAudioFrameSize);
+ data_buffer->SetDataSize(kFakeAudioFrameSize);
+ // |decoded_frame_| contains random data.
+ decoded_frame_ = data_buffer;
decoded_frame_list_.push_back(decoded_frame_);
}
@@ -99,7 +98,7 @@ class DecryptingAudioDecoderTest : public testing::Test {
decoder_->Initialize(demuxer_, NewExpectedStatusCB(status),
base::Bind(&MockStatisticsCB::OnStatistics,
base::Unretained(&statistics_cb_)));
- message_loop_.RunAllPending();
+ message_loop_.RunUntilIdle();
}
void Initialize() {
@@ -111,10 +110,10 @@ class DecryptingAudioDecoderTest : public testing::Test {
EXPECT_CALL(*decryptor_, RegisterKeyAddedCB(Decryptor::kAudio, _))
.WillOnce(SaveArg<1>(&key_added_cb_));
- config_.Initialize(kCodecVorbis, 16, CHANNEL_LAYOUT_STEREO, 44100,
- NULL, 0, true, true);
+ AudioDecoderConfig config(kCodecVorbis, 16, CHANNEL_LAYOUT_STEREO, 44100,
+ NULL, 0, true);
+ InitializeAndExpectStatus(config, PIPELINE_OK);
- InitializeAndExpectStatus(config_, PIPELINE_OK);
EXPECT_EQ(16, decoder_->bits_per_channel());
EXPECT_EQ(CHANNEL_LAYOUT_STEREO, decoder_->channel_layout());
EXPECT_EQ(44100, decoder_->samples_per_second());
@@ -132,7 +131,7 @@ class DecryptingAudioDecoderTest : public testing::Test {
decoder_->Read(base::Bind(&DecryptingAudioDecoderTest::FrameReady,
base::Unretained(this)));
- message_loop_.RunAllPending();
+ message_loop_.RunUntilIdle();
}
// Sets up expectations and actions to put DecryptingAudioDecoder in an
@@ -166,7 +165,7 @@ class DecryptingAudioDecoderTest : public testing::Test {
.WillOnce(SaveArg<0>(&pending_demuxer_read_cb_));
decoder_->Read(base::Bind(&DecryptingAudioDecoderTest::FrameReady,
base::Unretained(this)));
- message_loop_.RunAllPending();
+ message_loop_.RunUntilIdle();
// Make sure the Read() on the decoder triggers a Read() on the demuxer.
EXPECT_FALSE(pending_demuxer_read_cb_.is_null());
}
@@ -181,7 +180,7 @@ class DecryptingAudioDecoderTest : public testing::Test {
decoder_->Read(base::Bind(&DecryptingAudioDecoderTest::FrameReady,
base::Unretained(this)));
- message_loop_.RunAllPending();
+ message_loop_.RunUntilIdle();
// Make sure the Read() on the decoder triggers a DecryptAndDecode() on the
// decryptor.
EXPECT_FALSE(pending_audio_decode_cb_.is_null());
@@ -190,12 +189,12 @@ class DecryptingAudioDecoderTest : public testing::Test {
void EnterWaitingForKeyState() {
EXPECT_CALL(*demuxer_, Read(_))
.WillRepeatedly(ReturnBuffer(encrypted_buffer_));
- EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _))
+ EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(encrypted_buffer_, _))
.WillRepeatedly(RunCallback<1>(Decryptor::kNoKey,
Decryptor::AudioBuffers()));
decoder_->Read(base::Bind(&DecryptingAudioDecoderTest::FrameReady,
base::Unretained(this)));
- message_loop_.RunAllPending();
+ message_loop_.RunUntilIdle();
}
void AbortPendingAudioDecodeCB() {
@@ -211,7 +210,7 @@ class DecryptingAudioDecoderTest : public testing::Test {
this, &DecryptingAudioDecoderTest::AbortPendingAudioDecodeCB));
decoder_->Reset(NewExpectedClosure());
- message_loop_.RunAllPending();
+ message_loop_.RunUntilIdle();
}
MOCK_METHOD1(RequestDecryptorNotification,
@@ -221,11 +220,10 @@ class DecryptingAudioDecoderTest : public testing::Test {
const scoped_refptr<Buffer>&));
MessageLoop message_loop_;
- scoped_refptr<StrictMock<DecryptingAudioDecoder> > decoder_;
+ scoped_refptr<DecryptingAudioDecoder> decoder_;
scoped_ptr<StrictMock<MockDecryptor> > decryptor_;
scoped_refptr<StrictMock<MockDemuxerStream> > demuxer_;
MockStatisticsCB statistics_cb_;
- AudioDecoderConfig config_;
DemuxerStream::ReadCB pending_demuxer_read_cb_;
Decryptor::DecoderInitCB pending_init_cb_;
@@ -352,7 +350,7 @@ TEST_F(DecryptingAudioDecoderTest, KeyAdded_DuringWaitingForKey) {
EXPECT_CALL(statistics_cb_, OnStatistics(_));
EXPECT_CALL(*this, FrameReady(AudioDecoder::kOk, decoded_frame_));
key_added_cb_.Run();
- message_loop_.RunAllPending();
+ message_loop_.RunUntilIdle();
}
// Test the case where the a key is added when the decryptor is in
@@ -370,7 +368,7 @@ TEST_F(DecryptingAudioDecoderTest, KeyAdded_DruingPendingDecode) {
key_added_cb_.Run();
base::ResetAndReturn(&pending_audio_decode_cb_).Run(
Decryptor::kNoKey, Decryptor::AudioBuffers());
- message_loop_.RunAllPending();
+ message_loop_.RunUntilIdle();
}
// Test resetting when the decoder is in kIdle state but has not decoded any
@@ -398,7 +396,7 @@ TEST_F(DecryptingAudioDecoderTest, Reset_DuringPendingDemuxerRead) {
Reset();
base::ResetAndReturn(&pending_demuxer_read_cb_).Run(DemuxerStream::kOk,
encrypted_buffer_);
- message_loop_.RunAllPending();
+ message_loop_.RunUntilIdle();
}
// Test resetting when the decoder is in kPendingDecode state.
@@ -460,7 +458,7 @@ TEST_F(DecryptingAudioDecoderTest, DemuxerRead_AbortedDuringReset) {
Reset();
base::ResetAndReturn(&pending_demuxer_read_cb_).Run(DemuxerStream::kAborted,
NULL);
- message_loop_.RunAllPending();
+ message_loop_.RunUntilIdle();
}
// Test config change on the demuxer stream.

Powered by Google App Engine
This is Rietveld 408576698