xref: /aosp_15_r20/external/webrtc/pc/test/mock_peer_connection_internal.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright 2022 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 PC_TEST_MOCK_PEER_CONNECTION_INTERNAL_H_
12 #define PC_TEST_MOCK_PEER_CONNECTION_INTERNAL_H_
13 
14 #include <map>
15 #include <memory>
16 #include <set>
17 #include <string>
18 #include <vector>
19 
20 #include "pc/peer_connection_internal.h"
21 #include "test/gmock.h"
22 
23 namespace webrtc {
24 
25 class MockPeerConnectionInternal : public PeerConnectionInternal {
26  public:
MockPeerConnectionInternal()27   MockPeerConnectionInternal() {}
28   ~MockPeerConnectionInternal() = default;
29   // PeerConnectionInterface
30   MOCK_METHOD(rtc::scoped_refptr<StreamCollectionInterface>,
31               local_streams,
32               (),
33               (override));
34   MOCK_METHOD(rtc::scoped_refptr<StreamCollectionInterface>,
35               remote_streams,
36               (),
37               (override));
38   MOCK_METHOD(bool, AddStream, (MediaStreamInterface*), (override));
39   MOCK_METHOD(void, RemoveStream, (MediaStreamInterface*), (override));
40   MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>>,
41               AddTrack,
42               (rtc::scoped_refptr<MediaStreamTrackInterface>,
43                const std::vector<std::string>&),
44               (override));
45   MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>>,
46               AddTrack,
47               (rtc::scoped_refptr<MediaStreamTrackInterface>,
48                const std::vector<std::string>&,
49                const std::vector<RtpEncodingParameters>&),
50               (override));
51   MOCK_METHOD(RTCError,
52               RemoveTrackOrError,
53               (rtc::scoped_refptr<RtpSenderInterface>),
54               (override));
55   MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
56               AddTransceiver,
57               (rtc::scoped_refptr<MediaStreamTrackInterface>),
58               (override));
59   MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
60               AddTransceiver,
61               (rtc::scoped_refptr<MediaStreamTrackInterface>,
62                const RtpTransceiverInit&),
63               (override));
64   MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
65               AddTransceiver,
66               (cricket::MediaType),
67               (override));
68   MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
69               AddTransceiver,
70               (cricket::MediaType, const RtpTransceiverInit&),
71               (override));
72   MOCK_METHOD(rtc::scoped_refptr<RtpSenderInterface>,
73               CreateSender,
74               (const std::string&, const std::string&),
75               (override));
76   MOCK_METHOD(std::vector<rtc::scoped_refptr<RtpSenderInterface>>,
77               GetSenders,
78               (),
79               (const, override));
80   MOCK_METHOD(std::vector<rtc::scoped_refptr<RtpReceiverInterface>>,
81               GetReceivers,
82               (),
83               (const, override));
84   MOCK_METHOD(std::vector<rtc::scoped_refptr<RtpTransceiverInterface>>,
85               GetTransceivers,
86               (),
87               (const, override));
88   MOCK_METHOD(bool,
89               GetStats,
90               (StatsObserver*, MediaStreamTrackInterface*, StatsOutputLevel),
91               (override));
92   MOCK_METHOD(void, GetStats, (RTCStatsCollectorCallback*), (override));
93   MOCK_METHOD(void,
94               GetStats,
95               (rtc::scoped_refptr<RtpSenderInterface>,
96                rtc::scoped_refptr<RTCStatsCollectorCallback>),
97               (override));
98   MOCK_METHOD(void,
99               GetStats,
100               (rtc::scoped_refptr<RtpReceiverInterface>,
101                rtc::scoped_refptr<RTCStatsCollectorCallback>),
102               (override));
103   MOCK_METHOD(void, ClearStatsCache, (), (override));
104   MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<DataChannelInterface>>,
105               CreateDataChannelOrError,
106               (const std::string&, const DataChannelInit*),
107               (override));
108   MOCK_METHOD(SessionDescriptionInterface*,
109               local_description,
110               (),
111               (const, override));
112   MOCK_METHOD(SessionDescriptionInterface*,
113               remote_description,
114               (),
115               (const, override));
116   MOCK_METHOD(SessionDescriptionInterface*,
117               current_local_description,
118               (),
119               (const, override));
120   MOCK_METHOD(SessionDescriptionInterface*,
121               current_remote_description,
122               (),
123               (const, override));
124   MOCK_METHOD(SessionDescriptionInterface*,
125               pending_local_description,
126               (),
127               (const, override));
128   MOCK_METHOD(SessionDescriptionInterface*,
129               pending_remote_description,
130               (),
131               (const, override));
132   MOCK_METHOD(void, RestartIce, (), (override));
133   MOCK_METHOD(void,
134               CreateOffer,
135               (CreateSessionDescriptionObserver*, const RTCOfferAnswerOptions&),
136               (override));
137   MOCK_METHOD(void,
138               CreateAnswer,
139               (CreateSessionDescriptionObserver*, const RTCOfferAnswerOptions&),
140               (override));
141 
142   MOCK_METHOD(void,
143               SetLocalDescription,
144               (SetSessionDescriptionObserver*, SessionDescriptionInterface*),
145               (override));
146   MOCK_METHOD(void,
147               SetRemoteDescription,
148               (SetSessionDescriptionObserver*, SessionDescriptionInterface*),
149               (override));
150   MOCK_METHOD(void,
151               SetRemoteDescription,
152               (std::unique_ptr<SessionDescriptionInterface>,
153                rtc::scoped_refptr<SetRemoteDescriptionObserverInterface>),
154               (override));
155   MOCK_METHOD(PeerConnectionInterface::RTCConfiguration,
156               GetConfiguration,
157               (),
158               (override));
159   MOCK_METHOD(RTCError,
160               SetConfiguration,
161               (const PeerConnectionInterface::RTCConfiguration&),
162               (override));
163   MOCK_METHOD(bool,
164               AddIceCandidate,
165               (const IceCandidateInterface*),
166               (override));
167   MOCK_METHOD(bool,
168               RemoveIceCandidates,
169               (const std::vector<cricket::Candidate>&),
170               (override));
171   MOCK_METHOD(RTCError, SetBitrate, (const BitrateSettings&), (override));
172   MOCK_METHOD(void, SetAudioPlayout, (bool), (override));
173   MOCK_METHOD(void, SetAudioRecording, (bool), (override));
174   MOCK_METHOD(rtc::scoped_refptr<DtlsTransportInterface>,
175               LookupDtlsTransportByMid,
176               (const std::string&),
177               (override));
178   MOCK_METHOD(rtc::scoped_refptr<SctpTransportInterface>,
179               GetSctpTransport,
180               (),
181               (const, 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));
201   MOCK_METHOD(rtc::Thread*, signaling_thread, (), (const, override));
202 
203   // PeerConnectionSdpMethods
204   MOCK_METHOD(std::string, session_id, (), (const, override));
205   MOCK_METHOD(bool, NeedsIceRestart, (const std::string&), (const, override));
206   MOCK_METHOD(absl::optional<std::string>, sctp_mid, (), (const, override));
207   MOCK_METHOD(PeerConnectionInterface::RTCConfiguration*,
208               configuration,
209               (),
210               (const, override));
211   MOCK_METHOD(void,
212               ReportSdpBundleUsage,
213               (const SessionDescriptionInterface&),
214               (override));
215   MOCK_METHOD(PeerConnectionMessageHandler*, message_handler, (), (override));
216   MOCK_METHOD(RtpTransmissionManager*, rtp_manager, (), (override));
217   MOCK_METHOD(const RtpTransmissionManager*,
218               rtp_manager,
219               (),
220               (const, override));
221   MOCK_METHOD(bool, dtls_enabled, (), (const, override));
222   MOCK_METHOD(const PeerConnectionFactoryInterface::Options*,
223               options,
224               (),
225               (const, override));
226   MOCK_METHOD(CryptoOptions, GetCryptoOptions, (), (override));
227   MOCK_METHOD(JsepTransportController*, transport_controller_s, (), (override));
228   MOCK_METHOD(JsepTransportController*, transport_controller_n, (), (override));
229   MOCK_METHOD(DataChannelController*, data_channel_controller, (), (override));
230   MOCK_METHOD(cricket::PortAllocator*, port_allocator, (), (override));
231   MOCK_METHOD(LegacyStatsCollector*, legacy_stats, (), (override));
232   MOCK_METHOD(PeerConnectionObserver*, Observer, (), (const, override));
233   MOCK_METHOD(bool, GetSctpSslRole, (rtc::SSLRole*), (override));
234   MOCK_METHOD(PeerConnectionInterface::IceConnectionState,
235               ice_connection_state_internal,
236               (),
237               (override));
238   MOCK_METHOD(void,
239               SetIceConnectionState,
240               (PeerConnectionInterface::IceConnectionState),
241               (override));
242   MOCK_METHOD(void, NoteUsageEvent, (UsageEvent), (override));
243   MOCK_METHOD(bool, IsClosed, (), (const, override));
244   MOCK_METHOD(bool, IsUnifiedPlan, (), (const, override));
245   MOCK_METHOD(bool,
246               ValidateBundleSettings,
247               (const cricket::SessionDescription*,
248                (const std::map<std::string, const cricket::ContentGroup*>&)),
249               (override));
250   MOCK_METHOD(absl::optional<std::string>, GetDataMid, (), (const, override));
251   MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
252               AddTransceiver,
253               (cricket::MediaType,
254                rtc::scoped_refptr<MediaStreamTrackInterface>,
255                const RtpTransceiverInit&,
256                bool),
257               (override));
258   MOCK_METHOD(void, StartSctpTransport, (int, int, int), (override));
259   MOCK_METHOD(void,
260               AddRemoteCandidate,
261               (const std::string&, const cricket::Candidate&),
262               (override));
263   MOCK_METHOD(Call*, call_ptr, (), (override));
264   MOCK_METHOD(bool, SrtpRequired, (), (const, override));
265   MOCK_METHOD(bool,
266               SetupDataChannelTransport_n,
267               (const std::string&),
268               (override));
269   MOCK_METHOD(void, TeardownDataChannelTransport_n, (), (override));
270   MOCK_METHOD(void, SetSctpDataMid, (const std::string&), (override));
271   MOCK_METHOD(void, ResetSctpDataMid, (), (override));
272   MOCK_METHOD(const FieldTrialsView&, trials, (), (const, override));
273 
274   // PeerConnectionInternal
275   MOCK_METHOD(rtc::Thread*, network_thread, (), (const, override));
276   MOCK_METHOD(rtc::Thread*, worker_thread, (), (const, override));
277   MOCK_METHOD(bool, initial_offerer, (), (const, override));
278   MOCK_METHOD(
279       std::vector<
280           rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>,
281       GetTransceiversInternal,
282       (),
283       (const, override));
284   MOCK_METHOD(sigslot::signal1<SctpDataChannel*>&,
285               SignalSctpDataChannelCreated,
286               (),
287               (override));
288   MOCK_METHOD(std::vector<DataChannelStats>,
289               GetDataChannelStats,
290               (),
291               (const, override));
292   MOCK_METHOD(absl::optional<std::string>,
293               sctp_transport_name,
294               (),
295               (const, override));
296   MOCK_METHOD(cricket::CandidateStatsList,
297               GetPooledCandidateStats,
298               (),
299               (const, override));
300   MOCK_METHOD((std::map<std::string, cricket::TransportStats>),
301               GetTransportStatsByNames,
302               (const std::set<std::string>&),
303               (override));
304   MOCK_METHOD(Call::Stats, GetCallStats, (), (override));
305   MOCK_METHOD(bool,
306               GetLocalCertificate,
307               (const std::string&, rtc::scoped_refptr<rtc::RTCCertificate>*),
308               (override));
309   MOCK_METHOD(std::unique_ptr<rtc::SSLCertChain>,
310               GetRemoteSSLCertChain,
311               (const std::string&),
312               (override));
313   MOCK_METHOD(bool, IceRestartPending, (const std::string&), (const, override));
314   MOCK_METHOD(bool,
315               GetSslRole,
316               (const std::string&, rtc::SSLRole*),
317               (override));
318   MOCK_METHOD(void, NoteDataAddedEvent, (), (override));
319   MOCK_METHOD(void,
320               OnSctpDataChannelClosed,
321               (DataChannelInterface*),
322               (override));
323 };
324 
325 }  // namespace webrtc
326 
327 #endif  // PC_TEST_MOCK_PEER_CONNECTION_INTERNAL_H_
328