blob: 97b2b7d7b13361faada593293834f11049a246a5 [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 Castelli0fc787b2021-07-16 17:36:52 +020023#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));
Danil Chapovalovfc115192020-05-08 15:03:03 +020050 MOCK_METHOD(RTCError,
Harald Alvestrand09a0d012022-01-04 19:42:07 +000051 RemoveTrackOrError,
Danil Chapovalovfc115192020-05-08 15:03:03 +020052 (rtc::scoped_refptr<RtpSenderInterface>),
53 (override));
54 MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
55 AddTransceiver,
56 (rtc::scoped_refptr<MediaStreamTrackInterface>),
57 (override));
58 MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
59 AddTransceiver,
60 (rtc::scoped_refptr<MediaStreamTrackInterface>,
61 const RtpTransceiverInit&),
62 (override));
63 MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
64 AddTransceiver,
65 (cricket::MediaType),
66 (override));
67 MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
68 AddTransceiver,
69 (cricket::MediaType, const RtpTransceiverInit&),
70 (override));
71 MOCK_METHOD(rtc::scoped_refptr<RtpSenderInterface>,
72 CreateSender,
73 (const std::string&, const std::string&),
74 (override));
75 MOCK_METHOD(std::vector<rtc::scoped_refptr<RtpSenderInterface>>,
76 GetSenders,
77 (),
Ali Tofighc98687a2022-01-25 14:06:33 +010078 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +020079 MOCK_METHOD(std::vector<rtc::scoped_refptr<RtpReceiverInterface>>,
80 GetReceivers,
81 (),
Ali Tofighc98687a2022-01-25 14:06:33 +010082 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +020083 MOCK_METHOD(std::vector<rtc::scoped_refptr<RtpTransceiverInterface>>,
84 GetTransceivers,
85 (),
Ali Tofighc98687a2022-01-25 14:06:33 +010086 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +020087 MOCK_METHOD(bool,
88 GetStats,
89 (StatsObserver*, MediaStreamTrackInterface*, StatsOutputLevel),
90 (override));
91 MOCK_METHOD(void, GetStats, (RTCStatsCollectorCallback*), (override));
92 MOCK_METHOD(void,
93 GetStats,
94 (rtc::scoped_refptr<RtpSenderInterface>,
95 rtc::scoped_refptr<RTCStatsCollectorCallback>),
96 (override));
97 MOCK_METHOD(void,
98 GetStats,
99 (rtc::scoped_refptr<RtpReceiverInterface>,
100 rtc::scoped_refptr<RTCStatsCollectorCallback>),
101 (override));
102 MOCK_METHOD(void, ClearStatsCache, (), (override));
103 MOCK_METHOD(rtc::scoped_refptr<SctpTransportInterface>,
104 GetSctpTransport,
105 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100106 (const, override));
Harald Alvestranda9af50f2021-05-21 13:33:51 +0000107 MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<DataChannelInterface>>,
108 CreateDataChannelOrError,
Danil Chapovalovfc115192020-05-08 15:03:03 +0200109 (const std::string&, const DataChannelInit*),
110 (override));
111 MOCK_METHOD(const SessionDescriptionInterface*,
112 local_description,
113 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100114 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200115 MOCK_METHOD(const SessionDescriptionInterface*,
116 remote_description,
117 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100118 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200119 MOCK_METHOD(const SessionDescriptionInterface*,
120 current_local_description,
121 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100122 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200123 MOCK_METHOD(const SessionDescriptionInterface*,
124 current_remote_description,
125 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100126 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200127 MOCK_METHOD(const SessionDescriptionInterface*,
128 pending_local_description,
129 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100130 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200131 MOCK_METHOD(const SessionDescriptionInterface*,
132 pending_remote_description,
133 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100134 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200135 MOCK_METHOD(void, RestartIce, (), (override));
136 MOCK_METHOD(void,
137 CreateOffer,
138 (CreateSessionDescriptionObserver*, const RTCOfferAnswerOptions&),
139 (override));
140 MOCK_METHOD(void,
141 CreateAnswer,
142 (CreateSessionDescriptionObserver*, const RTCOfferAnswerOptions&),
143 (override));
144 MOCK_METHOD(void,
145 SetLocalDescription,
146 (SetSessionDescriptionObserver*, SessionDescriptionInterface*),
147 (override));
148 MOCK_METHOD(void,
149 SetRemoteDescription,
150 (SetSessionDescriptionObserver*, SessionDescriptionInterface*),
151 (override));
152 MOCK_METHOD(void,
153 SetRemoteDescription,
154 (std::unique_ptr<SessionDescriptionInterface>,
155 rtc::scoped_refptr<SetRemoteDescriptionObserverInterface>),
156 (override));
157 MOCK_METHOD(PeerConnectionInterface::RTCConfiguration,
158 GetConfiguration,
159 (),
160 (override));
161 MOCK_METHOD(RTCError,
162 SetConfiguration,
163 (const PeerConnectionInterface::RTCConfiguration&),
164 (override));
165 MOCK_METHOD(bool,
166 AddIceCandidate,
167 (const IceCandidateInterface*),
168 (override));
169 MOCK_METHOD(bool,
170 RemoveIceCandidates,
171 (const std::vector<cricket::Candidate>&),
172 (override));
173 MOCK_METHOD(RTCError, SetBitrate, (const BitrateSettings&), (override));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200174 MOCK_METHOD(void, SetAudioPlayout, (bool), (override));
175 MOCK_METHOD(void, SetAudioRecording, (bool), (override));
176 MOCK_METHOD(rtc::scoped_refptr<DtlsTransportInterface>,
177 LookupDtlsTransportByMid,
178 (const std::string&),
179 (override));
180 MOCK_METHOD(SignalingState, signaling_state, (), (override));
181 MOCK_METHOD(IceConnectionState, ice_connection_state, (), (override));
182 MOCK_METHOD(IceConnectionState,
183 standardized_ice_connection_state,
184 (),
185 (override));
186 MOCK_METHOD(PeerConnectionState, peer_connection_state, (), (override));
187 MOCK_METHOD(IceGatheringState, ice_gathering_state, (), (override));
188 MOCK_METHOD(absl::optional<bool>, can_trickle_ice_candidates, (), (override));
189 MOCK_METHOD(bool,
190 StartRtcEventLog,
191 (std::unique_ptr<RtcEventLogOutput>, int64_t),
192 (override));
193 MOCK_METHOD(bool,
194 StartRtcEventLog,
195 (std::unique_ptr<RtcEventLogOutput>),
196 (override));
197 MOCK_METHOD(void, StopRtcEventLog, (), (override));
198 MOCK_METHOD(void, Close, (), (override));
Jiawei Ou651b92e2018-06-29 15:46:44 -0700199};
200
Niels Möller9dde1202022-03-21 10:36:32 +0100201static_assert(
202 !std::is_abstract_v<rtc::RefCountedObject<MockPeerConnectionInterface>>,
203 "");
Niels Möller7b04a912019-09-13 15:41:21 +0200204
Jiawei Ou651b92e2018-06-29 15:46:44 -0700205} // namespace webrtc
206
207#endif // API_TEST_MOCK_PEERCONNECTIONINTERFACE_H_