Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "media/cdm/aes_decryptor.h" | 5 #include "media/cdm/aes_decryptor.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 #include "testing/gmock/include/gmock/gmock.h" | 31 #include "testing/gmock/include/gmock/gmock.h" |
| 32 #include "testing/gtest/include/gtest/gtest-param-test.h" | 32 #include "testing/gtest/include/gtest/gtest-param-test.h" |
| 33 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
| 34 #include "url/gurl.h" | 34 #include "url/gurl.h" |
| 35 | 35 |
| 36 using ::testing::_; | 36 using ::testing::_; |
| 37 using ::testing::Gt; | 37 using ::testing::Gt; |
| 38 using ::testing::IsNull; | 38 using ::testing::IsNull; |
| 39 using ::testing::NotNull; | 39 using ::testing::NotNull; |
| 40 using ::testing::SaveArg; | 40 using ::testing::SaveArg; |
| 41 using ::testing::StrictMock; | |
| 41 using ::testing::StrNe; | 42 using ::testing::StrNe; |
| 42 using ::testing::Unused; | 43 using ::testing::Unused; |
| 43 | 44 |
| 44 MATCHER(IsEmpty, "") { return arg.empty(); } | 45 MATCHER(IsEmpty, "") { return arg.empty(); } |
| 45 MATCHER(IsNotEmpty, "") { return !arg.empty(); } | 46 MATCHER(NotEmpty, "") { |
|
xhwang
2016/12/06 20:51:49
IsEmpty/NotEmpty is consistent with IsNull/NotNull
| |
| 47 return !arg.empty(); | |
| 48 } | |
| 46 MATCHER(IsJSONDictionary, "") { | 49 MATCHER(IsJSONDictionary, "") { |
| 47 std::string result(arg.begin(), arg.end()); | 50 std::string result(arg.begin(), arg.end()); |
| 48 std::unique_ptr<base::Value> root(base::JSONReader().ReadToValue(result)); | 51 std::unique_ptr<base::Value> root(base::JSONReader().ReadToValue(result)); |
| 49 return (root.get() && root->GetType() == base::Value::TYPE_DICTIONARY); | 52 return (root.get() && root->GetType() == base::Value::TYPE_DICTIONARY); |
| 50 } | 53 } |
| 51 | 54 |
| 52 namespace media { | 55 namespace media { |
| 53 | 56 |
| 54 const uint8_t kOriginalData[] = "Original subsample data."; | 57 const uint8_t kOriginalData[] = "Original subsample data."; |
| 55 const int kOriginalDataSize = 24; | 58 const int kOriginalDataSize = 24; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 iv_(kIv, kIv + arraysize(kIv)), | 234 iv_(kIv, kIv + arraysize(kIv)), |
| 232 normal_subsample_entries_( | 235 normal_subsample_entries_( |
| 233 kSubsampleEntriesNormal, | 236 kSubsampleEntriesNormal, |
| 234 kSubsampleEntriesNormal + arraysize(kSubsampleEntriesNormal)) {} | 237 kSubsampleEntriesNormal + arraysize(kSubsampleEntriesNormal)) {} |
| 235 | 238 |
| 236 protected: | 239 protected: |
| 237 void SetUp() override { | 240 void SetUp() override { |
| 238 if (GetParam() == "AesDecryptor") { | 241 if (GetParam() == "AesDecryptor") { |
| 239 OnCdmCreated( | 242 OnCdmCreated( |
| 240 new AesDecryptor(GURL::EmptyGURL(), | 243 new AesDecryptor(GURL::EmptyGURL(), |
| 241 base::Bind(&AesDecryptorTest::OnSessionMessage, | 244 base::Bind(&MockCdmClient::OnSessionMessage, |
| 242 base::Unretained(this)), | 245 base::Unretained(&cdm_client_)), |
| 243 base::Bind(&AesDecryptorTest::OnSessionClosed, | 246 base::Bind(&MockCdmClient::OnSessionClosed, |
| 244 base::Unretained(this)), | 247 base::Unretained(&cdm_client_)), |
| 245 base::Bind(&AesDecryptorTest::OnSessionKeysChange, | 248 base::Bind(&MockCdmClient::OnSessionKeysChange, |
| 246 base::Unretained(this))), | 249 base::Unretained(&cdm_client_))), |
| 247 std::string()); | 250 std::string()); |
| 248 } else if (GetParam() == "CdmAdapter") { | 251 } else if (GetParam() == "CdmAdapter") { |
| 249 CdmConfig cdm_config; // default settings of false are sufficient. | 252 CdmConfig cdm_config; // default settings of false are sufficient. |
| 250 | 253 |
| 251 helper_.reset(new ExternalClearKeyTestHelper()); | 254 helper_.reset(new ExternalClearKeyTestHelper()); |
| 252 std::unique_ptr<CdmAllocator> allocator(new SimpleCdmAllocator()); | 255 std::unique_ptr<CdmAllocator> allocator(new SimpleCdmAllocator()); |
| 253 CdmAdapter::Create( | 256 CdmAdapter::Create( |
| 254 helper_->KeySystemName(), helper_->LibraryPath(), cdm_config, | 257 helper_->KeySystemName(), helper_->LibraryPath(), cdm_config, |
| 255 std::move(allocator), base::Bind(&AesDecryptorTest::CreateCdmFileIO, | 258 std::move(allocator), base::Bind(&AesDecryptorTest::CreateCdmFileIO, |
| 256 base::Unretained(this)), | 259 base::Unretained(this)), |
| 257 base::Bind(&AesDecryptorTest::OnSessionMessage, | 260 base::Bind(&MockCdmClient::OnSessionMessage, |
| 258 base::Unretained(this)), | 261 base::Unretained(&cdm_client_)), |
| 259 base::Bind(&AesDecryptorTest::OnSessionClosed, | 262 base::Bind(&MockCdmClient::OnSessionClosed, |
| 260 base::Unretained(this)), | 263 base::Unretained(&cdm_client_)), |
| 261 base::Bind(&AesDecryptorTest::OnSessionKeysChange, | 264 base::Bind(&MockCdmClient::OnSessionKeysChange, |
| 262 base::Unretained(this)), | 265 base::Unretained(&cdm_client_)), |
| 263 base::Bind(&AesDecryptorTest::OnSessionExpirationUpdate, | 266 base::Bind(&MockCdmClient::OnSessionExpirationUpdate, |
| 264 base::Unretained(this)), | 267 base::Unretained(&cdm_client_)), |
| 265 base::Bind(&AesDecryptorTest::OnCdmCreated, base::Unretained(this))); | 268 base::Bind(&AesDecryptorTest::OnCdmCreated, base::Unretained(this))); |
| 266 | 269 |
| 267 base::RunLoop().RunUntilIdle(); | 270 base::RunLoop().RunUntilIdle(); |
| 268 } | 271 } |
| 269 } | 272 } |
| 270 | 273 |
| 271 void TearDown() override { | 274 void TearDown() override { |
| 272 if (GetParam() == "CdmAdapter") | 275 if (GetParam() == "CdmAdapter") |
| 273 helper_.reset(); | 276 helper_.reset(); |
| 274 } | 277 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 base::Bind(&AesDecryptorTest::OnResolveWithSession, | 319 base::Bind(&AesDecryptorTest::OnResolveWithSession, |
| 317 base::Unretained(this), expected_result), | 320 base::Unretained(this), expected_result), |
| 318 base::Bind(&AesDecryptorTest::OnReject, base::Unretained(this), | 321 base::Bind(&AesDecryptorTest::OnReject, base::Unretained(this), |
| 319 expected_result))); | 322 expected_result))); |
| 320 return promise; | 323 return promise; |
| 321 } | 324 } |
| 322 | 325 |
| 323 // Creates a new session using |key_id|. Returns the session ID. | 326 // Creates a new session using |key_id|. Returns the session ID. |
| 324 std::string CreateSession(const std::vector<uint8_t>& key_id) { | 327 std::string CreateSession(const std::vector<uint8_t>& key_id) { |
| 325 DCHECK(!key_id.empty()); | 328 DCHECK(!key_id.empty()); |
| 326 EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsJSONDictionary())); | 329 EXPECT_CALL(cdm_client_, |
| 330 OnSessionMessage(NotEmpty(), _, IsJSONDictionary())); | |
| 327 cdm_->CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION, | 331 cdm_->CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION, |
| 328 EmeInitDataType::WEBM, key_id, | 332 EmeInitDataType::WEBM, key_id, |
| 329 CreateSessionPromise(RESOLVED)); | 333 CreateSessionPromise(RESOLVED)); |
| 330 // This expects the promise to be called synchronously, which is the case | 334 // This expects the promise to be called synchronously, which is the case |
| 331 // for AesDecryptor. | 335 // for AesDecryptor. |
| 332 return session_id_; | 336 return session_id_; |
| 333 } | 337 } |
| 334 | 338 |
| 335 // Closes the session specified by |session_id|. | 339 // Closes the session specified by |session_id|. |
| 336 void CloseSession(const std::string& session_id) { | 340 void CloseSession(const std::string& session_id) { |
| 337 EXPECT_CALL(*this, OnSessionClosed(session_id)); | 341 EXPECT_CALL(cdm_client_, OnSessionClosed(session_id)); |
| 338 cdm_->CloseSession(session_id, CreatePromise(RESOLVED)); | 342 cdm_->CloseSession(session_id, CreatePromise(RESOLVED)); |
| 339 } | 343 } |
| 340 | 344 |
| 341 // Only persistent sessions can be removed. | 345 // Only persistent sessions can be removed. |
| 342 void RemoveSession(const std::string& session_id) { | 346 void RemoveSession(const std::string& session_id) { |
| 343 // TODO(ddorwin): This should be RESOLVED after https://crbug.com/616166. | 347 // TODO(ddorwin): This should be RESOLVED after https://crbug.com/616166. |
| 344 cdm_->RemoveSession(session_id, CreatePromise(REJECTED)); | 348 cdm_->RemoveSession(session_id, CreatePromise(REJECTED)); |
| 345 } | 349 } |
| 346 | 350 |
| 347 MOCK_METHOD2(OnSessionKeysChangeCalled, | |
| 348 void(const std::string& session_id, | |
| 349 bool has_additional_usable_key)); | |
| 350 | |
| 351 void OnSessionKeysChange(const std::string& session_id, | |
| 352 bool has_additional_usable_key, | |
| 353 CdmKeysInfo keys_info) { | |
| 354 keys_info_.swap(keys_info); | |
| 355 OnSessionKeysChangeCalled(session_id, has_additional_usable_key); | |
| 356 } | |
| 357 | |
| 358 // Updates the session specified by |session_id| with |key|. |result| | 351 // Updates the session specified by |session_id| with |key|. |result| |
| 359 // tests that the update succeeds or generates an error. | 352 // tests that the update succeeds or generates an error. |
| 360 void UpdateSessionAndExpect(std::string session_id, | 353 void UpdateSessionAndExpect(std::string session_id, |
| 361 const std::string& key, | 354 const std::string& key, |
| 362 ExpectedResult expected_result, | 355 ExpectedResult expected_result, |
| 363 bool new_key_expected) { | 356 bool new_key_expected) { |
| 364 DCHECK(!key.empty()); | 357 DCHECK(!key.empty()); |
| 365 | 358 |
| 366 if (expected_result == RESOLVED) { | 359 if (expected_result == RESOLVED) { |
| 367 EXPECT_CALL(*this, | 360 EXPECT_CALL(cdm_client_, |
| 368 OnSessionKeysChangeCalled(session_id, new_key_expected)); | 361 OnSessionKeysChangeCalled(session_id, new_key_expected)); |
| 369 } else { | 362 } else { |
| 370 EXPECT_CALL(*this, OnSessionKeysChangeCalled(_, _)).Times(0); | 363 EXPECT_CALL(cdm_client_, OnSessionKeysChangeCalled(_, _)).Times(0); |
| 371 } | 364 } |
| 372 | 365 |
| 373 cdm_->UpdateSession(session_id, | 366 cdm_->UpdateSession(session_id, |
| 374 std::vector<uint8_t>(key.begin(), key.end()), | 367 std::vector<uint8_t>(key.begin(), key.end()), |
| 375 CreatePromise(expected_result)); | 368 CreatePromise(expected_result)); |
| 376 } | 369 } |
| 377 | 370 |
| 378 bool KeysInfoContains(std::vector<uint8_t> expected) { | 371 bool KeysInfoContains(const std::vector<uint8_t>& expected) { |
| 379 for (auto* key_id : keys_info_) { | 372 for (auto* key_id : cdm_client_.keys_info()) { |
| 380 if (key_id->key_id == expected) | 373 if (key_id->key_id == expected) |
| 381 return true; | 374 return true; |
| 382 } | 375 } |
| 383 return false; | 376 return false; |
| 384 } | 377 } |
| 385 | 378 |
| 386 MOCK_METHOD2(BufferDecrypted, void(Decryptor::Status, | 379 MOCK_METHOD2(BufferDecrypted, void(Decryptor::Status, |
| 387 const scoped_refptr<DecoderBuffer>&)); | 380 const scoped_refptr<DecoderBuffer>&)); |
| 388 | 381 |
| 389 enum DecryptExpectation { | 382 enum DecryptExpectation { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 445 EXPECT_TRUE(decrypted_text.empty()); | 438 EXPECT_TRUE(decrypted_text.empty()); |
| 446 break; | 439 break; |
| 447 } | 440 } |
| 448 } | 441 } |
| 449 | 442 |
| 450 std::unique_ptr<CdmFileIO> CreateCdmFileIO(cdm::FileIOClient* client) { | 443 std::unique_ptr<CdmFileIO> CreateCdmFileIO(cdm::FileIOClient* client) { |
| 451 ADD_FAILURE() << "Should never be called"; | 444 ADD_FAILURE() << "Should never be called"; |
| 452 return nullptr; | 445 return nullptr; |
| 453 } | 446 } |
| 454 | 447 |
| 455 MOCK_METHOD3(OnSessionMessage, | 448 StrictMock<MockCdmClient> cdm_client_; |
| 456 void(const std::string& session_id, | |
| 457 MediaKeys::MessageType message_type, | |
| 458 const std::vector<uint8_t>& message)); | |
| 459 MOCK_METHOD1(OnSessionClosed, void(const std::string& session_id)); | |
| 460 MOCK_METHOD2(OnSessionExpirationUpdate, | |
| 461 void(const std::string& session_id, base::Time new_expiry_time)); | |
| 462 | |
| 463 scoped_refptr<MediaKeys> cdm_; | 449 scoped_refptr<MediaKeys> cdm_; |
| 464 Decryptor* decryptor_; | 450 Decryptor* decryptor_; |
| 465 Decryptor::DecryptCB decrypt_cb_; | 451 Decryptor::DecryptCB decrypt_cb_; |
| 466 std::string session_id_; | 452 std::string session_id_; |
| 467 CdmKeysInfo keys_info_; | |
| 468 | 453 |
| 469 // Helper class to load/unload External Clear Key Library, if necessary. | 454 // Helper class to load/unload External Clear Key Library, if necessary. |
| 470 std::unique_ptr<ExternalClearKeyTestHelper> helper_; | 455 std::unique_ptr<ExternalClearKeyTestHelper> helper_; |
| 471 | 456 |
| 472 base::MessageLoop message_loop_; | 457 base::MessageLoop message_loop_; |
| 473 | 458 |
| 474 // Constants for testing. | 459 // Constants for testing. |
| 475 const std::vector<uint8_t> original_data_; | 460 const std::vector<uint8_t> original_data_; |
| 476 const std::vector<uint8_t> encrypted_data_; | 461 const std::vector<uint8_t> encrypted_data_; |
| 477 const std::vector<uint8_t> subsample_encrypted_data_; | 462 const std::vector<uint8_t> subsample_encrypted_data_; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 489 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::CENC, | 474 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::CENC, |
| 490 std::vector<uint8_t>(), CreateSessionPromise(REJECTED)); | 475 std::vector<uint8_t>(), CreateSessionPromise(REJECTED)); |
| 491 cdm_->CreateSessionAndGenerateRequest( | 476 cdm_->CreateSessionAndGenerateRequest( |
| 492 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::KEYIDS, | 477 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::KEYIDS, |
| 493 std::vector<uint8_t>(), CreateSessionPromise(REJECTED)); | 478 std::vector<uint8_t>(), CreateSessionPromise(REJECTED)); |
| 494 } | 479 } |
| 495 | 480 |
| 496 TEST_P(AesDecryptorTest, CreateSessionWithVariousLengthInitData_WebM) { | 481 TEST_P(AesDecryptorTest, CreateSessionWithVariousLengthInitData_WebM) { |
| 497 std::vector<uint8_t> init_data; | 482 std::vector<uint8_t> init_data; |
| 498 init_data.resize(1); | 483 init_data.resize(1); |
| 484 EXPECT_CALL(cdm_client_, OnSessionMessage(NotEmpty(), _, IsJSONDictionary())); | |
| 499 cdm_->CreateSessionAndGenerateRequest( | 485 cdm_->CreateSessionAndGenerateRequest( |
| 500 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, | 486 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, |
| 501 std::vector<uint8_t>(init_data), CreateSessionPromise(RESOLVED)); | 487 std::vector<uint8_t>(init_data), CreateSessionPromise(RESOLVED)); |
| 502 | 488 |
| 503 init_data.resize(16); // The expected size. | 489 init_data.resize(16); // The expected size. |
| 490 EXPECT_CALL(cdm_client_, OnSessionMessage(NotEmpty(), _, IsJSONDictionary())); | |
| 504 cdm_->CreateSessionAndGenerateRequest( | 491 cdm_->CreateSessionAndGenerateRequest( |
| 505 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, | 492 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, |
| 506 std::vector<uint8_t>(init_data), CreateSessionPromise(RESOLVED)); | 493 std::vector<uint8_t>(init_data), CreateSessionPromise(RESOLVED)); |
| 507 | 494 |
| 508 init_data.resize(512); | 495 init_data.resize(512); |
| 496 EXPECT_CALL(cdm_client_, OnSessionMessage(NotEmpty(), _, IsJSONDictionary())); | |
| 509 cdm_->CreateSessionAndGenerateRequest( | 497 cdm_->CreateSessionAndGenerateRequest( |
| 510 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, | 498 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, |
| 511 std::vector<uint8_t>(init_data), CreateSessionPromise(RESOLVED)); | 499 std::vector<uint8_t>(init_data), CreateSessionPromise(RESOLVED)); |
| 512 | 500 |
| 513 init_data.resize(513); | 501 init_data.resize(513); |
| 514 cdm_->CreateSessionAndGenerateRequest( | 502 cdm_->CreateSessionAndGenerateRequest( |
| 515 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, | 503 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, |
| 516 std::vector<uint8_t>(init_data), CreateSessionPromise(REJECTED)); | 504 std::vector<uint8_t>(init_data), CreateSessionPromise(REJECTED)); |
| 517 } | 505 } |
| 518 | 506 |
| 519 TEST_P(AesDecryptorTest, MultipleCreateSession) { | 507 TEST_P(AesDecryptorTest, MultipleCreateSession) { |
| 520 EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsNotEmpty())); | 508 EXPECT_CALL(cdm_client_, OnSessionMessage(NotEmpty(), _, IsJSONDictionary())); |
| 521 cdm_->CreateSessionAndGenerateRequest( | 509 cdm_->CreateSessionAndGenerateRequest( |
| 522 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, | 510 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, |
| 523 std::vector<uint8_t>(1), CreateSessionPromise(RESOLVED)); | 511 std::vector<uint8_t>(1), CreateSessionPromise(RESOLVED)); |
| 524 | 512 |
| 525 EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsNotEmpty())); | 513 EXPECT_CALL(cdm_client_, OnSessionMessage(NotEmpty(), _, IsJSONDictionary())); |
| 526 cdm_->CreateSessionAndGenerateRequest( | 514 cdm_->CreateSessionAndGenerateRequest( |
| 527 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, | 515 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, |
| 528 std::vector<uint8_t>(1), CreateSessionPromise(RESOLVED)); | 516 std::vector<uint8_t>(1), CreateSessionPromise(RESOLVED)); |
| 529 | 517 |
| 530 EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsNotEmpty())); | 518 EXPECT_CALL(cdm_client_, OnSessionMessage(NotEmpty(), _, IsJSONDictionary())); |
| 531 cdm_->CreateSessionAndGenerateRequest( | 519 cdm_->CreateSessionAndGenerateRequest( |
| 532 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, | 520 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, |
| 533 std::vector<uint8_t>(1), CreateSessionPromise(RESOLVED)); | 521 std::vector<uint8_t>(1), CreateSessionPromise(RESOLVED)); |
| 534 } | 522 } |
| 535 | 523 |
| 536 TEST_P(AesDecryptorTest, CreateSessionWithCencInitData) { | 524 TEST_P(AesDecryptorTest, CreateSessionWithCencInitData) { |
| 537 const uint8_t init_data[] = { | 525 const uint8_t init_data[] = { |
| 538 0x00, 0x00, 0x00, 0x44, // size = 68 | 526 0x00, 0x00, 0x00, 0x44, // size = 68 |
| 539 0x70, 0x73, 0x73, 0x68, // 'pssh' | 527 0x70, 0x73, 0x73, 0x68, // 'pssh' |
| 540 0x01, // version | 528 0x01, // version |
| 541 0x00, 0x00, 0x00, // flags | 529 0x00, 0x00, 0x00, // flags |
| 542 0x10, 0x77, 0xEF, 0xEC, 0xC0, 0xB2, 0x4D, 0x02, // SystemID | 530 0x10, 0x77, 0xEF, 0xEC, 0xC0, 0xB2, 0x4D, 0x02, // SystemID |
| 543 0xAC, 0xE3, 0x3C, 0x1E, 0x52, 0xE2, 0xFB, 0x4B, | 531 0xAC, 0xE3, 0x3C, 0x1E, 0x52, 0xE2, 0xFB, 0x4B, |
| 544 0x00, 0x00, 0x00, 0x02, // key count | 532 0x00, 0x00, 0x00, 0x02, // key count |
| 545 0x7E, 0x57, 0x1D, 0x03, 0x7E, 0x57, 0x1D, 0x03, // key1 | 533 0x7E, 0x57, 0x1D, 0x03, 0x7E, 0x57, 0x1D, 0x03, // key1 |
| 546 0x7E, 0x57, 0x1D, 0x03, 0x7E, 0x57, 0x1D, 0x03, | 534 0x7E, 0x57, 0x1D, 0x03, 0x7E, 0x57, 0x1D, 0x03, |
| 547 0x7E, 0x57, 0x1D, 0x04, 0x7E, 0x57, 0x1D, 0x04, // key2 | 535 0x7E, 0x57, 0x1D, 0x04, 0x7E, 0x57, 0x1D, 0x04, // key2 |
| 548 0x7E, 0x57, 0x1D, 0x04, 0x7E, 0x57, 0x1D, 0x04, | 536 0x7E, 0x57, 0x1D, 0x04, 0x7E, 0x57, 0x1D, 0x04, |
| 549 0x00, 0x00, 0x00, 0x00 // datasize | 537 0x00, 0x00, 0x00, 0x00 // datasize |
| 550 }; | 538 }; |
| 551 | 539 |
| 552 #if defined(USE_PROPRIETARY_CODECS) | 540 #if defined(USE_PROPRIETARY_CODECS) |
| 553 EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsJSONDictionary())); | 541 EXPECT_CALL(cdm_client_, OnSessionMessage(NotEmpty(), _, IsJSONDictionary())); |
| 554 cdm_->CreateSessionAndGenerateRequest( | 542 cdm_->CreateSessionAndGenerateRequest( |
| 555 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::CENC, | 543 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::CENC, |
| 556 std::vector<uint8_t>(init_data, init_data + arraysize(init_data)), | 544 std::vector<uint8_t>(init_data, init_data + arraysize(init_data)), |
| 557 CreateSessionPromise(RESOLVED)); | 545 CreateSessionPromise(RESOLVED)); |
| 558 #else | 546 #else |
| 559 cdm_->CreateSessionAndGenerateRequest( | 547 cdm_->CreateSessionAndGenerateRequest( |
| 560 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::CENC, | 548 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::CENC, |
| 561 std::vector<uint8_t>(init_data, init_data + arraysize(init_data)), | 549 std::vector<uint8_t>(init_data, init_data + arraysize(init_data)), |
| 562 CreateSessionPromise(REJECTED)); | 550 CreateSessionPromise(REJECTED)); |
| 563 #endif | 551 #endif |
| 564 } | 552 } |
| 565 | 553 |
| 566 TEST_P(AesDecryptorTest, CreateSessionWithKeyIdsInitData) { | 554 TEST_P(AesDecryptorTest, CreateSessionWithKeyIdsInitData) { |
| 567 const char init_data[] = | 555 const char init_data[] = |
| 568 "{\"kids\":[\"AQI\",\"AQIDBA\",\"AQIDBAUGBwgJCgsMDQ4PEA\"]}"; | 556 "{\"kids\":[\"AQI\",\"AQIDBA\",\"AQIDBAUGBwgJCgsMDQ4PEA\"]}"; |
| 569 | 557 |
| 570 EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsJSONDictionary())); | 558 EXPECT_CALL(cdm_client_, OnSessionMessage(NotEmpty(), _, IsJSONDictionary())); |
| 571 cdm_->CreateSessionAndGenerateRequest( | 559 cdm_->CreateSessionAndGenerateRequest( |
| 572 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::KEYIDS, | 560 MediaKeys::TEMPORARY_SESSION, EmeInitDataType::KEYIDS, |
| 573 std::vector<uint8_t>(init_data, init_data + arraysize(init_data) - 1), | 561 std::vector<uint8_t>(init_data, init_data + arraysize(init_data) - 1), |
| 574 CreateSessionPromise(RESOLVED)); | 562 CreateSessionPromise(RESOLVED)); |
| 575 } | 563 } |
| 576 | 564 |
| 577 TEST_P(AesDecryptorTest, NormalDecryption) { | 565 TEST_P(AesDecryptorTest, NormalDecryption) { |
| 578 std::string session_id = CreateSession(key_id_); | 566 std::string session_id = CreateSession(key_id_); |
| 579 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, true); | 567 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, true); |
| 580 scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer( | 568 scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer( |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1024 INSTANTIATE_TEST_CASE_P(CdmAdapter, | 1012 INSTANTIATE_TEST_CASE_P(CdmAdapter, |
| 1025 AesDecryptorTest, | 1013 AesDecryptorTest, |
| 1026 testing::Values("CdmAdapter")); | 1014 testing::Values("CdmAdapter")); |
| 1027 #endif | 1015 #endif |
| 1028 | 1016 |
| 1029 // TODO(jrummell): Once MojoCdm/MojoCdmService/MojoDecryptor/ | 1017 // TODO(jrummell): Once MojoCdm/MojoCdmService/MojoDecryptor/ |
| 1030 // MojoDecryptorService are implemented, add a third version that tests the | 1018 // MojoDecryptorService are implemented, add a third version that tests the |
| 1031 // CDM via mojo. | 1019 // CDM via mojo. |
| 1032 | 1020 |
| 1033 } // namespace media | 1021 } // namespace media |
| OLD | NEW |