In video/ replace mock macros with unified MOCK_METHOD macro
Bug: webrtc:11564
Change-Id: Iec9dded7a3f045e048d0546c268ae206a7d3a7c7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175128
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31264}
diff --git a/video/adaptation/overuse_frame_detector_unittest.cc b/video/adaptation/overuse_frame_detector_unittest.cc
index bb34224..d4bf910 100644
--- a/video/adaptation/overuse_frame_detector_unittest.cc
+++ b/video/adaptation/overuse_frame_detector_unittest.cc
@@ -41,8 +41,8 @@
MockCpuOveruseObserver() {}
virtual ~MockCpuOveruseObserver() {}
- MOCK_METHOD0(AdaptUp, void());
- MOCK_METHOD0(AdaptDown, void());
+ MOCK_METHOD(void, AdaptUp, (), (override));
+ MOCK_METHOD(void, AdaptDown, (), (override));
};
class CpuOveruseObserverImpl : public OveruseFrameDetectorObserverInterface {
diff --git a/video/call_stats2_unittest.cc b/video/call_stats2_unittest.cc
index 73fe4b4..b3d43cb 100644
--- a/video/call_stats2_unittest.cc
+++ b/video/call_stats2_unittest.cc
@@ -33,7 +33,7 @@
MockStatsObserver() {}
virtual ~MockStatsObserver() {}
- MOCK_METHOD2(OnRttUpdate, void(int64_t, int64_t));
+ MOCK_METHOD(void, OnRttUpdate, (int64_t, int64_t), (override));
};
class CallStats2Test : public ::testing::Test {
diff --git a/video/call_stats_unittest.cc b/video/call_stats_unittest.cc
index c560ccb..e85c4f8 100644
--- a/video/call_stats_unittest.cc
+++ b/video/call_stats_unittest.cc
@@ -32,7 +32,7 @@
MockStatsObserver() {}
virtual ~MockStatsObserver() {}
- MOCK_METHOD2(OnRttUpdate, void(int64_t, int64_t));
+ MOCK_METHOD(void, OnRttUpdate, (int64_t, int64_t), (override));
};
class CallStatsTest : public ::testing::Test {
diff --git a/video/rtp_video_stream_receiver_unittest.cc b/video/rtp_video_stream_receiver_unittest.cc
index 255de54..510cad3 100644
--- a/video/rtp_video_stream_receiver_unittest.cc
+++ b/video/rtp_video_stream_receiver_unittest.cc
@@ -73,37 +73,45 @@
class MockTransport : public Transport {
public:
- MOCK_METHOD3(SendRtp,
- bool(const uint8_t* packet,
- size_t length,
- const PacketOptions& options));
- MOCK_METHOD2(SendRtcp, bool(const uint8_t* packet, size_t length));
+ MOCK_METHOD(bool,
+ SendRtp,
+ (const uint8_t*, size_t length, const PacketOptions& options),
+ (override));
+ MOCK_METHOD(bool, SendRtcp, (const uint8_t*, size_t length), (override));
};
class MockNackSender : public NackSender {
public:
- MOCK_METHOD1(SendNack, void(const std::vector<uint16_t>& sequence_numbers));
- MOCK_METHOD2(SendNack,
- void(const std::vector<uint16_t>& sequence_numbers,
- bool buffering_allowed));
+ MOCK_METHOD(void,
+ SendNack,
+ (const std::vector<uint16_t>& sequence_numbers,
+ bool buffering_allowed),
+ (override));
};
class MockKeyFrameRequestSender : public KeyFrameRequestSender {
public:
- MOCK_METHOD0(RequestKeyFrame, void());
+ MOCK_METHOD(void, RequestKeyFrame, (), (override));
};
class MockOnCompleteFrameCallback
: public video_coding::OnCompleteFrameCallback {
public:
- MOCK_METHOD1(DoOnCompleteFrame, void(video_coding::EncodedFrame* frame));
- MOCK_METHOD1(DoOnCompleteFrameFailNullptr,
- void(video_coding::EncodedFrame* frame));
- MOCK_METHOD1(DoOnCompleteFrameFailLength,
- void(video_coding::EncodedFrame* frame));
- MOCK_METHOD1(DoOnCompleteFrameFailBitstream,
- void(video_coding::EncodedFrame* frame));
- void OnCompleteFrame(std::unique_ptr<video_coding::EncodedFrame> frame) {
+ MOCK_METHOD(void, DoOnCompleteFrame, (video_coding::EncodedFrame*), ());
+ MOCK_METHOD(void,
+ DoOnCompleteFrameFailNullptr,
+ (video_coding::EncodedFrame*),
+ ());
+ MOCK_METHOD(void,
+ DoOnCompleteFrameFailLength,
+ (video_coding::EncodedFrame*),
+ ());
+ MOCK_METHOD(void,
+ DoOnCompleteFrameFailBitstream,
+ (video_coding::EncodedFrame*),
+ ());
+ void OnCompleteFrame(
+ std::unique_ptr<video_coding::EncodedFrame> frame) override {
if (!frame) {
DoOnCompleteFrameFailNullptr(nullptr);
return;
@@ -132,7 +140,7 @@
class MockRtpPacketSink : public RtpPacketSinkInterface {
public:
- MOCK_METHOD1(OnRtpPacket, void(const RtpPacketReceived&));
+ MOCK_METHOD(void, OnRtpPacket, (const RtpPacketReceived&), (override));
};
constexpr uint32_t kSsrc = 111;
diff --git a/video/test/mock_video_stream_encoder.h b/video/test/mock_video_stream_encoder.h
index 8e42968..4c076ea 100644
--- a/video/test/mock_video_stream_encoder.h
+++ b/video/test/mock_video_stream_encoder.h
@@ -17,22 +17,36 @@
class MockVideoStreamEncoder : public VideoStreamEncoderInterface {
public:
- MOCK_METHOD2(SetSource,
- void(rtc::VideoSourceInterface<VideoFrame>*,
- const DegradationPreference&));
- MOCK_METHOD2(SetSink, void(EncoderSink*, bool));
- MOCK_METHOD1(SetStartBitrate, void(int));
- MOCK_METHOD0(SendKeyFrame, void());
- MOCK_METHOD1(OnLossNotification, void(const VideoEncoder::LossNotification&));
- MOCK_METHOD6(OnBitrateUpdated,
- void(DataRate, DataRate, DataRate, uint8_t, int64_t, double));
- MOCK_METHOD1(OnFrame, void(const VideoFrame&));
- MOCK_METHOD1(SetBitrateAllocationObserver,
- void(VideoBitrateAllocationObserver*));
- MOCK_METHOD1(SetFecControllerOverride, void(FecControllerOverride*));
- MOCK_METHOD0(Stop, void());
+ MOCK_METHOD(void,
+ SetSource,
+ (rtc::VideoSourceInterface<VideoFrame>*,
+ const DegradationPreference&),
+ (override));
+ MOCK_METHOD(void, SetSink, (EncoderSink*, bool), (override));
+ MOCK_METHOD(void, SetStartBitrate, (int), (override));
+ MOCK_METHOD(void, SendKeyFrame, (), (override));
+ MOCK_METHOD(void,
+ OnLossNotification,
+ (const VideoEncoder::LossNotification&),
+ (override));
+ MOCK_METHOD(void,
+ OnBitrateUpdated,
+ (DataRate, DataRate, DataRate, uint8_t, int64_t, double),
+ (override));
+ MOCK_METHOD(void, OnFrame, (const VideoFrame&), (override));
+ MOCK_METHOD(void,
+ SetBitrateAllocationObserver,
+ (VideoBitrateAllocationObserver*),
+ (override));
+ MOCK_METHOD(void,
+ SetFecControllerOverride,
+ (FecControllerOverride*),
+ (override));
+ MOCK_METHOD(void, Stop, (), (override));
- MOCK_METHOD2(MockedConfigureEncoder, void(const VideoEncoderConfig&, size_t));
+ MOCK_METHOD(void,
+ MockedConfigureEncoder,
+ (const VideoEncoderConfig&, size_t));
// gtest generates implicit copy which is not allowed on VideoEncoderConfig,
// so we can't mock ConfigureEncoder directly.
void ConfigureEncoder(VideoEncoderConfig config,
diff --git a/video/video_receive_stream_unittest.cc b/video/video_receive_stream_unittest.cc
index 54896e8..07032fe 100644
--- a/video/video_receive_stream_unittest.cc
+++ b/video/video_receive_stream_unittest.cc
@@ -49,24 +49,30 @@
class MockTransport : public Transport {
public:
- MOCK_METHOD3(SendRtp,
- bool(const uint8_t* packet,
- size_t length,
- const PacketOptions& options));
- MOCK_METHOD2(SendRtcp, bool(const uint8_t* packet, size_t length));
+ MOCK_METHOD(bool,
+ SendRtp,
+ (const uint8_t*, size_t length, const PacketOptions& options),
+ (override));
+ MOCK_METHOD(bool, SendRtcp, (const uint8_t*, size_t length), (override));
};
class MockVideoDecoder : public VideoDecoder {
public:
- MOCK_METHOD2(InitDecode,
- int32_t(const VideoCodec* config, int32_t number_of_cores));
- MOCK_METHOD3(Decode,
- int32_t(const EncodedImage& input,
- bool missing_frames,
- int64_t render_time_ms));
- MOCK_METHOD1(RegisterDecodeCompleteCallback,
- int32_t(DecodedImageCallback* callback));
- MOCK_METHOD0(Release, int32_t(void));
+ MOCK_METHOD(int32_t,
+ InitDecode,
+ (const VideoCodec*, int32_t number_of_cores),
+ (override));
+ MOCK_METHOD(int32_t,
+ Decode,
+ (const EncodedImage& input,
+ bool missing_frames,
+ int64_t render_time_ms),
+ (override));
+ MOCK_METHOD(int32_t,
+ RegisterDecodeCompleteCallback,
+ (DecodedImageCallback*),
+ (override));
+ MOCK_METHOD(int32_t, Release, (), (override));
const char* ImplementationName() const { return "MockVideoDecoder"; }
};
diff --git a/video/video_send_stream_impl_unittest.cc b/video/video_send_stream_impl_unittest.cc
index 532e035..178d386 100644
--- a/video/video_send_stream_impl_unittest.cc
+++ b/video/video_send_stream_impl_unittest.cc
@@ -58,33 +58,45 @@
}
class MockRtpVideoSender : public RtpVideoSenderInterface {
public:
- MOCK_METHOD1(RegisterProcessThread, void(ProcessThread*));
- MOCK_METHOD0(DeRegisterProcessThread, void());
- MOCK_METHOD1(SetActive, void(bool));
- MOCK_METHOD1(SetActiveModules, void(const std::vector<bool>));
- MOCK_METHOD0(IsActive, bool());
- MOCK_METHOD1(OnNetworkAvailability, void(bool));
- MOCK_CONST_METHOD0(GetRtpStates, std::map<uint32_t, RtpState>());
- MOCK_CONST_METHOD0(GetRtpPayloadStates,
- std::map<uint32_t, RtpPayloadState>());
- MOCK_METHOD2(DeliverRtcp, void(const uint8_t*, size_t));
- MOCK_METHOD1(OnBitrateAllocationUpdated, void(const VideoBitrateAllocation&));
- MOCK_METHOD3(OnEncodedImage,
- EncodedImageCallback::Result(const EncodedImage&,
- const CodecSpecificInfo*,
- const RTPFragmentationHeader*));
- MOCK_METHOD1(OnTransportOverheadChanged, void(size_t));
- MOCK_METHOD1(OnOverheadChanged, void(size_t));
- MOCK_METHOD2(OnBitrateUpdated, void(BitrateAllocationUpdate, int));
- MOCK_CONST_METHOD0(GetPayloadBitrateBps, uint32_t());
- MOCK_CONST_METHOD0(GetProtectionBitrateBps, uint32_t());
- MOCK_METHOD3(SetEncodingData, void(size_t, size_t, size_t));
- MOCK_CONST_METHOD2(GetSentRtpPacketInfos,
- std::vector<RtpSequenceNumberMap::Info>(
- uint32_t ssrc,
- rtc::ArrayView<const uint16_t> sequence_numbers));
+ MOCK_METHOD(void, RegisterProcessThread, (ProcessThread*), (override));
+ MOCK_METHOD(void, DeRegisterProcessThread, (), (override));
+ MOCK_METHOD(void, SetActive, (bool), (override));
+ MOCK_METHOD(void, SetActiveModules, (const std::vector<bool>), (override));
+ MOCK_METHOD(bool, IsActive, (), (override));
+ MOCK_METHOD(void, OnNetworkAvailability, (bool), (override));
+ MOCK_METHOD((std::map<uint32_t, RtpState>),
+ GetRtpStates,
+ (),
+ (const, override));
+ MOCK_METHOD((std::map<uint32_t, RtpPayloadState>),
+ GetRtpPayloadStates,
+ (),
+ (const, override));
+ MOCK_METHOD(void, DeliverRtcp, (const uint8_t*, size_t), (override));
+ MOCK_METHOD(void,
+ OnBitrateAllocationUpdated,
+ (const VideoBitrateAllocation&),
+ (override));
+ MOCK_METHOD(EncodedImageCallback::Result,
+ OnEncodedImage,
+ (const EncodedImage&,
+ const CodecSpecificInfo*,
+ const RTPFragmentationHeader*),
+ (override));
+ MOCK_METHOD(void, OnTransportOverheadChanged, (size_t), (override));
+ MOCK_METHOD(void,
+ OnBitrateUpdated,
+ (BitrateAllocationUpdate, int),
+ (override));
+ MOCK_METHOD(uint32_t, GetPayloadBitrateBps, (), (const, override));
+ MOCK_METHOD(uint32_t, GetProtectionBitrateBps, (), (const, override));
+ MOCK_METHOD(void, SetEncodingData, (size_t, size_t, size_t), (override));
+ MOCK_METHOD(std::vector<RtpSequenceNumberMap::Info>,
+ GetSentRtpPacketInfos,
+ (uint32_t ssrc, rtc::ArrayView<const uint16_t> sequence_numbers),
+ (const, override));
- MOCK_METHOD1(SetFecAllowed, void(bool fec_allowed));
+ MOCK_METHOD(void, SetFecAllowed, (bool fec_allowed), (override));
};
BitrateAllocationUpdate CreateAllocation(int bitrate_bps) {
diff --git a/video/video_source_sink_controller_unittest.cc b/video/video_source_sink_controller_unittest.cc
index c4e2ea1..66881cd 100644
--- a/video/video_source_sink_controller_unittest.cc
+++ b/video/video_source_sink_controller_unittest.cc
@@ -30,8 +30,8 @@
public:
~MockVideoSinkWithVideoFrame() override {}
- MOCK_METHOD1(OnFrame, void(const VideoFrame& frame));
- MOCK_METHOD0(OnDiscardedFrame, void());
+ MOCK_METHOD(void, OnFrame, (const VideoFrame& frame), (override));
+ MOCK_METHOD(void, OnDiscardedFrame, (), (override));
};
class MockVideoSourceWithVideoFrame
@@ -39,10 +39,15 @@
public:
~MockVideoSourceWithVideoFrame() override {}
- MOCK_METHOD2(AddOrUpdateSink,
- void(rtc::VideoSinkInterface<VideoFrame>*,
- const rtc::VideoSinkWants&));
- MOCK_METHOD1(RemoveSink, void(rtc::VideoSinkInterface<VideoFrame>*));
+ MOCK_METHOD(void,
+ AddOrUpdateSink,
+ (rtc::VideoSinkInterface<VideoFrame>*,
+ const rtc::VideoSinkWants&),
+ (override));
+ MOCK_METHOD(void,
+ RemoveSink,
+ (rtc::VideoSinkInterface<VideoFrame>*),
+ (override));
};
} // namespace
diff --git a/video/video_stream_decoder_impl_unittest.cc b/video/video_stream_decoder_impl_unittest.cc
index 44e9140..a45a12c 100644
--- a/video/video_stream_decoder_impl_unittest.cc
+++ b/video/video_stream_decoder_impl_unittest.cc
@@ -27,21 +27,25 @@
class MockVideoStreamDecoderCallbacks
: public VideoStreamDecoderInterface::Callbacks {
public:
- MOCK_METHOD0(OnNonDecodableState, void());
- MOCK_METHOD1(OnContinuousUntil,
- void(const video_coding::VideoLayerFrameId& key));
- MOCK_METHOD1(OnEncodedFrame, void(const video_coding::EncodedFrame& frame));
- MOCK_METHOD3(OnDecodedFrame,
- void(VideoFrame decodedImage,
- absl::optional<int> decode_time_ms,
- absl::optional<int> qp));
+ MOCK_METHOD(void, OnNonDecodableState, (), (override));
+ MOCK_METHOD(void,
+ OnContinuousUntil,
+ (const video_coding::VideoLayerFrameId& key),
+ (override));
+ MOCK_METHOD(void,
+ OnDecodedFrame,
+ (VideoFrame decodedImage,
+ absl::optional<int> decode_time_ms,
+ absl::optional<int> qp),
+ (override));
};
class StubVideoDecoder : public VideoDecoder {
public:
- MOCK_METHOD2(InitDecode,
- int32_t(const VideoCodec* codec_settings,
- int32_t number_of_cores));
+ MOCK_METHOD(int32_t,
+ InitDecode,
+ (const VideoCodec*, int32_t number_of_cores),
+ (override));
int32_t Decode(const EncodedImage& input_image,
bool missing_frames,
@@ -57,10 +61,12 @@
return ret_code;
}
- MOCK_METHOD3(DecodeCall,
- int32_t(const EncodedImage& input_image,
- bool missing_frames,
- int64_t render_time_ms));
+ MOCK_METHOD(int32_t,
+ DecodeCall,
+ (const EncodedImage& input_image,
+ bool missing_frames,
+ int64_t render_time_ms),
+ ());
int32_t Release() override { return 0; }
diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc
index 158d745..a768203 100644
--- a/video/video_stream_encoder_unittest.cc
+++ b/video/video_stream_encoder_unittest.cc
@@ -507,16 +507,24 @@
class MockBitrateObserver : public VideoBitrateAllocationObserver {
public:
- MOCK_METHOD1(OnBitrateAllocationUpdated, void(const VideoBitrateAllocation&));
+ MOCK_METHOD(void,
+ OnBitrateAllocationUpdated,
+ (const VideoBitrateAllocation&),
+ (override));
};
class MockEncoderSelector
: public VideoEncoderFactory::EncoderSelectorInterface {
public:
- MOCK_METHOD1(OnCurrentEncoder, void(const SdpVideoFormat& format));
- MOCK_METHOD1(OnAvailableBitrate,
- absl::optional<SdpVideoFormat>(const DataRate& rate));
- MOCK_METHOD0(OnEncoderBroken, absl::optional<SdpVideoFormat>());
+ MOCK_METHOD(void,
+ OnCurrentEncoder,
+ (const SdpVideoFormat& format),
+ (override));
+ MOCK_METHOD(absl::optional<SdpVideoFormat>,
+ OnAvailableBitrate,
+ (const DataRate& rate),
+ (override));
+ MOCK_METHOD(absl::optional<SdpVideoFormat>, OnEncoderBroken, (), (override));
};
} // namespace
@@ -5518,10 +5526,12 @@
}
struct MockEncoderSwitchRequestCallback : public EncoderSwitchRequestCallback {
- MOCK_METHOD0(RequestEncoderFallback, void());
- MOCK_METHOD1(RequestEncoderSwitch, void(const Config& conf));
- MOCK_METHOD1(RequestEncoderSwitch,
- void(const webrtc::SdpVideoFormat& format));
+ MOCK_METHOD(void, RequestEncoderFallback, (), (override));
+ MOCK_METHOD(void, RequestEncoderSwitch, (const Config& conf), (override));
+ MOCK_METHOD(void,
+ RequestEncoderSwitch,
+ (const webrtc::SdpVideoFormat& format),
+ (override));
};
TEST_F(VideoStreamEncoderTest, BitrateEncoderSwitch) {