blob: ccc6ce46b192814a13c948b51dad46224df52eed [file] [log] [blame]
Jiawei Ou651b92e2018-06-29 15:46:44 -07001/*
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öller7b04a912019-09-13 15:41:21 +020016#include <type_traits>
Jiawei Ou651b92e2018-06-29 15:46:44 -070017#include <utility>
18#include <vector>
19
Steve Anton10542f22019-01-11 09:11:00 -080020#include "api/peer_connection_interface.h"
Florent Castelli0fc787b2021-07-16 17:36:52 +020021#include "api/scoped_refptr.h"
Harald Alvestrand15845af2019-03-05 09:50:57 +010022#include "api/sctp_transport_interface.h"
Florent Castelli123a0ed2022-11-10 13:28:42 +000023#include "rtc_base/ref_counted_object.h"
Jiawei Ou651b92e2018-06-29 15:46:44 -070024#include "test/gmock.h"
25
26namespace webrtc {
27
Niels Möller9dde1202022-03-21 10:36:32 +010028class MockPeerConnectionInterface : public webrtc::PeerConnectionInterface {
Jiawei Ou651b92e2018-06-29 15:46:44 -070029 public:
Florent Castelli0fc787b2021-07-16 17:36:52 +020030 static rtc::scoped_refptr<MockPeerConnectionInterface> Create() {
Niels Möller961f3822022-01-12 10:06:55 +010031 return rtc::make_ref_counted<MockPeerConnectionInterface>();
Florent Castelli0fc787b2021-07-16 17:36:52 +020032 }
33
Jiawei Ou651b92e2018-06-29 15:46:44 -070034 // PeerConnectionInterface
Danil Chapovalovfc115192020-05-08 15:03:03 +020035 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));
Jonas Oreland4b2a1062022-10-19 09:24:42 +020050 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));
Danil Chapovalovfc115192020-05-08 15:03:03 +020056 MOCK_METHOD(RTCError,
Harald Alvestrand09a0d012022-01-04 19:42:07 +000057 RemoveTrackOrError,
Danil Chapovalovfc115192020-05-08 15:03:03 +020058 (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 (),
Ali Tofighc98687a2022-01-25 14:06:33 +010084 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +020085 MOCK_METHOD(std::vector<rtc::scoped_refptr<RtpReceiverInterface>>,
86 GetReceivers,
87 (),
Ali Tofighc98687a2022-01-25 14:06:33 +010088 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +020089 MOCK_METHOD(std::vector<rtc::scoped_refptr<RtpTransceiverInterface>>,
90 GetTransceivers,
91 (),
Ali Tofighc98687a2022-01-25 14:06:33 +010092 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +020093 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 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100112 (const, override));
Harald Alvestranda9af50f2021-05-21 13:33:51 +0000113 MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<DataChannelInterface>>,
114 CreateDataChannelOrError,
Danil Chapovalovfc115192020-05-08 15:03:03 +0200115 (const std::string&, const DataChannelInit*),
116 (override));
117 MOCK_METHOD(const SessionDescriptionInterface*,
118 local_description,
119 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100120 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200121 MOCK_METHOD(const SessionDescriptionInterface*,
122 remote_description,
123 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100124 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200125 MOCK_METHOD(const SessionDescriptionInterface*,
126 current_local_description,
127 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100128 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200129 MOCK_METHOD(const SessionDescriptionInterface*,
130 current_remote_description,
131 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100132 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200133 MOCK_METHOD(const SessionDescriptionInterface*,
134 pending_local_description,
135 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100136 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200137 MOCK_METHOD(const SessionDescriptionInterface*,
138 pending_remote_description,
139 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100140 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200141 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));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200180 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));
Jiawei Ou651b92e2018-06-29 15:46:44 -0700205};
206
Niels Möller9dde1202022-03-21 10:36:32 +0100207static_assert(
Florent Castelli123a0ed2022-11-10 13:28:42 +0000208 !std::is_abstract_v<rtc::RefCountedObject<MockPeerConnectionInterface>>,
209 "");
Niels Möller7b04a912019-09-13 15:41:21 +0200210
Jiawei Ou651b92e2018-06-29 15:46:44 -0700211} // namespace webrtc
212
213#endif // API_TEST_MOCK_PEERCONNECTIONINTERFACE_H_