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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 // for AesDecryptor. | 332 // for AesDecryptor. |
333 return session_id_; | 333 return session_id_; |
334 } | 334 } |
335 | 335 |
336 // Closes the session specified by |session_id|. | 336 // Closes the session specified by |session_id|. |
337 void CloseSession(const std::string& session_id) { | 337 void CloseSession(const std::string& session_id) { |
338 EXPECT_CALL(*this, OnSessionClosed(session_id)); | 338 EXPECT_CALL(*this, OnSessionClosed(session_id)); |
339 cdm_->CloseSession(session_id, CreatePromise(RESOLVED)); | 339 cdm_->CloseSession(session_id, CreatePromise(RESOLVED)); |
340 } | 340 } |
341 | 341 |
342 // Removes the session specified by |session_id|. This should simply do a | 342 // Only persistent sessions can be removed. |
343 // CloseSession(). | |
344 // TODO(jrummell): Clean this up when the prefixed API is removed. | |
345 // http://crbug.com/249976. | |
346 void RemoveSession(const std::string& session_id) { | 343 void RemoveSession(const std::string& session_id) { |
347 if (GetParam() == "AesDecryptor") { | 344 cdm_->RemoveSession(session_id, CreatePromise(REJECTED)); |
348 EXPECT_CALL(*this, OnSessionClosed(session_id)); | |
349 cdm_->RemoveSession(session_id, CreatePromise(RESOLVED)); | |
350 } else { | |
351 // CdmAdapter fails as only persistent sessions can be removed. | |
352 cdm_->RemoveSession(session_id, CreatePromise(REJECTED)); | |
353 } | |
354 } | 345 } |
355 | 346 |
356 MOCK_METHOD2(OnSessionKeysChangeCalled, | 347 MOCK_METHOD2(OnSessionKeysChangeCalled, |
357 void(const std::string& session_id, | 348 void(const std::string& session_id, |
358 bool has_additional_usable_key)); | 349 bool has_additional_usable_key)); |
359 | 350 |
360 void OnSessionKeysChange(const std::string& session_id, | 351 void OnSessionKeysChange(const std::string& session_id, |
361 bool has_additional_usable_key, | 352 bool has_additional_usable_key, |
362 CdmKeysInfo keys_info) { | 353 CdmKeysInfo keys_info) { |
363 keys_info_.swap(keys_info); | 354 keys_info_.swap(keys_info); |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
759 encrypted_data_, key_id_, iv_, no_subsample_entries_); | 750 encrypted_data_, key_id_, iv_, no_subsample_entries_); |
760 | 751 |
761 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, true); | 752 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, true); |
762 ASSERT_NO_FATAL_FAILURE( | 753 ASSERT_NO_FATAL_FAILURE( |
763 DecryptAndExpect(encrypted_buffer, original_data_, SUCCESS)); | 754 DecryptAndExpect(encrypted_buffer, original_data_, SUCCESS)); |
764 | 755 |
765 CloseSession(session_id); | 756 CloseSession(session_id); |
766 } | 757 } |
767 | 758 |
768 TEST_P(AesDecryptorTest, RemoveSession) { | 759 TEST_P(AesDecryptorTest, RemoveSession) { |
769 // TODO(jrummell): Clean this up when the prefixed API is removed. | |
ddorwin
2016/06/23 01:06:47
I'm not sure what this meant other than all the ot
jrummell
2016/06/23 17:20:16
When I added the comment the test was simply Remov
| |
770 // http://crbug.com/249976. | |
771 std::string session_id = CreateSession(key_id_); | 760 std::string session_id = CreateSession(key_id_); |
772 scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer( | 761 scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer( |
773 encrypted_data_, key_id_, iv_, no_subsample_entries_); | 762 encrypted_data_, key_id_, iv_, no_subsample_entries_); |
774 | 763 |
775 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, true); | 764 UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED, true); |
776 ASSERT_NO_FATAL_FAILURE( | 765 ASSERT_NO_FATAL_FAILURE( |
777 DecryptAndExpect(encrypted_buffer, original_data_, SUCCESS)); | 766 DecryptAndExpect(encrypted_buffer, original_data_, SUCCESS)); |
778 | 767 |
779 RemoveSession(session_id); | 768 RemoveSession(session_id); |
780 } | 769 } |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1020 INSTANTIATE_TEST_CASE_P(CdmAdapter, | 1009 INSTANTIATE_TEST_CASE_P(CdmAdapter, |
1021 AesDecryptorTest, | 1010 AesDecryptorTest, |
1022 testing::Values("CdmAdapter")); | 1011 testing::Values("CdmAdapter")); |
1023 #endif | 1012 #endif |
1024 | 1013 |
1025 // TODO(jrummell): Once MojoCdm/MojoCdmService/MojoDecryptor/ | 1014 // TODO(jrummell): Once MojoCdm/MojoCdmService/MojoDecryptor/ |
1026 // MojoDecryptorService are implemented, add a third version that tests the | 1015 // MojoDecryptorService are implemented, add a third version that tests the |
1027 // CDM via mojo. | 1016 // CDM via mojo. |
1028 | 1017 |
1029 } // namespace media | 1018 } // namespace media |
OLD | NEW |