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

Unified Diff: webrtc/modules/video_coding/codecs/test/videoprocessor_unittest.cc

Issue 2997283002: VideoProcessorIntegrationTest: make it runnable on a task queue. (Closed)
Patch Set: asapersson comments 1. Created 3 years, 4 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 825c076a5033bd68f10b62dba70ee3e5ae1de8e5..5f71a68cb25f1d99604ab3ce006a7f7684bba197 100644
--- a/webrtc/modules/video_coding/codecs/test/videoprocessor_unittest.cc
+++ b/webrtc/modules/video_coding/codecs/test/videoprocessor_unittest.cc
@@ -11,6 +11,7 @@
#include <memory>
#include "webrtc/api/video/i420_buffer.h"
+#include "webrtc/common_types.h"
#include "webrtc/modules/video_coding/codecs/test/mock/mock_packet_manipulator.h"
#include "webrtc/modules/video_coding/codecs/test/videoprocessor.h"
#include "webrtc/modules/video_coding/include/mock/mock_video_codec_interface.h"
@@ -27,6 +28,8 @@
using ::testing::_;
using ::testing::AtLeast;
+using ::testing::ElementsAre;
+using ::testing::Property;
using ::testing::Return;
namespace webrtc {
@@ -37,7 +40,6 @@ namespace {
const int kWidth = 352;
const int kHeight = 288;
const int kFrameSize = kWidth * kHeight * 3 / 2; // I420.
-const int kFramerate = 30;
const int kNumFrames = 2;
} // namespace
@@ -49,7 +51,6 @@ class VideoProcessorTest : public testing::Test {
webrtc::test::CodecSettings(kVideoCodecVP8, &config_.codec_settings);
config_.codec_settings.width = kWidth;
config_.codec_settings.height = kHeight;
- config_.codec_settings.maxFramerate = kFramerate;
EXPECT_CALL(frame_reader_mock_, NumberOfFrames())
.WillRepeatedly(Return(kNumFrames));
@@ -63,11 +64,16 @@ class VideoProcessorTest : public testing::Test {
void ExpectInit() {
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(decoder_mock_, RegisterDecodeCompleteCallback(_)).Times(1);
+ }
+
+ void ExpectRelease() {
+ EXPECT_CALL(encoder_mock_, Release()).Times(1);
+ EXPECT_CALL(encoder_mock_, RegisterEncodeCompleteCallback(_)).Times(1);
+ EXPECT_CALL(decoder_mock_, Release()).Times(1);
+ EXPECT_CALL(decoder_mock_, RegisterDecodeCompleteCallback(_)).Times(1);
}
TestConfig config_;
@@ -81,28 +87,101 @@ class VideoProcessorTest : public testing::Test {
std::unique_ptr<VideoProcessor> video_processor_;
};
-TEST_F(VideoProcessorTest, Init) {
+TEST_F(VideoProcessorTest, InitRelease) {
ExpectInit();
video_processor_->Init();
+
+ ExpectRelease();
+ video_processor_->Release();
}
-TEST_F(VideoProcessorTest, ProcessFrames) {
+TEST_F(VideoProcessorTest, ProcessFrames_FixedFramerate) {
ExpectInit();
video_processor_->Init();
+ const int kBitrateKbps = 456;
+ const int kFramerateFps = 31;
+ video_processor_->SetRates(kBitrateKbps, kFramerateFps);
+
EXPECT_CALL(frame_reader_mock_, ReadFrame())
.WillRepeatedly(Return(I420Buffer::Create(kWidth, kHeight)));
- EXPECT_CALL(encoder_mock_, Encode(testing::Property(&VideoFrame::timestamp,
- 1 * 90000 / kFramerate),
+ EXPECT_CALL(
+ encoder_mock_,
+ Encode(Property(&VideoFrame::timestamp, 1 * 90000 / kFramerateFps), _, _))
+ .Times(1);
+ video_processor_->ProcessFrame(0);
+
+ EXPECT_CALL(
+ encoder_mock_,
+ Encode(Property(&VideoFrame::timestamp, 2 * 90000 / kFramerateFps), _, _))
+ .Times(1);
+ video_processor_->ProcessFrame(1);
+
+ ExpectRelease();
+ video_processor_->Release();
+}
+
+TEST_F(VideoProcessorTest, ProcessFrames_VariableFramerate) {
+ ExpectInit();
+ video_processor_->Init();
+
+ const int kBitrateKbps = 456;
+ const int kStartFramerateFps = 27;
+ video_processor_->SetRates(kBitrateKbps, kStartFramerateFps);
+
+ EXPECT_CALL(frame_reader_mock_, ReadFrame())
+ .WillRepeatedly(Return(I420Buffer::Create(kWidth, kHeight)));
+ EXPECT_CALL(encoder_mock_, Encode(Property(&VideoFrame::timestamp,
+ 1 * 90000 / kStartFramerateFps),
_, _))
.Times(1);
video_processor_->ProcessFrame(0);
- EXPECT_CALL(encoder_mock_, Encode(testing::Property(&VideoFrame::timestamp,
- 2 * 90000 / kFramerate),
+ const int kNewFramerateFps = 13;
+ video_processor_->SetRates(kBitrateKbps, kNewFramerateFps);
+
+ EXPECT_CALL(encoder_mock_, Encode(Property(&VideoFrame::timestamp,
+ 2 * 90000 / kNewFramerateFps),
_, _))
.Times(1);
video_processor_->ProcessFrame(1);
+
+ ExpectRelease();
+ video_processor_->Release();
+}
+
+TEST_F(VideoProcessorTest, SetRates) {
+ ExpectInit();
+ video_processor_->Init();
+
+ const int kBitrateKbps = 123;
+ const int kFramerateFps = 17;
+ EXPECT_CALL(encoder_mock_,
+ SetRateAllocation(
+ Property(&BitrateAllocation::get_sum_kbps, kBitrateKbps),
+ kFramerateFps))
+ .Times(1);
+ video_processor_->SetRates(kBitrateKbps, kFramerateFps);
+ EXPECT_THAT(video_processor_->NumberDroppedFramesPerRateUpdate(),
+ ElementsAre(0));
+ EXPECT_THAT(video_processor_->NumberSpatialResizesPerRateUpdate(),
+ ElementsAre(0));
+
+ const int kNewBitrateKbps = 456;
+ const int kNewFramerateFps = 34;
+ EXPECT_CALL(encoder_mock_,
+ SetRateAllocation(
+ Property(&BitrateAllocation::get_sum_kbps, kNewBitrateKbps),
+ kNewFramerateFps))
+ .Times(1);
+ video_processor_->SetRates(kNewBitrateKbps, kNewFramerateFps);
+ EXPECT_THAT(video_processor_->NumberDroppedFramesPerRateUpdate(),
+ ElementsAre(0, 0));
+ EXPECT_THAT(video_processor_->NumberSpatialResizesPerRateUpdate(),
+ ElementsAre(0, 0));
+
+ ExpectRelease();
+ video_processor_->Release();
}
} // 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