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

Unified Diff: media/filters/decrypting_audio_decoder_unittest.cc

Issue 11824066: Encrypted Media: Update config/state after config changed in DecryptingAudioDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rename SetAudioConfig to UpdateAudioConfig Created 7 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
« no previous file with comments | « media/filters/decrypting_audio_decoder.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1aa39e707779e283b3eb445eb6ef5b4e0d7d1db0..210779945824c6321ada265e8ca795563a8a26af 100644
--- a/media/filters/decrypting_audio_decoder_unittest.cc
+++ b/media/filters/decrypting_audio_decoder_unittest.cc
@@ -27,7 +27,9 @@ using ::testing::StrictMock;
namespace media {
-static const int kFakeAudioFrameSize = 16;
+// Make sure the kFakeAudioFrameSize is a valid frame size for all audio decoder
+// configs used in this test.
+static const int kFakeAudioFrameSize = 48;
static const uint8 kFakeKeyId[] = { 0x4b, 0x65, 0x79, 0x20, 0x49, 0x44 };
static const uint8 kFakeIv[DecryptConfig::kDecryptionKeySize] = { 0 };
@@ -352,6 +354,16 @@ TEST_F(DecryptingAudioDecoderTest, DemuxerRead_Aborted) {
TEST_F(DecryptingAudioDecoderTest, DemuxerRead_ConfigChange) {
Initialize();
+ // The new config is different from the initial config in bits-per-channel,
+ // channel layout and samples_per_second.
+ AudioDecoderConfig new_config(kCodecVorbis, kSampleFormatPlanarS16,
+ CHANNEL_LAYOUT_5_1, 88200, NULL, 0, false);
+ EXPECT_NE(new_config.bits_per_channel(), config_.bits_per_channel());
+ EXPECT_NE(new_config.channel_layout(), config_.channel_layout());
+ EXPECT_NE(new_config.samples_per_second(), config_.samples_per_second());
+
+ EXPECT_CALL(*demuxer_, audio_decoder_config())
+ .WillRepeatedly(ReturnRef(new_config));
EXPECT_CALL(*decryptor_, DeinitializeDecoder(Decryptor::kAudio));
EXPECT_CALL(*decryptor_, InitializeAudioDecoderMock(_, _))
.WillOnce(RunCallback<1>(true));
@@ -364,6 +376,10 @@ TEST_F(DecryptingAudioDecoderTest, DemuxerRead_ConfigChange) {
EXPECT_CALL(statistics_cb_, OnStatistics(_));
ReadAndExpectFrameReadyWith(AudioDecoder::kOk, decoded_frame_);
+
+ EXPECT_EQ(new_config.bits_per_channel(), decoder_->bits_per_channel());
+ EXPECT_EQ(new_config.channel_layout(), decoder_->channel_layout());
+ EXPECT_EQ(new_config.samples_per_second(), decoder_->samples_per_second());
}
// Test config change failure.
@@ -465,8 +481,18 @@ TEST_F(DecryptingAudioDecoderTest, Reset_DuringDemuxerRead_ConfigChange) {
Reset();
+ // The new config is different from the initial config in bits-per-channel,
+ // channel layout and samples_per_second.
+ AudioDecoderConfig new_config(kCodecVorbis, kSampleFormatPlanarS16,
+ CHANNEL_LAYOUT_5_1, 88200, NULL, 0, false);
+ EXPECT_NE(new_config.bits_per_channel(), config_.bits_per_channel());
+ EXPECT_NE(new_config.channel_layout(), config_.channel_layout());
+ EXPECT_NE(new_config.samples_per_second(), config_.samples_per_second());
+
// Even during pending reset, the decoder still needs to be initialized with
// the new config.
+ EXPECT_CALL(*demuxer_, audio_decoder_config())
+ .WillRepeatedly(ReturnRef(new_config));
EXPECT_CALL(*decryptor_, DeinitializeDecoder(Decryptor::kAudio));
EXPECT_CALL(*decryptor_, InitializeAudioDecoderMock(_, _))
.WillOnce(RunCallback<1>(true));
@@ -475,6 +501,10 @@ TEST_F(DecryptingAudioDecoderTest, Reset_DuringDemuxerRead_ConfigChange) {
base::ResetAndReturn(&pending_demuxer_read_cb_)
.Run(DemuxerStream::kConfigChanged, NULL);
message_loop_.RunUntilIdle();
+
+ EXPECT_EQ(new_config.bits_per_channel(), decoder_->bits_per_channel());
+ EXPECT_EQ(new_config.channel_layout(), decoder_->channel_layout());
+ EXPECT_EQ(new_config.samples_per_second(), decoder_->samples_per_second());
}
// Test resetting when the decoder is in kPendingDemuxerRead state, the read
« no previous file with comments | « media/filters/decrypting_audio_decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698