summaryrefslogtreecommitdiffstats
path: root/media/base/video_frame_impl_unittest.cc
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-10 20:47:51 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-10 20:47:51 +0000
commitba650a35365f11389eebe5b5325d1ad0e9a69b8e (patch)
tree80089187df282aec574b927ca720449b4bff15a0 /media/base/video_frame_impl_unittest.cc
parentfe9d5d06dd4acbd1df3f828207d7ebfa1a245279 (diff)
downloadchromium_src-ba650a35365f11389eebe5b5325d1ad0e9a69b8e.zip
chromium_src-ba650a35365f11389eebe5b5325d1ad0e9a69b8e.tar.gz
chromium_src-ba650a35365f11389eebe5b5325d1ad0e9a69b8e.tar.bz2
Converted remaining tests to use gmock and deleted all old mocking code.
The most important part was refactoring PipelineImpl tests in preparation for message loop injection. The old mocks just did not work *at all* with my message loop injection patch. BUG=16008 TEST=media_unittests should pass and not flake out Review URL: http://codereview.chromium.org/149423 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20412 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/video_frame_impl_unittest.cc')
-rw-r--r--media/base/video_frame_impl_unittest.cc50
1 files changed, 37 insertions, 13 deletions
diff --git a/media/base/video_frame_impl_unittest.cc b/media/base/video_frame_impl_unittest.cc
index a6a1a6a..eeec716 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