Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(549)

Side by Side Diff: media/crypto/aes_decryptor_unittest.cc

Issue 11275088: Remove implicit scoped_refptr operator T* Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/base/video_frame.cc ('k') | media/filters/audio_renderer_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <vector> 6 #include <vector>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "media/base/decoder_buffer.h" 10 #include "media/base/decoder_buffer.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 MOCK_METHOD2(BufferDecrypted, void(Decryptor::Status, 265 MOCK_METHOD2(BufferDecrypted, void(Decryptor::Status,
266 const scoped_refptr<DecoderBuffer>&)); 266 const scoped_refptr<DecoderBuffer>&));
267 267
268 void DecryptAndExpectToSucceed(const scoped_refptr<DecoderBuffer>& encrypted, 268 void DecryptAndExpectToSucceed(const scoped_refptr<DecoderBuffer>& encrypted,
269 const uint8* plain_text, int plain_text_size) { 269 const uint8* plain_text, int plain_text_size) {
270 scoped_refptr<DecoderBuffer> decrypted; 270 scoped_refptr<DecoderBuffer> decrypted;
271 EXPECT_CALL(*this, BufferDecrypted(AesDecryptor::kSuccess, NotNull())) 271 EXPECT_CALL(*this, BufferDecrypted(AesDecryptor::kSuccess, NotNull()))
272 .WillOnce(SaveArg<1>(&decrypted)); 272 .WillOnce(SaveArg<1>(&decrypted));
273 273
274 decryptor_.Decrypt(Decryptor::kVideo, encrypted, decrypt_cb_); 274 decryptor_.Decrypt(Decryptor::kVideo, encrypted, decrypt_cb_);
275 ASSERT_TRUE(decrypted); 275 ASSERT_TRUE(decrypted.get());
276 ASSERT_EQ(plain_text_size, decrypted->GetDataSize()); 276 ASSERT_EQ(plain_text_size, decrypted->GetDataSize());
277 EXPECT_EQ(0, memcmp(plain_text, decrypted->GetData(), plain_text_size)); 277 EXPECT_EQ(0, memcmp(plain_text, decrypted->GetData(), plain_text_size));
278 } 278 }
279 279
280 void DecryptAndExpectDataMismatch( 280 void DecryptAndExpectDataMismatch(
281 const scoped_refptr<DecoderBuffer>& encrypted, 281 const scoped_refptr<DecoderBuffer>& encrypted,
282 const uint8* plain_text, int plain_text_size) { 282 const uint8* plain_text, int plain_text_size) {
283 scoped_refptr<DecoderBuffer> decrypted; 283 scoped_refptr<DecoderBuffer> decrypted;
284 EXPECT_CALL(*this, BufferDecrypted(AesDecryptor::kSuccess, NotNull())) 284 EXPECT_CALL(*this, BufferDecrypted(AesDecryptor::kSuccess, NotNull()))
285 .WillOnce(SaveArg<1>(&decrypted)); 285 .WillOnce(SaveArg<1>(&decrypted));
286 286
287 decryptor_.Decrypt(Decryptor::kVideo, encrypted, decrypt_cb_); 287 decryptor_.Decrypt(Decryptor::kVideo, encrypted, decrypt_cb_);
288 ASSERT_TRUE(decrypted); 288 ASSERT_TRUE(decrypted.get());
289 ASSERT_EQ(plain_text_size, decrypted->GetDataSize()); 289 ASSERT_EQ(plain_text_size, decrypted->GetDataSize());
290 EXPECT_NE(0, memcmp(plain_text, decrypted->GetData(), plain_text_size)); 290 EXPECT_NE(0, memcmp(plain_text, decrypted->GetData(), plain_text_size));
291 } 291 }
292 292
293 void DecryptAndExpectSizeDataMismatch( 293 void DecryptAndExpectSizeDataMismatch(
294 const scoped_refptr<DecoderBuffer>& encrypted, 294 const scoped_refptr<DecoderBuffer>& encrypted,
295 const uint8* plain_text, int plain_text_size) { 295 const uint8* plain_text, int plain_text_size) {
296 scoped_refptr<DecoderBuffer> decrypted; 296 scoped_refptr<DecoderBuffer> decrypted;
297 EXPECT_CALL(*this, BufferDecrypted(AesDecryptor::kSuccess, NotNull())) 297 EXPECT_CALL(*this, BufferDecrypted(AesDecryptor::kSuccess, NotNull()))
298 .WillOnce(SaveArg<1>(&decrypted)); 298 .WillOnce(SaveArg<1>(&decrypted));
299 299
300 decryptor_.Decrypt(Decryptor::kVideo, encrypted, decrypt_cb_); 300 decryptor_.Decrypt(Decryptor::kVideo, encrypted, decrypt_cb_);
301 ASSERT_TRUE(decrypted); 301 ASSERT_TRUE(decrypted.get());
302 EXPECT_NE(plain_text_size, decrypted->GetDataSize()); 302 EXPECT_NE(plain_text_size, decrypted->GetDataSize());
303 EXPECT_NE(0, memcmp(plain_text, decrypted->GetData(), plain_text_size)); 303 EXPECT_NE(0, memcmp(plain_text, decrypted->GetData(), plain_text_size));
304 } 304 }
305 305
306 void DecryptAndExpectToFail(const scoped_refptr<DecoderBuffer>& encrypted) { 306 void DecryptAndExpectToFail(const scoped_refptr<DecoderBuffer>& encrypted) {
307 EXPECT_CALL(*this, BufferDecrypted(AesDecryptor::kError, IsNull())); 307 EXPECT_CALL(*this, BufferDecrypted(AesDecryptor::kError, IsNull()));
308 decryptor_.Decrypt(Decryptor::kVideo, encrypted, decrypt_cb_); 308 decryptor_.Decrypt(Decryptor::kVideo, encrypted, decrypt_cb_);
309 } 309 }
310 310
311 MockDecryptorClient client_; 311 MockDecryptorClient client_;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 scoped_refptr<DecoderBuffer> encrypted_data = CreateSubsampleEncryptedBuffer( 582 scoped_refptr<DecoderBuffer> encrypted_data = CreateSubsampleEncryptedBuffer(
583 kSubsampleData, arraysize(kSubsampleData), 583 kSubsampleData, arraysize(kSubsampleData),
584 kSubsampleKeyId, arraysize(kSubsampleKeyId), 584 kSubsampleKeyId, arraysize(kSubsampleKeyId),
585 kSubsampleIv, arraysize(kSubsampleIv), 585 kSubsampleIv, arraysize(kSubsampleIv),
586 0, 586 0,
587 entries); 587 entries);
588 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToFail(encrypted_data)); 588 ASSERT_NO_FATAL_FAILURE(DecryptAndExpectToFail(encrypted_data));
589 } 589 }
590 590
591 } // namespace media 591 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame.cc ('k') | media/filters/audio_renderer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698