Make VideoProcessor::Init/Release methods private and call from constructor/destructor.

TestConfig: Replace Print method with ToString and add test.

Bug: none
Change-Id: I9853cb16875199a51c5731d1cec326159751d001
Reviewed-on: https://webrtc-review.googlesource.com/14320
Commit-Queue: Åsa Persson <asapersson@webrtc.org>
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20420}
This commit is contained in:
Åsa Persson
2017-10-24 16:03:39 +02:00
committed by Commit Bot
parent c22a3a6a7d
commit f0c44672df
8 changed files with 255 additions and 215 deletions

View File

@ -27,7 +27,6 @@
#include "typedefs.h" // NOLINT(build/include)
using ::testing::_;
using ::testing::AtLeast;
using ::testing::ElementsAre;
using ::testing::Property;
using ::testing::Return;
@ -40,7 +39,6 @@ namespace {
const int kWidth = 352;
const int kHeight = 288;
const int kFrameSize = kWidth * kHeight * 3 / 2; // I420.
const int kNumFrames = 2;
} // namespace
@ -52,8 +50,7 @@ class VideoProcessorTest : public testing::Test {
config_.codec_settings.width = kWidth;
config_.codec_settings.height = kHeight;
EXPECT_CALL(frame_reader_mock_, NumberOfFrames())
.WillRepeatedly(Return(kNumFrames));
ExpectInit();
EXPECT_CALL(frame_reader_mock_, FrameLength())
.WillRepeatedly(Return(kFrameSize));
video_processor_ = rtc::MakeUnique<VideoProcessor>(
@ -88,19 +85,15 @@ class VideoProcessorTest : public testing::Test {
};
TEST_F(VideoProcessorTest, InitRelease) {
ExpectInit();
video_processor_->Init();
ExpectRelease();
video_processor_->Release();
}
TEST_F(VideoProcessorTest, ProcessFrames_FixedFramerate) {
ExpectInit();
video_processor_->Init();
const int kBitrateKbps = 456;
const int kFramerateFps = 31;
EXPECT_CALL(encoder_mock_, SetRateAllocation(_, kFramerateFps))
.Times(1)
.WillOnce(Return(0));
video_processor_->SetRates(kBitrateKbps, kFramerateFps);
EXPECT_CALL(frame_reader_mock_, ReadFrame())
@ -118,15 +111,14 @@ TEST_F(VideoProcessorTest, ProcessFrames_FixedFramerate) {
video_processor_->ProcessFrame();
ExpectRelease();
video_processor_->Release();
}
TEST_F(VideoProcessorTest, ProcessFrames_VariableFramerate) {
ExpectInit();
video_processor_->Init();
const int kBitrateKbps = 456;
const int kStartFramerateFps = 27;
EXPECT_CALL(encoder_mock_, SetRateAllocation(_, kStartFramerateFps))
.Times(1)
.WillOnce(Return(0));
video_processor_->SetRates(kBitrateKbps, kStartFramerateFps);
EXPECT_CALL(frame_reader_mock_, ReadFrame())
@ -138,6 +130,9 @@ TEST_F(VideoProcessorTest, ProcessFrames_VariableFramerate) {
video_processor_->ProcessFrame();
const int kNewFramerateFps = 13;
EXPECT_CALL(encoder_mock_, SetRateAllocation(_, kNewFramerateFps))
.Times(1)
.WillOnce(Return(0));
video_processor_->SetRates(kBitrateKbps, kNewFramerateFps);
EXPECT_CALL(encoder_mock_, Encode(Property(&VideoFrame::timestamp,
@ -147,13 +142,9 @@ TEST_F(VideoProcessorTest, ProcessFrames_VariableFramerate) {
video_processor_->ProcessFrame();
ExpectRelease();
video_processor_->Release();
}
TEST_F(VideoProcessorTest, SetRates) {
ExpectInit();
video_processor_->Init();
const int kBitrateKbps = 123;
const int kFramerateFps = 17;
EXPECT_CALL(encoder_mock_,
@ -181,7 +172,6 @@ TEST_F(VideoProcessorTest, SetRates) {
ElementsAre(0, 0));
ExpectRelease();
video_processor_->Release();
}
} // namespace test