| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "media/base/cdm_callback_promise.h" | 12 #include "media/base/cdm_callback_promise.h" |
| 13 #include "media/base/cdm_key_information.h" | 13 #include "media/base/cdm_key_information.h" |
| 14 #include "media/base/media_keys.h" | 14 #include "media/base/media_keys.h" |
| 15 #include "media/cdm/cdm_adapter.h" | 15 #include "media/cdm/cdm_adapter.h" |
| 16 #include "media/cdm/cdm_buffer_allocator_impl.h" |
| 16 #include "media/cdm/external_clear_key_test_helper.h" | 17 #include "media/cdm/external_clear_key_test_helper.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 20 |
| 20 using ::testing::_; | 21 using ::testing::_; |
| 21 using ::testing::SaveArg; | 22 using ::testing::SaveArg; |
| 22 MATCHER(IsNotEmpty, "") { | 23 MATCHER(IsNotEmpty, "") { |
| 23 return !arg.empty(); | 24 return !arg.empty(); |
| 24 } | 25 } |
| 25 | 26 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 helper_.KeySystemName(), library_path, cdm_config, | 86 helper_.KeySystemName(), library_path, cdm_config, |
| 86 base::Bind(&CdmAdapterTest::OnSessionMessage, base::Unretained(this)), | 87 base::Bind(&CdmAdapterTest::OnSessionMessage, base::Unretained(this)), |
| 87 base::Bind(&CdmAdapterTest::OnSessionClosed, base::Unretained(this)), | 88 base::Bind(&CdmAdapterTest::OnSessionClosed, base::Unretained(this)), |
| 88 base::Bind(&CdmAdapterTest::OnLegacySessionError, | 89 base::Bind(&CdmAdapterTest::OnLegacySessionError, |
| 89 base::Unretained(this)), | 90 base::Unretained(this)), |
| 90 base::Bind(&CdmAdapterTest::OnSessionKeysChange, | 91 base::Bind(&CdmAdapterTest::OnSessionKeysChange, |
| 91 base::Unretained(this)), | 92 base::Unretained(this)), |
| 92 base::Bind(&CdmAdapterTest::OnSessionExpirationUpdate, | 93 base::Bind(&CdmAdapterTest::OnSessionExpirationUpdate, |
| 93 base::Unretained(this)), | 94 base::Unretained(this)), |
| 94 base::Bind(&CdmAdapterTest::OnCdmCreated, base::Unretained(this), | 95 base::Bind(&CdmAdapterTest::OnCdmCreated, base::Unretained(this), |
| 95 expected_result)); | 96 expected_result), |
| 97 new CdmBufferAllocatorImpl()); |
| 96 RunUntilIdle(); | 98 RunUntilIdle(); |
| 97 } | 99 } |
| 98 | 100 |
| 99 // Creates a new session using |key_id|. |session_id_| will be set | 101 // Creates a new session using |key_id|. |session_id_| will be set |
| 100 // when the promise is resolved. |expected_result| tests that | 102 // when the promise is resolved. |expected_result| tests that |
| 101 // CreateSessionAndGenerateRequest() succeeds or generates an error. | 103 // CreateSessionAndGenerateRequest() succeeds or generates an error. |
| 102 void CreateSessionAndExpect(EmeInitDataType data_type, | 104 void CreateSessionAndExpect(EmeInitDataType data_type, |
| 103 const std::vector<uint8_t>& key_id, | 105 const std::vector<uint8_t>& key_id, |
| 104 ExpectedResult expected_result) { | 106 ExpectedResult expected_result) { |
| 105 DCHECK(!key_id.empty()); | 107 DCHECK(!key_id.empty()); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 TEST_F(CdmAdapterTest, UpdateSessionWithBadData) { | 315 TEST_F(CdmAdapterTest, UpdateSessionWithBadData) { |
| 314 InitializeAndExpect(ExternalClearKeyLibrary(), SUCCESS); | 316 InitializeAndExpect(ExternalClearKeyLibrary(), SUCCESS); |
| 315 | 317 |
| 316 std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId)); | 318 std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId)); |
| 317 CreateSessionAndExpect(EmeInitDataType::WEBM, key_id, SUCCESS); | 319 CreateSessionAndExpect(EmeInitDataType::WEBM, key_id, SUCCESS); |
| 318 | 320 |
| 319 UpdateSessionAndExpect(SessionId(), "random data", FAILURE, true); | 321 UpdateSessionAndExpect(SessionId(), "random data", FAILURE, true); |
| 320 } | 322 } |
| 321 | 323 |
| 322 } // namespace media | 324 } // namespace media |
| OLD | NEW |