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 7462010793fefa197f00d01978663ebaf89ad1ef..d31e9a4f5792d6edeb6c43f912c41464a7f14b61 100644 |
| --- a/media/cdm/aes_decryptor_unittest.cc |
| +++ b/media/cdm/aes_decryptor_unittest.cc |
| @@ -339,18 +339,9 @@ class AesDecryptorTest : public testing::TestWithParam<std::string> { |
| cdm_->CloseSession(session_id, CreatePromise(RESOLVED)); |
| } |
| - // Removes the session specified by |session_id|. This should simply do a |
| - // CloseSession(). |
| - // TODO(jrummell): Clean this up when the prefixed API is removed. |
| - // http://crbug.com/249976. |
| + // Only persistent sessions can be removed. |
| void RemoveSession(const std::string& session_id) { |
| - if (GetParam() == "AesDecryptor") { |
| - EXPECT_CALL(*this, OnSessionClosed(session_id)); |
| - cdm_->RemoveSession(session_id, CreatePromise(RESOLVED)); |
| - } else { |
| - // CdmAdapter fails as only persistent sessions can be removed. |
| - cdm_->RemoveSession(session_id, CreatePromise(REJECTED)); |
| - } |
| + cdm_->RemoveSession(session_id, CreatePromise(REJECTED)); |
| } |
| MOCK_METHOD2(OnSessionKeysChangeCalled, |
| @@ -497,32 +488,59 @@ class AesDecryptorTest : public testing::TestWithParam<std::string> { |
| const std::vector<SubsampleEntry> no_subsample_entries_; |
| }; |
| -TEST_P(AesDecryptorTest, CreateSessionWithNullInitData) { |
| - EXPECT_CALL(*this, |
| - OnSessionMessage(IsNotEmpty(), _, IsEmpty(), GURL::EmptyGURL())); |
| +TEST_P(AesDecryptorTest, CreateSessionWithEmptyInitData) { |
| cdm_->CreateSessionAndGenerateRequest( |
| MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, |
| - std::vector<uint8_t>(), CreateSessionPromise(RESOLVED)); |
| + std::vector<uint8_t>(), CreateSessionPromise(REJECTED)); |
| + cdm_->CreateSessionAndGenerateRequest( |
| + MediaKeys::TEMPORARY_SESSION, EmeInitDataType::CENC, |
| + std::vector<uint8_t>(), CreateSessionPromise(REJECTED)); |
| + cdm_->CreateSessionAndGenerateRequest( |
| + MediaKeys::TEMPORARY_SESSION, EmeInitDataType::KEYIDS, |
| + std::vector<uint8_t>(), CreateSessionPromise(REJECTED)); |
| +} |
| + |
| +TEST_P(AesDecryptorTest, CreateSessionWithVariousLengthInitData_WebM) { |
| + std::vector<uint8_t> init_data; |
| + init_data.resize(1); |
| + cdm_->CreateSessionAndGenerateRequest( |
| + MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, |
| + std::vector<uint8_t>(init_data), CreateSessionPromise(RESOLVED)); |
| + |
| + init_data.resize(16); // The expected size. |
| + cdm_->CreateSessionAndGenerateRequest( |
| + MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, |
| + std::vector<uint8_t>(init_data), CreateSessionPromise(RESOLVED)); |
| + |
| + init_data.resize(512); |
|
jrummell
2016/06/25 00:39:38
Should limits::kMaxKeyIdLength be used here (and +
ddorwin
2016/08/11 20:28:32
Tests should avoid using the same constants as the
jrummell
2016/08/12 19:24:25
Acknowledged.
|
| + cdm_->CreateSessionAndGenerateRequest( |
| + MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, |
| + std::vector<uint8_t>(init_data), CreateSessionPromise(RESOLVED)); |
| + |
| + init_data.resize(513); |
| + cdm_->CreateSessionAndGenerateRequest( |
| + MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, |
| + std::vector<uint8_t>(init_data), CreateSessionPromise(REJECTED)); |
| } |
| TEST_P(AesDecryptorTest, MultipleCreateSession) { |
| - EXPECT_CALL(*this, |
| - OnSessionMessage(IsNotEmpty(), _, IsEmpty(), GURL::EmptyGURL())); |
| + EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsNotEmpty(), |
| + GURL::EmptyGURL())); |
| cdm_->CreateSessionAndGenerateRequest( |
| MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, |
| - std::vector<uint8_t>(), CreateSessionPromise(RESOLVED)); |
| + std::vector<uint8_t>(1), CreateSessionPromise(RESOLVED)); |
| - EXPECT_CALL(*this, |
| - OnSessionMessage(IsNotEmpty(), _, IsEmpty(), GURL::EmptyGURL())); |
| + EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsNotEmpty(), |
| + GURL::EmptyGURL())); |
| cdm_->CreateSessionAndGenerateRequest( |
| MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, |
| - std::vector<uint8_t>(), CreateSessionPromise(RESOLVED)); |
| + std::vector<uint8_t>(1), CreateSessionPromise(RESOLVED)); |
| - EXPECT_CALL(*this, |
| - OnSessionMessage(IsNotEmpty(), _, IsEmpty(), GURL::EmptyGURL())); |
| + EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsNotEmpty(), |
| + GURL::EmptyGURL())); |
| cdm_->CreateSessionAndGenerateRequest( |
| MediaKeys::TEMPORARY_SESSION, EmeInitDataType::WEBM, |
| - std::vector<uint8_t>(), CreateSessionPromise(RESOLVED)); |
| + std::vector<uint8_t>(1), CreateSessionPromise(RESOLVED)); |
| } |
| TEST_P(AesDecryptorTest, CreateSessionWithCencInitData) { |
| @@ -765,9 +783,8 @@ TEST_P(AesDecryptorTest, CloseSession) { |
| CloseSession(session_id); |
| } |
| -TEST_P(AesDecryptorTest, RemoveSession) { |
| - // TODO(jrummell): Clean this up when the prefixed API is removed. |
| - // http://crbug.com/249976. |
| +// Re-enable if https://crbug.com/416194 is fixed. |
| +TEST_P(AesDecryptorTest, RemoveSession_DISABLED) { |
| std::string session_id = CreateSession(key_id_); |
| scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer( |
| encrypted_data_, key_id_, iv_, no_subsample_entries_); |