Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: webrtc/modules/video_coding/codecs/test/videoprocessor_unittest.cc

Issue 2741953002: Step #4: Run VideoProcessor integration test batch mode on task queue. (Closed)
Patch Set: Fix gn again. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10 matching lines...) Expand all
21 #include "webrtc/test/testsupport/unittest_utils.h" 21 #include "webrtc/test/testsupport/unittest_utils.h"
22 #include "webrtc/typedefs.h" 22 #include "webrtc/typedefs.h"
23 23
24 using ::testing::_; 24 using ::testing::_;
25 using ::testing::AtLeast; 25 using ::testing::AtLeast;
26 using ::testing::Return; 26 using ::testing::Return;
27 27
28 namespace webrtc { 28 namespace webrtc {
29 namespace test { 29 namespace test {
30 30
31 // Very basic testing for VideoProcessor. It's mostly tested by running the 31 namespace {
32 // video_quality_measurement program. 32
33 const VideoCodecType kCodecType = kVideoCodecVP8;
34
35 const int kWidth = 352;
36 const int kHeight = 288;
37 const int kFrameLength =
38 kWidth * kHeight + 2 * ((kWidth + 1) / 2) * ((kHeight + 1) / 2);
39 const int kNumFrames = 2;
40
41 const int kStartBitrate = 100;
42 const int kStartFramerate = 15;
43
44 } // namespace
45
33 class VideoProcessorTest : public testing::Test { 46 class VideoProcessorTest : public testing::Test {
34 protected: 47 protected:
35 MockVideoEncoder encoder_mock_; 48 VideoProcessorTest() {
36 MockVideoDecoder decoder_mock_; 49 VideoCodingModule::Codec(kCodecType, &codec_settings_);
37 MockFrameReader frame_reader_mock_; 50 config_.codec_settings = &codec_settings_;
38 MockFrameWriter frame_writer_mock_; 51 config_.codec_settings->startBitrate = kStartBitrate;
39 MockPacketManipulator packet_manipulator_mock_; 52 config_.codec_settings->width = kWidth;
40 Stats stats_; 53 config_.codec_settings->height = kHeight;
54
55 EXPECT_CALL(frame_reader_mock_, NumberOfFrames())
56 .WillOnce(Return(kNumFrames));
57 EXPECT_CALL(frame_reader_mock_, FrameLength())
58 .WillRepeatedly(Return(kFrameLength));
59 processor_.reset(new VideoProcessorImpl(
60 &encoder_mock_, &decoder_mock_, &frame_reader_mock_,
61 &frame_writer_mock_, &packet_manipulator_mock_, config_, &stats_,
62 nullptr /* source_frame_writer */, nullptr /* encoded_frame_writer */,
63 nullptr /* decoded_frame_writer */));
64
65 Init();
66 }
67
68 ~VideoProcessorTest() override { Release(); }
69
70 void Init() {
71 EXPECT_CALL(encoder_mock_, InitEncode(_, _, _)).Times(1);
72 EXPECT_CALL(encoder_mock_, RegisterEncodeCompleteCallback(_)).Times(1);
73 EXPECT_CALL(decoder_mock_, InitDecode(_, _)).Times(1);
74 EXPECT_CALL(decoder_mock_, RegisterDecodeCompleteCallback(_)).Times(1);
75
76 processor_->Init();
77 }
78
79 void ExpectProcessOneFrame() {
80 EXPECT_CALL(frame_reader_mock_, ReadFrame())
81 .WillOnce(Return(I420Buffer::Create(50, 50)));
82 EXPECT_CALL(encoder_mock_, Encode(_, _, _)).Times(1);
83 // Cannot EXPECT callbacks, since our MockVideo{En,De}coders do not
84 // generate callbacks.
85 }
86
87 void Release() {
88 EXPECT_CALL(encoder_mock_, RegisterEncodeCompleteCallback(_)).Times(1);
89 EXPECT_CALL(decoder_mock_, RegisterDecodeCompleteCallback(_)).Times(1);
90
91 EXPECT_CALL(encoder_mock_, Release()).Times(1);
92 EXPECT_CALL(decoder_mock_, Release()).Times(1);
93
94 processor_->Release();
95 }
96
97 testing::StrictMock<MockVideoEncoder> encoder_mock_;
98 testing::StrictMock<MockVideoDecoder> decoder_mock_;
99 testing::StrictMock<MockFrameReader> frame_reader_mock_;
100 testing::StrictMock<MockFrameWriter> frame_writer_mock_;
101 testing::StrictMock<MockPacketManipulator> packet_manipulator_mock_;
41 TestConfig config_; 102 TestConfig config_;
42 VideoCodec codec_settings_; 103 VideoCodec codec_settings_;
43 104 Stats stats_;
44 VideoProcessorTest() {} 105 std::unique_ptr<VideoProcessor> processor_;
45 virtual ~VideoProcessorTest() {}
46 void SetUp() {
47 // Get a codec configuration struct and configure it.
48 VideoCodingModule::Codec(kVideoCodecVP8, &codec_settings_);
49 config_.codec_settings = &codec_settings_;
50 config_.codec_settings->startBitrate = 100;
51 config_.codec_settings->width = 352;
52 config_.codec_settings->height = 288;
53 }
54 void TearDown() {}
55
56 void ExpectInit() {
57 EXPECT_CALL(encoder_mock_, InitEncode(_, _, _)).Times(1);
58 EXPECT_CALL(encoder_mock_, RegisterEncodeCompleteCallback(_))
59 .Times(AtLeast(1));
60 EXPECT_CALL(decoder_mock_, InitDecode(_, _)).Times(1);
61 EXPECT_CALL(decoder_mock_, RegisterDecodeCompleteCallback(_))
62 .Times(AtLeast(1));
63 EXPECT_CALL(frame_reader_mock_, NumberOfFrames()).WillRepeatedly(Return(1));
64 EXPECT_CALL(frame_reader_mock_, FrameLength()).WillOnce(Return(152064));
65 }
66 }; 106 };
67 107
68 TEST_F(VideoProcessorTest, Init) { 108 TEST_F(VideoProcessorTest, InitRelease) {}
69 ExpectInit(); 109
70 VideoProcessorImpl video_processor( 110 TEST_F(VideoProcessorTest, SetRates) {
71 &encoder_mock_, &decoder_mock_, &frame_reader_mock_, &frame_writer_mock_, 111 EXPECT_CALL(encoder_mock_, SetRateAllocation(_, kStartFramerate)).Times(1);
72 &packet_manipulator_mock_, config_, &stats_, 112 processor_->SetRates(kStartBitrate, kStartFramerate);
73 nullptr /* source_frame_writer */, nullptr /* encoded_frame_writer */, 113
74 nullptr /* decoded_frame_writer */); 114 // Frame statistics should be reset after new rates have been set.
75 video_processor.Init(); 115 EXPECT_EQ(0, processor_->NumberDroppedFrames());
116 EXPECT_EQ(0, processor_->NumberSpatialResizes());
76 } 117 }
77 118
78 TEST_F(VideoProcessorTest, ProcessFrame) { 119 TEST_F(VideoProcessorTest, ProcessFrames) {
79 ExpectInit(); 120 ExpectProcessOneFrame();
80 EXPECT_CALL(encoder_mock_, Encode(_, _, _)).Times(1); 121 EXPECT_TRUE(processor_->ProcessFrame(0));
81 EXPECT_CALL(frame_reader_mock_, ReadFrame()) 122
82 .WillOnce(Return(I420Buffer::Create(50, 50))); 123 ExpectProcessOneFrame();
83 // Since we don't return any callback from the mock, the decoder will not 124 EXPECT_TRUE(processor_->ProcessFrame(1));
84 // be more than initialized... 125
85 VideoProcessorImpl video_processor( 126 // End of file.
86 &encoder_mock_, &decoder_mock_, &frame_reader_mock_, &frame_writer_mock_, 127 EXPECT_CALL(frame_reader_mock_, ReadFrame()).WillOnce(Return(nullptr));
87 &packet_manipulator_mock_, config_, &stats_, 128 EXPECT_FALSE(processor_->ProcessFrame(2));
88 nullptr /* source_frame_writer */, nullptr /* encoded_frame_writer */,
89 nullptr /* decoded_frame_writer */);
90 video_processor.Init();
91 video_processor.ProcessFrame(0);
92 } 129 }
93 130
94 } // namespace test 131 } // namespace test
95 } // namespace webrtc 132 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698