In media/ and modules/video_coding replace mock macros with unified MOCK_METHOD macro

Bug: webrtc:11564
Change-Id: I5c7f5dc99e62619403ed726c23201ab4fbd37cbe
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175647
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31340}
This commit is contained in:
Danil Chapovalov 2020-05-19 13:20:27 +02:00 committed by Commit Bot
parent b85889d6d5
commit f2c0f15282
7 changed files with 144 additions and 114 deletions

View File

@ -26,8 +26,10 @@ namespace {
class MockRtpHeaderExtensionQueryInterface
: public RtpHeaderExtensionQueryInterface {
public:
MOCK_CONST_METHOD0(GetRtpHeaderExtensions,
std::vector<RtpHeaderExtensionCapability>());
MOCK_METHOD(std::vector<RtpHeaderExtensionCapability>,
GetRtpHeaderExtensions,
(),
(const, override));
};
} // namespace

View File

@ -199,8 +199,10 @@ class MockVideoEncoder : public VideoEncoder {
video_format_("unknown"),
callback_(nullptr) {}
MOCK_METHOD1(SetFecControllerOverride,
void(FecControllerOverride* fec_controller_override));
MOCK_METHOD(void,
SetFecControllerOverride,
(FecControllerOverride * fec_controller_override),
(override));
// TODO(nisse): Valid overrides commented out, because the gmock
// methods don't use any override declarations, and we want to avoid
@ -212,10 +214,11 @@ class MockVideoEncoder : public VideoEncoder {
return init_encode_return_value_;
}
MOCK_METHOD2(
Encode,
int32_t(const VideoFrame& inputImage,
const std::vector<VideoFrameType>* frame_types) /* override */);
MOCK_METHOD(int32_t,
Encode,
(const VideoFrame& inputImage,
const std::vector<VideoFrameType>* frame_types),
(override));
int32_t RegisterEncodeCompleteCallback(
EncodedImageCallback* callback) override {
@ -223,7 +226,7 @@ class MockVideoEncoder : public VideoEncoder {
return 0;
}
MOCK_METHOD0(Release, int32_t() /* override */);
MOCK_METHOD(int32_t, Release, (), (override));
void SetRates(const RateControlParameters& parameters) {
last_set_rates_ = parameters;
@ -334,8 +337,7 @@ std::vector<SdpVideoFormat> MockVideoEncoderFactory::GetSupportedFormats()
std::unique_ptr<VideoEncoder> MockVideoEncoderFactory::CreateVideoEncoder(
const SdpVideoFormat& format) {
std::unique_ptr<MockVideoEncoder> encoder(
new ::testing::NiceMock<MockVideoEncoder>(this));
auto encoder = std::make_unique<::testing::NiceMock<MockVideoEncoder>>(this);
encoder->set_init_encode_return_value(init_encode_return_value_);
const char* encoder_name = encoder_names_.empty()
? "codec_implementation_name"

View File

@ -209,11 +209,15 @@ int GetMaxDefaultBitrateBps(size_t width, size_t height) {
class MockVideoSource : public rtc::VideoSourceInterface<webrtc::VideoFrame> {
public:
MOCK_METHOD2(AddOrUpdateSink,
void(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink,
const rtc::VideoSinkWants& wants));
MOCK_METHOD1(RemoveSink,
void(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink));
MOCK_METHOD(void,
AddOrUpdateSink,
(rtc::VideoSinkInterface<webrtc::VideoFrame> * sink,
const rtc::VideoSinkWants& wants),
(override));
MOCK_METHOD(void,
RemoveSink,
(rtc::VideoSinkInterface<webrtc::VideoFrame> * sink),
(override));
};
} // namespace

View File

@ -19,74 +19,86 @@ namespace webrtc {
class MockLibvpxVp8Interface : public LibvpxInterface {
public:
MOCK_CONST_METHOD5(img_alloc,
vpx_image_t*(vpx_image_t*,
vpx_img_fmt_t,
unsigned int,
unsigned int,
unsigned int));
MOCK_CONST_METHOD6(img_wrap,
vpx_image_t*(vpx_image_t*,
vpx_img_fmt_t,
unsigned int,
unsigned int,
unsigned int,
unsigned char*));
MOCK_CONST_METHOD1(img_free, void(vpx_image_t* img));
MOCK_CONST_METHOD2(codec_enc_config_set,
vpx_codec_err_t(vpx_codec_ctx_t*,
const vpx_codec_enc_cfg_t*));
MOCK_CONST_METHOD3(codec_enc_config_default,
vpx_codec_err_t(vpx_codec_iface_t*,
vpx_codec_enc_cfg_t*,
unsigned int));
MOCK_CONST_METHOD4(codec_enc_init,
vpx_codec_err_t(vpx_codec_ctx_t*,
vpx_codec_iface_t*,
const vpx_codec_enc_cfg_t*,
vpx_codec_flags_t));
MOCK_CONST_METHOD6(codec_enc_init_multi,
vpx_codec_err_t(vpx_codec_ctx_t*,
vpx_codec_iface_t*,
vpx_codec_enc_cfg_t*,
int,
vpx_codec_flags_t,
vpx_rational_t*));
MOCK_CONST_METHOD1(codec_destroy, vpx_codec_err_t(vpx_codec_ctx_t*));
MOCK_CONST_METHOD3(codec_control,
vpx_codec_err_t(vpx_codec_ctx_t*,
vp8e_enc_control_id,
uint32_t));
MOCK_CONST_METHOD3(codec_control,
vpx_codec_err_t(vpx_codec_ctx_t*,
vp8e_enc_control_id,
int));
MOCK_CONST_METHOD3(codec_control,
vpx_codec_err_t(vpx_codec_ctx_t*,
vp8e_enc_control_id,
int*));
MOCK_CONST_METHOD3(codec_control,
vpx_codec_err_t(vpx_codec_ctx_t*,
vp8e_enc_control_id,
vpx_roi_map*));
MOCK_CONST_METHOD3(codec_control,
vpx_codec_err_t(vpx_codec_ctx_t*,
vp8e_enc_control_id,
vpx_active_map*));
MOCK_CONST_METHOD3(codec_control,
vpx_codec_err_t(vpx_codec_ctx_t*,
vp8e_enc_control_id,
vpx_scaling_mode*));
MOCK_CONST_METHOD6(codec_encode,
vpx_codec_err_t(vpx_codec_ctx_t*,
const vpx_image_t*,
vpx_codec_pts_t,
uint64_t,
vpx_enc_frame_flags_t,
uint64_t));
MOCK_CONST_METHOD2(codec_get_cx_data,
const vpx_codec_cx_pkt_t*(vpx_codec_ctx_t*,
vpx_codec_iter_t*));
MOCK_METHOD(
vpx_image_t*,
img_alloc,
(vpx_image_t*, vpx_img_fmt_t, unsigned int, unsigned int, unsigned int),
(const, override));
MOCK_METHOD(vpx_image_t*,
img_wrap,
(vpx_image_t*,
vpx_img_fmt_t,
unsigned int,
unsigned int,
unsigned int,
unsigned char*),
(const, override));
MOCK_METHOD(void, img_free, (vpx_image_t * img), (const, override));
MOCK_METHOD(vpx_codec_err_t,
codec_enc_config_set,
(vpx_codec_ctx_t*, const vpx_codec_enc_cfg_t*),
(const, override));
MOCK_METHOD(vpx_codec_err_t,
codec_enc_config_default,
(vpx_codec_iface_t*, vpx_codec_enc_cfg_t*, unsigned int),
(const, override));
MOCK_METHOD(vpx_codec_err_t,
codec_enc_init,
(vpx_codec_ctx_t*,
vpx_codec_iface_t*,
const vpx_codec_enc_cfg_t*,
vpx_codec_flags_t),
(const, override));
MOCK_METHOD(vpx_codec_err_t,
codec_enc_init_multi,
(vpx_codec_ctx_t*,
vpx_codec_iface_t*,
vpx_codec_enc_cfg_t*,
int,
vpx_codec_flags_t,
vpx_rational_t*),
(const, override));
MOCK_METHOD(vpx_codec_err_t,
codec_destroy,
(vpx_codec_ctx_t*),
(const, override));
MOCK_METHOD(vpx_codec_err_t,
codec_control,
(vpx_codec_ctx_t*, vp8e_enc_control_id, uint32_t),
(const, override));
MOCK_METHOD(vpx_codec_err_t,
codec_control,
(vpx_codec_ctx_t*, vp8e_enc_control_id, int),
(const, override));
MOCK_METHOD(vpx_codec_err_t,
codec_control,
(vpx_codec_ctx_t*, vp8e_enc_control_id, int*),
(const, override));
MOCK_METHOD(vpx_codec_err_t,
codec_control,
(vpx_codec_ctx_t*, vp8e_enc_control_id, vpx_roi_map*),
(const, override));
MOCK_METHOD(vpx_codec_err_t,
codec_control,
(vpx_codec_ctx_t*, vp8e_enc_control_id, vpx_active_map*),
(const, override));
MOCK_METHOD(vpx_codec_err_t,
codec_control,
(vpx_codec_ctx_t*, vp8e_enc_control_id, vpx_scaling_mode*),
(const, override));
MOCK_METHOD(vpx_codec_err_t,
codec_encode,
(vpx_codec_ctx_t*,
const vpx_image_t*,
vpx_codec_pts_t,
uint64_t,
vpx_enc_frame_flags_t,
uint64_t),
(const, override));
MOCK_METHOD(const vpx_codec_cx_pkt_t*,
codec_get_cx_data,
(vpx_codec_ctx_t*, vpx_codec_iter_t*),
(const, override));
};
} // namespace webrtc

View File

@ -108,21 +108,26 @@ class FrameObjectFake : public EncodedFrame {
class VCMReceiveStatisticsCallbackMock : public VCMReceiveStatisticsCallback {
public:
MOCK_METHOD3(OnCompleteFrame,
void(bool is_keyframe,
size_t size_bytes,
VideoContentType content_type));
MOCK_METHOD1(OnDroppedFrames, void(uint32_t frames_dropped));
MOCK_METHOD1(OnDiscardedPacketsUpdated, void(int discarded_packets));
MOCK_METHOD1(OnFrameCountsUpdated, void(const FrameCounts& frame_counts));
MOCK_METHOD6(OnFrameBufferTimingsUpdated,
void(int max_decode_ms,
int current_delay_ms,
int target_delay_ms,
int jitter_buffer_ms,
int min_playout_delay_ms,
int render_delay_ms));
MOCK_METHOD1(OnTimingFrameInfoUpdated, void(const TimingFrameInfo& info));
MOCK_METHOD(void,
OnCompleteFrame,
(bool is_keyframe,
size_t size_bytes,
VideoContentType content_type),
(override));
MOCK_METHOD(void, OnDroppedFrames, (uint32_t frames_dropped), (override));
MOCK_METHOD(void,
OnFrameBufferTimingsUpdated,
(int max_decode_ms,
int current_delay_ms,
int target_delay_ms,
int jitter_buffer_ms,
int min_playout_delay_ms,
int render_delay_ms),
(override));
MOCK_METHOD(void,
OnTimingFrameInfoUpdated,
(const TimingFrameInfo& info),
(override));
};
class TestFrameBuffer2 : public ::testing::Test {

View File

@ -38,14 +38,16 @@ constexpr uint32_t kSimulcastScreenshareMaxBitrateKbps = 1250;
class MockTemporalLayers : public Vp8FrameBufferController {
public:
MOCK_METHOD2(NextFrameConfig, Vp8FrameConfig(size_t, uint32_t));
MOCK_METHOD3(OnRatesUpdated, void(size_t, const std::vector<uint32_t>&, int));
MOCK_METHOD1(UpdateConfiguration, Vp8EncoderConfig(size_t));
MOCK_METHOD6(OnEncodeDone,
void(size_t, uint32_t, size_t, bool, int, CodecSpecificInfo*));
MOCK_METHOD4(FrameEncoded, void(size_t, uint32_t, size_t, int));
MOCK_CONST_METHOD0(Tl0PicIdx, uint8_t());
MOCK_CONST_METHOD1(GetTemporalLayerId, int(const Vp8FrameConfig&));
MOCK_METHOD(Vp8FrameConfig, NextFrameConfig, (size_t, uint32_t), (override));
MOCK_METHOD(void,
OnRatesUpdated,
(size_t, const std::vector<uint32_t>&, int),
(override));
MOCK_METHOD(Vp8EncoderConfig, UpdateConfiguration, (size_t), (override));
MOCK_METHOD(void,
OnEncodeDone,
(size_t, uint32_t, size_t, bool, int, CodecSpecificInfo*),
(override));
};
} // namespace

View File

@ -26,8 +26,10 @@ namespace {
class MockPacketRequestCallback : public VCMPacketRequestCallback {
public:
MOCK_METHOD2(ResendPackets,
int32_t(const uint16_t* sequenceNumbers, uint16_t length));
MOCK_METHOD(int32_t,
ResendPackets,
(const uint16_t* sequenceNumbers, uint16_t length),
(override));
};
class MockVCMReceiveCallback : public VCMReceiveCallback {
@ -35,11 +37,12 @@ class MockVCMReceiveCallback : public VCMReceiveCallback {
MockVCMReceiveCallback() {}
virtual ~MockVCMReceiveCallback() {}
MOCK_METHOD4(
FrameToRender,
int32_t(VideoFrame&, absl::optional<uint8_t>, int32_t, VideoContentType));
MOCK_METHOD1(OnIncomingPayloadType, void(int));
MOCK_METHOD1(OnDecoderImplementationName, void(const char*));
MOCK_METHOD(int32_t,
FrameToRender,
(VideoFrame&, absl::optional<uint8_t>, int32_t, VideoContentType),
(override));
MOCK_METHOD(void, OnIncomingPayloadType, (int), (override));
MOCK_METHOD(void, OnDecoderImplementationName, (const char*), (override));
};
class TestVideoReceiver : public ::testing::Test {