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

Side by Side Diff: media/cdm/simple_cdm_allocator_unittest.cc

Issue 1915443003: Replace scoped_ptr with std::unique_ptr in //media. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptr-media-base
Patch Set: scopedptr-media: rebase Created 4 years, 7 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
« no previous file with comments | « media/cdm/simple_cdm_allocator.cc ('k') | media/ffmpeg/ffmpeg_common.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <stdint.h> 5 #include <stdint.h>
6 #include <memory>
6 7
7 #include "base/macros.h" 8 #include "base/macros.h"
8 #include "media/base/video_frame.h" 9 #include "media/base/video_frame.h"
9 #include "media/cdm/api/content_decryption_module.h" 10 #include "media/cdm/api/content_decryption_module.h"
10 #include "media/cdm/cdm_helpers.h" 11 #include "media/cdm/cdm_helpers.h"
11 #include "media/cdm/simple_cdm_allocator.h" 12 #include "media/cdm/simple_cdm_allocator.h"
12 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace media { 16 namespace media {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 DISALLOW_COPY_AND_ASSIGN(SimpleCdmAllocatorTest); 58 DISALLOW_COPY_AND_ASSIGN(SimpleCdmAllocatorTest);
58 }; 59 };
59 60
60 TEST_F(SimpleCdmAllocatorTest, CreateCdmBuffer) { 61 TEST_F(SimpleCdmAllocatorTest, CreateCdmBuffer) {
61 cdm::Buffer* buffer = allocator_.CreateCdmBuffer(100); 62 cdm::Buffer* buffer = allocator_.CreateCdmBuffer(100);
62 EXPECT_GE(buffer->Capacity(), 100u); 63 EXPECT_GE(buffer->Capacity(), 100u);
63 buffer->Destroy(); 64 buffer->Destroy();
64 } 65 }
65 66
66 TEST_F(SimpleCdmAllocatorTest, CreateCdmVideoFrame) { 67 TEST_F(SimpleCdmAllocatorTest, CreateCdmVideoFrame) {
67 scoped_ptr<VideoFrameImpl> video_frame = allocator_.CreateCdmVideoFrame(); 68 std::unique_ptr<VideoFrameImpl> video_frame =
69 allocator_.CreateCdmVideoFrame();
68 EXPECT_EQ(video_frame->FrameBuffer(), nullptr); 70 EXPECT_EQ(video_frame->FrameBuffer(), nullptr);
69 video_frame->SetFrameBuffer(TestCdmBuffer::Create(100)); 71 video_frame->SetFrameBuffer(TestCdmBuffer::Create(100));
70 EXPECT_NE(video_frame->FrameBuffer(), nullptr); 72 EXPECT_NE(video_frame->FrameBuffer(), nullptr);
71 73
72 // Releasing |video_frame| should free the cdm::Buffer created above 74 // Releasing |video_frame| should free the cdm::Buffer created above
73 // (verified by the mock method TestCdmBuffer::DestroyCalled). 75 // (verified by the mock method TestCdmBuffer::DestroyCalled).
74 video_frame.reset(); 76 video_frame.reset();
75 } 77 }
76 78
77 TEST_F(SimpleCdmAllocatorTest, TransformToVideoFrame) { 79 TEST_F(SimpleCdmAllocatorTest, TransformToVideoFrame) {
78 // For this test we need to pretend we have valid video data. So create 80 // For this test we need to pretend we have valid video data. So create
79 // a small video frame of size 2x2. 81 // a small video frame of size 2x2.
80 gfx::Size size(2, 2); 82 gfx::Size size(2, 2);
81 size_t memory_needed = VideoFrame::AllocationSize(PIXEL_FORMAT_YV12, size); 83 size_t memory_needed = VideoFrame::AllocationSize(PIXEL_FORMAT_YV12, size);
82 84
83 // Now create a VideoFrameImpl. 85 // Now create a VideoFrameImpl.
84 scoped_ptr<VideoFrameImpl> video_frame = allocator_.CreateCdmVideoFrame(); 86 std::unique_ptr<VideoFrameImpl> video_frame =
87 allocator_.CreateCdmVideoFrame();
85 EXPECT_EQ(video_frame->FrameBuffer(), nullptr); 88 EXPECT_EQ(video_frame->FrameBuffer(), nullptr);
86 89
87 // Fill VideoFrameImpl as if it was a small video frame. 90 // Fill VideoFrameImpl as if it was a small video frame.
88 video_frame->SetFormat(cdm::kI420); 91 video_frame->SetFormat(cdm::kI420);
89 video_frame->SetSize(cdm::Size(size.width(), size.height())); 92 video_frame->SetSize(cdm::Size(size.width(), size.height()));
90 video_frame->SetFrameBuffer(TestCdmBuffer::Create(memory_needed)); 93 video_frame->SetFrameBuffer(TestCdmBuffer::Create(memory_needed));
91 video_frame->FrameBuffer()->SetSize(memory_needed); 94 video_frame->FrameBuffer()->SetSize(memory_needed);
92 95
93 // Now transform VideoFrameImpl to a VideoFrame, and make sure that 96 // Now transform VideoFrameImpl to a VideoFrame, and make sure that
94 // FrameBuffer() is transferred to the new object. 97 // FrameBuffer() is transferred to the new object.
95 EXPECT_NE(video_frame->FrameBuffer(), nullptr); 98 EXPECT_NE(video_frame->FrameBuffer(), nullptr);
96 scoped_refptr<media::VideoFrame> transformed_frame = 99 scoped_refptr<media::VideoFrame> transformed_frame =
97 video_frame->TransformToVideoFrame(size); 100 video_frame->TransformToVideoFrame(size);
98 EXPECT_EQ(video_frame->FrameBuffer(), nullptr); 101 EXPECT_EQ(video_frame->FrameBuffer(), nullptr);
99 102
100 // Releasing |transformed_frame| should free the cdm::Buffer created above 103 // Releasing |transformed_frame| should free the cdm::Buffer created above
101 // (verified by the mock method TestCdmBuffer::DestroyCalled). 104 // (verified by the mock method TestCdmBuffer::DestroyCalled).
102 transformed_frame = nullptr; 105 transformed_frame = nullptr;
103 } 106 }
104 107
105 } // namespace media 108 } // namespace media
OLDNEW
« no previous file with comments | « media/cdm/simple_cdm_allocator.cc ('k') | media/ffmpeg/ffmpeg_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698