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