| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 using ::testing::_; | 23 using ::testing::_; |
| 24 using ::testing::AtLeast; | 24 using ::testing::AtLeast; |
| 25 using ::testing::Return; | 25 using ::testing::Return; |
| 26 | 26 |
| 27 namespace webrtc { | 27 namespace webrtc { |
| 28 namespace test { | 28 namespace test { |
| 29 | 29 |
| 30 // Very basic testing for VideoProcessor. It's mostly tested by running the | 30 // Very basic testing for VideoProcessor. It's mostly tested by running the |
| 31 // video_quality_measurement program. | 31 // video_quality_measurement program. |
| 32 class VideoProcessorTest: public testing::Test { | 32 class VideoProcessorTest : public testing::Test { |
| 33 protected: | 33 protected: |
| 34 MockVideoEncoder encoder_mock_; | 34 MockVideoEncoder encoder_mock_; |
| 35 MockVideoDecoder decoder_mock_; | 35 MockVideoDecoder decoder_mock_; |
| 36 MockFrameReader frame_reader_mock_; | 36 MockFrameReader frame_reader_mock_; |
| 37 MockFrameWriter frame_writer_mock_; | 37 MockFrameWriter frame_writer_mock_; |
| 38 MockPacketManipulator packet_manipulator_mock_; | 38 MockPacketManipulator packet_manipulator_mock_; |
| 39 Stats stats_; | 39 Stats stats_; |
| 40 TestConfig config_; | 40 TestConfig config_; |
| 41 VideoCodec codec_settings_; | 41 VideoCodec codec_settings_; |
| 42 | 42 |
| 43 VideoProcessorTest() {} | 43 VideoProcessorTest() {} |
| 44 virtual ~VideoProcessorTest() {} | 44 virtual ~VideoProcessorTest() {} |
| 45 void SetUp() { | 45 void SetUp() { |
| 46 // Get a codec configuration struct and configure it. | 46 // Get a codec configuration struct and configure it. |
| 47 VideoCodingModule::Codec(kVideoCodecVP8, &codec_settings_); | 47 VideoCodingModule::Codec(kVideoCodecVP8, &codec_settings_); |
| 48 config_.codec_settings = &codec_settings_; | 48 config_.codec_settings = &codec_settings_; |
| 49 config_.codec_settings->startBitrate = 100; | 49 config_.codec_settings->startBitrate = 100; |
| 50 config_.codec_settings->width = 352; | 50 config_.codec_settings->width = 352; |
| 51 config_.codec_settings->height = 288; | 51 config_.codec_settings->height = 288; |
| 52 } | 52 } |
| 53 void TearDown() {} | 53 void TearDown() {} |
| 54 | 54 |
| 55 void ExpectInit() { | 55 void ExpectInit() { |
| 56 EXPECT_CALL(encoder_mock_, InitEncode(_, _, _)) | 56 EXPECT_CALL(encoder_mock_, InitEncode(_, _, _)).Times(1); |
| 57 .Times(1); | |
| 58 EXPECT_CALL(encoder_mock_, RegisterEncodeCompleteCallback(_)) | 57 EXPECT_CALL(encoder_mock_, RegisterEncodeCompleteCallback(_)) |
| 59 .Times(AtLeast(1)); | 58 .Times(AtLeast(1)); |
| 60 EXPECT_CALL(decoder_mock_, InitDecode(_, _)) | 59 EXPECT_CALL(decoder_mock_, InitDecode(_, _)).Times(1); |
| 61 .Times(1); | |
| 62 EXPECT_CALL(decoder_mock_, RegisterDecodeCompleteCallback(_)) | 60 EXPECT_CALL(decoder_mock_, RegisterDecodeCompleteCallback(_)) |
| 63 .Times(AtLeast(1)); | 61 .Times(AtLeast(1)); |
| 64 EXPECT_CALL(frame_reader_mock_, NumberOfFrames()) | 62 EXPECT_CALL(frame_reader_mock_, NumberOfFrames()).WillOnce(Return(1)); |
| 65 .WillOnce(Return(1)); | 63 EXPECT_CALL(frame_reader_mock_, FrameLength()).WillOnce(Return(152064)); |
| 66 EXPECT_CALL(frame_reader_mock_, FrameLength()) | |
| 67 .WillOnce(Return(152064)); | |
| 68 } | 64 } |
| 69 }; | 65 }; |
| 70 | 66 |
| 71 TEST_F(VideoProcessorTest, Init) { | 67 TEST_F(VideoProcessorTest, Init) { |
| 72 ExpectInit(); | 68 ExpectInit(); |
| 73 VideoProcessorImpl video_processor(&encoder_mock_, &decoder_mock_, | 69 VideoProcessorImpl video_processor( |
| 74 &frame_reader_mock_, | 70 &encoder_mock_, &decoder_mock_, &frame_reader_mock_, &frame_writer_mock_, |
| 75 &frame_writer_mock_, | 71 &packet_manipulator_mock_, config_, &stats_); |
| 76 &packet_manipulator_mock_, config_, | |
| 77 &stats_); | |
| 78 ASSERT_TRUE(video_processor.Init()); | 72 ASSERT_TRUE(video_processor.Init()); |
| 79 } | 73 } |
| 80 | 74 |
| 81 TEST_F(VideoProcessorTest, ProcessFrame) { | 75 TEST_F(VideoProcessorTest, ProcessFrame) { |
| 82 ExpectInit(); | 76 ExpectInit(); |
| 83 EXPECT_CALL(encoder_mock_, Encode(_, _, _)) | 77 EXPECT_CALL(encoder_mock_, Encode(_, _, _)).Times(1); |
| 84 .Times(1); | 78 EXPECT_CALL(frame_reader_mock_, ReadFrame(_)).WillOnce(Return(true)); |
| 85 EXPECT_CALL(frame_reader_mock_, ReadFrame(_)) | |
| 86 .WillOnce(Return(true)); | |
| 87 // Since we don't return any callback from the mock, the decoder will not | 79 // Since we don't return any callback from the mock, the decoder will not |
| 88 // be more than initialized... | 80 // be more than initialized... |
| 89 VideoProcessorImpl video_processor(&encoder_mock_, &decoder_mock_, | 81 VideoProcessorImpl video_processor( |
| 90 &frame_reader_mock_, | 82 &encoder_mock_, &decoder_mock_, &frame_reader_mock_, &frame_writer_mock_, |
| 91 &frame_writer_mock_, | 83 &packet_manipulator_mock_, config_, &stats_); |
| 92 &packet_manipulator_mock_, config_, | |
| 93 &stats_); | |
| 94 ASSERT_TRUE(video_processor.Init()); | 84 ASSERT_TRUE(video_processor.Init()); |
| 95 video_processor.ProcessFrame(0); | 85 video_processor.ProcessFrame(0); |
| 96 } | 86 } |
| 97 | 87 |
| 98 } // namespace test | 88 } // namespace test |
| 99 } // namespace webrtc | 89 } // namespace webrtc |
| OLD | NEW |