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

Side by Side Diff: media/crypto/aes_decryptor_unittest.cc

Issue 15772012: Separate MediaKeys interface from Decryptor interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « media/crypto/aes_decryptor.cc ('k') | media/filters/pipeline_integration_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "media/base/decoder_buffer.h" 10 #include "media/base/decoder_buffer.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 void AddKeyAndExpectToSucceed(const uint8* key_id, int key_id_size, 254 void AddKeyAndExpectToSucceed(const uint8* key_id, int key_id_size,
255 const uint8* key, int key_size) { 255 const uint8* key, int key_size) {
256 EXPECT_CALL(*this, KeyAdded(kClearKeySystem, session_id_string_)); 256 EXPECT_CALL(*this, KeyAdded(kClearKeySystem, session_id_string_));
257 decryptor_.AddKey(kClearKeySystem, key, key_size, key_id, key_id_size, 257 decryptor_.AddKey(kClearKeySystem, key, key_size, key_id, key_id_size,
258 session_id_string_); 258 session_id_string_);
259 } 259 }
260 260
261 void AddKeyAndExpectToFail(const uint8* key_id, int key_id_size, 261 void AddKeyAndExpectToFail(const uint8* key_id, int key_id_size,
262 const uint8* key, int key_size) { 262 const uint8* key, int key_size) {
263 EXPECT_CALL(*this, KeyError(kClearKeySystem, session_id_string_, 263 EXPECT_CALL(*this, KeyError(kClearKeySystem, session_id_string_,
264 Decryptor::kUnknownError, 0)); 264 MediaKeys::kUnknownError, 0));
265 decryptor_.AddKey(kClearKeySystem, key, key_size, key_id, key_id_size, 265 decryptor_.AddKey(kClearKeySystem, key, key_size, key_id, key_id_size,
266 session_id_string_); 266 session_id_string_);
267 } 267 }
268 268
269 MOCK_METHOD2(BufferDecrypted, void(Decryptor::Status, 269 MOCK_METHOD2(BufferDecrypted, void(Decryptor::Status,
270 const scoped_refptr<DecoderBuffer>&)); 270 const scoped_refptr<DecoderBuffer>&));
271 271
272 void DecryptAndExpectToSucceed(const scoped_refptr<DecoderBuffer>& encrypted, 272 void DecryptAndExpectToSucceed(const scoped_refptr<DecoderBuffer>& encrypted,
273 const uint8* plain_text, int plain_text_size) { 273 const uint8* plain_text, int plain_text_size) {
274 scoped_refptr<DecoderBuffer> decrypted; 274 scoped_refptr<DecoderBuffer> decrypted;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 EXPECT_NE(0, memcmp(plain_text, decrypted->GetData(), plain_text_size)); 307 EXPECT_NE(0, memcmp(plain_text, decrypted->GetData(), plain_text_size));
308 } 308 }
309 309
310 void DecryptAndExpectToFail(const scoped_refptr<DecoderBuffer>& encrypted) { 310 void DecryptAndExpectToFail(const scoped_refptr<DecoderBuffer>& encrypted) {
311 EXPECT_CALL(*this, BufferDecrypted(AesDecryptor::kError, IsNull())); 311 EXPECT_CALL(*this, BufferDecrypted(AesDecryptor::kError, IsNull()));
312 decryptor_.Decrypt(Decryptor::kVideo, encrypted, decrypt_cb_); 312 decryptor_.Decrypt(Decryptor::kVideo, encrypted, decrypt_cb_);
313 } 313 }
314 314
315 MOCK_METHOD2(KeyAdded, void(const std::string&, const std::string&)); 315 MOCK_METHOD2(KeyAdded, void(const std::string&, const std::string&));
316 MOCK_METHOD4(KeyError, void(const std::string&, const std::string&, 316 MOCK_METHOD4(KeyError, void(const std::string&, const std::string&,
317 Decryptor::KeyError, int)); 317 MediaKeys::KeyError, int));
318 MOCK_METHOD4(KeyMessage, void(const std::string& key_system, 318 MOCK_METHOD4(KeyMessage, void(const std::string& key_system,
319 const std::string& session_id, 319 const std::string& session_id,
320 const std::string& message, 320 const std::string& message,
321 const std::string& default_url)); 321 const std::string& default_url));
322 322
323 AesDecryptor decryptor_; 323 AesDecryptor decryptor_;
324 std::string session_id_string_; 324 std::string session_id_string_;
325 AesDecryptor::DecryptCB decrypt_cb_; 325 AesDecryptor::DecryptCB decrypt_cb_;
326 std::vector<SubsampleEntry> subsample_entries_; 326 std::vector<SubsampleEntry> subsample_entries_;
327 }; 327 };
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 scoped_refptr<DecoderBuffer> encrypted_data = CreateSubsampleEncryptedBuffer( 599 scoped_refptr<DecoderBuffer> encrypted_data = CreateSubsampleEncryptedBuffer(
600 kSubsampleData, arraysize(kSubsampleData), 600 kSubsampleData, arraysize(kSubsampleData),
601 kSubsampleKeyId, arraysize(kSubsampleKeyId), 601 kSubsampleKeyId, arraysize(kSubsampleKeyId),
602 kSubsampleIv, arraysize(kSubsampleIv), 602 kSubsampleIv, arraysize(kSubsampleIv),
603 0, 603 0,
604 entries); 604 entries);
605 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToFail(encrypted_data)); 605 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToFail(encrypted_data));
606 } 606 }
607 607
608 } // namespace media 608 } // namespace media
OLDNEW
« no previous file with comments | « media/crypto/aes_decryptor.cc ('k') | media/filters/pipeline_integration_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698