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..bc14480dbd71e815f770258e8470e2a7df763d15 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; |
| @@ -24,6 +26,22 @@ using ::testing::SaveArg; |
| static const int kNumConfigs = 3; |
| static const int kNumBuffersInOneConfig = 5; |
| +// Use anonymous namespace here to prevent the actions to be defined multiple |
| +// times across multiple test files. Sadly we can't use static for them. |
| +namespace { |
| + |
| +ACTION_P3(ExecuteCallbackWithVerifier, decryptor, done_cb, verifier) { |
| + // verifier must be called first since |done_cb| call will invoke it as well. |
| + verifier->A(); |
| + arg0.Run(decryptor, done_cb); |
| +} |
| + |
| +ACTION_P(CheckCallbackHappenedUsingVerifier, verifier) { |
|
ddorwin
2014/08/08 21:15:26
ditto
jrummell
2014/08/08 23:40:00
Acknowledged.
|
| + verifier->B(); |
| +} |
| + |
| +} // namespace |
| + |
| namespace media { |
| struct VideoFrameStreamTestParams { |
| @@ -93,6 +111,7 @@ class VideoFrameStreamTest |
| 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; |
| @@ -197,6 +216,17 @@ class VideoFrameStreamTest |
| DECODER_RESET |
| }; |
| + void ExpectDecryptorNotification() { |
| + EXPECT_CALL(*this, SetDecryptorReadyCallback(_)) |
| + .WillRepeatedly(ExecuteCallbackWithVerifier( |
| + decryptor_.get(), |
| + base::Bind(&VideoFrameStreamTest::DecryptorSet, |
| + base::Unretained(this)), |
| + &verifier_)); |
| + EXPECT_CALL(*this, DecryptorSet(Eq(true))) |
| + .WillRepeatedly(CheckCallbackHappenedUsingVerifier(&verifier_)); |
| + } |
| + |
| void EnterPendingState(PendingState state) { |
| DCHECK_NE(state, NOT_PENDING); |
| switch (state) { |
| @@ -219,15 +249,13 @@ class VideoFrameStreamTest |
| break; |
| case DECRYPTOR_NO_KEY: |
| - EXPECT_CALL(*this, SetDecryptorReadyCallback(_)) |
| - .WillRepeatedly(RunCallback<0>(decryptor_.get())); |
| + ExpectDecryptorNotification(); |
| has_no_key_ = true; |
| ReadOneFrame(); |
| break; |
| case DECODER_INIT: |
| - EXPECT_CALL(*this, SetDecryptorReadyCallback(_)) |
| - .WillRepeatedly(RunCallback<0>(decryptor_.get())); |
| + ExpectDecryptorNotification(); |
| decoder_->HoldNextInit(); |
| InitializeVideoFrameStream(); |
| break; |
| @@ -332,6 +360,8 @@ class VideoFrameStreamTest |
| // Decryptor has no key to decrypt a frame. |
| bool has_no_key_; |
| + MatchingCallbackVerifier verifier_; |
| + |
| private: |
| DISALLOW_COPY_AND_ASSIGN(VideoFrameStreamTest); |
| }; |