| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/location.h" | 6 #include "base/location.h" |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 MOCK_METHOD4(OnEncodedVideo, | 75 MOCK_METHOD4(OnEncodedVideo, |
| 76 void(const scoped_refptr<media::VideoFrame>& frame, | 76 void(const scoped_refptr<media::VideoFrame>& frame, |
| 77 const base::StringPiece& encoded_data, | 77 const base::StringPiece& encoded_data, |
| 78 base::TimeTicks timestamp, | 78 base::TimeTicks timestamp, |
| 79 bool keyframe)); | 79 bool keyframe)); |
| 80 | 80 |
| 81 void Encode(const scoped_refptr<media::VideoFrame>& frame, | 81 void Encode(const scoped_refptr<media::VideoFrame>& frame, |
| 82 base::TimeTicks capture_time) { | 82 base::TimeTicks capture_time) { |
| 83 EXPECT_TRUE(message_loop_.IsCurrent()); | 83 EXPECT_TRUE(message_loop_.IsCurrent()); |
| 84 video_track_recorder_->OnVideoFrame(frame, capture_time); | 84 video_track_recorder_->OnVideoFrameForTesting(frame, capture_time); |
| 85 } | 85 } |
| 86 | 86 |
| 87 // A ChildProcess and a MessageLoopForUI are both needed to fool the Tracks | 87 // A ChildProcess and a MessageLoopForUI are both needed to fool the Tracks |
| 88 // and Sources below into believing they are on the right threads. | 88 // and Sources below into believing they are on the right threads. |
| 89 const base::MessageLoopForUI message_loop_; | 89 const base::MessageLoopForUI message_loop_; |
| 90 ChildProcess child_process_; | 90 const ChildProcess child_process_; |
| 91 | 91 |
| 92 // All members are non-const due to the series of initialize() calls needed. | 92 // All members are non-const due to the series of initialize() calls needed. |
| 93 // |mock_source_| is owned by |blink_source_|, |track_| by |blink_track_|. | 93 // |mock_source_| is owned by |blink_source_|, |track_| by |blink_track_|. |
| 94 MockMediaStreamVideoSource* mock_source_; | 94 MockMediaStreamVideoSource* mock_source_; |
| 95 blink::WebMediaStreamSource blink_source_; | 95 blink::WebMediaStreamSource blink_source_; |
| 96 MediaStreamVideoTrack* track_; | 96 MediaStreamVideoTrack* track_; |
| 97 blink::WebMediaStreamTrack blink_track_; | 97 blink::WebMediaStreamTrack blink_track_; |
| 98 | 98 |
| 99 scoped_ptr<VideoTrackRecorder> video_track_recorder_; | 99 scoped_ptr<VideoTrackRecorder> video_track_recorder_; |
| 100 | 100 |
| 101 private: | 101 private: |
| 102 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorderTest); | 102 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorderTest); |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 // Construct and destruct all objects, in particular |video_track_recorder_| and |
| 106 // its inner object(s). This is a non trivial sequence. |
| 107 TEST_F(VideoTrackRecorderTest, ConstructAndDestruct) {} |
| 108 |
| 105 // Creates the encoder and encodes 2 frames of the same size; the encoder should | 109 // Creates the encoder and encodes 2 frames of the same size; the encoder should |
| 106 // be initialised and produce a keyframe, then a non-keyframe. Finally a frame | 110 // be initialised and produce a keyframe, then a non-keyframe. Finally a frame |
| 107 // of larger size is sent and is expected to be encoded as a keyframe. | 111 // of larger size is sent and is expected to be encoded as a keyframe. |
| 108 TEST_F(VideoTrackRecorderTest, VideoEncoding) { | 112 TEST_F(VideoTrackRecorderTest, VideoEncoding) { |
| 109 // |frame_size| cannot be arbitrarily small, should be reasonable. | 113 // |frame_size| cannot be arbitrarily small, should be reasonable. |
| 110 const gfx::Size frame_size(160, 80); | 114 const gfx::Size frame_size(160, 80); |
| 111 const scoped_refptr<media::VideoFrame> video_frame = | 115 const scoped_refptr<media::VideoFrame> video_frame = |
| 112 media::VideoFrame::CreateBlackFrame(frame_size); | 116 media::VideoFrame::CreateBlackFrame(frame_size); |
| 113 const double kFrameRate = 60.0f; | 117 const double kFrameRate = 60.0f; |
| 114 video_frame->metadata()->SetDouble(media::VideoFrameMetadata::FRAME_RATE, | 118 video_frame->metadata()->SetDouble(media::VideoFrameMetadata::FRAME_RATE, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 EXPECT_EQ(first_frame_encoded_data.size(), kFirstEncodedDataSize); | 155 EXPECT_EQ(first_frame_encoded_data.size(), kFirstEncodedDataSize); |
| 152 const size_t kSecondEncodedDataSize = 32; | 156 const size_t kSecondEncodedDataSize = 32; |
| 153 EXPECT_EQ(second_frame_encoded_data.size(), kSecondEncodedDataSize); | 157 EXPECT_EQ(second_frame_encoded_data.size(), kSecondEncodedDataSize); |
| 154 const size_t kThirdEncodedDataSize = 57; | 158 const size_t kThirdEncodedDataSize = 57; |
| 155 EXPECT_EQ(third_frame_encoded_data.size(), kThirdEncodedDataSize); | 159 EXPECT_EQ(third_frame_encoded_data.size(), kThirdEncodedDataSize); |
| 156 | 160 |
| 157 Mock::VerifyAndClearExpectations(this); | 161 Mock::VerifyAndClearExpectations(this); |
| 158 } | 162 } |
| 159 | 163 |
| 160 } // namespace content | 164 } // namespace content |
| OLD | NEW |