| 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 ed956ea1d51e0a172fb9e09cb7edc2f854dafddc..11dc52ae7a0be4c7f3ca84f3c9da51fa8c9b1865 100644
|
| --- a/media/filters/decrypting_video_decoder_unittest.cc
|
| +++ b/media/filters/decrypting_video_decoder_unittest.cc
|
| @@ -44,13 +44,8 @@ static scoped_refptr<DecoderBuffer> CreateFakeEncryptedBuffer() {
|
| // times across multiple test files. Sadly we can't use static for them.
|
| namespace {
|
|
|
| -ACTION_P(RunCallbackIfNotNull, param) {
|
| - if (!arg0.is_null())
|
| - arg0.Run(param);
|
| -}
|
| -
|
| -ACTION_P2(ResetAndRunCallback, callback, param) {
|
| - base::ResetAndReturn(callback).Run(param);
|
| +ACTION_P3(ResetAndRunCallback, callback, p1, p2) {
|
| + base::ResetAndReturn(callback).Run(p1, p2);
|
| }
|
|
|
| } // namespace
|
| @@ -70,14 +65,20 @@ class DecryptingVideoDecoderTest : public testing::Test {
|
| decoded_video_frame_(VideoFrame::CreateBlackFrame(
|
| TestVideoConfig::NormalCodedSize())),
|
| null_video_frame_(scoped_refptr<VideoFrame>()) {
|
| - EXPECT_CALL(*this, RequestDecryptorNotification(_))
|
| - .WillRepeatedly(RunCallbackIfNotNull(decryptor_.get()));
|
| }
|
|
|
| virtual ~DecryptingVideoDecoderTest() {
|
| Destroy();
|
| }
|
|
|
| + void ExpectDecryptorNotification(Decryptor* decryptor, bool expected_result) {
|
| + EXPECT_CALL(*this, RequestDecryptorNotification(_)).WillOnce(
|
| + RunCallback<0>(decryptor,
|
| + base::Bind(&DecryptingVideoDecoderTest::DecryptorSet,
|
| + base::Unretained(this))));
|
| + EXPECT_CALL(*this, DecryptorSet(expected_result));
|
| + }
|
| +
|
| // Initializes the |decoder_| and expects |status|. Note the initialization
|
| // can succeed or fail.
|
| void InitializeAndExpectStatus(const VideoDecoderConfig& config,
|
| @@ -90,6 +91,7 @@ class DecryptingVideoDecoderTest : public testing::Test {
|
|
|
| // Initialize the |decoder_| and expects it to succeed.
|
| void Initialize() {
|
| + ExpectDecryptorNotification(decryptor_.get(), true);
|
| EXPECT_CALL(*decryptor_, InitializeVideoDecoder(_, _))
|
| .WillOnce(RunCallback<1>(true));
|
| EXPECT_CALL(*decryptor_, RegisterNewKeyCB(Decryptor::kVideo, _))
|
| @@ -223,6 +225,8 @@ class DecryptingVideoDecoderTest : public testing::Test {
|
| MOCK_METHOD1(FrameReady, void(const scoped_refptr<VideoFrame>&));
|
| MOCK_METHOD1(DecodeDone, void(VideoDecoder::Status));
|
|
|
| + MOCK_METHOD1(DecryptorSet, void(bool));
|
| +
|
| base::MessageLoop message_loop_;
|
| scoped_ptr<DecryptingVideoDecoder> decoder_;
|
| scoped_ptr<StrictMock<MockDecryptor> > decryptor_;
|
| @@ -249,8 +253,7 @@ TEST_F(DecryptingVideoDecoderTest, Initialize_Normal) {
|
| }
|
|
|
| TEST_F(DecryptingVideoDecoderTest, Initialize_NullDecryptor) {
|
| - EXPECT_CALL(*this, RequestDecryptorNotification(_))
|
| - .WillRepeatedly(RunCallbackIfNotNull(static_cast<Decryptor*>(NULL)));
|
| + ExpectDecryptorNotification(NULL, false);
|
| InitializeAndExpectStatus(TestVideoConfig::NormalEncrypted(),
|
| DECODER_ERROR_NOT_SUPPORTED);
|
| }
|
| @@ -415,14 +418,18 @@ TEST_F(DecryptingVideoDecoderTest, Destroy_DuringDecryptorRequested) {
|
|
|
| // During destruction, RequestDecryptorNotification() should be called with a
|
| // NULL callback to cancel the |decryptor_ready_cb|.
|
| - EXPECT_CALL(*this, RequestDecryptorNotification(IsNullCallback()))
|
| - .WillOnce(ResetAndRunCallback(&decryptor_ready_cb,
|
| - reinterpret_cast<Decryptor*>(NULL)));
|
| + EXPECT_CALL(*this, RequestDecryptorNotification(IsNullCallback())).WillOnce(
|
| + ResetAndRunCallback(&decryptor_ready_cb,
|
| + reinterpret_cast<Decryptor*>(NULL),
|
| + base::Bind(&DecryptingVideoDecoderTest::DecryptorSet,
|
| + base::Unretained(this))));
|
| + EXPECT_CALL(*this, DecryptorSet(_)).Times(0);
|
| Destroy();
|
| }
|
|
|
| // Test destruction when the decoder is in kPendingDecoderInit state.
|
| TEST_F(DecryptingVideoDecoderTest, Destroy_DuringPendingDecoderInit) {
|
| + ExpectDecryptorNotification(decryptor_.get(), true);
|
| EXPECT_CALL(*decryptor_, InitializeVideoDecoder(_, _))
|
| .WillOnce(SaveArg<1>(&pending_init_cb_));
|
|
|
|
|