| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/base/video_frame_pool.h" | 5 #include "media/base/video_frame_pool.h" |
| 6 #include "testing/gmock/include/gmock/gmock.h" | 6 #include "testing/gmock/include/gmock/gmock.h" |
| 7 | 7 |
| 8 namespace media { | 8 namespace media { |
| 9 | 9 |
| 10 class VideoFramePoolTest : public ::testing::Test { | 10 class VideoFramePoolTest : public ::testing::Test { |
| 11 public: | 11 public: |
| 12 VideoFramePoolTest() : pool_(new VideoFramePool()) {} | 12 VideoFramePoolTest() : pool_(new VideoFramePool()) {} |
| 13 | 13 |
| 14 scoped_refptr<VideoFrame> CreateFrame(VideoFrame::Format format, | 14 scoped_refptr<VideoFrame> CreateFrame(VideoFrame::Format format, |
| 15 int timestamp_ms) { | 15 int timestamp_ms) { |
| 16 gfx::Size coded_size(320,240); | 16 gfx::Size coded_size(320,240); |
| 17 gfx::Rect visible_rect(coded_size); | 17 gfx::Rect visible_rect(coded_size); |
| 18 gfx::Size natural_size(coded_size); | 18 gfx::Size natural_size(coded_size); |
| 19 | 19 |
| 20 scoped_refptr<VideoFrame> frame = | 20 scoped_refptr<VideoFrame> frame = |
| 21 pool_->CreateFrame( | 21 pool_->CreateFrame( |
| 22 format, coded_size, visible_rect, natural_size, | 22 format, coded_size, visible_rect, natural_size, |
| 23 base::TimeDelta::FromMilliseconds(timestamp_ms)); | 23 base::TimeDelta::FromMilliseconds(timestamp_ms)); |
| 24 EXPECT_EQ(format, frame->format()); | 24 EXPECT_EQ(format, frame->format()); |
| 25 EXPECT_EQ(base::TimeDelta::FromMilliseconds(timestamp_ms), | 25 EXPECT_EQ(base::TimeDelta::FromMilliseconds(timestamp_ms), |
| 26 frame->GetTimestamp()); | 26 frame->timestamp()); |
| 27 EXPECT_EQ(coded_size, frame->coded_size()); | 27 EXPECT_EQ(coded_size, frame->coded_size()); |
| 28 EXPECT_EQ(visible_rect, frame->visible_rect()); | 28 EXPECT_EQ(visible_rect, frame->visible_rect()); |
| 29 EXPECT_EQ(natural_size, frame->natural_size()); | 29 EXPECT_EQ(natural_size, frame->natural_size()); |
| 30 | 30 |
| 31 return frame; | 31 return frame; |
| 32 } | 32 } |
| 33 | 33 |
| 34 void CheckPoolSize(size_t size) const { | 34 void CheckPoolSize(size_t size) const { |
| 35 EXPECT_EQ(size, pool_->GetPoolSizeForTesting()); | 35 EXPECT_EQ(size, pool_->GetPoolSizeForTesting()); |
| 36 } | 36 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // Destroy the pool. | 74 // Destroy the pool. |
| 75 pool_.reset(); | 75 pool_.reset(); |
| 76 | 76 |
| 77 // Write to the Y plane. The memory tools should detect a | 77 // Write to the Y plane. The memory tools should detect a |
| 78 // use-after-free if the storage was actually removed by pool destruction. | 78 // use-after-free if the storage was actually removed by pool destruction. |
| 79 memset(frame->data(VideoFrame::kYPlane), 0xff, | 79 memset(frame->data(VideoFrame::kYPlane), 0xff, |
| 80 frame->rows(VideoFrame::kYPlane) * frame->stride(VideoFrame::kYPlane)); | 80 frame->rows(VideoFrame::kYPlane) * frame->stride(VideoFrame::kYPlane)); |
| 81 } | 81 } |
| 82 | 82 |
| 83 } // namespace media | 83 } // namespace media |
| OLD | NEW |