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

Unified Diff: media/filters/decrypting_audio_decoder_unittest.cc

Issue 416333011: Allow setContentDecryptionModule() to get called when setting is done. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More changes Created 6 years, 4 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
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 83d7f5f36bdc9a7fec59aea600c9e2e9538f6953..ae8aeb290e2816be1cb6fba8f0091a8b405c17a2 100644
--- a/media/filters/decrypting_audio_decoder_unittest.cc
+++ b/media/filters/decrypting_audio_decoder_unittest.cc
@@ -20,6 +20,7 @@
using ::testing::_;
using ::testing::AtMost;
+using ::testing::Eq;
using ::testing::SaveArg;
using ::testing::StrictMock;
@@ -54,11 +55,6 @@ ACTION_P(ReturnBuffer, buffer) {
return buffer;
}
-ACTION_P(RunCallbackIfNotNull, param) {
- if (!arg0.is_null())
- arg0.Run(param);
-}
-
} // namespace
class DecryptingAudioDecoderTest : public testing::Test {
@@ -103,12 +99,19 @@ class DecryptingAudioDecoderTest : public testing::Test {
message_loop_.RunUntilIdle();
}
+ void ExpectDecryptorNotification(Decryptor* decryptor, bool expected_result) {
+ EXPECT_CALL(*this, RequestDecryptorNotification(_)).WillOnce(
+ RunCallback<0>(decryptor,
+ base::Bind(&DecryptingAudioDecoderTest::DecryptorSet,
+ base::Unretained(this))));
+ EXPECT_CALL(*this, DecryptorSet(Eq(expected_result)));
+ }
+
void Initialize() {
EXPECT_CALL(*decryptor_, InitializeAudioDecoder(_, _))
.Times(AtMost(1))
.WillOnce(RunCallback<1>(true));
- EXPECT_CALL(*this, RequestDecryptorNotification(_))
- .WillOnce(RunCallbackIfNotNull(decryptor_.get()));
+ ExpectDecryptorNotification(decryptor_.get(), true);
EXPECT_CALL(*decryptor_, RegisterNewKeyCB(Decryptor::kAudio, _))
.WillOnce(SaveArg<1>(&key_added_cb_));
@@ -248,6 +251,8 @@ class DecryptingAudioDecoderTest : public testing::Test {
MOCK_METHOD1(FrameReady, void(const scoped_refptr<AudioBuffer>&));
MOCK_METHOD1(DecodeDone, void(AudioDecoder::Status));
+ MOCK_METHOD1(DecryptorSet, void(bool));
+
base::MessageLoop message_loop_;
scoped_ptr<DecryptingAudioDecoder> decoder_;
scoped_ptr<StrictMock<MockDecryptor> > decryptor_;
@@ -294,8 +299,7 @@ TEST_F(DecryptingAudioDecoderTest, Initialize_InvalidAudioConfig) {
TEST_F(DecryptingAudioDecoderTest, Initialize_UnsupportedAudioConfig) {
EXPECT_CALL(*decryptor_, InitializeAudioDecoder(_, _))
.WillOnce(RunCallback<1>(false));
- EXPECT_CALL(*this, RequestDecryptorNotification(_))
- .WillOnce(RunCallbackIfNotNull(decryptor_.get()));
+ ExpectDecryptorNotification(decryptor_.get(), true);
AudioDecoderConfig config(kCodecVorbis, kSampleFormatPlanarF32,
CHANNEL_LAYOUT_STEREO, kSampleRate, NULL, 0, true);
@@ -303,9 +307,7 @@ TEST_F(DecryptingAudioDecoderTest, Initialize_UnsupportedAudioConfig) {
}
TEST_F(DecryptingAudioDecoderTest, Initialize_NullDecryptor) {
- EXPECT_CALL(*this, RequestDecryptorNotification(_))
- .WillRepeatedly(RunCallbackIfNotNull(static_cast<Decryptor*>(NULL)));
-
+ ExpectDecryptorNotification(NULL, false);
AudioDecoderConfig config(kCodecVorbis, kSampleFormatPlanarF32,
CHANNEL_LAYOUT_STEREO, kSampleRate, NULL, 0, true);
InitializeAndExpectStatus(config, DECODER_ERROR_NOT_SUPPORTED);

Powered by Google App Engine
This is Rietveld 408576698