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> 16 #include <type_traits> 17 #include <utility> 18 #include <vector> 19 20 #include "api/peer_connection_interface.h" 21 #include "api/scoped_refptr.h" 22 #include "api/sctp_transport_interface.h" 23 #include "rtc_base/ref_counted_object.h" 24 #include "test/gmock.h" 25 26 namespace webrtc { 27 28 class MockPeerConnectionInterface : public webrtc::PeerConnectionInterface { 29 public: Create()30 static rtc::scoped_refptr<MockPeerConnectionInterface> Create() { 31 return rtc::make_ref_counted<MockPeerConnectionInterface>(); 32 } 33 34 // PeerConnectionInterface 35 MOCK_METHOD(rtc::scoped_refptr<StreamCollectionInterface>, 36 local_streams, 37 (), 38 (override)); 39 MOCK_METHOD(rtc::scoped_refptr<StreamCollectionInterface>, 40 remote_streams, 41 (), 42 (override)); 43 MOCK_METHOD(bool, AddStream, (MediaStreamInterface*), (override)); 44 MOCK_METHOD(void, RemoveStream, (MediaStreamInterface*), (override)); 45 MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>>, 46 AddTrack, 47 (rtc::scoped_refptr<MediaStreamTrackInterface>, 48 const std::vector<std::string>&), 49 (override)); 50 MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>>, 51 AddTrack, 52 (rtc::scoped_refptr<MediaStreamTrackInterface>, 53 const std::vector<std::string>&, 54 const std::vector<RtpEncodingParameters>&), 55 (override)); 56 MOCK_METHOD(RTCError, 57 RemoveTrackOrError, 58 (rtc::scoped_refptr<RtpSenderInterface>), 59 (override)); 60 MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>, 61 AddTransceiver, 62 (rtc::scoped_refptr<MediaStreamTrackInterface>), 63 (override)); 64 MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>, 65 AddTransceiver, 66 (rtc::scoped_refptr<MediaStreamTrackInterface>, 67 const RtpTransceiverInit&), 68 (override)); 69 MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>, 70 AddTransceiver, 71 (cricket::MediaType), 72 (override)); 73 MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>, 74 AddTransceiver, 75 (cricket::MediaType, const RtpTransceiverInit&), 76 (override)); 77 MOCK_METHOD(rtc::scoped_refptr<RtpSenderInterface>, 78 CreateSender, 79 (const std::string&, const std::string&), 80 (override)); 81 MOCK_METHOD(std::vector<rtc::scoped_refptr<RtpSenderInterface>>, 82 GetSenders, 83 (), 84 (const, override)); 85 MOCK_METHOD(std::vector<rtc::scoped_refptr<RtpReceiverInterface>>, 86 GetReceivers, 87 (), 88 (const, override)); 89 MOCK_METHOD(std::vector<rtc::scoped_refptr<RtpTransceiverInterface>>, 90 GetTransceivers, 91 (), 92 (const, override)); 93 MOCK_METHOD(bool, 94 GetStats, 95 (StatsObserver*, MediaStreamTrackInterface*, StatsOutputLevel), 96 (override)); 97 MOCK_METHOD(void, GetStats, (RTCStatsCollectorCallback*), (override)); 98 MOCK_METHOD(void, 99 GetStats, 100 (rtc::scoped_refptr<RtpSenderInterface>, 101 rtc::scoped_refptr<RTCStatsCollectorCallback>), 102 (override)); 103 MOCK_METHOD(void, 104 GetStats, 105 (rtc::scoped_refptr<RtpReceiverInterface>, 106 rtc::scoped_refptr<RTCStatsCollectorCallback>), 107 (override)); 108 MOCK_METHOD(void, ClearStatsCache, (), (override)); 109 MOCK_METHOD(rtc::scoped_refptr<SctpTransportInterface>, 110 GetSctpTransport, 111 (), 112 (const, override)); 113 MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<DataChannelInterface>>, 114 CreateDataChannelOrError, 115 (const std::string&, const DataChannelInit*), 116 (override)); 117 MOCK_METHOD(const SessionDescriptionInterface*, 118 local_description, 119 (), 120 (const, override)); 121 MOCK_METHOD(const SessionDescriptionInterface*, 122 remote_description, 123 (), 124 (const, override)); 125 MOCK_METHOD(const SessionDescriptionInterface*, 126 current_local_description, 127 (), 128 (const, override)); 129 MOCK_METHOD(const SessionDescriptionInterface*, 130 current_remote_description, 131 (), 132 (const, override)); 133 MOCK_METHOD(const SessionDescriptionInterface*, 134 pending_local_description, 135 (), 136 (const, override)); 137 MOCK_METHOD(const SessionDescriptionInterface*, 138 pending_remote_description, 139 (), 140 (const, override)); 141 MOCK_METHOD(void, RestartIce, (), (override)); 142 MOCK_METHOD(void, 143 CreateOffer, 144 (CreateSessionDescriptionObserver*, const RTCOfferAnswerOptions&), 145 (override)); 146 MOCK_METHOD(void, 147 CreateAnswer, 148 (CreateSessionDescriptionObserver*, const RTCOfferAnswerOptions&), 149 (override)); 150 MOCK_METHOD(void, 151 SetLocalDescription, 152 (SetSessionDescriptionObserver*, SessionDescriptionInterface*), 153 (override)); 154 MOCK_METHOD(void, 155 SetRemoteDescription, 156 (SetSessionDescriptionObserver*, SessionDescriptionInterface*), 157 (override)); 158 MOCK_METHOD(void, 159 SetRemoteDescription, 160 (std::unique_ptr<SessionDescriptionInterface>, 161 rtc::scoped_refptr<SetRemoteDescriptionObserverInterface>), 162 (override)); 163 MOCK_METHOD(PeerConnectionInterface::RTCConfiguration, 164 GetConfiguration, 165 (), 166 (override)); 167 MOCK_METHOD(RTCError, 168 SetConfiguration, 169 (const PeerConnectionInterface::RTCConfiguration&), 170 (override)); 171 MOCK_METHOD(bool, 172 AddIceCandidate, 173 (const IceCandidateInterface*), 174 (override)); 175 MOCK_METHOD(bool, 176 RemoveIceCandidates, 177 (const std::vector<cricket::Candidate>&), 178 (override)); 179 MOCK_METHOD(RTCError, SetBitrate, (const BitrateSettings&), (override)); 180 MOCK_METHOD(void, SetAudioPlayout, (bool), (override)); 181 MOCK_METHOD(void, SetAudioRecording, (bool), (override)); 182 MOCK_METHOD(rtc::scoped_refptr<DtlsTransportInterface>, 183 LookupDtlsTransportByMid, 184 (const std::string&), 185 (override)); 186 MOCK_METHOD(SignalingState, signaling_state, (), (override)); 187 MOCK_METHOD(IceConnectionState, ice_connection_state, (), (override)); 188 MOCK_METHOD(IceConnectionState, 189 standardized_ice_connection_state, 190 (), 191 (override)); 192 MOCK_METHOD(PeerConnectionState, peer_connection_state, (), (override)); 193 MOCK_METHOD(IceGatheringState, ice_gathering_state, (), (override)); 194 MOCK_METHOD(absl::optional<bool>, can_trickle_ice_candidates, (), (override)); 195 MOCK_METHOD(bool, 196 StartRtcEventLog, 197 (std::unique_ptr<RtcEventLogOutput>, int64_t), 198 (override)); 199 MOCK_METHOD(bool, 200 StartRtcEventLog, 201 (std::unique_ptr<RtcEventLogOutput>), 202 (override)); 203 MOCK_METHOD(void, StopRtcEventLog, (), (override)); 204 MOCK_METHOD(void, Close, (), (override)); 205 }; 206 207 static_assert( 208 !std::is_abstract_v<rtc::RefCountedObject<MockPeerConnectionInterface>>, 209 ""); 210 211 } // namespace webrtc 212 213 #endif // API_TEST_MOCK_PEERCONNECTIONINTERFACE_H_ 214