| 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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 24 |
| 25 using ::testing::_; | 25 using ::testing::_; |
| 26 using ::testing::SaveArg; | 26 using ::testing::SaveArg; |
| 27 using ::testing::StrictMock; | 27 using ::testing::StrictMock; |
| 28 | 28 |
| 29 MATCHER(IsNotEmpty, "") { | 29 MATCHER(IsNotEmpty, "") { |
| 30 return !arg.empty(); | 30 return !arg.empty(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 MATCHER(IsNullTime, "") { |
| 34 return arg.is_null(); |
| 35 } |
| 36 |
| 33 // TODO(jrummell): These tests are a subset of those in aes_decryptor_unittest. | 37 // TODO(jrummell): These tests are a subset of those in aes_decryptor_unittest. |
| 34 // Refactor aes_decryptor_unittest.cc to handle AesDecryptor directly and | 38 // Refactor aes_decryptor_unittest.cc to handle AesDecryptor directly and |
| 35 // via CdmAdapter once CdmAdapter supports decrypting functionality. There | 39 // via CdmAdapter once CdmAdapter supports decrypting functionality. There |
| 36 // will also be tests that only CdmAdapter supports, like file IO, which | 40 // will also be tests that only CdmAdapter supports, like file IO, which |
| 37 // will need to be handled separately. | 41 // will need to be handled separately. |
| 38 | 42 |
| 39 namespace media { | 43 namespace media { |
| 40 | 44 |
| 41 // Random key ID used to create a session. | 45 // Random key ID used to create a session. |
| 42 const uint8_t kKeyId[] = { | 46 const uint8_t kKeyId[] = { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 bool new_key_expected) { | 148 bool new_key_expected) { |
| 145 DCHECK(!key.empty()); | 149 DCHECK(!key.empty()); |
| 146 | 150 |
| 147 if (expected_result == SUCCESS) { | 151 if (expected_result == SUCCESS) { |
| 148 EXPECT_CALL(cdm_client_, | 152 EXPECT_CALL(cdm_client_, |
| 149 OnSessionKeysChangeCalled(session_id, new_key_expected)); | 153 OnSessionKeysChangeCalled(session_id, new_key_expected)); |
| 150 } else { | 154 } else { |
| 151 EXPECT_CALL(cdm_client_, OnSessionKeysChangeCalled(_, _)).Times(0); | 155 EXPECT_CALL(cdm_client_, OnSessionKeysChangeCalled(_, _)).Times(0); |
| 152 } | 156 } |
| 153 | 157 |
| 158 // ClearKeyCdm always call OnSessionExpirationUpdate() for testing purpose. |
| 159 EXPECT_CALL(cdm_client_, |
| 160 OnSessionExpirationUpdate(session_id, IsNullTime())) |
| 161 .Times(1); |
| 162 |
| 154 adapter_->UpdateSession(session_id, | 163 adapter_->UpdateSession(session_id, |
| 155 std::vector<uint8_t>(key.begin(), key.end()), | 164 std::vector<uint8_t>(key.begin(), key.end()), |
| 156 CreatePromise(expected_result)); | 165 CreatePromise(expected_result)); |
| 157 RunUntilIdle(); | 166 RunUntilIdle(); |
| 158 } | 167 } |
| 159 | 168 |
| 160 base::FilePath ExternalClearKeyLibrary() { return helper_.LibraryPath(); } | 169 base::FilePath ExternalClearKeyLibrary() { return helper_.LibraryPath(); } |
| 161 | 170 |
| 162 std::string SessionId() { return session_id_; } | 171 std::string SessionId() { return session_id_; } |
| 163 | 172 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 TEST_F(CdmAdapterTest, UpdateSessionWithBadData) { | 313 TEST_F(CdmAdapterTest, UpdateSessionWithBadData) { |
| 305 InitializeAndExpect(ExternalClearKeyLibrary(), SUCCESS); | 314 InitializeAndExpect(ExternalClearKeyLibrary(), SUCCESS); |
| 306 | 315 |
| 307 std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId)); | 316 std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId)); |
| 308 CreateSessionAndExpect(EmeInitDataType::WEBM, key_id, SUCCESS); | 317 CreateSessionAndExpect(EmeInitDataType::WEBM, key_id, SUCCESS); |
| 309 | 318 |
| 310 UpdateSessionAndExpect(SessionId(), "random data", FAILURE, true); | 319 UpdateSessionAndExpect(SessionId(), "random data", FAILURE, true); |
| 311 } | 320 } |
| 312 | 321 |
| 313 } // namespace media | 322 } // namespace media |
| OLD | NEW |