Chromium Code Reviews| 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..483363b76a5dccd68b9eb58f37ed3610e5098b7b 100644 |
| --- a/media/cdm/aes_decryptor_unittest.cc |
| +++ b/media/cdm/aes_decryptor_unittest.cc |
| @@ -211,6 +211,8 @@ class AesDecryptorTest : public testing::Test { |
| : decryptor_(base::Bind(&AesDecryptorTest::OnSessionMessage, |
| base::Unretained(this)), |
| base::Bind(&AesDecryptorTest::OnSessionClosed, |
| + base::Unretained(this)), |
| + base::Bind(&AesDecryptorTest::OnSessionKeysChange, |
| base::Unretained(this))), |
| decrypt_cb_(base::Bind(&AesDecryptorTest::BufferDecrypted, |
| base::Unretained(this))), |
| @@ -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(). |
|
ddorwin
2014/09/12 21:46:31
Note that this should be updated when prefixed is
jrummell
2014/09/15 18:22:40
Done.
|
| + 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) { |
|
ddorwin
2014/09/12 21:46:31
expected_result?
jrummell
2014/09/15 18:22:40
Done.
|
| 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) { |
|
ddorwin
2014/09/12 21:46:31
ditto
jrummell
2014/09/15 18:22:40
Done.
|
| 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) { |