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" |
| 6 |
5 #include <stdint.h> | 7 #include <stdint.h> |
6 | 8 #include <memory> |
7 #include <string> | 9 #include <string> |
8 #include <vector> | 10 #include <vector> |
9 | 11 |
10 #include "base/bind.h" | 12 #include "base/bind.h" |
11 #include "base/debug/leak_annotations.h" | 13 #include "base/debug/leak_annotations.h" |
12 #include "base/json/json_reader.h" | 14 #include "base/json/json_reader.h" |
13 #include "base/macros.h" | 15 #include "base/macros.h" |
14 #include "base/values.h" | 16 #include "base/values.h" |
15 #include "media/base/cdm_callback_promise.h" | 17 #include "media/base/cdm_callback_promise.h" |
16 #include "media/base/cdm_config.h" | 18 #include "media/base/cdm_config.h" |
17 #include "media/base/cdm_key_information.h" | 19 #include "media/base/cdm_key_information.h" |
18 #include "media/base/decoder_buffer.h" | 20 #include "media/base/decoder_buffer.h" |
19 #include "media/base/decrypt_config.h" | 21 #include "media/base/decrypt_config.h" |
20 #include "media/base/decryptor.h" | 22 #include "media/base/decryptor.h" |
21 #include "media/base/mock_filters.h" | 23 #include "media/base/mock_filters.h" |
22 #include "media/cdm/aes_decryptor.h" | |
23 #include "media/cdm/api/content_decryption_module.h" | 24 #include "media/cdm/api/content_decryption_module.h" |
24 #include "media/cdm/cdm_adapter.h" | 25 #include "media/cdm/cdm_adapter.h" |
| 26 #include "media/cdm/cdm_file_io.h" |
25 #include "media/cdm/external_clear_key_test_helper.h" | 27 #include "media/cdm/external_clear_key_test_helper.h" |
26 #include "media/cdm/simple_cdm_allocator.h" | 28 #include "media/cdm/simple_cdm_allocator.h" |
27 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
28 #include "testing/gtest/include/gtest/gtest-param-test.h" | 30 #include "testing/gtest/include/gtest/gtest-param-test.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
30 #include "url/gurl.h" | 32 #include "url/gurl.h" |
31 | 33 |
32 using ::testing::_; | 34 using ::testing::_; |
33 using ::testing::Gt; | 35 using ::testing::Gt; |
34 using ::testing::IsNull; | 36 using ::testing::IsNull; |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 base::Bind(&AesDecryptorTest::OnSessionKeysChange, | 243 base::Bind(&AesDecryptorTest::OnSessionKeysChange, |
242 base::Unretained(this))), | 244 base::Unretained(this))), |
243 std::string()); | 245 std::string()); |
244 } else if (GetParam() == "CdmAdapter") { | 246 } else if (GetParam() == "CdmAdapter") { |
245 CdmConfig cdm_config; // default settings of false are sufficient. | 247 CdmConfig cdm_config; // default settings of false are sufficient. |
246 | 248 |
247 helper_.reset(new ExternalClearKeyTestHelper()); | 249 helper_.reset(new ExternalClearKeyTestHelper()); |
248 scoped_ptr<CdmAllocator> allocator(new SimpleCdmAllocator()); | 250 scoped_ptr<CdmAllocator> allocator(new SimpleCdmAllocator()); |
249 CdmAdapter::Create( | 251 CdmAdapter::Create( |
250 helper_->KeySystemName(), helper_->LibraryPath(), cdm_config, | 252 helper_->KeySystemName(), helper_->LibraryPath(), cdm_config, |
251 std::move(allocator), base::Bind(&AesDecryptorTest::OnSessionMessage, | 253 std::move(allocator), base::Bind(&AesDecryptorTest::CreateCdmFileIO, |
252 base::Unretained(this)), | 254 base::Unretained(this)), |
| 255 base::Bind(&AesDecryptorTest::OnSessionMessage, |
| 256 base::Unretained(this)), |
253 base::Bind(&AesDecryptorTest::OnSessionClosed, | 257 base::Bind(&AesDecryptorTest::OnSessionClosed, |
254 base::Unretained(this)), | 258 base::Unretained(this)), |
255 base::Bind(&AesDecryptorTest::OnLegacySessionError, | 259 base::Bind(&AesDecryptorTest::OnLegacySessionError, |
256 base::Unretained(this)), | 260 base::Unretained(this)), |
257 base::Bind(&AesDecryptorTest::OnSessionKeysChange, | 261 base::Bind(&AesDecryptorTest::OnSessionKeysChange, |
258 base::Unretained(this)), | 262 base::Unretained(this)), |
259 base::Bind(&AesDecryptorTest::OnSessionExpirationUpdate, | 263 base::Bind(&AesDecryptorTest::OnSessionExpirationUpdate, |
260 base::Unretained(this)), | 264 base::Unretained(this)), |
261 base::Bind(&AesDecryptorTest::OnCdmCreated, base::Unretained(this))); | 265 base::Bind(&AesDecryptorTest::OnCdmCreated, base::Unretained(this))); |
262 | 266 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 case DATA_AND_SIZE_MISMATCH: | 452 case DATA_AND_SIZE_MISMATCH: |
449 EXPECT_NE(plain_text.size(), decrypted_text.size()); | 453 EXPECT_NE(plain_text.size(), decrypted_text.size()); |
450 break; | 454 break; |
451 case DECRYPT_ERROR: | 455 case DECRYPT_ERROR: |
452 case NO_KEY: | 456 case NO_KEY: |
453 EXPECT_TRUE(decrypted_text.empty()); | 457 EXPECT_TRUE(decrypted_text.empty()); |
454 break; | 458 break; |
455 } | 459 } |
456 } | 460 } |
457 | 461 |
| 462 std::unique_ptr<CdmFileIO> CreateCdmFileIO(cdm::FileIOClient* client) { |
| 463 ADD_FAILURE() << "Should never be called"; |
| 464 return nullptr; |
| 465 } |
| 466 |
458 MOCK_METHOD4(OnSessionMessage, | 467 MOCK_METHOD4(OnSessionMessage, |
459 void(const std::string& session_id, | 468 void(const std::string& session_id, |
460 MediaKeys::MessageType message_type, | 469 MediaKeys::MessageType message_type, |
461 const std::vector<uint8_t>& message, | 470 const std::vector<uint8_t>& message, |
462 const GURL& legacy_destination_url)); | 471 const GURL& legacy_destination_url)); |
463 MOCK_METHOD1(OnSessionClosed, void(const std::string& session_id)); | 472 MOCK_METHOD1(OnSessionClosed, void(const std::string& session_id)); |
464 MOCK_METHOD4(OnLegacySessionError, | 473 MOCK_METHOD4(OnLegacySessionError, |
465 void(const std::string& session_id, | 474 void(const std::string& session_id, |
466 MediaKeys::Exception exception, | 475 MediaKeys::Exception exception, |
467 uint32_t system_code, | 476 uint32_t system_code, |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 INSTANTIATE_TEST_CASE_P(CdmAdapter, | 1023 INSTANTIATE_TEST_CASE_P(CdmAdapter, |
1015 AesDecryptorTest, | 1024 AesDecryptorTest, |
1016 testing::Values("CdmAdapter")); | 1025 testing::Values("CdmAdapter")); |
1017 #endif | 1026 #endif |
1018 | 1027 |
1019 // TODO(jrummell): Once MojoCdm/MojoCdmService/MojoDecryptor/ | 1028 // TODO(jrummell): Once MojoCdm/MojoCdmService/MojoDecryptor/ |
1020 // MojoDecryptorService are implemented, add a third version that tests the | 1029 // MojoDecryptorService are implemented, add a third version that tests the |
1021 // CDM via mojo. | 1030 // CDM via mojo. |
1022 | 1031 |
1023 } // namespace media | 1032 } // namespace media |
OLD | NEW |