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" |
11 #include "media/base/decoder_buffer.h" | 11 #include "media/base/decoder_buffer.h" |
12 #include "media/base/decrypt_config.h" | 12 #include "media/base/decrypt_config.h" |
13 #include "media/base/gmock_callback_support.h" | 13 #include "media/base/gmock_callback_support.h" |
14 #include "media/base/mock_callback.h" | 14 #include "media/base/mock_callback.h" |
15 #include "media/base/mock_filters.h" | 15 #include "media/base/mock_filters.h" |
16 #include "media/base/video_frame.h" | 16 #include "media/base/video_frame.h" |
17 #include "media/filters/decrypting_video_decoder.h" | 17 #include "media/filters/decrypting_video_decoder.h" |
18 #include "media/filters/ffmpeg_decoder_unittest.h" | 18 #include "media/filters/ffmpeg_decoder_unittest.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
20 | 20 |
21 using ::testing::_; | 21 using ::testing::_; |
22 using ::testing::AtMost; | 22 using ::testing::AtMost; |
23 using ::testing::Invoke; | |
24 using ::testing::IsNull; | 23 using ::testing::IsNull; |
25 using ::testing::ReturnRef; | 24 using ::testing::ReturnRef; |
26 using ::testing::SaveArg; | 25 using ::testing::SaveArg; |
27 using ::testing::StrictMock; | 26 using ::testing::StrictMock; |
28 | 27 |
29 namespace media { | 28 namespace media { |
30 | 29 |
31 static const VideoFrame::Format kVideoFormat = VideoFrame::YV12; | 30 static const VideoFrame::Format kVideoFormat = VideoFrame::YV12; |
32 static const gfx::Size kCodedSize(320, 240); | 31 static const gfx::Size kCodedSize(320, 240); |
33 static const gfx::Rect kVisibleRect(320, 240); | 32 static const gfx::Rect kVisibleRect(320, 240); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 66 |
68 MATCHER(IsEndOfStream, "end of stream") { | 67 MATCHER(IsEndOfStream, "end of stream") { |
69 return (arg->IsEndOfStream()); | 68 return (arg->IsEndOfStream()); |
70 } | 69 } |
71 | 70 |
72 } // namespace | 71 } // namespace |
73 | 72 |
74 class DecryptingVideoDecoderTest : public testing::Test { | 73 class DecryptingVideoDecoderTest : public testing::Test { |
75 public: | 74 public: |
76 DecryptingVideoDecoderTest() | 75 DecryptingVideoDecoderTest() |
77 : decoder_(new StrictMock<DecryptingVideoDecoder>( | 76 : decoder_(new DecryptingVideoDecoder( |
78 base::Bind(&Identity<scoped_refptr<base::MessageLoopProxy> >, | 77 base::Bind(&Identity<scoped_refptr<base::MessageLoopProxy> >, |
79 message_loop_.message_loop_proxy()), | 78 message_loop_.message_loop_proxy()), |
80 base::Bind( | 79 base::Bind( |
81 &DecryptingVideoDecoderTest::RequestDecryptorNotification, | 80 &DecryptingVideoDecoderTest::RequestDecryptorNotification, |
82 base::Unretained(this)))), | 81 base::Unretained(this)))), |
83 decryptor_(new StrictMock<MockDecryptor>()), | 82 decryptor_(new StrictMock<MockDecryptor>()), |
84 demuxer_(new StrictMock<MockDemuxerStream>()), | 83 demuxer_(new StrictMock<MockDemuxerStream>()), |
85 encrypted_buffer_(CreateFakeEncryptedBuffer()), | 84 encrypted_buffer_(CreateFakeEncryptedBuffer()), |
86 decoded_video_frame_(VideoFrame::CreateBlackFrame(kCodedSize)), | 85 decoded_video_frame_(VideoFrame::CreateBlackFrame(kCodedSize)), |
87 null_video_frame_(scoped_refptr<VideoFrame>()), | 86 null_video_frame_(scoped_refptr<VideoFrame>()), |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 message_loop_.RunUntilIdle(); | 231 message_loop_.RunUntilIdle(); |
233 } | 232 } |
234 | 233 |
235 MOCK_METHOD1(RequestDecryptorNotification, | 234 MOCK_METHOD1(RequestDecryptorNotification, |
236 void(const DecryptingVideoDecoder::DecryptorNotificationCB&)); | 235 void(const DecryptingVideoDecoder::DecryptorNotificationCB&)); |
237 | 236 |
238 MOCK_METHOD2(FrameReady, void(VideoDecoder::Status, | 237 MOCK_METHOD2(FrameReady, void(VideoDecoder::Status, |
239 const scoped_refptr<VideoFrame>&)); | 238 const scoped_refptr<VideoFrame>&)); |
240 | 239 |
241 MessageLoop message_loop_; | 240 MessageLoop message_loop_; |
242 scoped_refptr<StrictMock<DecryptingVideoDecoder> > decoder_; | 241 scoped_refptr<DecryptingVideoDecoder> decoder_; |
243 scoped_ptr<StrictMock<MockDecryptor> > decryptor_; | 242 scoped_ptr<StrictMock<MockDecryptor> > decryptor_; |
244 scoped_refptr<StrictMock<MockDemuxerStream> > demuxer_; | 243 scoped_refptr<StrictMock<MockDemuxerStream> > demuxer_; |
245 MockStatisticsCB statistics_cb_; | 244 MockStatisticsCB statistics_cb_; |
246 VideoDecoderConfig config_; | 245 VideoDecoderConfig config_; |
247 | 246 |
248 DemuxerStream::ReadCB pending_demuxer_read_cb_; | 247 DemuxerStream::ReadCB pending_demuxer_read_cb_; |
249 Decryptor::DecoderInitCB pending_init_cb_; | 248 Decryptor::DecoderInitCB pending_init_cb_; |
250 Decryptor::KeyAddedCB key_added_cb_; | 249 Decryptor::KeyAddedCB key_added_cb_; |
251 Decryptor::VideoDecodeCB pending_video_decode_cb_; | 250 Decryptor::VideoDecodeCB pending_video_decode_cb_; |
252 | 251 |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 EXPECT_CALL(*demuxer_, Read(_)) | 600 EXPECT_CALL(*demuxer_, Read(_)) |
602 .WillOnce(RunCallback<0>(DemuxerStream::kConfigChanged, | 601 .WillOnce(RunCallback<0>(DemuxerStream::kConfigChanged, |
603 scoped_refptr<DecoderBuffer>())); | 602 scoped_refptr<DecoderBuffer>())); |
604 | 603 |
605 // TODO(xhwang): Update this test when kConfigChanged is supported in | 604 // TODO(xhwang): Update this test when kConfigChanged is supported in |
606 // DecryptingVideoDecoder. | 605 // DecryptingVideoDecoder. |
607 ReadAndExpectFrameReadyWith(VideoDecoder::kDecodeError, null_video_frame_); | 606 ReadAndExpectFrameReadyWith(VideoDecoder::kDecodeError, null_video_frame_); |
608 } | 607 } |
609 | 608 |
610 } // namespace media | 609 } // namespace media |
OLD | NEW |