| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "media/base/decoder_buffer.h" | 8 #include "media/base/decoder_buffer.h" |
| 9 #include "media/base/decrypt_config.h" | 9 #include "media/base/decrypt_config.h" |
| 10 #include "media/base/mock_filters.h" | 10 #include "media/base/mock_filters.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 const uint8 (&key)[KeySize]) { | 65 const uint8 (&key)[KeySize]) { |
| 66 EXPECT_CALL(client_, KeyAdded(kClearKeySystem, session_id_string_)); | 66 EXPECT_CALL(client_, KeyAdded(kClearKeySystem, session_id_string_)); |
| 67 decryptor_.AddKey(kClearKeySystem, key, KeySize, key_id, KeyIdSize, | 67 decryptor_.AddKey(kClearKeySystem, key, KeySize, key_id, KeyIdSize, |
| 68 session_id_string_); | 68 session_id_string_); |
| 69 } | 69 } |
| 70 | 70 |
| 71 template <int KeyIdSize, int KeySize> | 71 template <int KeyIdSize, int KeySize> |
| 72 void AddKeyAndExpectToFail(const uint8 (&key_id)[KeyIdSize], | 72 void AddKeyAndExpectToFail(const uint8 (&key_id)[KeyIdSize], |
| 73 const uint8 (&key)[KeySize]) { | 73 const uint8 (&key)[KeySize]) { |
| 74 EXPECT_CALL(client_, KeyError(kClearKeySystem, session_id_string_, | 74 EXPECT_CALL(client_, KeyError(kClearKeySystem, session_id_string_, |
| 75 AesDecryptor::kUnknownError, 0)); | 75 Decryptor::kUnknownError, 0)); |
| 76 decryptor_.AddKey(kClearKeySystem, key, KeySize, key_id, KeyIdSize, | 76 decryptor_.AddKey(kClearKeySystem, key, KeySize, key_id, KeyIdSize, |
| 77 session_id_string_); | 77 session_id_string_); |
| 78 } | 78 } |
| 79 | 79 |
| 80 template <int KeyIdSize> | 80 template <int KeyIdSize> |
| 81 void SetKeyIdForEncryptedData(const uint8 (&key_id)[KeyIdSize]) { | 81 void SetKeyIdForEncryptedData(const uint8 (&key_id)[KeyIdSize]) { |
| 82 encrypted_data_->SetDecryptConfig( | 82 encrypted_data_->SetDecryptConfig( |
| 83 scoped_ptr<DecryptConfig>(new DecryptConfig(key_id, KeyIdSize))); | 83 scoped_ptr<DecryptConfig>(new DecryptConfig(key_id, KeyIdSize))); |
| 84 } | 84 } |
| 85 | 85 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToFail()); | 129 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToFail()); |
| 130 AddKeyAndExpectToSucceed(kKeyId1, kRightKey); | 130 AddKeyAndExpectToSucceed(kKeyId1, kRightKey); |
| 131 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToSucceed()); | 131 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToSucceed()); |
| 132 } | 132 } |
| 133 | 133 |
| 134 TEST_F(AesDecryptorTest, WrongSizedKey) { | 134 TEST_F(AesDecryptorTest, WrongSizedKey) { |
| 135 AddKeyAndExpectToFail(kKeyId1, kWrongSizedKey); | 135 AddKeyAndExpectToFail(kKeyId1, kWrongSizedKey); |
| 136 } | 136 } |
| 137 | 137 |
| 138 } // media | 138 } // media |
| OLD | NEW |