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

Side by Side Diff: media/mojo/services/mojo_cdm_allocator_unittest.cc

Issue 2069043003: (reland) media: Enable media_mojo_unittests on bots (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: drop test on windows (gyp) bots Created 4 years, 6 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/mojo/BUILD.gn ('k') | testing/buildbot/chromium.fyi.json » ('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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <cstring> 8 #include <cstring>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // the number of free buffers will be capped at |kMaxExpectedFreeBuffers|. 78 // the number of free buffers will be capped at |kMaxExpectedFreeBuffers|.
79 for (int i = 0; i < 10; ++i) { 79 for (int i = 0; i < 10; ++i) {
80 buffer_size += kBufferSizeIncrease; 80 buffer_size += kBufferSizeIncrease;
81 cdm::Buffer* buffer = CreateCdmBuffer(buffer_size); 81 cdm::Buffer* buffer = CreateCdmBuffer(buffer_size);
82 buffer->Destroy(); 82 buffer->Destroy();
83 EXPECT_LE(GetAvailableBufferCount(), kMaxExpectedFreeBuffers); 83 EXPECT_LE(GetAvailableBufferCount(), kMaxExpectedFreeBuffers);
84 } 84 }
85 } 85 }
86 86
87 TEST_F(MojoCdmAllocatorTest, CreateCdmVideoFrame) { 87 TEST_F(MojoCdmAllocatorTest, CreateCdmVideoFrame) {
88 const size_t kHeight = 16; 88 const int kHeight = 16;
89 const size_t kWidth = 9; 89 const int kWidth = 9;
90 const VideoPixelFormat kFormat = PIXEL_FORMAT_I420; 90 const VideoPixelFormat kFormat = PIXEL_FORMAT_I420;
91 const gfx::Size kSize(kHeight, kWidth); 91 const gfx::Size kSize(kHeight, kWidth);
92 const size_t kBufferSize = VideoFrame::AllocationSize(kFormat, kSize); 92 const size_t kBufferSize = VideoFrame::AllocationSize(kFormat, kSize);
93 93
94 // Create a VideoFrameImpl and initialize it. 94 // Create a VideoFrameImpl and initialize it.
95 std::unique_ptr<VideoFrameImpl> video_frame = CreateCdmVideoFrame(); 95 std::unique_ptr<VideoFrameImpl> video_frame = CreateCdmVideoFrame();
96 video_frame->SetFormat(cdm::kI420); 96 video_frame->SetFormat(cdm::kI420);
97 video_frame->SetSize(cdm::Size(kHeight, kWidth)); 97 video_frame->SetSize(cdm::Size(kHeight, kWidth));
98 video_frame->SetStride( 98 video_frame->SetStride(VideoFrameImpl::kYPlane,
99 VideoFrameImpl::kYPlane, 99 static_cast<uint32_t>(VideoFrame::RowBytes(
100 VideoFrame::RowBytes(VideoFrame::kYPlane, kFormat, kWidth)); 100 VideoFrame::kYPlane, kFormat, kWidth)));
101 video_frame->SetStride( 101 video_frame->SetStride(VideoFrameImpl::kUPlane,
102 VideoFrameImpl::kUPlane, 102 static_cast<uint32_t>(VideoFrame::RowBytes(
103 VideoFrame::RowBytes(VideoFrame::kUPlane, kFormat, kWidth)); 103 VideoFrame::kUPlane, kFormat, kWidth)));
104 video_frame->SetStride( 104 video_frame->SetStride(VideoFrameImpl::kVPlane,
105 VideoFrameImpl::kVPlane, 105 static_cast<uint32_t>(VideoFrame::RowBytes(
106 VideoFrame::RowBytes(VideoFrame::kVPlane, kFormat, kWidth)); 106 VideoFrame::kVPlane, kFormat, kWidth)));
107 EXPECT_EQ(nullptr, video_frame->FrameBuffer()); 107 EXPECT_EQ(nullptr, video_frame->FrameBuffer());
108 108
109 // Now create a buffer to hold the frame and assign it to the VideoFrameImpl. 109 // Now create a buffer to hold the frame and assign it to the VideoFrameImpl.
110 cdm::Buffer* buffer = CreateCdmBuffer(kBufferSize); 110 cdm::Buffer* buffer = CreateCdmBuffer(kBufferSize);
111 EXPECT_EQ(0u, GetAvailableBufferCount()); 111 EXPECT_EQ(0u, GetAvailableBufferCount());
112 buffer->SetSize(kBufferSize); 112 buffer->SetSize(static_cast<uint32_t>(kBufferSize));
113 video_frame->SetFrameBuffer(buffer); 113 video_frame->SetFrameBuffer(buffer);
114 EXPECT_NE(nullptr, video_frame->FrameBuffer()); 114 EXPECT_NE(nullptr, video_frame->FrameBuffer());
115 115
116 // Transform it into a VideoFrame and make sure the buffer is no longer owned. 116 // Transform it into a VideoFrame and make sure the buffer is no longer owned.
117 scoped_refptr<VideoFrame> frame = video_frame->TransformToVideoFrame(kSize); 117 scoped_refptr<VideoFrame> frame = video_frame->TransformToVideoFrame(kSize);
118 EXPECT_EQ(nullptr, video_frame->FrameBuffer()); 118 EXPECT_EQ(nullptr, video_frame->FrameBuffer());
119 EXPECT_EQ(0u, GetAvailableBufferCount()); 119 EXPECT_EQ(0u, GetAvailableBufferCount());
120 video_frame.reset(); 120 video_frame.reset();
121 121
122 // Check that the buffer is still in use. It will be freed when |frame| 122 // Check that the buffer is still in use. It will be freed when |frame|
123 // is destroyed. 123 // is destroyed.
124 EXPECT_EQ(0u, GetAvailableBufferCount()); 124 EXPECT_EQ(0u, GetAvailableBufferCount());
125 frame = nullptr; 125 frame = nullptr;
126 126
127 // Check that the buffer is now in the free list. 127 // Check that the buffer is now in the free list.
128 EXPECT_EQ(1u, GetAvailableBufferCount()); 128 EXPECT_EQ(1u, GetAvailableBufferCount());
129 } 129 }
130 130
131 } // namespace media 131 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/BUILD.gn ('k') | testing/buildbot/chromium.fyi.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698