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

Unified 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, 6 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/video_coding/codecs/test/videoprocessor_unittest.cc
diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor_unittest.cc b/webrtc/modules/video_coding/codecs/test/videoprocessor_unittest.cc
index 2a54358e0d6abb4c8ff6970e9bcd2b88c14b2490..07b1dab008f549329c727467195759859ee4e548 100644
--- a/webrtc/modules/video_coding/codecs/test/videoprocessor_unittest.cc
+++ b/webrtc/modules/video_coding/codecs/test/videoprocessor_unittest.cc
@@ -28,67 +28,104 @@ using ::testing::Return;
namespace webrtc {
namespace test {
-// Very basic testing for VideoProcessor. It's mostly tested by running the
-// video_quality_measurement program.
+namespace {
+
+const VideoCodecType kCodecType = kVideoCodecVP8;
+
+const int kWidth = 352;
+const int kHeight = 288;
+const int kFrameLength =
+ kWidth * kHeight + 2 * ((kWidth + 1) / 2) * ((kHeight + 1) / 2);
+const int kNumFrames = 2;
+
+const int kStartBitrate = 100;
+const int kStartFramerate = 15;
+
+} // namespace
+
class VideoProcessorTest : public testing::Test {
protected:
- MockVideoEncoder encoder_mock_;
- MockVideoDecoder decoder_mock_;
- MockFrameReader frame_reader_mock_;
- MockFrameWriter frame_writer_mock_;
- MockPacketManipulator packet_manipulator_mock_;
- Stats stats_;
- TestConfig config_;
- VideoCodec codec_settings_;
-
- VideoProcessorTest() {}
- virtual ~VideoProcessorTest() {}
- void SetUp() {
- // Get a codec configuration struct and configure it.
- VideoCodingModule::Codec(kVideoCodecVP8, &codec_settings_);
+ VideoProcessorTest() {
+ VideoCodingModule::Codec(kCodecType, &codec_settings_);
config_.codec_settings = &codec_settings_;
- config_.codec_settings->startBitrate = 100;
- config_.codec_settings->width = 352;
- config_.codec_settings->height = 288;
+ config_.codec_settings->startBitrate = kStartBitrate;
+ config_.codec_settings->width = kWidth;
+ config_.codec_settings->height = kHeight;
+
+ EXPECT_CALL(frame_reader_mock_, NumberOfFrames())
+ .WillOnce(Return(kNumFrames));
+ EXPECT_CALL(frame_reader_mock_, FrameLength())
+ .WillRepeatedly(Return(kFrameLength));
+ processor_.reset(new VideoProcessorImpl(
+ &encoder_mock_, &decoder_mock_, &frame_reader_mock_,
+ &frame_writer_mock_, &packet_manipulator_mock_, config_, &stats_,
+ nullptr /* source_frame_writer */, nullptr /* encoded_frame_writer */,
+ nullptr /* decoded_frame_writer */));
+
+ Init();
}
- void TearDown() {}
- void ExpectInit() {
+ ~VideoProcessorTest() override { Release(); }
+
+ void Init() {
EXPECT_CALL(encoder_mock_, InitEncode(_, _, _)).Times(1);
- EXPECT_CALL(encoder_mock_, RegisterEncodeCompleteCallback(_))
- .Times(AtLeast(1));
+ EXPECT_CALL(encoder_mock_, RegisterEncodeCompleteCallback(_)).Times(1);
EXPECT_CALL(decoder_mock_, InitDecode(_, _)).Times(1);
- EXPECT_CALL(decoder_mock_, RegisterDecodeCompleteCallback(_))
- .Times(AtLeast(1));
- EXPECT_CALL(frame_reader_mock_, NumberOfFrames()).WillRepeatedly(Return(1));
- EXPECT_CALL(frame_reader_mock_, FrameLength()).WillOnce(Return(152064));
+ EXPECT_CALL(decoder_mock_, RegisterDecodeCompleteCallback(_)).Times(1);
+
+ processor_->Init();
}
+
+ void ExpectProcessOneFrame() {
+ EXPECT_CALL(frame_reader_mock_, ReadFrame())
+ .WillOnce(Return(I420Buffer::Create(50, 50)));
+ EXPECT_CALL(encoder_mock_, Encode(_, _, _)).Times(1);
+ // Cannot EXPECT callbacks, since our MockVideo{En,De}coders do not
+ // generate callbacks.
+ }
+
+ void Release() {
+ EXPECT_CALL(encoder_mock_, RegisterEncodeCompleteCallback(_)).Times(1);
+ EXPECT_CALL(decoder_mock_, RegisterDecodeCompleteCallback(_)).Times(1);
+
+ EXPECT_CALL(encoder_mock_, Release()).Times(1);
+ EXPECT_CALL(decoder_mock_, Release()).Times(1);
+
+ processor_->Release();
+ }
+
+ testing::StrictMock<MockVideoEncoder> encoder_mock_;
+ testing::StrictMock<MockVideoDecoder> decoder_mock_;
+ testing::StrictMock<MockFrameReader> frame_reader_mock_;
+ testing::StrictMock<MockFrameWriter> frame_writer_mock_;
+ testing::StrictMock<MockPacketManipulator> packet_manipulator_mock_;
+ TestConfig config_;
+ VideoCodec codec_settings_;
+ Stats stats_;
+ std::unique_ptr<VideoProcessor> processor_;
};
-TEST_F(VideoProcessorTest, Init) {
- ExpectInit();
- VideoProcessorImpl video_processor(
- &encoder_mock_, &decoder_mock_, &frame_reader_mock_, &frame_writer_mock_,
- &packet_manipulator_mock_, config_, &stats_,
- nullptr /* source_frame_writer */, nullptr /* encoded_frame_writer */,
- nullptr /* decoded_frame_writer */);
- video_processor.Init();
+TEST_F(VideoProcessorTest, InitRelease) {}
+
+TEST_F(VideoProcessorTest, SetRates) {
+ EXPECT_CALL(encoder_mock_, SetRateAllocation(_, kStartFramerate)).Times(1);
+ processor_->SetRates(kStartBitrate, kStartFramerate);
+
+ // Frame statistics should be reset after new rates have been set.
+ EXPECT_EQ(0, processor_->NumberDroppedFrames());
+ EXPECT_EQ(0, processor_->NumberSpatialResizes());
}
-TEST_F(VideoProcessorTest, ProcessFrame) {
- ExpectInit();
- EXPECT_CALL(encoder_mock_, Encode(_, _, _)).Times(1);
- EXPECT_CALL(frame_reader_mock_, ReadFrame())
- .WillOnce(Return(I420Buffer::Create(50, 50)));
- // Since we don't return any callback from the mock, the decoder will not
- // be more than initialized...
- VideoProcessorImpl video_processor(
- &encoder_mock_, &decoder_mock_, &frame_reader_mock_, &frame_writer_mock_,
- &packet_manipulator_mock_, config_, &stats_,
- nullptr /* source_frame_writer */, nullptr /* encoded_frame_writer */,
- nullptr /* decoded_frame_writer */);
- video_processor.Init();
- video_processor.ProcessFrame(0);
+TEST_F(VideoProcessorTest, ProcessFrames) {
+ ExpectProcessOneFrame();
+ EXPECT_TRUE(processor_->ProcessFrame(0));
+
+ ExpectProcessOneFrame();
+ EXPECT_TRUE(processor_->ProcessFrame(1));
+
+ // End of file.
+ EXPECT_CALL(frame_reader_mock_, ReadFrame()).WillOnce(Return(nullptr));
+ EXPECT_FALSE(processor_->ProcessFrame(2));
}
} // namespace test
« 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