1 /*
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>
16 #include <type_traits>
17 #include <utility>
18 #include <vector>
19 
20 #include "api/peer_connection_interface.h"
21 #include "api/sctp_transport_interface.h"
22 #include "test/gmock.h"
23 
24 namespace webrtc {
25 
26 class MockPeerConnectionInterface
27     : public rtc::RefCountedObject<webrtc::PeerConnectionInterface> {
28  public:
29   // PeerConnectionInterface
30   MOCK_METHOD0(local_streams, rtc::scoped_refptr<StreamCollectionInterface>());
31   MOCK_METHOD0(remote_streams, rtc::scoped_refptr<StreamCollectionInterface>());
32   MOCK_METHOD1(AddStream, bool(MediaStreamInterface*));
33   MOCK_METHOD1(RemoveStream, void(MediaStreamInterface*));
34   MOCK_METHOD2(AddTrack,
35                RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>>(
36                    rtc::scoped_refptr<MediaStreamTrackInterface>,
37                    const std::vector<std::string>&));
38   MOCK_METHOD2(AddTrack,
39                rtc::scoped_refptr<RtpSenderInterface>(
40                    MediaStreamTrackInterface*,
41                    std::vector<MediaStreamInterface*>));
42   MOCK_METHOD1(RemoveTrack, bool(RtpSenderInterface*));
43   MOCK_METHOD1(RemoveTrackNew,
44                RTCError(rtc::scoped_refptr<RtpSenderInterface>));
45   MOCK_METHOD1(AddTransceiver,
46                RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>(
47                    rtc::scoped_refptr<MediaStreamTrackInterface>));
48   MOCK_METHOD2(AddTransceiver,
49                RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>(
50                    rtc::scoped_refptr<MediaStreamTrackInterface>,
51                    const RtpTransceiverInit&));
52   MOCK_METHOD1(AddTransceiver,
53                RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>(
54                    cricket::MediaType));
55   MOCK_METHOD2(AddTransceiver,
56                RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>(
57                    cricket::MediaType,
58                    const RtpTransceiverInit&));
59   MOCK_METHOD2(CreateSender,
60                rtc::scoped_refptr<RtpSenderInterface>(const std::string&,
61                                                       const std::string&));
62   MOCK_CONST_METHOD0(GetSenders,
63                      std::vector<rtc::scoped_refptr<RtpSenderInterface>>());
64   MOCK_CONST_METHOD0(GetReceivers,
65                      std::vector<rtc::scoped_refptr<RtpReceiverInterface>>());
66   MOCK_CONST_METHOD0(
67       GetTransceivers,
68       std::vector<rtc::scoped_refptr<RtpTransceiverInterface>>());
69   MOCK_METHOD3(GetStats,
70                bool(StatsObserver*,
71                     MediaStreamTrackInterface*,
72                     StatsOutputLevel));
73   MOCK_METHOD1(GetStats, void(RTCStatsCollectorCallback*));
74   MOCK_METHOD2(GetStats,
75                void(rtc::scoped_refptr<RtpSenderInterface>,
76                     rtc::scoped_refptr<RTCStatsCollectorCallback>));
77   MOCK_METHOD2(GetStats,
78                void(rtc::scoped_refptr<RtpReceiverInterface>,
79                     rtc::scoped_refptr<RTCStatsCollectorCallback>));
80   MOCK_METHOD0(ClearStatsCache, void());
81   MOCK_CONST_METHOD0(GetSctpTransport,
82                      rtc::scoped_refptr<SctpTransportInterface>());
83   MOCK_METHOD2(
84       CreateDataChannel,
85       rtc::scoped_refptr<DataChannelInterface>(const std::string&,
86                                                const DataChannelInit*));
87   MOCK_CONST_METHOD0(local_description, const SessionDescriptionInterface*());
88   MOCK_CONST_METHOD0(remote_description, const SessionDescriptionInterface*());
89   MOCK_CONST_METHOD0(current_local_description,
90                      const SessionDescriptionInterface*());
91   MOCK_CONST_METHOD0(current_remote_description,
92                      const SessionDescriptionInterface*());
93   MOCK_CONST_METHOD0(pending_local_description,
94                      const SessionDescriptionInterface*());
95   MOCK_CONST_METHOD0(pending_remote_description,
96                      const SessionDescriptionInterface*());
97   MOCK_METHOD0(RestartIce, void());
98   MOCK_METHOD2(CreateOffer,
99                void(CreateSessionDescriptionObserver*,
100                     const RTCOfferAnswerOptions&));
101   MOCK_METHOD2(CreateAnswer,
102                void(CreateSessionDescriptionObserver*,
103                     const RTCOfferAnswerOptions&));
104   MOCK_METHOD2(SetLocalDescription,
105                void(SetSessionDescriptionObserver*,
106                     SessionDescriptionInterface*));
107   MOCK_METHOD2(SetRemoteDescription,
108                void(SetSessionDescriptionObserver*,
109                     SessionDescriptionInterface*));
110   MOCK_METHOD2(SetRemoteDescription,
111                void(std::unique_ptr<SessionDescriptionInterface>,
112                     rtc::scoped_refptr<SetRemoteDescriptionObserverInterface>));
113   MOCK_METHOD0(GetConfiguration, PeerConnectionInterface::RTCConfiguration());
114   MOCK_METHOD1(SetConfiguration,
115                RTCError(const PeerConnectionInterface::RTCConfiguration&));
116   MOCK_METHOD1(AddIceCandidate, bool(const IceCandidateInterface*));
117   MOCK_METHOD1(RemoveIceCandidates,
118                bool(const std::vector<cricket::Candidate>&));
119   MOCK_METHOD1(SetBitrate, RTCError(const BitrateSettings&));
120   MOCK_METHOD1(SetBitrate, RTCError(const BitrateParameters&));
121   MOCK_METHOD1(SetAudioPlayout, void(bool));
122   MOCK_METHOD1(SetAudioRecording, void(bool));
123   MOCK_METHOD1(LookupDtlsTransportByMid,
124                rtc::scoped_refptr<DtlsTransportInterface>(const std::string&));
125   MOCK_METHOD0(signaling_state, SignalingState());
126   MOCK_METHOD0(ice_connection_state, IceConnectionState());
127   MOCK_METHOD0(standardized_ice_connection_state, IceConnectionState());
128   MOCK_METHOD0(peer_connection_state, PeerConnectionState());
129   MOCK_METHOD0(ice_gathering_state, IceGatheringState());
130   MOCK_METHOD0(can_trickle_ice_candidates, absl::optional<bool>());
131   MOCK_METHOD2(StartRtcEventLog,
132                bool(std::unique_ptr<RtcEventLogOutput>, int64_t));
133   MOCK_METHOD1(StartRtcEventLog, bool(std::unique_ptr<RtcEventLogOutput>));
134   MOCK_METHOD0(StopRtcEventLog, void());
135   MOCK_METHOD0(Close, void());
136 };
137 
138 static_assert(!std::is_abstract<MockPeerConnectionInterface>::value, "");
139 
140 }  // namespace webrtc
141 
142 #endif  // API_TEST_MOCK_PEERCONNECTIONINTERFACE_H_
143