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

Side by Side Diff: media/mojo/common/media_type_converters_unittest.cc

Issue 2253943004: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "media/mojo/common/media_type_converters.h" 5 #include "media/mojo/common/media_type_converters.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string.h> 9 #include <string.h>
10 10
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 251
252 std::vector<SubsampleEntry> subsamples; 252 std::vector<SubsampleEntry> subsamples;
253 subsamples.push_back(SubsampleEntry(10, 20)); 253 subsamples.push_back(SubsampleEntry(10, 20));
254 subsamples.push_back(SubsampleEntry(30, 40)); 254 subsamples.push_back(SubsampleEntry(30, 40));
255 subsamples.push_back(SubsampleEntry(50, 60)); 255 subsamples.push_back(SubsampleEntry(50, 60));
256 256
257 // Original. 257 // Original.
258 scoped_refptr<DecoderBuffer> buffer(DecoderBuffer::CopyFrom( 258 scoped_refptr<DecoderBuffer> buffer(DecoderBuffer::CopyFrom(
259 reinterpret_cast<const uint8_t*>(&kData), kDataSize)); 259 reinterpret_cast<const uint8_t*>(&kData), kDataSize));
260 buffer->set_decrypt_config( 260 buffer->set_decrypt_config(
261 base::WrapUnique(new DecryptConfig(kKeyId, kIv, subsamples))); 261 base::MakeUnique<DecryptConfig>(kKeyId, kIv, subsamples));
262 262
263 // Convert from and back. 263 // Convert from and back.
264 mojom::DecoderBufferPtr ptr(mojom::DecoderBuffer::From(buffer)); 264 mojom::DecoderBufferPtr ptr(mojom::DecoderBuffer::From(buffer));
265 scoped_refptr<DecoderBuffer> result(ptr.To<scoped_refptr<DecoderBuffer>>()); 265 scoped_refptr<DecoderBuffer> result(ptr.To<scoped_refptr<DecoderBuffer>>());
266 266
267 // Compare. 267 // Compare.
268 // Note: We intentionally do not serialize the data section of the 268 // Note: We intentionally do not serialize the data section of the
269 // DecoderBuffer; no need to check the data here. 269 // DecoderBuffer; no need to check the data here.
270 EXPECT_EQ(kDataSize, result->data_size()); 270 EXPECT_EQ(kDataSize, result->data_size());
271 EXPECT_TRUE(buffer->decrypt_config()->Matches(*result->decrypt_config())); 271 EXPECT_TRUE(buffer->decrypt_config()->Matches(*result->decrypt_config()));
272 272
273 // Test empty IV. This is used for clear buffer in an encrypted stream. 273 // Test empty IV. This is used for clear buffer in an encrypted stream.
274 buffer->set_decrypt_config(base::WrapUnique( 274 buffer->set_decrypt_config(base::MakeUnique<DecryptConfig>(
275 new DecryptConfig(kKeyId, "", std::vector<SubsampleEntry>()))); 275 kKeyId, "", std::vector<SubsampleEntry>()));
276 result = 276 result =
277 mojom::DecoderBuffer::From(buffer).To<scoped_refptr<DecoderBuffer>>(); 277 mojom::DecoderBuffer::From(buffer).To<scoped_refptr<DecoderBuffer>>();
278 EXPECT_TRUE(buffer->decrypt_config()->Matches(*result->decrypt_config())); 278 EXPECT_TRUE(buffer->decrypt_config()->Matches(*result->decrypt_config()));
279 EXPECT_TRUE(buffer->decrypt_config()->iv().empty()); 279 EXPECT_TRUE(buffer->decrypt_config()->iv().empty());
280 } 280 }
281 281
282 // TODO(tim): Check other properties. 282 // TODO(tim): Check other properties.
283 283
284 TEST(MediaTypeConvertersTest, ConvertAudioDecoderConfig_Normal) { 284 TEST(MediaTypeConvertersTest, ConvertAudioDecoderConfig_Normal) {
285 const uint8_t kExtraData[] = "config extra data"; 285 const uint8_t kExtraData[] = "config extra data";
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 EncryptionScheme result(ptr.To<EncryptionScheme>()); 458 EncryptionScheme result(ptr.To<EncryptionScheme>());
459 459
460 EXPECT_TRUE(result.Matches(scheme)); 460 EXPECT_TRUE(result.Matches(scheme));
461 461
462 // Verify a couple of negative cases. 462 // Verify a couple of negative cases.
463 EXPECT_FALSE(result.Matches(Unencrypted())); 463 EXPECT_FALSE(result.Matches(Unencrypted()));
464 EXPECT_FALSE(result.Matches(AesCtrEncryptionScheme())); 464 EXPECT_FALSE(result.Matches(AesCtrEncryptionScheme()));
465 } 465 }
466 466
467 } // namespace media 467 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/common/media_type_converters.cc ('k') | media/mojo/common/mojo_decoder_buffer_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698