Jiawei Ou | 651b92e | 2018-06-29 15:46:44 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef API_TEST_MOCK_PEERCONNECTIONINTERFACE_H_ |
| 12 | #define API_TEST_MOCK_PEERCONNECTIONINTERFACE_H_ |
| 13 | |
| 14 | #include <memory> |
| 15 | #include <string> |
Niels Möller | 7b04a91 | 2019-09-13 15:41:21 +0200 | [diff] [blame^] | 16 | #include <type_traits> |
Jiawei Ou | 651b92e | 2018-06-29 15:46:44 -0700 | [diff] [blame] | 17 | #include <utility> |
| 18 | #include <vector> |
| 19 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 20 | #include "api/peer_connection_interface.h" |
Harald Alvestrand | 15845af | 2019-03-05 09:50:57 +0100 | [diff] [blame] | 21 | #include "api/sctp_transport_interface.h" |
Jiawei Ou | 651b92e | 2018-06-29 15:46:44 -0700 | [diff] [blame] | 22 | #include "test/gmock.h" |
| 23 | |
| 24 | namespace webrtc { |
| 25 | |
| 26 | class MockPeerConnectionInterface |
| 27 | : public rtc::RefCountedObject<webrtc::PeerConnectionInterface> { |
| 28 | public: |
| 29 | // PeerConnectionInterface |
| 30 | MOCK_METHOD0(local_streams, rtc::scoped_refptr<StreamCollectionInterface>()); |
| 31 | MOCK_METHOD0(remote_streams, rtc::scoped_refptr<StreamCollectionInterface>()); |
| 32 | MOCK_METHOD1(AddStream, bool(MediaStreamInterface*)); |
| 33 | MOCK_METHOD1(RemoveStream, void(MediaStreamInterface*)); |
| 34 | MOCK_METHOD2(AddTrack, |
| 35 | RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>>( |
| 36 | rtc::scoped_refptr<MediaStreamTrackInterface>, |
| 37 | const std::vector<std::string>&)); |
| 38 | MOCK_METHOD2(AddTrack, |
| 39 | rtc::scoped_refptr<RtpSenderInterface>( |
| 40 | MediaStreamTrackInterface*, |
| 41 | std::vector<MediaStreamInterface*>)); |
| 42 | MOCK_METHOD1(RemoveTrack, bool(RtpSenderInterface*)); |
Niels Möller | 7b04a91 | 2019-09-13 15:41:21 +0200 | [diff] [blame^] | 43 | MOCK_METHOD1(RemoveTrackNew, |
| 44 | RTCError(rtc::scoped_refptr<RtpSenderInterface>)); |
Jiawei Ou | 651b92e | 2018-06-29 15:46:44 -0700 | [diff] [blame] | 45 | MOCK_METHOD1(AddTransceiver, |
| 46 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>( |
| 47 | rtc::scoped_refptr<MediaStreamTrackInterface>)); |
| 48 | MOCK_METHOD2(AddTransceiver, |
| 49 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>( |
| 50 | rtc::scoped_refptr<MediaStreamTrackInterface>, |
| 51 | const RtpTransceiverInit&)); |
| 52 | MOCK_METHOD1(AddTransceiver, |
| 53 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>( |
| 54 | cricket::MediaType)); |
| 55 | MOCK_METHOD2(AddTransceiver, |
| 56 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>( |
| 57 | cricket::MediaType, |
| 58 | const RtpTransceiverInit&)); |
| 59 | MOCK_METHOD2(CreateSender, |
| 60 | rtc::scoped_refptr<RtpSenderInterface>(const std::string&, |
| 61 | const std::string&)); |
| 62 | MOCK_CONST_METHOD0(GetSenders, |
| 63 | std::vector<rtc::scoped_refptr<RtpSenderInterface>>()); |
| 64 | MOCK_CONST_METHOD0(GetReceivers, |
| 65 | std::vector<rtc::scoped_refptr<RtpReceiverInterface>>()); |
| 66 | MOCK_CONST_METHOD0( |
| 67 | GetTransceivers, |
| 68 | std::vector<rtc::scoped_refptr<RtpTransceiverInterface>>()); |
| 69 | MOCK_METHOD3(GetStats, |
| 70 | bool(StatsObserver*, |
| 71 | MediaStreamTrackInterface*, |
| 72 | StatsOutputLevel)); |
| 73 | MOCK_METHOD1(GetStats, void(RTCStatsCollectorCallback*)); |
| 74 | MOCK_METHOD2(GetStats, |
| 75 | void(rtc::scoped_refptr<RtpSenderInterface>, |
| 76 | rtc::scoped_refptr<RTCStatsCollectorCallback>)); |
| 77 | MOCK_METHOD2(GetStats, |
| 78 | void(rtc::scoped_refptr<RtpReceiverInterface>, |
| 79 | rtc::scoped_refptr<RTCStatsCollectorCallback>)); |
| 80 | MOCK_METHOD0(ClearStatsCache, void()); |
Harald Alvestrand | 15845af | 2019-03-05 09:50:57 +0100 | [diff] [blame] | 81 | MOCK_CONST_METHOD0(GetSctpTransport, |
| 82 | rtc::scoped_refptr<SctpTransportInterface>()); |
Jiawei Ou | 651b92e | 2018-06-29 15:46:44 -0700 | [diff] [blame] | 83 | MOCK_METHOD2( |
| 84 | CreateDataChannel, |
| 85 | rtc::scoped_refptr<DataChannelInterface>(const std::string&, |
| 86 | const DataChannelInit*)); |
| 87 | MOCK_CONST_METHOD0(local_description, const SessionDescriptionInterface*()); |
| 88 | MOCK_CONST_METHOD0(remote_description, const SessionDescriptionInterface*()); |
| 89 | MOCK_CONST_METHOD0(current_local_description, |
| 90 | const SessionDescriptionInterface*()); |
| 91 | MOCK_CONST_METHOD0(current_remote_description, |
| 92 | const SessionDescriptionInterface*()); |
| 93 | MOCK_CONST_METHOD0(pending_local_description, |
| 94 | const SessionDescriptionInterface*()); |
| 95 | MOCK_CONST_METHOD0(pending_remote_description, |
| 96 | const SessionDescriptionInterface*()); |
Niels Möller | 7b04a91 | 2019-09-13 15:41:21 +0200 | [diff] [blame^] | 97 | MOCK_METHOD0(RestartIce, void()); |
Jiawei Ou | 651b92e | 2018-06-29 15:46:44 -0700 | [diff] [blame] | 98 | MOCK_METHOD2(CreateOffer, |
| 99 | void(CreateSessionDescriptionObserver*, |
Jiawei Ou | 651b92e | 2018-06-29 15:46:44 -0700 | [diff] [blame] | 100 | const RTCOfferAnswerOptions&)); |
| 101 | MOCK_METHOD2(CreateAnswer, |
| 102 | void(CreateSessionDescriptionObserver*, |
| 103 | const RTCOfferAnswerOptions&)); |
Jiawei Ou | 651b92e | 2018-06-29 15:46:44 -0700 | [diff] [blame] | 104 | MOCK_METHOD2(SetLocalDescription, |
| 105 | void(SetSessionDescriptionObserver*, |
| 106 | SessionDescriptionInterface*)); |
| 107 | MOCK_METHOD2(SetRemoteDescription, |
| 108 | void(SetSessionDescriptionObserver*, |
| 109 | SessionDescriptionInterface*)); |
| 110 | MOCK_METHOD2(SetRemoteDescription, |
| 111 | void(std::unique_ptr<SessionDescriptionInterface>, |
| 112 | rtc::scoped_refptr<SetRemoteDescriptionObserverInterface>)); |
| 113 | MOCK_METHOD0(GetConfiguration, PeerConnectionInterface::RTCConfiguration()); |
Jiawei Ou | 651b92e | 2018-06-29 15:46:44 -0700 | [diff] [blame] | 114 | MOCK_METHOD1(SetConfiguration, |
Niels Möller | 2579f0c | 2019-08-19 09:58:17 +0200 | [diff] [blame] | 115 | RTCError(const PeerConnectionInterface::RTCConfiguration&)); |
Jiawei Ou | 651b92e | 2018-06-29 15:46:44 -0700 | [diff] [blame] | 116 | MOCK_METHOD1(AddIceCandidate, bool(const IceCandidateInterface*)); |
| 117 | MOCK_METHOD1(RemoveIceCandidates, |
| 118 | bool(const std::vector<cricket::Candidate>&)); |
Jiawei Ou | 651b92e | 2018-06-29 15:46:44 -0700 | [diff] [blame] | 119 | MOCK_METHOD1(SetBitrate, RTCError(const BitrateSettings&)); |
| 120 | MOCK_METHOD1(SetBitrate, RTCError(const BitrateParameters&)); |
Jiawei Ou | 651b92e | 2018-06-29 15:46:44 -0700 | [diff] [blame] | 121 | MOCK_METHOD1(SetAudioPlayout, void(bool)); |
| 122 | MOCK_METHOD1(SetAudioRecording, void(bool)); |
Niels Möller | 7b04a91 | 2019-09-13 15:41:21 +0200 | [diff] [blame^] | 123 | MOCK_METHOD1(LookupDtlsTransportByMid, |
| 124 | rtc::scoped_refptr<DtlsTransportInterface>(const std::string&)); |
Jiawei Ou | 651b92e | 2018-06-29 15:46:44 -0700 | [diff] [blame] | 125 | MOCK_METHOD0(signaling_state, SignalingState()); |
| 126 | MOCK_METHOD0(ice_connection_state, IceConnectionState()); |
Niels Möller | 7b04a91 | 2019-09-13 15:41:21 +0200 | [diff] [blame^] | 127 | MOCK_METHOD0(standardized_ice_connection_state, IceConnectionState()); |
| 128 | MOCK_METHOD0(peer_connection_state, PeerConnectionState()); |
Jiawei Ou | 651b92e | 2018-06-29 15:46:44 -0700 | [diff] [blame] | 129 | MOCK_METHOD0(ice_gathering_state, IceGatheringState()); |
Jiawei Ou | 651b92e | 2018-06-29 15:46:44 -0700 | [diff] [blame] | 130 | MOCK_METHOD2(StartRtcEventLog, |
| 131 | bool(std::unique_ptr<RtcEventLogOutput>, int64_t)); |
Niels Möller | 7b04a91 | 2019-09-13 15:41:21 +0200 | [diff] [blame^] | 132 | MOCK_METHOD1(StartRtcEventLog, bool(std::unique_ptr<RtcEventLogOutput>)); |
Jiawei Ou | 651b92e | 2018-06-29 15:46:44 -0700 | [diff] [blame] | 133 | MOCK_METHOD0(StopRtcEventLog, void()); |
| 134 | MOCK_METHOD0(Close, void()); |
| 135 | }; |
| 136 | |
Niels Möller | 7b04a91 | 2019-09-13 15:41:21 +0200 | [diff] [blame^] | 137 | static_assert(!std::is_abstract<MockPeerConnectionInterface>::value, ""); |
| 138 | |
Jiawei Ou | 651b92e | 2018-06-29 15:46:44 -0700 | [diff] [blame] | 139 | } // namespace webrtc |
| 140 | |
| 141 | #endif // API_TEST_MOCK_PEERCONNECTIONINTERFACE_H_ |