@@ -84,6 +84,12 @@ TEST(TestVideoFrame, InitialValues) {
8484 EXPECT_EQ (kVideoRotation_0 , frame.rotation ());
8585}
8686
87+ TEST (TestVideoFrame, CopiesInitialFrameWithoutCrashing) {
88+ VideoFrame frame;
89+ VideoFrame frame2;
90+ frame2.CopyFrame (frame);
91+ }
92+
8793TEST (TestVideoFrame, WidthHeightValues) {
8894 VideoFrame frame (I420Buffer::Create (10 , 10 , 10 , 14 , 90 ),
8995 webrtc::kVideoRotation_0 ,
@@ -98,6 +104,44 @@ TEST(TestVideoFrame, WidthHeightValues) {
98104 EXPECT_EQ (789 , frame.render_time_ms ());
99105}
100106
107+ TEST (TestVideoFrame, CopyFrame) {
108+ int stride_y = 15 ;
109+ int stride_u = 10 ;
110+ int stride_v = 10 ;
111+ int width = 15 ;
112+ int height = 15 ;
113+ // Copy frame.
114+ VideoFrame small_frame;
115+ const int kSizeY = 400 ;
116+ const int kSizeU = 100 ;
117+ const int kSizeV = 100 ;
118+ const VideoRotation kRotation = kVideoRotation_270 ;
119+ uint8_t buffer_y[kSizeY ];
120+ uint8_t buffer_u[kSizeU ];
121+ uint8_t buffer_v[kSizeV ];
122+ memset (buffer_y, 16 , kSizeY );
123+ memset (buffer_u, 8 , kSizeU );
124+ memset (buffer_v, 4 , kSizeV );
125+ VideoFrame big_frame;
126+ big_frame.CreateFrame (buffer_y, buffer_u, buffer_v,
127+ width + 5 , height + 5 , stride_y + 5 ,
128+ stride_u, stride_v, kRotation );
129+ // Frame of smaller dimensions.
130+ small_frame.CopyFrame (big_frame);
131+ EXPECT_TRUE (test::FramesEqual (small_frame, big_frame));
132+ EXPECT_EQ (kRotation , small_frame.rotation ());
133+
134+ // Frame of larger dimensions.
135+ rtc::scoped_refptr<I420Buffer> buffer =
136+ I420Buffer::Create (width, height, stride_y, stride_u, stride_v);
137+ memset (buffer->MutableDataY (), 1 , width * height);
138+ memset (buffer->MutableDataU (), 2 , ((height + 1 ) / 2 ) * stride_u);
139+ memset (buffer->MutableDataV (), 3 , ((height + 1 ) / 2 ) * stride_u);
140+ VideoFrame other_frame (buffer, 0 , 0 , webrtc::kVideoRotation_0 );
141+ big_frame.CopyFrame (other_frame);
142+ EXPECT_TRUE (test::FramesEqual (other_frame, big_frame));
143+ }
144+
101145TEST (TestVideoFrame, ShallowCopy) {
102146 uint32_t timestamp = 1 ;
103147 int64_t ntp_time_ms = 2 ;
0 commit comments