| Index: media/cdm/aes_decryptor_unittest.cc
|
| diff --git a/media/cdm/aes_decryptor_unittest.cc b/media/cdm/aes_decryptor_unittest.cc
|
| index a40867e7d1b5a6d212df41d4a12ac6686018f93e..9ee0a7463c97f7c046b55ca6107b8d0b03c8bcef 100644
|
| --- a/media/cdm/aes_decryptor_unittest.cc
|
| +++ b/media/cdm/aes_decryptor_unittest.cc
|
| @@ -210,6 +210,8 @@ class AesDecryptorTest : public testing::Test {
|
| AesDecryptorTest()
|
| : decryptor_(base::Bind(&AesDecryptorTest::OnSessionMessage,
|
| base::Unretained(this)),
|
| + base::Bind(&AesDecryptorTest::OnSessionKeysChange,
|
| + base::Unretained(this)),
|
| base::Bind(&AesDecryptorTest::OnSessionClosed,
|
| base::Unretained(this))),
|
| decrypt_cb_(base::Bind(&AesDecryptorTest::BufferDecrypted,
|
| @@ -307,10 +309,17 @@ class AesDecryptorTest : public testing::Test {
|
| return web_session_id_;
|
| }
|
|
|
| - // Releases the session specified by |session_id|.
|
| - void ReleaseSession(const std::string& session_id) {
|
| + // Closes the session specified by |session_id|.
|
| + void CloseSession(const std::string& session_id) {
|
| EXPECT_CALL(*this, OnSessionClosed(session_id));
|
| - decryptor_.ReleaseSession(session_id, CreatePromise(RESOLVED));
|
| + decryptor_.CloseSession(session_id, CreatePromise(RESOLVED));
|
| + }
|
| +
|
| + // Removes the session specified by |session_id|. This should simply do a
|
| + // CloseSession().
|
| + void RemoveSession(const std::string& session_id) {
|
| + EXPECT_CALL(*this, OnSessionClosed(session_id));
|
| + decryptor_.RemoveSession(session_id, CreatePromise(RESOLVED));
|
| }
|
|
|
| // Updates the session specified by |session_id| with |key|. |result|
|
| @@ -320,6 +329,12 @@ class AesDecryptorTest : public testing::Test {
|
| PromiseResult result) {
|
| DCHECK(!key.empty());
|
|
|
| + if (result == RESOLVED) {
|
| + EXPECT_CALL(*this, OnSessionKeysChange(session_id, true));
|
| + } else {
|
| + EXPECT_CALL(*this, OnSessionKeysChange(_, _)).Times(0);
|
| + }
|
| +
|
| decryptor_.UpdateSession(session_id,
|
| reinterpret_cast<const uint8*>(key.c_str()),
|
| key.length(),
|
| @@ -406,6 +421,9 @@ class AesDecryptorTest : public testing::Test {
|
| void(const std::string& web_session_id,
|
| const std::vector<uint8>& message,
|
| const GURL& destination_url));
|
| + MOCK_METHOD2(OnSessionKeysChange,
|
| + void(const std::string& web_session_id,
|
| + bool has_additional_usable_key));
|
| MOCK_METHOD1(OnSessionClosed, void(const std::string& web_session_id));
|
|
|
| AesDecryptor decryptor_;
|
| @@ -647,7 +665,19 @@ TEST_F(AesDecryptorTest, SubsampleCypherBytesOnly) {
|
| DecryptAndExpect(encrypted_buffer, original_data_, SUCCESS);
|
| }
|
|
|
| -TEST_F(AesDecryptorTest, ReleaseSession) {
|
| +TEST_F(AesDecryptorTest, CloseSession) {
|
| + std::string session_id = CreateSession(key_id_);
|
| + scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer(
|
| + encrypted_data_, key_id_, iv_, no_subsample_entries_);
|
| +
|
| + UpdateSessionAndExpect(session_id, kKeyAsJWK, RESOLVED);
|
| + ASSERT_NO_FATAL_FAILURE(
|
| + DecryptAndExpect(encrypted_buffer, original_data_, SUCCESS));
|
| +
|
| + CloseSession(session_id);
|
| +}
|
| +
|
| +TEST_F(AesDecryptorTest, RemoveSession) {
|
| std::string session_id = CreateSession(key_id_);
|
| scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer(
|
| encrypted_data_, key_id_, iv_, no_subsample_entries_);
|
| @@ -656,10 +686,10 @@ TEST_F(AesDecryptorTest, ReleaseSession) {
|
| ASSERT_NO_FATAL_FAILURE(
|
| DecryptAndExpect(encrypted_buffer, original_data_, SUCCESS));
|
|
|
| - ReleaseSession(session_id);
|
| + RemoveSession(session_id);
|
| }
|
|
|
| -TEST_F(AesDecryptorTest, NoKeyAfterReleaseSession) {
|
| +TEST_F(AesDecryptorTest, NoKeyAfterCloseSession) {
|
| std::string session_id = CreateSession(key_id_);
|
| scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer(
|
| encrypted_data_, key_id_, iv_, no_subsample_entries_);
|
| @@ -668,7 +698,7 @@ TEST_F(AesDecryptorTest, NoKeyAfterReleaseSession) {
|
| ASSERT_NO_FATAL_FAILURE(
|
| DecryptAndExpect(encrypted_buffer, original_data_, SUCCESS));
|
|
|
| - ReleaseSession(session_id);
|
| + CloseSession(session_id);
|
| ASSERT_NO_FATAL_FAILURE(
|
| DecryptAndExpect(encrypted_buffer, original_data_, NO_KEY));
|
| }
|
| @@ -692,7 +722,7 @@ TEST_F(AesDecryptorTest, LatestKeyUsed) {
|
| DecryptAndExpect(encrypted_buffer, original_data_, SUCCESS));
|
| }
|
|
|
| -TEST_F(AesDecryptorTest, LatestKeyUsedAfterReleaseSession) {
|
| +TEST_F(AesDecryptorTest, LatestKeyUsedAfterCloseSession) {
|
| std::string session_id1 = CreateSession(key_id_);
|
| scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer(
|
| encrypted_data_, key_id_, iv_, no_subsample_entries_);
|
| @@ -709,7 +739,7 @@ TEST_F(AesDecryptorTest, LatestKeyUsedAfterReleaseSession) {
|
| DecryptAndExpect(encrypted_buffer, original_data_, DATA_MISMATCH));
|
|
|
| // Close second session, should revert to original key.
|
| - ReleaseSession(session_id2);
|
| + CloseSession(session_id2);
|
| ASSERT_NO_FATAL_FAILURE(
|
| DecryptAndExpect(encrypted_buffer, original_data_, SUCCESS));
|
| }
|
| @@ -841,7 +871,7 @@ TEST_F(AesDecryptorTest, JWKKey) {
|
| " ]"
|
| "}";
|
| UpdateSessionAndExpect(session_id, kJwksWithEmptyKeyId, REJECTED);
|
| - ReleaseSession(session_id);
|
| + CloseSession(session_id);
|
| }
|
|
|
| TEST_F(AesDecryptorTest, GetKeyIds) {
|
|
|