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

Unified Diff: media/filters/video_decoder_selector_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: enhance tests Created 6 years, 5 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/video_decoder_selector_unittest.cc
diff --git a/media/filters/video_decoder_selector_unittest.cc b/media/filters/video_decoder_selector_unittest.cc
index 57760b5e065439d48cceec13a57eff5ff4236df1..8736b5e7c936a4a7075f0f4af6047106d828af33 100644
--- a/media/filters/video_decoder_selector_unittest.cc
+++ b/media/filters/video_decoder_selector_unittest.cc
@@ -14,6 +14,8 @@
#include "testing/gtest/include/gtest/gtest.h"
using ::testing::_;
+using ::testing::Eq;
+using ::testing::InvokeWithoutArgs;
using ::testing::IsNull;
using ::testing::NiceMock;
using ::testing::NotNull;
@@ -48,9 +50,30 @@ class VideoDecoderSelectorTest : public ::testing::Test {
message_loop_.RunUntilIdle();
}
+ // Used to verify that the number of calls to SetDecryptorReadyCallback()
ddorwin 2014/08/04 18:59:08 ditto - skipped this file.
jrummell 2014/08/07 01:54:25 Acknowledged.
+ // match the number of calls to DecryptorSet() and that the calls happen in
+ // pairs (e.g. DecryptorSet() called after every SetDecryptorReadyCallback()
+ // call). There may be any number of pairs (including 0).
+ class CallbackVerifier {
+ public:
+ CallbackVerifier() : ready_called_(0), set_called_(0) {}
+ ~CallbackVerifier() { Verify(); }
+ void SetDecryptorReadyCallbackCalled() { ++ready_called_; }
+ void DecryptorSetCalled() {
+ ++set_called_;
+ Verify();
+ }
+ void Verify() { EXPECT_EQ(set_called_, ready_called_); }
+
+ private:
+ int ready_called_;
+ int set_called_;
+ };
+
MOCK_METHOD1(SetDecryptorReadyCallback, void(const media::DecryptorReadyCB&));
MOCK_METHOD2(OnDecoderSelected,
void(VideoDecoder*, DecryptingDemuxerStream*));
+ MOCK_METHOD1(DecryptorSet, void(bool));
void MockOnDecoderSelected(
scoped_ptr<VideoDecoder> decoder,
@@ -79,8 +102,14 @@ class VideoDecoderSelectorTest : public ::testing::Test {
if (decryptor_capability == kDecryptOnly ||
decryptor_capability == kDecryptAndDecode) {
- EXPECT_CALL(*this, SetDecryptorReadyCallback(_))
- .WillRepeatedly(RunCallback<0>(decryptor_.get()));
+ EXPECT_CALL(*this, SetDecryptorReadyCallback(_)).WillRepeatedly(DoAll(
+ InvokeWithoutArgs(&verifier_,
+ &CallbackVerifier::SetDecryptorReadyCallbackCalled),
+ RunCallback<0>(decryptor_.get(),
+ base::Bind(&VideoDecoderSelectorTest::DecryptorSet,
+ base::Unretained(this)))));
+ EXPECT_CALL(*this, DecryptorSet(Eq(true))).WillRepeatedly(
+ InvokeWithoutArgs(&verifier_, &CallbackVerifier::DecryptorSetCalled));
if (decryptor_capability == kDecryptOnly) {
EXPECT_CALL(*decryptor_, InitializeVideoDecoder(_, _))
@@ -145,6 +174,8 @@ class VideoDecoderSelectorTest : public ::testing::Test {
base::MessageLoop message_loop_;
+ CallbackVerifier verifier_;
+
private:
DISALLOW_COPY_AND_ASSIGN(VideoDecoderSelectorTest);
};

Powered by Google App Engine
This is Rietveld 408576698