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

Unified Diff: media/filters/decrypting_video_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: ReportCallback 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_video_decoder_unittest.cc
diff --git a/media/filters/decrypting_video_decoder_unittest.cc b/media/filters/decrypting_video_decoder_unittest.cc
index ed956ea1d51e0a172fb9e09cb7edc2f854dafddc..da1f5d2166a04436790409e7e0653c7f1fdc5861 100644
--- a/media/filters/decrypting_video_decoder_unittest.cc
+++ b/media/filters/decrypting_video_decoder_unittest.cc
@@ -18,6 +18,7 @@
#include "testing/gmock/include/gmock/gmock.h"
using ::testing::_;
+using ::testing::Eq;
using ::testing::Invoke;
using ::testing::SaveArg;
using ::testing::StrictMock;
@@ -44,13 +45,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 +66,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(Eq(expected_result)));
+ }
+
// Initializes the |decoder_| and expects |status|. Note the initialization
// can succeed or fail.
void InitializeAndExpectStatus(const VideoDecoderConfig& config,
@@ -90,6 +92,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 +226,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 +254,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 +419,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_));

Powered by Google App Engine
This is Rietveld 408576698