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

Unified Diff: media/filters/audio_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/audio_decoder_selector_unittest.cc
diff --git a/media/filters/audio_decoder_selector_unittest.cc b/media/filters/audio_decoder_selector_unittest.cc
index eb0e8dbd3c4606db23ec86518f46613b41989eca..6725e2f1a9f5e86e8df51e50344da77886b403e3 100644
--- a/media/filters/audio_decoder_selector_unittest.cc
+++ b/media/filters/audio_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 AudioDecoderSelectorTest : public ::testing::Test {
message_loop_.RunUntilIdle();
}
+ // Used to verify that the number of calls to SetDecryptorReadyCallback()
+ // 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_; }
ddorwin 2014/08/04 18:59:08 Is it okay/expected for the values to be >1 apart?
jrummell 2014/08/07 01:54:25 Done.
+ 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(AudioDecoder*, DecryptingDemuxerStream*));
+ MOCK_METHOD1(DecryptorSet, void(bool));
void MockOnDecoderSelected(scoped_ptr<AudioDecoder> decoder,
scoped_ptr<DecryptingDemuxerStream> stream) {
@@ -83,9 +106,14 @@ class AudioDecoderSelectorTest : 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(
ddorwin 2014/08/04 18:59:08 This looks odd. Do we need SetDecryptorReadyCallba
jrummell 2014/08/07 01:54:25 The problem is that SetDecryptorReadyCallback() is
+ InvokeWithoutArgs(&verifier_,
+ &CallbackVerifier::SetDecryptorReadyCallbackCalled),
+ RunCallback<0>(decryptor_.get(),
+ base::Bind(&AudioDecoderSelectorTest::DecryptorSet,
+ base::Unretained(this)))));
+ EXPECT_CALL(*this, DecryptorSet(Eq(true))).WillRepeatedly(
+ InvokeWithoutArgs(&verifier_, &CallbackVerifier::DecryptorSetCalled));
if (decryptor_capability == kDecryptOnly) {
EXPECT_CALL(*decryptor_, InitializeAudioDecoder(_, _))
@@ -149,6 +177,8 @@ class AudioDecoderSelectorTest : public ::testing::Test {
base::MessageLoop message_loop_;
+ CallbackVerifier verifier_;
+
private:
DISALLOW_COPY_AND_ASSIGN(AudioDecoderSelectorTest);
};

Powered by Google App Engine
This is Rietveld 408576698