blob: fc740b07184b69b70291cdce3e41d648d467bbd1 [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
28class MockPeerConnectionInterface
29 : public rtc::RefCountedObject<webrtc::PeerConnectionInterface> {
30 public:
Florent Castelli0fc787b2021-07-16 17:36:52 +020031 static rtc::scoped_refptr<MockPeerConnectionInterface> Create() {
32 return new MockPeerConnectionInterface();
33 }
34
Jiawei Ou651b92e2018-06-29 15:46:44 -070035 // PeerConnectionInterface
Danil Chapovalovfc115192020-05-08 15:03:03 +020036 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 Alvestrand09a0d012022-01-04 19:42:07 +000053 RemoveTrackOrError,
Danil Chapovalovfc115192020-05-08 15:03:03 +020054 (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 Alvestranda9af50f2021-05-21 13:33:51 +0000109 MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<DataChannelInterface>>,
110 CreateDataChannelOrError,
Danil Chapovalovfc115192020-05-08 15:03:03 +0200111 (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 Chapovalovfc115192020-05-08 15:03:03 +0200176 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 Ou651b92e2018-06-29 15:46:44 -0700201};
202
Niels Möller7b04a912019-09-13 15:41:21 +0200203static_assert(!std::is_abstract<MockPeerConnectionInterface>::value, "");
204
Jiawei Ou651b92e2018-06-29 15:46:44 -0700205} // namespace webrtc
206
207#endif // API_TEST_MOCK_PEERCONNECTIONINTERFACE_H_