| Index: media/base/video_frame_impl_unittest.cc
|
| diff --git a/media/base/video_frame_impl_unittest.cc b/media/base/video_frame_impl_unittest.cc
|
| index a6a1a6acf1626af5b4d9e164b48b14657b2f4937..eeec716fc871d3767f9cb17a59b6969ac347d0e1 100644
|
| --- a/media/base/video_frame_impl_unittest.cc
|
| +++ b/media/base/video_frame_impl_unittest.cc
|
| @@ -3,15 +3,40 @@
|
| // found in the LICENSE file.
|
|
|
| #include "media/base/buffers.h"
|
| -#include "media/base/mock_media_filters.h"
|
| +#include "media/base/mock_filters.h"
|
| #include "media/base/video_frame_impl.h"
|
| #include "media/base/yuv_convert.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| -using media::VideoFrameImpl;
|
| -using media::VideoSurface;
|
| +namespace media {
|
|
|
| -namespace {
|
| +// Helper function that initializes a YV12 frame with white and black scan
|
| +// lines based on the |white_to_black| parameter. If 0, then the entire
|
| +// frame will be black, if 1 then the entire frame will be white.
|
| +void InitializeYV12Frame(VideoFrame* frame, double white_to_black) {
|
| + VideoSurface surface;
|
| + if (!frame->Lock(&surface)) {
|
| + ADD_FAILURE();
|
| + return;
|
| + }
|
| + EXPECT_EQ(surface.format, VideoSurface::YV12);
|
| + size_t first_black_row = static_cast<size_t>(surface.height * white_to_black);
|
| + uint8* y_plane = surface.data[VideoSurface::kYPlane];
|
| + for (size_t row = 0; row < surface.height; ++row) {
|
| + int color = (row < first_black_row) ? 0xFF : 0x00;
|
| + memset(y_plane, color, surface.width);
|
| + y_plane += surface.strides[VideoSurface::kYPlane];
|
| + }
|
| + uint8* u_plane = surface.data[VideoSurface::kUPlane];
|
| + uint8* v_plane = surface.data[VideoSurface::kVPlane];
|
| + for (size_t row = 0; row < surface.height; row += 2) {
|
| + memset(u_plane, 0x80, surface.width / 2);
|
| + memset(v_plane, 0x80, surface.width / 2);
|
| + u_plane += surface.strides[VideoSurface::kUPlane];
|
| + v_plane += surface.strides[VideoSurface::kVPlane];
|
| + }
|
| + frame->Unlock();
|
| +}
|
|
|
| // Given a |yv12_frame| this method converts the YV12 frame to RGBA and
|
| // makes sure that all the pixels of the RBG frame equal |expect_rgb_color|.
|
| @@ -65,10 +90,7 @@ void ExpectFrameColor(media::VideoFrame* yv12_frame, uint32 expect_rgb_color) {
|
| yv12_frame->Unlock();
|
| }
|
|
|
| -} // namespace
|
| -
|
| -
|
| -TEST(VideoFrameImpl, Basic) {
|
| +TEST(VideoFrameImpl, CreateFrame) {
|
| const size_t kWidth = 64;
|
| const size_t kHeight = 48;
|
| const base::TimeDelta kTimestampA = base::TimeDelta::FromMicroseconds(1337);
|
| @@ -78,8 +100,8 @@ TEST(VideoFrameImpl, Basic) {
|
|
|
| // Create a YV12 Video Frame.
|
| scoped_refptr<media::VideoFrame> frame;
|
| - media::VideoFrameImpl::CreateFrame(media::VideoSurface::YV12, kWidth, kHeight,
|
| - kTimestampA, kDurationA, &frame);
|
| + VideoFrameImpl::CreateFrame(media::VideoSurface::YV12, kWidth, kHeight,
|
| + kTimestampA, kDurationA, &frame);
|
| ASSERT_TRUE(frame);
|
|
|
| // Test StreamSample implementation.
|
| @@ -98,12 +120,14 @@ TEST(VideoFrameImpl, Basic) {
|
| EXPECT_FALSE(frame->IsDiscontinuous());
|
|
|
| // Test VideoFrame implementation.
|
| - media::old_mocks::MockVideoDecoder::InitializeYV12Frame(frame, 0.0f);
|
| + InitializeYV12Frame(frame, 0.0f);
|
| ExpectFrameColor(frame, 0xFF000000);
|
| - media::old_mocks::MockVideoDecoder::InitializeYV12Frame(frame, 1.0f);
|
| + InitializeYV12Frame(frame, 1.0f);
|
| ExpectFrameColor(frame, 0xFFFFFFFF);
|
|
|
| // Test an empty frame.
|
| - media::VideoFrameImpl::CreateEmptyFrame(&frame);
|
| + VideoFrameImpl::CreateEmptyFrame(&frame);
|
| EXPECT_TRUE(frame->IsEndOfStream());
|
| }
|
| +
|
| +} // namespace media
|
|
|