Index: webrtc/common_video/i420_video_frame_unittest.cc |
diff --git a/webrtc/common_video/i420_video_frame_unittest.cc b/webrtc/common_video/i420_video_frame_unittest.cc |
index 1ec451cb7971f8efff47eed9ac6bc4adb6f18d6b..bc58e5b3b942bf9c1feda2b325979a271da36739 100644 |
--- a/webrtc/common_video/i420_video_frame_unittest.cc |
+++ b/webrtc/common_video/i420_video_frame_unittest.cc |
@@ -15,15 +15,11 @@ |
#include "webrtc/base/bind.h" |
#include "webrtc/base/scoped_ptr.h" |
#include "webrtc/test/fake_texture_frame.h" |
+#include "webrtc/test/frame_utils.h" |
#include "webrtc/video_frame.h" |
namespace webrtc { |
-bool EqualPlane(const uint8_t* data1, |
- const uint8_t* data2, |
- int stride, |
- int width, |
- int height); |
int ExpectedSize(int plane_stride, int image_height, PlaneType type); |
TEST(TestVideoFrame, InitialValues) { |
@@ -41,7 +37,7 @@ TEST(TestVideoFrame, CopiesInitialFrameWithoutCrashing) { |
TEST(TestVideoFrame, WidthHeightValues) { |
VideoFrame frame; |
const int valid_value = 10; |
- EXPECT_EQ(0, frame.CreateEmptyFrame(10, 10, 10, 14, 90)); |
+ frame.CreateEmptyFrame(10, 10, 10, 14, 90); |
EXPECT_EQ(valid_value, frame.width()); |
EXPECT_EQ(valid_value, frame.height()); |
frame.set_timestamp(123u); |
@@ -54,7 +50,7 @@ TEST(TestVideoFrame, WidthHeightValues) { |
TEST(TestVideoFrame, SizeAllocation) { |
VideoFrame frame; |
- EXPECT_EQ(0, frame. CreateEmptyFrame(10, 10, 12, 14, 220)); |
+ frame. CreateEmptyFrame(10, 10, 12, 14, 220); |
int height = frame.height(); |
int stride_y = frame.stride(kYPlane); |
int stride_u = frame.stride(kUPlane); |
@@ -79,8 +75,8 @@ TEST(TestVideoFrame, CopyFrame) { |
int height = 15; |
// Copy frame. |
VideoFrame small_frame; |
- EXPECT_EQ(0, small_frame.CreateEmptyFrame(width, height, |
- stride_y, stride_u, stride_v)); |
+ small_frame.CreateEmptyFrame(width, height, |
+ stride_y, stride_u, stride_v); |
small_frame.set_timestamp(timestamp); |
small_frame.set_ntp_time_ms(ntp_time_ms); |
small_frame.set_render_time_ms(render_time_ms); |
@@ -95,23 +91,22 @@ TEST(TestVideoFrame, CopyFrame) { |
memset(buffer_u, 8, kSizeU); |
memset(buffer_v, 4, kSizeV); |
VideoFrame big_frame; |
- EXPECT_EQ(0, |
- big_frame.CreateFrame(buffer_y, buffer_u, buffer_v, |
- width + 5, height + 5, stride_y + 5, |
- stride_u, stride_v, kRotation)); |
+ big_frame.CreateFrame(buffer_y, buffer_u, buffer_v, |
+ width + 5, height + 5, stride_y + 5, |
+ stride_u, stride_v, kRotation); |
// Frame of smaller dimensions. |
- EXPECT_EQ(0, small_frame.CopyFrame(big_frame)); |
- EXPECT_TRUE(small_frame.EqualsFrame(big_frame)); |
+ small_frame.CopyFrame(big_frame); |
+ EXPECT_TRUE(test::FramesEqual(small_frame, big_frame)); |
EXPECT_EQ(kRotation, small_frame.rotation()); |
// Frame of larger dimensions. |
- EXPECT_EQ(0, small_frame.CreateEmptyFrame(width, height, |
- stride_y, stride_u, stride_v)); |
+ small_frame.CreateEmptyFrame(width, height, |
+ stride_y, stride_u, stride_v); |
memset(small_frame.buffer(kYPlane), 1, small_frame.allocated_size(kYPlane)); |
memset(small_frame.buffer(kUPlane), 2, small_frame.allocated_size(kUPlane)); |
memset(small_frame.buffer(kVPlane), 3, small_frame.allocated_size(kVPlane)); |
- EXPECT_EQ(0, big_frame.CopyFrame(small_frame)); |
- EXPECT_TRUE(small_frame.EqualsFrame(big_frame)); |
+ big_frame.CopyFrame(small_frame); |
+ EXPECT_TRUE(test::FramesEqual(small_frame, big_frame)); |
} |
TEST(TestVideoFrame, ShallowCopy) { |
@@ -135,8 +130,8 @@ TEST(TestVideoFrame, ShallowCopy) { |
memset(buffer_u, 8, kSizeU); |
memset(buffer_v, 4, kSizeV); |
VideoFrame frame1; |
- EXPECT_EQ(0, frame1.CreateFrame(buffer_y, buffer_u, buffer_v, width, height, |
- stride_y, stride_u, stride_v, kRotation)); |
+ frame1.CreateFrame(buffer_y, buffer_u, buffer_v, width, height, |
+ stride_y, stride_u, stride_v, kRotation); |
frame1.set_timestamp(timestamp); |
frame1.set_ntp_time_ms(ntp_time_ms); |
frame1.set_render_time_ms(render_time_ms); |
@@ -172,7 +167,7 @@ TEST(TestVideoFrame, ShallowCopy) { |
TEST(TestVideoFrame, Reset) { |
VideoFrame frame; |
- ASSERT_EQ(frame.CreateEmptyFrame(5, 5, 5, 5, 5), 0); |
+ frame.CreateEmptyFrame(5, 5, 5, 5, 5); |
frame.set_ntp_time_ms(1); |
frame.set_timestamp(2); |
frame.set_render_time_ms(3); |
@@ -193,8 +188,8 @@ TEST(TestVideoFrame, CopyBuffer) { |
int stride_uv = 10; |
const int kSizeY = 225; |
const int kSizeUv = 80; |
- EXPECT_EQ(0, frame2.CreateEmptyFrame(width, height, |
- stride_y, stride_uv, stride_uv)); |
+ frame2.CreateEmptyFrame(width, height, |
+ stride_y, stride_uv, stride_uv); |
uint8_t buffer_y[kSizeY]; |
uint8_t buffer_u[kSizeUv]; |
uint8_t buffer_v[kSizeUv]; |
@@ -202,11 +197,15 @@ TEST(TestVideoFrame, CopyBuffer) { |
memset(buffer_u, 8, kSizeUv); |
memset(buffer_v, 4, kSizeUv); |
frame2.CreateFrame(buffer_y, buffer_u, buffer_v, |
- width, height, stride_y, stride_uv, stride_uv); |
+ width, height, stride_y, stride_uv, stride_uv, |
+ kVideoRotation_0); |
// Expect exactly the same pixel data. |
- EXPECT_TRUE(EqualPlane(buffer_y, frame2.buffer(kYPlane), stride_y, 15, 15)); |
- EXPECT_TRUE(EqualPlane(buffer_u, frame2.buffer(kUPlane), stride_uv, 8, 8)); |
- EXPECT_TRUE(EqualPlane(buffer_v, frame2.buffer(kVPlane), stride_uv, 8, 8)); |
+ EXPECT_TRUE( |
+ test::EqualPlane(buffer_y, frame2.buffer(kYPlane), stride_y, 15, 15)); |
+ EXPECT_TRUE( |
+ test::EqualPlane(buffer_u, frame2.buffer(kUPlane), stride_uv, 8, 8)); |
+ EXPECT_TRUE( |
+ test::EqualPlane(buffer_v, frame2.buffer(kVPlane), stride_uv, 8, 8)); |
// Compare size. |
EXPECT_LE(kSizeY, frame2.allocated_size(kYPlane)); |