blob: effd24e29400ac1ec1a084f23b9d29f68e73b7bb [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
Tomas Gunnarsson82c94af2022-03-20 18:38:25 +000028class MockPeerConnectionInterface
29 : public rtc::RefCountedObject<webrtc::PeerConnectionInterface> {
Jiawei Ou651b92e2018-06-29 15:46:44 -070030 public:
Florent Castelli0fc787b2021-07-16 17:36:52 +020031 static rtc::scoped_refptr<MockPeerConnectionInterface> Create() {
Niels Möller961f3822022-01-12 10:06:55 +010032 return rtc::make_ref_counted<MockPeerConnectionInterface>();
Florent Castelli0fc787b2021-07-16 17:36:52 +020033 }
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));
Danil Chapovalovfc115192020-05-08 15:03:03 +020051 MOCK_METHOD(RTCError,
Harald Alvestrand09a0d012022-01-04 19:42:07 +000052 RemoveTrackOrError,
Danil Chapovalovfc115192020-05-08 15:03:03 +020053 (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 (),
Ali Tofighc98687a2022-01-25 14:06:33 +010079 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +020080 MOCK_METHOD(std::vector<rtc::scoped_refptr<RtpReceiverInterface>>,
81 GetReceivers,
82 (),
Ali Tofighc98687a2022-01-25 14:06:33 +010083 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +020084 MOCK_METHOD(std::vector<rtc::scoped_refptr<RtpTransceiverInterface>>,
85 GetTransceivers,
86 (),
Ali Tofighc98687a2022-01-25 14:06:33 +010087 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +020088 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(rtc::scoped_refptr<SctpTransportInterface>,
105 GetSctpTransport,
106 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100107 (const, override));
Harald Alvestranda9af50f2021-05-21 13:33:51 +0000108 MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<DataChannelInterface>>,
109 CreateDataChannelOrError,
Danil Chapovalovfc115192020-05-08 15:03:03 +0200110 (const std::string&, const DataChannelInit*),
111 (override));
112 MOCK_METHOD(const SessionDescriptionInterface*,
113 local_description,
114 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100115 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200116 MOCK_METHOD(const SessionDescriptionInterface*,
117 remote_description,
118 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100119 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200120 MOCK_METHOD(const SessionDescriptionInterface*,
121 current_local_description,
122 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100123 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200124 MOCK_METHOD(const SessionDescriptionInterface*,
125 current_remote_description,
126 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100127 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200128 MOCK_METHOD(const SessionDescriptionInterface*,
129 pending_local_description,
130 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100131 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200132 MOCK_METHOD(const SessionDescriptionInterface*,
133 pending_remote_description,
134 (),
Ali Tofighc98687a2022-01-25 14:06:33 +0100135 (const, override));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200136 MOCK_METHOD(void, RestartIce, (), (override));
137 MOCK_METHOD(void,
138 CreateOffer,
139 (CreateSessionDescriptionObserver*, const RTCOfferAnswerOptions&),
140 (override));
141 MOCK_METHOD(void,
142 CreateAnswer,
143 (CreateSessionDescriptionObserver*, const RTCOfferAnswerOptions&),
144 (override));
145 MOCK_METHOD(void,
146 SetLocalDescription,
147 (SetSessionDescriptionObserver*, SessionDescriptionInterface*),
148 (override));
149 MOCK_METHOD(void,
150 SetRemoteDescription,
151 (SetSessionDescriptionObserver*, SessionDescriptionInterface*),
152 (override));
153 MOCK_METHOD(void,
154 SetRemoteDescription,
155 (std::unique_ptr<SessionDescriptionInterface>,
156 rtc::scoped_refptr<SetRemoteDescriptionObserverInterface>),
157 (override));
158 MOCK_METHOD(PeerConnectionInterface::RTCConfiguration,
159 GetConfiguration,
160 (),
161 (override));
162 MOCK_METHOD(RTCError,
163 SetConfiguration,
164 (const PeerConnectionInterface::RTCConfiguration&),
165 (override));
166 MOCK_METHOD(bool,
167 AddIceCandidate,
168 (const IceCandidateInterface*),
169 (override));
170 MOCK_METHOD(bool,
171 RemoveIceCandidates,
172 (const std::vector<cricket::Candidate>&),
173 (override));
174 MOCK_METHOD(RTCError, SetBitrate, (const BitrateSettings&), (override));
Danil Chapovalovfc115192020-05-08 15:03:03 +0200175 MOCK_METHOD(void, SetAudioPlayout, (bool), (override));
176 MOCK_METHOD(void, SetAudioRecording, (bool), (override));
177 MOCK_METHOD(rtc::scoped_refptr<DtlsTransportInterface>,
178 LookupDtlsTransportByMid,
179 (const std::string&),
180 (override));
181 MOCK_METHOD(SignalingState, signaling_state, (), (override));
182 MOCK_METHOD(IceConnectionState, ice_connection_state, (), (override));
183 MOCK_METHOD(IceConnectionState,
184 standardized_ice_connection_state,
185 (),
186 (override));
187 MOCK_METHOD(PeerConnectionState, peer_connection_state, (), (override));
188 MOCK_METHOD(IceGatheringState, ice_gathering_state, (), (override));
189 MOCK_METHOD(absl::optional<bool>, can_trickle_ice_candidates, (), (override));
190 MOCK_METHOD(bool,
191 StartRtcEventLog,
192 (std::unique_ptr<RtcEventLogOutput>, int64_t),
193 (override));
194 MOCK_METHOD(bool,
195 StartRtcEventLog,
196 (std::unique_ptr<RtcEventLogOutput>),
197 (override));
198 MOCK_METHOD(void, StopRtcEventLog, (), (override));
199 MOCK_METHOD(void, Close, (), (override));
Jiawei Ou651b92e2018-06-29 15:46:44 -0700200};
201
Tomas Gunnarsson82c94af2022-03-20 18:38:25 +0000202static_assert(!std::is_abstract<MockPeerConnectionInterface>::value, "");
Niels Möller7b04a912019-09-13 15:41:21 +0200203
Jiawei Ou651b92e2018-06-29 15:46:44 -0700204} // namespace webrtc
205
206#endif // API_TEST_MOCK_PEERCONNECTIONINTERFACE_H_