OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/cdm_adapter.h" | 5 #include "media/cdm/cdm_adapter.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "media/base/cdm_callback_promise.h" | 14 #include "media/base/cdm_callback_promise.h" |
15 #include "media/base/cdm_key_information.h" | 15 #include "media/base/cdm_key_information.h" |
16 #include "media/base/content_decryption_module.h" | 16 #include "media/base/content_decryption_module.h" |
17 #include "media/base/mock_filters.h" | 17 #include "media/base/mock_filters.h" |
18 #include "media/cdm/cdm_file_io.h" | 18 #include "media/cdm/cdm_file_io.h" |
19 #include "media/cdm/external_clear_key_test_helper.h" | 19 #include "media/cdm/external_clear_key_test_helper.h" |
20 #include "media/cdm/simple_cdm_allocator.h" | 20 #include "media/cdm/simple_cdm_allocator.h" |
| 21 #include "media/media_features.h" |
21 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
23 | 24 |
24 using ::testing::_; | 25 using ::testing::_; |
25 using ::testing::SaveArg; | 26 using ::testing::SaveArg; |
26 using ::testing::StrictMock; | 27 using ::testing::StrictMock; |
27 | 28 |
28 MATCHER(IsNotEmpty, "") { | 29 MATCHER(IsNotEmpty, "") { |
29 return !arg.empty(); | 30 return !arg.empty(); |
30 } | 31 } |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 std::vector<uint8_t> key_id(kKeyIdAsJWK, | 262 std::vector<uint8_t> key_id(kKeyIdAsJWK, |
262 kKeyIdAsJWK + arraysize(kKeyIdAsJWK) - 1); | 263 kKeyIdAsJWK + arraysize(kKeyIdAsJWK) - 1); |
263 CreateSessionAndExpect(EmeInitDataType::KEYIDS, key_id, SUCCESS); | 264 CreateSessionAndExpect(EmeInitDataType::KEYIDS, key_id, SUCCESS); |
264 } | 265 } |
265 | 266 |
266 TEST_F(CdmAdapterTest, CreateCencSession) { | 267 TEST_F(CdmAdapterTest, CreateCencSession) { |
267 InitializeAndExpect(ExternalClearKeyLibrary(), SUCCESS); | 268 InitializeAndExpect(ExternalClearKeyLibrary(), SUCCESS); |
268 | 269 |
269 std::vector<uint8_t> key_id(kKeyIdAsPssh, | 270 std::vector<uint8_t> key_id(kKeyIdAsPssh, |
270 kKeyIdAsPssh + arraysize(kKeyIdAsPssh)); | 271 kKeyIdAsPssh + arraysize(kKeyIdAsPssh)); |
271 #if defined(USE_PROPRIETARY_CODECS) | 272 #if BUILDFLAG(USE_PROPRIETARY_CODECS) |
272 CreateSessionAndExpect(EmeInitDataType::CENC, key_id, SUCCESS); | 273 CreateSessionAndExpect(EmeInitDataType::CENC, key_id, SUCCESS); |
273 #else | 274 #else |
274 CreateSessionAndExpect(EmeInitDataType::CENC, key_id, FAILURE); | 275 CreateSessionAndExpect(EmeInitDataType::CENC, key_id, FAILURE); |
275 #endif | 276 #endif |
276 } | 277 } |
277 | 278 |
278 TEST_F(CdmAdapterTest, CreateSessionWithBadData) { | 279 TEST_F(CdmAdapterTest, CreateSessionWithBadData) { |
279 InitializeAndExpect(ExternalClearKeyLibrary(), SUCCESS); | 280 InitializeAndExpect(ExternalClearKeyLibrary(), SUCCESS); |
280 | 281 |
281 // Use |kKeyId| but specify KEYIDS format. | 282 // Use |kKeyId| but specify KEYIDS format. |
(...skipping 21 matching lines...) Expand all Loading... |
303 TEST_F(CdmAdapterTest, UpdateSessionWithBadData) { | 304 TEST_F(CdmAdapterTest, UpdateSessionWithBadData) { |
304 InitializeAndExpect(ExternalClearKeyLibrary(), SUCCESS); | 305 InitializeAndExpect(ExternalClearKeyLibrary(), SUCCESS); |
305 | 306 |
306 std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId)); | 307 std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId)); |
307 CreateSessionAndExpect(EmeInitDataType::WEBM, key_id, SUCCESS); | 308 CreateSessionAndExpect(EmeInitDataType::WEBM, key_id, SUCCESS); |
308 | 309 |
309 UpdateSessionAndExpect(SessionId(), "random data", FAILURE, true); | 310 UpdateSessionAndExpect(SessionId(), "random data", FAILURE, true); |
310 } | 311 } |
311 | 312 |
312 } // namespace media | 313 } // namespace media |
OLD | NEW |