OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 .Times(AtMost(1)); | 223 .Times(AtMost(1)); |
224 EXPECT_CALL(*decryptor_, DeinitializeDecoder(Decryptor::kVideo)) | 224 EXPECT_CALL(*decryptor_, DeinitializeDecoder(Decryptor::kVideo)) |
225 .WillRepeatedly(InvokeWithoutArgs( | 225 .WillRepeatedly(InvokeWithoutArgs( |
226 this, &DecryptingVideoDecoderTest::AbortAllPendingCBs)); | 226 this, &DecryptingVideoDecoderTest::AbortAllPendingCBs)); |
227 | 227 |
228 decoder_->Stop(NewExpectedClosure()); | 228 decoder_->Stop(NewExpectedClosure()); |
229 message_loop_.RunUntilIdle(); | 229 message_loop_.RunUntilIdle(); |
230 } | 230 } |
231 | 231 |
232 MOCK_METHOD1(RequestDecryptorNotification, | 232 MOCK_METHOD1(RequestDecryptorNotification, |
233 void(const DecryptingVideoDecoder::DecryptorNotificationCB&)); | 233 void(const DecryptingVideoDecoder::DecryptorReadyCB&)); |
234 | 234 |
235 MOCK_METHOD2(FrameReady, void(VideoDecoder::Status, | 235 MOCK_METHOD2(FrameReady, void(VideoDecoder::Status, |
236 const scoped_refptr<VideoFrame>&)); | 236 const scoped_refptr<VideoFrame>&)); |
237 | 237 |
238 MessageLoop message_loop_; | 238 MessageLoop message_loop_; |
239 scoped_refptr<DecryptingVideoDecoder> decoder_; | 239 scoped_refptr<DecryptingVideoDecoder> decoder_; |
240 scoped_ptr<StrictMock<MockDecryptor> > decryptor_; | 240 scoped_ptr<StrictMock<MockDecryptor> > decryptor_; |
241 scoped_refptr<StrictMock<MockDemuxerStream> > demuxer_; | 241 scoped_refptr<StrictMock<MockDemuxerStream> > demuxer_; |
242 MockStatisticsCB statistics_cb_; | 242 MockStatisticsCB statistics_cb_; |
243 VideoDecoderConfig config_; | 243 VideoDecoderConfig config_; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 Reset(); | 439 Reset(); |
440 } | 440 } |
441 | 441 |
442 // Test stopping when the decoder is in kDecryptorRequested state. | 442 // Test stopping when the decoder is in kDecryptorRequested state. |
443 TEST_F(DecryptingVideoDecoderTest, Stop_DuringDecryptorRequested) { | 443 TEST_F(DecryptingVideoDecoderTest, Stop_DuringDecryptorRequested) { |
444 config_.Initialize(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, kVideoFormat, | 444 config_.Initialize(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, kVideoFormat, |
445 kCodedSize, kVisibleRect, kNaturalSize, | 445 kCodedSize, kVisibleRect, kNaturalSize, |
446 NULL, 0, true, true); | 446 NULL, 0, true, true); |
447 EXPECT_CALL(*demuxer_, video_decoder_config()) | 447 EXPECT_CALL(*demuxer_, video_decoder_config()) |
448 .WillRepeatedly(ReturnRef(config_)); | 448 .WillRepeatedly(ReturnRef(config_)); |
449 DecryptingVideoDecoder::DecryptorNotificationCB decryptor_notification_cb; | 449 DecryptingVideoDecoder::DecryptorReadyCB decryptor_ready_cb; |
450 EXPECT_CALL(*this, RequestDecryptorNotification(_)) | 450 EXPECT_CALL(*this, RequestDecryptorNotification(_)) |
451 .WillOnce(SaveArg<0>(&decryptor_notification_cb)); | 451 .WillOnce(SaveArg<0>(&decryptor_ready_cb)); |
452 decoder_->Initialize(demuxer_, | 452 decoder_->Initialize(demuxer_, |
453 NewExpectedStatusCB(DECODER_ERROR_NOT_SUPPORTED), | 453 NewExpectedStatusCB(DECODER_ERROR_NOT_SUPPORTED), |
454 base::Bind(&MockStatisticsCB::OnStatistics, | 454 base::Bind(&MockStatisticsCB::OnStatistics, |
455 base::Unretained(&statistics_cb_))); | 455 base::Unretained(&statistics_cb_))); |
456 message_loop_.RunUntilIdle(); | 456 message_loop_.RunUntilIdle(); |
457 // |decryptor_notification_cb| is saved but not called here. | 457 // |decryptor_ready_cb| is saved but not called here. |
458 EXPECT_FALSE(decryptor_notification_cb.is_null()); | 458 EXPECT_FALSE(decryptor_ready_cb.is_null()); |
459 | 459 |
460 // During stop, RequestDecryptorNotification() should be called with a NULL | 460 // During stop, RequestDecryptorNotification() should be called with a NULL |
461 // callback to cancel the |decryptor_notification_cb|. | 461 // callback to cancel the |decryptor_ready_cb|. |
462 EXPECT_CALL(*this, RequestDecryptorNotification(IsNullCallback())) | 462 EXPECT_CALL(*this, RequestDecryptorNotification(IsNullCallback())) |
463 .WillOnce(ResetAndRunCallback(&decryptor_notification_cb, | 463 .WillOnce(ResetAndRunCallback(&decryptor_ready_cb, |
464 reinterpret_cast<Decryptor*>(NULL))); | 464 reinterpret_cast<Decryptor*>(NULL))); |
465 Stop(); | 465 Stop(); |
466 } | 466 } |
467 | 467 |
468 // Test stopping when the decoder is in kPendingDecoderInit state. | 468 // Test stopping when the decoder is in kPendingDecoderInit state. |
469 TEST_F(DecryptingVideoDecoderTest, Stop_DuringPendingDecoderInit) { | 469 TEST_F(DecryptingVideoDecoderTest, Stop_DuringPendingDecoderInit) { |
470 EXPECT_CALL(*decryptor_, InitializeVideoDecoderMock(_, _)) | 470 EXPECT_CALL(*decryptor_, InitializeVideoDecoderMock(_, _)) |
471 .WillOnce(SaveArg<1>(&pending_init_cb_)); | 471 .WillOnce(SaveArg<1>(&pending_init_cb_)); |
472 | 472 |
473 config_.Initialize(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, kVideoFormat, | 473 config_.Initialize(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, kVideoFormat, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 EXPECT_CALL(*demuxer_, Read(_)) | 598 EXPECT_CALL(*demuxer_, Read(_)) |
599 .WillOnce(RunCallback<0>(DemuxerStream::kConfigChanged, | 599 .WillOnce(RunCallback<0>(DemuxerStream::kConfigChanged, |
600 scoped_refptr<DecoderBuffer>())); | 600 scoped_refptr<DecoderBuffer>())); |
601 | 601 |
602 // TODO(xhwang): Update this test when kConfigChanged is supported in | 602 // TODO(xhwang): Update this test when kConfigChanged is supported in |
603 // DecryptingVideoDecoder. | 603 // DecryptingVideoDecoder. |
604 ReadAndExpectFrameReadyWith(VideoDecoder::kDecodeError, null_video_frame_); | 604 ReadAndExpectFrameReadyWith(VideoDecoder::kDecodeError, null_video_frame_); |
605 } | 605 } |
606 | 606 |
607 } // namespace media | 607 } // namespace media |
OLD | NEW |