Index: media/capture/webm_muxer_unittest.cc |
diff --git a/media/capture/webm_muxer_unittest.cc b/media/capture/webm_muxer_unittest.cc |
index 7e162fa0a676b0422cb17b88956486dd6de22e7c..0df1db81712b85432c1a2a30f9b51993b8725675 100644 |
--- a/media/capture/webm_muxer_unittest.cc |
+++ b/media/capture/webm_muxer_unittest.cc |
@@ -79,14 +79,63 @@ TEST_F(WebmMuxerTest, OnEncodedVideoTwoFrames) { |
VideoFrame::CreateBlackFrame(frame_size); |
const std::string encoded_data("abcdefghijklmnopqrstuvwxyz"); |
+ WebmMuxer::EncodedVideoCB encoded_video_cb = |
+ webm_muxer_.GenerateOnEncodedVideoCallback(); |
+ |
+ EXPECT_CALL(*this, WriteCallback(_)) |
+ .Times(AtLeast(1)) |
+ .WillRepeatedly(WithArgs<0>( |
+ Invoke(this, &WebmMuxerTest::SaveEncodedDataLen))); |
+ |
+ encoded_video_cb.Run(video_frame, |
+ make_scoped_ptr(new std::string(encoded_data)), |
+ base::TimeTicks::Now(), |
+ false /* keyframe */); |
+ |
+ // First time around WriteCallback() is pinged a number of times to write the |
+ // Matroska header, but at the end it dumps |encoded_data|. |
+ EXPECT_EQ(last_encoded_length_, encoded_data.size()); |
+ EXPECT_EQ(GetWebmMuxerPosition(), accumulated_position_); |
+ EXPECT_GE(GetWebmMuxerPosition(), static_cast<int64_t>(last_encoded_length_)); |
+ EXPECT_EQ(GetWebmSegmentMode(), mkvmuxer::Segment::kLive); |
+ |
+ const int64_t begin_of_second_block = accumulated_position_; |
+ EXPECT_CALL(*this, WriteCallback(_)) |
+ .Times(AtLeast(1)) |
+ .WillRepeatedly(WithArgs<0>( |
+ Invoke(this, &WebmMuxerTest::SaveEncodedDataLen))); |
+ encoded_video_cb.Run(video_frame, |
+ make_scoped_ptr(new std::string(encoded_data)), |
+ base::TimeTicks::Now(), |
+ false /* keyframe */); |
+ |
+ // The second time around the callbacks should include a SimpleBlock header, |
+ // namely the track index, a timestamp and a flags byte, for a total of 6B. |
+ EXPECT_EQ(last_encoded_length_, encoded_data.size()); |
+ EXPECT_EQ(GetWebmMuxerPosition(), accumulated_position_); |
+ const uint32_t kSimpleBlockSize = 6u; |
+ EXPECT_EQ(static_cast<int64_t>(begin_of_second_block + kSimpleBlockSize + |
+ encoded_data.size()), |
+ accumulated_position_); |
+} |
+ |
+TEST_F(WebmMuxerTest, OnEncodedVideoTwoTracks) { |
+ const gfx::Size frame_size(160, 80); |
+ const scoped_refptr<VideoFrame> video_frame = |
+ VideoFrame::CreateBlackFrame(frame_size); |
+ const std::string encoded_data("abcdefghijklmnopqrstuvwxyz"); |
+ WebmMuxer::EncodedVideoCB encoded_video_cb_1 = |
+ webm_muxer_.GenerateOnEncodedVideoCallback(); |
+ WebmMuxer::EncodedVideoCB encoded_video_cb_2 = |
+ webm_muxer_.GenerateOnEncodedVideoCallback(); |
EXPECT_CALL(*this, WriteCallback(_)) |
.Times(AtLeast(1)) |
.WillRepeatedly(WithArgs<0>( |
Invoke(this, &WebmMuxerTest::SaveEncodedDataLen))); |
- webm_muxer_.OnEncodedVideo(video_frame, |
- make_scoped_ptr(new std::string(encoded_data)), |
- base::TimeTicks::Now(), |
- false /* keyframe */); |
+ encoded_video_cb_1.Run(video_frame, |
+ make_scoped_ptr(new std::string(encoded_data)), |
+ base::TimeTicks::Now(), |
+ false /* keyframe */); |
// First time around WriteCallback() is pinged a number of times to write the |
// Matroska header, but at the end it dumps |encoded_data|. |
@@ -100,10 +149,10 @@ TEST_F(WebmMuxerTest, OnEncodedVideoTwoFrames) { |
.Times(AtLeast(1)) |
.WillRepeatedly(WithArgs<0>( |
Invoke(this, &WebmMuxerTest::SaveEncodedDataLen))); |
- webm_muxer_.OnEncodedVideo(video_frame, |
- make_scoped_ptr(new std::string(encoded_data)), |
- base::TimeTicks::Now(), |
- false /* keyframe */); |
+ encoded_video_cb_2.Run(video_frame, |
+ make_scoped_ptr(new std::string(encoded_data)), |
+ base::TimeTicks::Now(), |
+ false /* keyframe */); |
// The second time around the callbacks should include a SimpleBlock header, |
// namely the track index, a timestamp and a flags byte, for a total of 6B. |