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

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

Issue 813683005: Add |legacy_destination_url| back to SessionMessage for EME (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changes Created 5 years, 11 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
« no previous file with comments | « media/cdm/aes_decryptor.cc ('k') | media/cdm/ppapi/cdm_adapter.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 expected_result), 275 expected_result),
276 base::Bind(&AesDecryptorTest::OnReject, 276 base::Bind(&AesDecryptorTest::OnReject,
277 base::Unretained(this), 277 base::Unretained(this),
278 expected_result))); 278 expected_result)));
279 return promise.Pass(); 279 return promise.Pass();
280 } 280 }
281 281
282 // Creates a new session using |key_id|. Returns the session ID. 282 // Creates a new session using |key_id|. Returns the session ID.
283 std::string CreateSession(const std::vector<uint8>& key_id) { 283 std::string CreateSession(const std::vector<uint8>& key_id) {
284 DCHECK(!key_id.empty()); 284 DCHECK(!key_id.empty());
285 EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsJSONDictionary())); 285 EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsJSONDictionary(),
286 GURL::EmptyGURL()));
286 decryptor_.CreateSessionAndGenerateRequest( 287 decryptor_.CreateSessionAndGenerateRequest(
287 MediaKeys::TEMPORARY_SESSION, std::string(), &key_id[0], key_id.size(), 288 MediaKeys::TEMPORARY_SESSION, std::string(), &key_id[0], key_id.size(),
288 CreateSessionPromise(RESOLVED)); 289 CreateSessionPromise(RESOLVED));
289 // This expects the promise to be called synchronously, which is the case 290 // This expects the promise to be called synchronously, which is the case
290 // for AesDecryptor. 291 // for AesDecryptor.
291 return web_session_id_; 292 return web_session_id_;
292 } 293 }
293 294
294 // Closes the session specified by |session_id|. 295 // Closes the session specified by |session_id|.
295 void CloseSession(const std::string& session_id) { 296 void CloseSession(const std::string& session_id) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 case DATA_AND_SIZE_MISMATCH: 397 case DATA_AND_SIZE_MISMATCH:
397 EXPECT_NE(plain_text.size(), decrypted_text.size()); 398 EXPECT_NE(plain_text.size(), decrypted_text.size());
398 break; 399 break;
399 case DECRYPT_ERROR: 400 case DECRYPT_ERROR:
400 case NO_KEY: 401 case NO_KEY:
401 EXPECT_TRUE(decrypted_text.empty()); 402 EXPECT_TRUE(decrypted_text.empty());
402 break; 403 break;
403 } 404 }
404 } 405 }
405 406
406 MOCK_METHOD3(OnSessionMessage, 407 MOCK_METHOD4(OnSessionMessage,
407 void(const std::string& web_session_id, 408 void(const std::string& web_session_id,
408 MediaKeys::MessageType message_type, 409 MediaKeys::MessageType message_type,
409 const std::vector<uint8>& message)); 410 const std::vector<uint8>& message,
411 const GURL& legacy_destination_url));
410 MOCK_METHOD1(OnSessionClosed, void(const std::string& web_session_id)); 412 MOCK_METHOD1(OnSessionClosed, void(const std::string& web_session_id));
411 413
412 AesDecryptor decryptor_; 414 AesDecryptor decryptor_;
413 AesDecryptor::DecryptCB decrypt_cb_; 415 AesDecryptor::DecryptCB decrypt_cb_;
414 std::string web_session_id_; 416 std::string web_session_id_;
415 CdmKeysInfo keys_info_; 417 CdmKeysInfo keys_info_;
416 418
417 // Constants for testing. 419 // Constants for testing.
418 const std::vector<uint8> original_data_; 420 const std::vector<uint8> original_data_;
419 const std::vector<uint8> encrypted_data_; 421 const std::vector<uint8> encrypted_data_;
420 const std::vector<uint8> subsample_encrypted_data_; 422 const std::vector<uint8> subsample_encrypted_data_;
421 const std::vector<uint8> key_id_; 423 const std::vector<uint8> key_id_;
422 const std::vector<uint8> iv_; 424 const std::vector<uint8> iv_;
423 const std::vector<SubsampleEntry> normal_subsample_entries_; 425 const std::vector<SubsampleEntry> normal_subsample_entries_;
424 const std::vector<SubsampleEntry> no_subsample_entries_; 426 const std::vector<SubsampleEntry> no_subsample_entries_;
425 }; 427 };
426 428
427 TEST_F(AesDecryptorTest, CreateSessionWithNullInitData) { 429 TEST_F(AesDecryptorTest, CreateSessionWithNullInitData) {
428 EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsEmpty())); 430 EXPECT_CALL(*this,
431 OnSessionMessage(IsNotEmpty(), _, IsEmpty(), GURL::EmptyGURL()));
429 decryptor_.CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION, 432 decryptor_.CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION,
430 std::string(), NULL, 0, 433 std::string(), NULL, 0,
431 CreateSessionPromise(RESOLVED)); 434 CreateSessionPromise(RESOLVED));
432 } 435 }
433 436
434 TEST_F(AesDecryptorTest, MultipleCreateSession) { 437 TEST_F(AesDecryptorTest, MultipleCreateSession) {
435 EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsEmpty())); 438 EXPECT_CALL(*this,
439 OnSessionMessage(IsNotEmpty(), _, IsEmpty(), GURL::EmptyGURL()));
436 decryptor_.CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION, 440 decryptor_.CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION,
437 std::string(), NULL, 0, 441 std::string(), NULL, 0,
438 CreateSessionPromise(RESOLVED)); 442 CreateSessionPromise(RESOLVED));
439 443
440 EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsEmpty())); 444 EXPECT_CALL(*this,
445 OnSessionMessage(IsNotEmpty(), _, IsEmpty(), GURL::EmptyGURL()));
441 decryptor_.CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION, 446 decryptor_.CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION,
442 std::string(), NULL, 0, 447 std::string(), NULL, 0,
443 CreateSessionPromise(RESOLVED)); 448 CreateSessionPromise(RESOLVED));
444 449
445 EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsEmpty())); 450 EXPECT_CALL(*this,
451 OnSessionMessage(IsNotEmpty(), _, IsEmpty(), GURL::EmptyGURL()));
446 decryptor_.CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION, 452 decryptor_.CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION,
447 std::string(), NULL, 0, 453 std::string(), NULL, 0,
448 CreateSessionPromise(RESOLVED)); 454 CreateSessionPromise(RESOLVED));
449 } 455 }
450 456
451 TEST_F(AesDecryptorTest, NormalDecryption) { 457 TEST_F(AesDecryptorTest, NormalDecryption) {
452 std::string session_id = CreateSession(key_id_); 458 std::string session_id = CreateSession(key_id_);
453 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED); 459 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED);
454 scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer( 460 scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer(
455 encrypted_data_, key_id_, iv_, no_subsample_entries_); 461 encrypted_data_, key_id_, iv_, no_subsample_entries_);
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 EXPECT_TRUE(KeysInfoContains(key_id1)); 871 EXPECT_TRUE(KeysInfoContains(key_id1));
866 EXPECT_FALSE(KeysInfoContains(key_id2)); 872 EXPECT_FALSE(KeysInfoContains(key_id2));
867 873
868 // Add second key, verify both IDs returned. 874 // Add second key, verify both IDs returned.
869 UpdateSessionAndExpect(session_id, kKey2AsJWK, RESOLVED); 875 UpdateSessionAndExpect(session_id, kKey2AsJWK, RESOLVED);
870 EXPECT_TRUE(KeysInfoContains(key_id1)); 876 EXPECT_TRUE(KeysInfoContains(key_id1));
871 EXPECT_TRUE(KeysInfoContains(key_id2)); 877 EXPECT_TRUE(KeysInfoContains(key_id2));
872 } 878 }
873 879
874 } // namespace media 880 } // namespace media
OLDNEW
« no previous file with comments | « media/cdm/aes_decryptor.cc ('k') | media/cdm/ppapi/cdm_adapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698