Chromium Code Reviews| Index: media/filters/video_frame_stream_unittest.cc |
| diff --git a/media/filters/video_frame_stream_unittest.cc b/media/filters/video_frame_stream_unittest.cc |
| index 492e7cf9ffbb50e3b17f6fdfa28e7c46940a5fa5..790b137864c419b8a5eae87c2df4c90180dd006a 100644 |
| --- a/media/filters/video_frame_stream_unittest.cc |
| +++ b/media/filters/video_frame_stream_unittest.cc |
| @@ -16,7 +16,9 @@ |
| using ::testing::_; |
| using ::testing::AnyNumber; |
| using ::testing::Assign; |
| +using ::testing::Eq; |
| using ::testing::Invoke; |
| +using ::testing::InvokeWithoutArgs; |
| using ::testing::NiceMock; |
| using ::testing::Return; |
| using ::testing::SaveArg; |
| @@ -91,8 +93,29 @@ class VideoFrameStreamTest |
| DCHECK(!pending_stop_); |
| } |
| + // Used to verify that the number of calls to SetDecryptorReadyCallback() |
|
ddorwin
2014/08/04 18:59:08
ditto - skipped this file.
Since we now have 3 co
jrummell
2014/08/07 01:54:25
Done.
|
| + // 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(OnNewSpliceBuffer, void(base::TimeDelta)); |
| MOCK_METHOD1(SetDecryptorReadyCallback, void(const media::DecryptorReadyCB&)); |
| + MOCK_METHOD1(DecryptorSet, void(bool)); |
| void OnStatistics(const PipelineStatistics& statistics) { |
| total_bytes_decoded_ += statistics.video_bytes_decoded; |
| @@ -219,15 +242,29 @@ class VideoFrameStreamTest |
| break; |
| case DECRYPTOR_NO_KEY: |
| - 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(&VideoFrameStreamTest::DecryptorSet, |
| + base::Unretained(this))))); |
| + EXPECT_CALL(*this, DecryptorSet(Eq(true))) |
| + .WillRepeatedly(InvokeWithoutArgs( |
| + &verifier_, &CallbackVerifier::DecryptorSetCalled)); |
| has_no_key_ = true; |
| ReadOneFrame(); |
| break; |
| case DECODER_INIT: |
| - 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(&VideoFrameStreamTest::DecryptorSet, |
| + base::Unretained(this))))); |
| + EXPECT_CALL(*this, DecryptorSet(Eq(true))) |
| + .WillRepeatedly(InvokeWithoutArgs( |
| + &verifier_, &CallbackVerifier::DecryptorSetCalled)); |
| decoder_->HoldNextInit(); |
| InitializeVideoFrameStream(); |
| break; |
| @@ -332,6 +369,8 @@ class VideoFrameStreamTest |
| // Decryptor has no key to decrypt a frame. |
| bool has_no_key_; |
| + CallbackVerifier verifier_; |
| + |
| private: |
| DISALLOW_COPY_AND_ASSIGN(VideoFrameStreamTest); |
| }; |