Cleanup mocks in api/test

Modernise functions to unified MOCK_METHOD macro,
delete few deprecated functions on the way.
add one missing function (in MockEncodedImageCallback)
Remove proxy mock function (in MockVideoBitrateAllocatorFactory)

Remove default constructors and destructors

Bug: None
Change-Id: Ibebb0d9e3c9be5877649af7bde8b87222ddf04fb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174751
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31195}
This commit is contained in:
Danil Chapovalov 2020-05-08 15:03:03 +02:00 committed by Commit Bot
parent 74ef940d79
commit fc11519c92
17 changed files with 299 additions and 306 deletions

View File

@ -785,10 +785,7 @@ if (rtc_include_tests) {
rtc_library("mock_frame_encryptor") {
testonly = true
sources = [
"test/mock_frame_encryptor.cc",
"test/mock_frame_encryptor.h",
]
sources = [ "test/mock_frame_encryptor.h" ]
deps = [
# For api/crypto/frame_encryptor_interface.h
":libjingle_peerconnection_api",
@ -799,10 +796,7 @@ if (rtc_include_tests) {
rtc_library("mock_frame_decryptor") {
testonly = true
sources = [
"test/mock_frame_decryptor.cc",
"test/mock_frame_decryptor.h",
]
sources = [ "test/mock_frame_decryptor.h" ]
deps = [
":libjingle_peerconnection_api",
"../test:test_support",
@ -917,10 +911,7 @@ if (rtc_include_tests) {
visibility = [ "*" ]
testonly = true
sources = [
"test/mock_video_decoder.cc",
"test/mock_video_decoder.h",
]
sources = [ "test/mock_video_decoder.h" ]
deps = [
"../api/video_codecs:video_codecs_api",
@ -932,10 +923,7 @@ if (rtc_include_tests) {
visibility = [ "*" ]
testonly = true
sources = [
"test/mock_video_encoder.cc",
"test/mock_video_encoder.h",
]
sources = [ "test/mock_video_encoder.h" ]
deps = [
"../api/video_codecs:video_codecs_api",

View File

@ -19,11 +19,12 @@ namespace test {
class MockAudioMixer : public AudioMixer {
public:
MOCK_METHOD1(AddSource, bool(Source* audio_source));
MOCK_METHOD1(RemoveSource, void(Source* audio_source));
MOCK_METHOD2(Mix,
void(size_t number_of_channels,
AudioFrame* audio_frame_for_mixing));
MOCK_METHOD(bool, AddSource, (Source * audio_source), (override));
MOCK_METHOD(void, RemoveSource, (Source * audio_source), (override));
MOCK_METHOD(void,
Mix,
(size_t number_of_channels, AudioFrame* audio_frame_for_mixing),
(override));
};
} // namespace test
} // namespace webrtc

View File

@ -18,9 +18,7 @@ namespace webrtc {
class MockFecControllerOverride : public FecControllerOverride {
public:
~MockFecControllerOverride() override = default;
MOCK_METHOD1(SetFecAllowed, void(bool fec_allowed));
MOCK_METHOD(void, SetFecAllowed, (bool fec_allowed), (override));
};
} // namespace webrtc

View File

@ -1,18 +0,0 @@
/*
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "api/test/mock_frame_decryptor.h"
namespace webrtc {
MockFrameDecryptor::MockFrameDecryptor() = default;
MockFrameDecryptor::~MockFrameDecryptor() = default;
} // namespace webrtc

View File

@ -20,18 +20,19 @@ namespace webrtc {
class MockFrameDecryptor : public FrameDecryptorInterface {
public:
MockFrameDecryptor();
~MockFrameDecryptor() override;
MOCK_METHOD(Result,
Decrypt,
(cricket::MediaType,
const std::vector<uint32_t>&,
rtc::ArrayView<const uint8_t>,
rtc::ArrayView<const uint8_t>,
rtc::ArrayView<uint8_t>),
(override));
MOCK_METHOD5(Decrypt,
Result(cricket::MediaType,
const std::vector<uint32_t>&,
rtc::ArrayView<const uint8_t>,
rtc::ArrayView<const uint8_t>,
rtc::ArrayView<uint8_t>));
MOCK_METHOD2(GetMaxPlaintextByteSize,
size_t(cricket::MediaType, size_t encrypted_frame_size));
MOCK_METHOD(size_t,
GetMaxPlaintextByteSize,
(cricket::MediaType, size_t encrypted_frame_size),
(override));
};
} // namespace webrtc

View File

@ -1,20 +0,0 @@
/*
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "api/test/mock_frame_encryptor.h"
#include "test/gmock.h"
namespace webrtc {
MockFrameEncryptor::MockFrameEncryptor() = default;
MockFrameEncryptor::~MockFrameEncryptor() = default;
} // namespace webrtc

View File

@ -18,19 +18,20 @@ namespace webrtc {
class MockFrameEncryptor : public FrameEncryptorInterface {
public:
MockFrameEncryptor();
~MockFrameEncryptor() override;
MOCK_METHOD(int,
Encrypt,
(cricket::MediaType,
uint32_t,
rtc::ArrayView<const uint8_t>,
rtc::ArrayView<const uint8_t>,
rtc::ArrayView<uint8_t>,
size_t*),
(override));
MOCK_METHOD6(Encrypt,
int(cricket::MediaType,
uint32_t,
rtc::ArrayView<const uint8_t>,
rtc::ArrayView<const uint8_t>,
rtc::ArrayView<uint8_t>,
size_t*));
MOCK_METHOD2(GetMaxCiphertextByteSize,
size_t(cricket::MediaType media_type, size_t frame_size));
MOCK_METHOD(size_t,
GetMaxCiphertextByteSize,
(cricket::MediaType media_type, size_t frame_size),
(override));
};
} // namespace webrtc

View File

@ -27,112 +27,172 @@ class MockPeerConnectionInterface
: public rtc::RefCountedObject<webrtc::PeerConnectionInterface> {
public:
// PeerConnectionInterface
MOCK_METHOD0(local_streams, rtc::scoped_refptr<StreamCollectionInterface>());
MOCK_METHOD0(remote_streams, rtc::scoped_refptr<StreamCollectionInterface>());
MOCK_METHOD1(AddStream, bool(MediaStreamInterface*));
MOCK_METHOD1(RemoveStream, void(MediaStreamInterface*));
MOCK_METHOD2(AddTrack,
RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>>(
rtc::scoped_refptr<MediaStreamTrackInterface>,
const std::vector<std::string>&));
MOCK_METHOD2(AddTrack,
rtc::scoped_refptr<RtpSenderInterface>(
MediaStreamTrackInterface*,
std::vector<MediaStreamInterface*>));
MOCK_METHOD1(RemoveTrack, bool(RtpSenderInterface*));
MOCK_METHOD1(RemoveTrackNew,
RTCError(rtc::scoped_refptr<RtpSenderInterface>));
MOCK_METHOD1(AddTransceiver,
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>(
rtc::scoped_refptr<MediaStreamTrackInterface>));
MOCK_METHOD2(AddTransceiver,
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>(
rtc::scoped_refptr<MediaStreamTrackInterface>,
const RtpTransceiverInit&));
MOCK_METHOD1(AddTransceiver,
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>(
cricket::MediaType));
MOCK_METHOD2(AddTransceiver,
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>(
cricket::MediaType,
const RtpTransceiverInit&));
MOCK_METHOD2(CreateSender,
rtc::scoped_refptr<RtpSenderInterface>(const std::string&,
const std::string&));
MOCK_CONST_METHOD0(GetSenders,
std::vector<rtc::scoped_refptr<RtpSenderInterface>>());
MOCK_CONST_METHOD0(GetReceivers,
std::vector<rtc::scoped_refptr<RtpReceiverInterface>>());
MOCK_CONST_METHOD0(
GetTransceivers,
std::vector<rtc::scoped_refptr<RtpTransceiverInterface>>());
MOCK_METHOD3(GetStats,
bool(StatsObserver*,
MediaStreamTrackInterface*,
StatsOutputLevel));
MOCK_METHOD1(GetStats, void(RTCStatsCollectorCallback*));
MOCK_METHOD2(GetStats,
void(rtc::scoped_refptr<RtpSenderInterface>,
rtc::scoped_refptr<RTCStatsCollectorCallback>));
MOCK_METHOD2(GetStats,
void(rtc::scoped_refptr<RtpReceiverInterface>,
rtc::scoped_refptr<RTCStatsCollectorCallback>));
MOCK_METHOD0(ClearStatsCache, void());
MOCK_CONST_METHOD0(GetSctpTransport,
rtc::scoped_refptr<SctpTransportInterface>());
MOCK_METHOD2(
CreateDataChannel,
rtc::scoped_refptr<DataChannelInterface>(const std::string&,
const DataChannelInit*));
MOCK_CONST_METHOD0(local_description, const SessionDescriptionInterface*());
MOCK_CONST_METHOD0(remote_description, const SessionDescriptionInterface*());
MOCK_CONST_METHOD0(current_local_description,
const SessionDescriptionInterface*());
MOCK_CONST_METHOD0(current_remote_description,
const SessionDescriptionInterface*());
MOCK_CONST_METHOD0(pending_local_description,
const SessionDescriptionInterface*());
MOCK_CONST_METHOD0(pending_remote_description,
const SessionDescriptionInterface*());
MOCK_METHOD0(RestartIce, void());
MOCK_METHOD2(CreateOffer,
void(CreateSessionDescriptionObserver*,
const RTCOfferAnswerOptions&));
MOCK_METHOD2(CreateAnswer,
void(CreateSessionDescriptionObserver*,
const RTCOfferAnswerOptions&));
MOCK_METHOD2(SetLocalDescription,
void(SetSessionDescriptionObserver*,
SessionDescriptionInterface*));
MOCK_METHOD2(SetRemoteDescription,
void(SetSessionDescriptionObserver*,
SessionDescriptionInterface*));
MOCK_METHOD2(SetRemoteDescription,
void(std::unique_ptr<SessionDescriptionInterface>,
rtc::scoped_refptr<SetRemoteDescriptionObserverInterface>));
MOCK_METHOD0(GetConfiguration, PeerConnectionInterface::RTCConfiguration());
MOCK_METHOD1(SetConfiguration,
RTCError(const PeerConnectionInterface::RTCConfiguration&));
MOCK_METHOD1(AddIceCandidate, bool(const IceCandidateInterface*));
MOCK_METHOD1(RemoveIceCandidates,
bool(const std::vector<cricket::Candidate>&));
MOCK_METHOD1(SetBitrate, RTCError(const BitrateSettings&));
MOCK_METHOD1(SetBitrate, RTCError(const BitrateParameters&));
MOCK_METHOD1(SetAudioPlayout, void(bool));
MOCK_METHOD1(SetAudioRecording, void(bool));
MOCK_METHOD1(LookupDtlsTransportByMid,
rtc::scoped_refptr<DtlsTransportInterface>(const std::string&));
MOCK_METHOD0(signaling_state, SignalingState());
MOCK_METHOD0(ice_connection_state, IceConnectionState());
MOCK_METHOD0(standardized_ice_connection_state, IceConnectionState());
MOCK_METHOD0(peer_connection_state, PeerConnectionState());
MOCK_METHOD0(ice_gathering_state, IceGatheringState());
MOCK_METHOD0(can_trickle_ice_candidates, absl::optional<bool>());
MOCK_METHOD2(StartRtcEventLog,
bool(std::unique_ptr<RtcEventLogOutput>, int64_t));
MOCK_METHOD1(StartRtcEventLog, bool(std::unique_ptr<RtcEventLogOutput>));
MOCK_METHOD0(StopRtcEventLog, void());
MOCK_METHOD0(Close, void());
MOCK_METHOD(rtc::scoped_refptr<StreamCollectionInterface>,
local_streams,
(),
(override));
MOCK_METHOD(rtc::scoped_refptr<StreamCollectionInterface>,
remote_streams,
(),
(override));
MOCK_METHOD(bool, AddStream, (MediaStreamInterface*), (override));
MOCK_METHOD(void, RemoveStream, (MediaStreamInterface*), (override));
MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>>,
AddTrack,
(rtc::scoped_refptr<MediaStreamTrackInterface>,
const std::vector<std::string>&),
(override));
MOCK_METHOD(bool, RemoveTrack, (RtpSenderInterface*), (override));
MOCK_METHOD(RTCError,
RemoveTrackNew,
(rtc::scoped_refptr<RtpSenderInterface>),
(override));
MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
AddTransceiver,
(rtc::scoped_refptr<MediaStreamTrackInterface>),
(override));
MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
AddTransceiver,
(rtc::scoped_refptr<MediaStreamTrackInterface>,
const RtpTransceiverInit&),
(override));
MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
AddTransceiver,
(cricket::MediaType),
(override));
MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
AddTransceiver,
(cricket::MediaType, const RtpTransceiverInit&),
(override));
MOCK_METHOD(rtc::scoped_refptr<RtpSenderInterface>,
CreateSender,
(const std::string&, const std::string&),
(override));
MOCK_METHOD(std::vector<rtc::scoped_refptr<RtpSenderInterface>>,
GetSenders,
(),
(const override));
MOCK_METHOD(std::vector<rtc::scoped_refptr<RtpReceiverInterface>>,
GetReceivers,
(),
(const override));
MOCK_METHOD(std::vector<rtc::scoped_refptr<RtpTransceiverInterface>>,
GetTransceivers,
(),
(const override));
MOCK_METHOD(bool,
GetStats,
(StatsObserver*, MediaStreamTrackInterface*, StatsOutputLevel),
(override));
MOCK_METHOD(void, GetStats, (RTCStatsCollectorCallback*), (override));
MOCK_METHOD(void,
GetStats,
(rtc::scoped_refptr<RtpSenderInterface>,
rtc::scoped_refptr<RTCStatsCollectorCallback>),
(override));
MOCK_METHOD(void,
GetStats,
(rtc::scoped_refptr<RtpReceiverInterface>,
rtc::scoped_refptr<RTCStatsCollectorCallback>),
(override));
MOCK_METHOD(void, ClearStatsCache, (), (override));
MOCK_METHOD(rtc::scoped_refptr<SctpTransportInterface>,
GetSctpTransport,
(),
(const override));
MOCK_METHOD(rtc::scoped_refptr<DataChannelInterface>,
CreateDataChannel,
(const std::string&, const DataChannelInit*),
(override));
MOCK_METHOD(const SessionDescriptionInterface*,
local_description,
(),
(const override));
MOCK_METHOD(const SessionDescriptionInterface*,
remote_description,
(),
(const override));
MOCK_METHOD(const SessionDescriptionInterface*,
current_local_description,
(),
(const override));
MOCK_METHOD(const SessionDescriptionInterface*,
current_remote_description,
(),
(const override));
MOCK_METHOD(const SessionDescriptionInterface*,
pending_local_description,
(),
(const override));
MOCK_METHOD(const SessionDescriptionInterface*,
pending_remote_description,
(),
(const override));
MOCK_METHOD(void, RestartIce, (), (override));
MOCK_METHOD(void,
CreateOffer,
(CreateSessionDescriptionObserver*, const RTCOfferAnswerOptions&),
(override));
MOCK_METHOD(void,
CreateAnswer,
(CreateSessionDescriptionObserver*, const RTCOfferAnswerOptions&),
(override));
MOCK_METHOD(void,
SetLocalDescription,
(SetSessionDescriptionObserver*, SessionDescriptionInterface*),
(override));
MOCK_METHOD(void,
SetRemoteDescription,
(SetSessionDescriptionObserver*, SessionDescriptionInterface*),
(override));
MOCK_METHOD(void,
SetRemoteDescription,
(std::unique_ptr<SessionDescriptionInterface>,
rtc::scoped_refptr<SetRemoteDescriptionObserverInterface>),
(override));
MOCK_METHOD(PeerConnectionInterface::RTCConfiguration,
GetConfiguration,
(),
(override));
MOCK_METHOD(RTCError,
SetConfiguration,
(const PeerConnectionInterface::RTCConfiguration&),
(override));
MOCK_METHOD(bool,
AddIceCandidate,
(const IceCandidateInterface*),
(override));
MOCK_METHOD(bool,
RemoveIceCandidates,
(const std::vector<cricket::Candidate>&),
(override));
MOCK_METHOD(RTCError, SetBitrate, (const BitrateSettings&), (override));
MOCK_METHOD(RTCError, SetBitrate, (const BitrateParameters&), (override));
MOCK_METHOD(void, SetAudioPlayout, (bool), (override));
MOCK_METHOD(void, SetAudioRecording, (bool), (override));
MOCK_METHOD(rtc::scoped_refptr<DtlsTransportInterface>,
LookupDtlsTransportByMid,
(const std::string&),
(override));
MOCK_METHOD(SignalingState, signaling_state, (), (override));
MOCK_METHOD(IceConnectionState, ice_connection_state, (), (override));
MOCK_METHOD(IceConnectionState,
standardized_ice_connection_state,
(),
(override));
MOCK_METHOD(PeerConnectionState, peer_connection_state, (), (override));
MOCK_METHOD(IceGatheringState, ice_gathering_state, (), (override));
MOCK_METHOD(absl::optional<bool>, can_trickle_ice_candidates, (), (override));
MOCK_METHOD(bool,
StartRtcEventLog,
(std::unique_ptr<RtcEventLogOutput>, int64_t),
(override));
MOCK_METHOD(bool,
StartRtcEventLog,
(std::unique_ptr<RtcEventLogOutput>),
(override));
MOCK_METHOD(void, StopRtcEventLog, (), (override));
MOCK_METHOD(void, Close, (), (override));
};
static_assert(!std::is_abstract<MockPeerConnectionInterface>::value, "");

View File

@ -21,16 +21,23 @@ namespace webrtc {
class MockRtpReceiver : public rtc::RefCountedObject<RtpReceiverInterface> {
public:
MOCK_METHOD1(SetTrack, void(MediaStreamTrackInterface*));
MOCK_CONST_METHOD0(track, rtc::scoped_refptr<MediaStreamTrackInterface>());
MOCK_CONST_METHOD0(streams,
std::vector<rtc::scoped_refptr<MediaStreamInterface>>());
MOCK_CONST_METHOD0(media_type, cricket::MediaType());
MOCK_CONST_METHOD0(id, std::string());
MOCK_CONST_METHOD0(GetParameters, RtpParameters());
MOCK_METHOD1(SetObserver, void(RtpReceiverObserverInterface*));
MOCK_METHOD1(SetJitterBufferMinimumDelay, void(absl::optional<double>));
MOCK_CONST_METHOD0(GetSources, std::vector<RtpSource>());
MOCK_METHOD(rtc::scoped_refptr<MediaStreamTrackInterface>,
track,
(),
(const override));
MOCK_METHOD(std::vector<rtc::scoped_refptr<MediaStreamInterface>>,
streams,
(),
(const override));
MOCK_METHOD(cricket::MediaType, media_type, (), (const override));
MOCK_METHOD(std::string, id, (), (const override));
MOCK_METHOD(RtpParameters, GetParameters, (), (const override));
MOCK_METHOD(void, SetObserver, (RtpReceiverObserverInterface*), (override));
MOCK_METHOD(void,
SetJitterBufferMinimumDelay,
(absl::optional<double>),
(override));
MOCK_METHOD(std::vector<RtpSource>, GetSources, (), (const override));
};
} // namespace webrtc

View File

@ -21,16 +21,25 @@ namespace webrtc {
class MockRtpSender : public rtc::RefCountedObject<RtpSenderInterface> {
public:
MOCK_METHOD1(SetTrack, bool(MediaStreamTrackInterface*));
MOCK_CONST_METHOD0(track, rtc::scoped_refptr<MediaStreamTrackInterface>());
MOCK_CONST_METHOD0(ssrc, uint32_t());
MOCK_CONST_METHOD0(media_type, cricket::MediaType());
MOCK_CONST_METHOD0(id, std::string());
MOCK_CONST_METHOD0(stream_ids, std::vector<std::string>());
MOCK_CONST_METHOD0(init_send_encodings, std::vector<RtpEncodingParameters>());
MOCK_CONST_METHOD0(GetParameters, RtpParameters());
MOCK_METHOD1(SetParameters, RTCError(const RtpParameters&));
MOCK_CONST_METHOD0(GetDtmfSender, rtc::scoped_refptr<DtmfSenderInterface>());
MOCK_METHOD(bool, SetTrack, (MediaStreamTrackInterface*), (override));
MOCK_METHOD(rtc::scoped_refptr<MediaStreamTrackInterface>,
track,
(),
(const override));
MOCK_METHOD(uint32_t, ssrc, (), (const override));
MOCK_METHOD(cricket::MediaType, media_type, (), (const override));
MOCK_METHOD(std::string, id, (), (const override));
MOCK_METHOD(std::vector<std::string>, stream_ids, (), (const override));
MOCK_METHOD(std::vector<RtpEncodingParameters>,
init_send_encodings,
(),
(const override));
MOCK_METHOD(RtpParameters, GetParameters, (), (const override));
MOCK_METHOD(RTCError, SetParameters, (const RtpParameters&), (override));
MOCK_METHOD(rtc::scoped_refptr<DtmfSenderInterface>,
GetDtmfSender,
(),
(const override));
};
} // namespace webrtc

View File

@ -17,10 +17,10 @@
namespace webrtc {
class MockVideoBitrateAllocator : public webrtc::VideoBitrateAllocator {
MOCK_METHOD1(
Allocate,
VideoBitrateAllocation(VideoBitrateAllocationParameters parameters));
MOCK_METHOD1(GetPreferredBitrateBps, uint32_t(uint32_t framerate));
MOCK_METHOD(VideoBitrateAllocation,
Allocate,
(VideoBitrateAllocationParameters parameters),
(override));
};
} // namespace webrtc

View File

@ -21,15 +21,12 @@ namespace webrtc {
class MockVideoBitrateAllocatorFactory
: public webrtc::VideoBitrateAllocatorFactory {
public:
virtual std::unique_ptr<VideoBitrateAllocator> CreateVideoBitrateAllocator(
const VideoCodec& codec) {
return std::unique_ptr<VideoBitrateAllocator>(
CreateVideoBitrateAllocatorProxy(codec));
}
~MockVideoBitrateAllocatorFactory() { Die(); }
MOCK_METHOD1(CreateVideoBitrateAllocatorProxy,
VideoBitrateAllocator*(const VideoCodec&));
MOCK_METHOD0(Die, void());
~MockVideoBitrateAllocatorFactory() override { Die(); }
MOCK_METHOD(std::unique_ptr<VideoBitrateAllocator>,
CreateVideoBitrateAllocator,
(const VideoCodec&),
(override));
MOCK_METHOD(void, Die, (), ());
};
} // namespace webrtc

View File

@ -1,20 +0,0 @@
/*
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "api/test/mock_video_decoder.h"
namespace webrtc {
MockDecodedImageCallback::MockDecodedImageCallback() = default;
MockDecodedImageCallback::~MockDecodedImageCallback() = default;
MockVideoDecoder::MockVideoDecoder() = default;
MockVideoDecoder::~MockVideoDecoder() = default;
} // namespace webrtc

View File

@ -18,34 +18,40 @@ namespace webrtc {
class MockDecodedImageCallback : public DecodedImageCallback {
public:
MockDecodedImageCallback();
~MockDecodedImageCallback() override;
MOCK_METHOD1(Decoded, int32_t(VideoFrame& decodedImage)); // NOLINT
MOCK_METHOD2(Decoded,
int32_t(VideoFrame& decodedImage, // NOLINT
int64_t decode_time_ms));
MOCK_METHOD3(Decoded,
void(VideoFrame& decodedImage, // NOLINT
absl::optional<int32_t> decode_time_ms,
absl::optional<uint8_t> qp));
MOCK_METHOD(int32_t,
Decoded,
(VideoFrame & decoded_image), // NOLINT
(override));
MOCK_METHOD(int32_t,
Decoded,
(VideoFrame & decoded_image, // NOLINT
int64_t decode_time_ms),
(override));
MOCK_METHOD(void,
Decoded,
(VideoFrame & decoded_image, // NOLINT
absl::optional<int32_t> decode_time_ms,
absl::optional<uint8_t> qp),
(override));
};
class MockVideoDecoder : public VideoDecoder {
public:
MockVideoDecoder();
~MockVideoDecoder() override;
MOCK_METHOD2(InitDecode,
int32_t(const VideoCodec* codecSettings, int32_t numberOfCores));
MOCK_METHOD3(Decode,
int32_t(const EncodedImage& inputImage,
bool missingFrames,
int64_t renderTimeMs));
MOCK_METHOD1(RegisterDecodeCompleteCallback,
int32_t(DecodedImageCallback* callback));
MOCK_METHOD0(Release, int32_t());
MOCK_METHOD0(Copy, VideoDecoder*());
MOCK_METHOD(int32_t,
InitDecode,
(const VideoCodec* codec_settings, int32_t number_of_cores),
(override));
MOCK_METHOD(int32_t,
Decode,
(const EncodedImage& input_image,
bool missing_frames,
int64_t render_time_ms),
(override));
MOCK_METHOD(int32_t,
RegisterDecodeCompleteCallback,
(DecodedImageCallback * callback),
(override));
MOCK_METHOD(int32_t, Release, (), (override));
};
} // namespace webrtc

View File

@ -1,20 +0,0 @@
/*
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "api/test/mock_video_encoder.h"
namespace webrtc {
MockEncodedImageCallback::MockEncodedImageCallback() = default;
MockEncodedImageCallback::~MockEncodedImageCallback() = default;
MockVideoEncoder::MockVideoEncoder() = default;
MockVideoEncoder::~MockVideoEncoder() = default;
} // namespace webrtc

View File

@ -20,25 +20,27 @@ namespace webrtc {
class MockEncodedImageCallback : public EncodedImageCallback {
public:
MockEncodedImageCallback();
~MockEncodedImageCallback();
MOCK_METHOD3(OnEncodedImage,
Result(const EncodedImage& encodedImage,
const CodecSpecificInfo* codecSpecificInfo,
const RTPFragmentationHeader* fragmentation));
MOCK_METHOD(Result,
OnEncodedImage,
(const EncodedImage& encodedImage,
const CodecSpecificInfo* codecSpecificInfo,
const RTPFragmentationHeader* fragmentation),
(override));
MOCK_METHOD(void, OnDroppedFrame, (DropReason reason), (override));
};
class MockVideoEncoder : public VideoEncoder {
public:
MockVideoEncoder();
~MockVideoEncoder();
MOCK_METHOD1(SetFecControllerOverride,
void(FecControllerOverride* fec_controller_override));
MOCK_CONST_METHOD2(Version, int32_t(int8_t* version, int32_t length));
MOCK_METHOD3(InitEncode,
int32_t(const VideoCodec* codecSettings,
int32_t numberOfCores,
size_t maxPayloadSize));
MOCK_METHOD(void,
SetFecControllerOverride,
(FecControllerOverride * fec_controller_override),
(override));
MOCK_METHOD(int32_t,
InitEncode,
(const VideoCodec* codecSettings,
int32_t numberOfCores,
size_t maxPayloadSize),
(override));
MOCK_METHOD2(InitEncode,
int32_t(const VideoCodec* codecSettings,
const VideoEncoder::Settings& settings));

View File

@ -1082,9 +1082,10 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, Vp8) {
rate_allocator_factory =
std::make_unique<webrtc::MockVideoBitrateAllocatorFactory>();
EXPECT_CALL(*rate_allocator_factory,
CreateVideoBitrateAllocatorProxy(Field(
&webrtc::VideoCodec::codecType, webrtc::kVideoCodecVP8)))
.WillOnce(Return(new webrtc::MockVideoBitrateAllocator()));
CreateVideoBitrateAllocator(Field(&webrtc::VideoCodec::codecType,
webrtc::kVideoCodecVP8)))
.WillOnce(
[] { return std::make_unique<webrtc::MockVideoBitrateAllocator>(); });
WebRtcVideoEngine engine(
(std::unique_ptr<webrtc::VideoEncoderFactory>(encoder_factory)),
(std::unique_ptr<webrtc::VideoDecoderFactory>(decoder_factory)));