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

Side by Side Diff: media/filters/decrypting_demuxer_stream_unittest.cc

Issue 11226019: Encrypted Media: Replace DecryptorClient with key event callbacks. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase again Created 7 years, 12 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 unified diff | Download patch
OLDNEW
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 108 }
109 109
110 // The following functions are used to test stream-type-neutral logic in 110 // The following functions are used to test stream-type-neutral logic in
111 // DecryptingDemuxerStream. Therefore, we don't specify audio or video in the 111 // DecryptingDemuxerStream. Therefore, we don't specify audio or video in the
112 // function names. But for testing purpose, they all use an audio input 112 // function names. But for testing purpose, they all use an audio input
113 // demuxer stream. 113 // demuxer stream.
114 114
115 void Initialize() { 115 void Initialize() {
116 EXPECT_CALL(*this, RequestDecryptorNotification(_)) 116 EXPECT_CALL(*this, RequestDecryptorNotification(_))
117 .WillOnce(RunCallbackIfNotNull(decryptor_.get())); 117 .WillOnce(RunCallbackIfNotNull(decryptor_.get()));
118 EXPECT_CALL(*decryptor_, RegisterKeyAddedCB(Decryptor::kAudio, _)) 118 EXPECT_CALL(*decryptor_, RegisterNewKeyCB(Decryptor::kAudio, _))
119 .WillOnce(SaveArg<1>(&key_added_cb_)); 119 .WillOnce(SaveArg<1>(&key_added_cb_));
120 120
121 AudioDecoderConfig input_config( 121 AudioDecoderConfig input_config(
122 kCodecVorbis, 16, CHANNEL_LAYOUT_STEREO, 44100, NULL, 0, true); 122 kCodecVorbis, 16, CHANNEL_LAYOUT_STEREO, 44100, NULL, 0, true);
123 InitializeAudioAndExpectStatus(input_config, PIPELINE_OK); 123 InitializeAudioAndExpectStatus(input_config, PIPELINE_OK);
124 124
125 const AudioDecoderConfig& output_config = 125 const AudioDecoderConfig& output_config =
126 demuxer_stream_->audio_decoder_config(); 126 demuxer_stream_->audio_decoder_config();
127 EXPECT_EQ(DemuxerStream::AUDIO, demuxer_stream_->type()); 127 EXPECT_EQ(DemuxerStream::AUDIO, demuxer_stream_->type());
128 EXPECT_FALSE(output_config.is_encrypted()); 128 EXPECT_FALSE(output_config.is_encrypted());
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 MOCK_METHOD2(BufferReady, void(DemuxerStream::Status, 215 MOCK_METHOD2(BufferReady, void(DemuxerStream::Status,
216 const scoped_refptr<DecoderBuffer>&)); 216 const scoped_refptr<DecoderBuffer>&));
217 217
218 MessageLoop message_loop_; 218 MessageLoop message_loop_;
219 scoped_refptr<DecryptingDemuxerStream> demuxer_stream_; 219 scoped_refptr<DecryptingDemuxerStream> demuxer_stream_;
220 scoped_ptr<StrictMock<MockDecryptor> > decryptor_; 220 scoped_ptr<StrictMock<MockDecryptor> > decryptor_;
221 scoped_refptr<StrictMock<MockDemuxerStream> > input_audio_stream_; 221 scoped_refptr<StrictMock<MockDemuxerStream> > input_audio_stream_;
222 scoped_refptr<StrictMock<MockDemuxerStream> > input_video_stream_; 222 scoped_refptr<StrictMock<MockDemuxerStream> > input_video_stream_;
223 223
224 DemuxerStream::ReadCB pending_demuxer_read_cb_; 224 DemuxerStream::ReadCB pending_demuxer_read_cb_;
225 Decryptor::KeyAddedCB key_added_cb_; 225 Decryptor::NewKeyCB key_added_cb_;
226 Decryptor::DecryptCB pending_decrypt_cb_; 226 Decryptor::DecryptCB pending_decrypt_cb_;
227 227
228 // Constant buffers to be returned by the input demuxer streams and the 228 // Constant buffers to be returned by the input demuxer streams and the
229 // |decryptor_|. 229 // |decryptor_|.
230 scoped_refptr<DecoderBuffer> encrypted_buffer_; 230 scoped_refptr<DecoderBuffer> encrypted_buffer_;
231 scoped_refptr<DecoderBuffer> decrypted_buffer_; 231 scoped_refptr<DecoderBuffer> decrypted_buffer_;
232 232
233 private: 233 private:
234 DISALLOW_COPY_AND_ASSIGN(DecryptingDemuxerStreamTest); 234 DISALLOW_COPY_AND_ASSIGN(DecryptingDemuxerStreamTest);
235 }; 235 };
(...skipping 14 matching lines...) Expand all
250 TEST_F(DecryptingDemuxerStreamTest, Initialize_InvalidAudioConfig) { 250 TEST_F(DecryptingDemuxerStreamTest, Initialize_InvalidAudioConfig) {
251 AudioDecoderConfig config(kUnknownAudioCodec, 0, CHANNEL_LAYOUT_STEREO, 0, 251 AudioDecoderConfig config(kUnknownAudioCodec, 0, CHANNEL_LAYOUT_STEREO, 0,
252 NULL, 0, true); 252 NULL, 0, true);
253 253
254 InitializeAudioAndExpectStatus(config, DEMUXER_ERROR_NO_SUPPORTED_STREAMS); 254 InitializeAudioAndExpectStatus(config, DEMUXER_ERROR_NO_SUPPORTED_STREAMS);
255 } 255 }
256 256
257 TEST_F(DecryptingDemuxerStreamTest, Initialize_NormalVideo) { 257 TEST_F(DecryptingDemuxerStreamTest, Initialize_NormalVideo) {
258 EXPECT_CALL(*this, RequestDecryptorNotification(_)) 258 EXPECT_CALL(*this, RequestDecryptorNotification(_))
259 .WillOnce(RunCallbackIfNotNull(decryptor_.get())); 259 .WillOnce(RunCallbackIfNotNull(decryptor_.get()));
260 EXPECT_CALL(*decryptor_, RegisterKeyAddedCB(Decryptor::kVideo, _)) 260 EXPECT_CALL(*decryptor_, RegisterNewKeyCB(Decryptor::kVideo, _))
261 .WillOnce(SaveArg<1>(&key_added_cb_)); 261 .WillOnce(SaveArg<1>(&key_added_cb_));
262 262
263 VideoDecoderConfig config(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, 263 VideoDecoderConfig config(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN,
264 kVideoFormat, 264 kVideoFormat,
265 kCodedSize, kVisibleRect, kNaturalSize, 265 kCodedSize, kVisibleRect, kNaturalSize,
266 NULL, 0, true); 266 NULL, 0, true);
267 InitializeVideoAndExpectStatus(config, PIPELINE_OK); 267 InitializeVideoAndExpectStatus(config, PIPELINE_OK);
268 268
269 const VideoDecoderConfig& output_config = 269 const VideoDecoderConfig& output_config =
270 demuxer_stream_->video_decoder_config(); 270 demuxer_stream_->video_decoder_config();
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 447
448 EXPECT_CALL(*input_audio_stream_, Read(_)) 448 EXPECT_CALL(*input_audio_stream_, Read(_))
449 .WillOnce(RunCallback<0>(DemuxerStream::kConfigChanged, 449 .WillOnce(RunCallback<0>(DemuxerStream::kConfigChanged,
450 scoped_refptr<DecoderBuffer>())); 450 scoped_refptr<DecoderBuffer>()));
451 451
452 // TODO(xhwang): Update this when kConfigChanged is supported. 452 // TODO(xhwang): Update this when kConfigChanged is supported.
453 ReadAndExpectBufferReadyWith(DemuxerStream::kAborted, NULL); 453 ReadAndExpectBufferReadyWith(DemuxerStream::kAborted, NULL);
454 } 454 }
455 455
456 } // namespace media 456 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698