tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

mock_peerconnectioninterface.h (9374B)


      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 <cstdint>
     15 #include <memory>
     16 #include <optional>
     17 #include <string>
     18 #include <type_traits>
     19 #include <vector>
     20 
     21 #include "api/adaptation/resource.h"
     22 #include "api/data_channel_event_observer_interface.h"
     23 #include "api/data_channel_interface.h"
     24 #include "api/dtls_transport_interface.h"
     25 #include "api/jsep.h"
     26 #include "api/make_ref_counted.h"
     27 #include "api/media_stream_interface.h"
     28 #include "api/media_types.h"
     29 #include "api/peer_connection_interface.h"
     30 #include "api/rtc_error.h"
     31 #include "api/rtc_event_log_output.h"
     32 #include "api/rtp_parameters.h"
     33 #include "api/rtp_receiver_interface.h"
     34 #include "api/rtp_sender_interface.h"
     35 #include "api/rtp_transceiver_interface.h"
     36 #include "api/scoped_refptr.h"
     37 #include "api/sctp_transport_interface.h"
     38 #include "api/set_remote_description_observer_interface.h"
     39 #include "api/stats/rtc_stats_collector_callback.h"
     40 #include "api/transport/bandwidth_estimation_settings.h"
     41 #include "api/transport/bitrate_settings.h"
     42 #include "rtc_base/ref_counted_object.h"
     43 #include "rtc_base/thread.h"
     44 #include "test/gmock.h"
     45 
     46 namespace webrtc {
     47 
     48 class MockPeerConnectionInterface : public PeerConnectionInterface {
     49 public:
     50  static scoped_refptr<MockPeerConnectionInterface> Create() {
     51    return make_ref_counted<MockPeerConnectionInterface>();
     52  }
     53 
     54  // PeerConnectionInterface
     55  MOCK_METHOD(scoped_refptr<StreamCollectionInterface>,
     56              local_streams,
     57              (),
     58              (override));
     59  MOCK_METHOD(scoped_refptr<StreamCollectionInterface>,
     60              remote_streams,
     61              (),
     62              (override));
     63  MOCK_METHOD(bool, AddStream, (MediaStreamInterface*), (override));
     64  MOCK_METHOD(void, RemoveStream, (MediaStreamInterface*), (override));
     65  MOCK_METHOD(RTCErrorOr<scoped_refptr<RtpSenderInterface>>,
     66              AddTrack,
     67              (scoped_refptr<MediaStreamTrackInterface>,
     68               const std::vector<std::string>&),
     69              (override));
     70  MOCK_METHOD(RTCErrorOr<scoped_refptr<RtpSenderInterface>>,
     71              AddTrack,
     72              (scoped_refptr<MediaStreamTrackInterface>,
     73               const std::vector<std::string>&,
     74               const std::vector<RtpEncodingParameters>&),
     75              (override));
     76  MOCK_METHOD(RTCError,
     77              RemoveTrackOrError,
     78              (scoped_refptr<RtpSenderInterface>),
     79              (override));
     80  MOCK_METHOD(RTCErrorOr<scoped_refptr<RtpTransceiverInterface>>,
     81              AddTransceiver,
     82              (scoped_refptr<MediaStreamTrackInterface>),
     83              (override));
     84  MOCK_METHOD(RTCErrorOr<scoped_refptr<RtpTransceiverInterface>>,
     85              AddTransceiver,
     86              (scoped_refptr<MediaStreamTrackInterface>,
     87               const RtpTransceiverInit&),
     88              (override));
     89  MOCK_METHOD(RTCErrorOr<scoped_refptr<RtpTransceiverInterface>>,
     90              AddTransceiver,
     91              (MediaType),
     92              (override));
     93  MOCK_METHOD(RTCErrorOr<scoped_refptr<RtpTransceiverInterface>>,
     94              AddTransceiver,
     95              (MediaType, const RtpTransceiverInit&),
     96              (override));
     97  MOCK_METHOD(scoped_refptr<RtpSenderInterface>,
     98              CreateSender,
     99              (const std::string&, const std::string&),
    100              (override));
    101  MOCK_METHOD(std::vector<scoped_refptr<RtpSenderInterface>>,
    102              GetSenders,
    103              (),
    104              (const, override));
    105  MOCK_METHOD(std::vector<scoped_refptr<RtpReceiverInterface>>,
    106              GetReceivers,
    107              (),
    108              (const, override));
    109  MOCK_METHOD(std::vector<scoped_refptr<RtpTransceiverInterface>>,
    110              GetTransceivers,
    111              (),
    112              (const, override));
    113  MOCK_METHOD(bool,
    114              GetStats,
    115              (StatsObserver*, MediaStreamTrackInterface*, StatsOutputLevel),
    116              (override));
    117  MOCK_METHOD(void, GetStats, (RTCStatsCollectorCallback*), (override));
    118  MOCK_METHOD(void,
    119              GetStats,
    120              (scoped_refptr<RtpSenderInterface>,
    121               scoped_refptr<RTCStatsCollectorCallback>),
    122              (override));
    123  MOCK_METHOD(void,
    124              GetStats,
    125              (scoped_refptr<RtpReceiverInterface>,
    126               scoped_refptr<RTCStatsCollectorCallback>),
    127              (override));
    128  MOCK_METHOD(void, ClearStatsCache, (), (override));
    129  MOCK_METHOD(scoped_refptr<SctpTransportInterface>,
    130              GetSctpTransport,
    131              (),
    132              (const, override));
    133  MOCK_METHOD(RTCErrorOr<scoped_refptr<DataChannelInterface>>,
    134              CreateDataChannelOrError,
    135              (const std::string&, const DataChannelInit*),
    136              (override));
    137  MOCK_METHOD(const SessionDescriptionInterface*,
    138              local_description,
    139              (),
    140              (const, override));
    141  MOCK_METHOD(const SessionDescriptionInterface*,
    142              remote_description,
    143              (),
    144              (const, override));
    145  MOCK_METHOD(const SessionDescriptionInterface*,
    146              current_local_description,
    147              (),
    148              (const, override));
    149  MOCK_METHOD(const SessionDescriptionInterface*,
    150              current_remote_description,
    151              (),
    152              (const, override));
    153  MOCK_METHOD(const SessionDescriptionInterface*,
    154              pending_local_description,
    155              (),
    156              (const, override));
    157  MOCK_METHOD(const SessionDescriptionInterface*,
    158              pending_remote_description,
    159              (),
    160              (const, override));
    161  MOCK_METHOD(void, RestartIce, (), (override));
    162  MOCK_METHOD(void,
    163              CreateOffer,
    164              (CreateSessionDescriptionObserver*, const RTCOfferAnswerOptions&),
    165              (override));
    166  MOCK_METHOD(void,
    167              CreateAnswer,
    168              (CreateSessionDescriptionObserver*, const RTCOfferAnswerOptions&),
    169              (override));
    170  MOCK_METHOD(void,
    171              SetLocalDescription,
    172              (SetSessionDescriptionObserver*, SessionDescriptionInterface*),
    173              (override));
    174  MOCK_METHOD(void,
    175              SetRemoteDescription,
    176              (SetSessionDescriptionObserver*, SessionDescriptionInterface*),
    177              (override));
    178  MOCK_METHOD(void,
    179              SetRemoteDescription,
    180              (std::unique_ptr<SessionDescriptionInterface>,
    181               scoped_refptr<SetRemoteDescriptionObserverInterface>),
    182              (override));
    183  MOCK_METHOD(bool,
    184              ShouldFireNegotiationNeededEvent,
    185              (uint32_t event_id),
    186              (override));
    187  MOCK_METHOD(PeerConnectionInterface::RTCConfiguration,
    188              GetConfiguration,
    189              (),
    190              (override));
    191  MOCK_METHOD(RTCError,
    192              SetConfiguration,
    193              (const PeerConnectionInterface::RTCConfiguration&),
    194              (override));
    195  MOCK_METHOD(bool, AddIceCandidate, (const IceCandidate*), (override));
    196  MOCK_METHOD(bool,
    197              RemoveIceCandidate,
    198              (const IceCandidate* candidate),
    199              (override));
    200  MOCK_METHOD(RTCError, SetBitrate, (const BitrateSettings&), (override));
    201  MOCK_METHOD(void,
    202              ReconfigureBandwidthEstimation,
    203              (const BandwidthEstimationSettings&),
    204              (override));
    205  MOCK_METHOD(void, SetAudioPlayout, (bool), (override));
    206  MOCK_METHOD(void, SetAudioRecording, (bool), (override));
    207  MOCK_METHOD(scoped_refptr<DtlsTransportInterface>,
    208              LookupDtlsTransportByMid,
    209              (const std::string&),
    210              (override));
    211  MOCK_METHOD(SignalingState, signaling_state, (), (override));
    212  MOCK_METHOD(IceConnectionState, ice_connection_state, (), (override));
    213  MOCK_METHOD(IceConnectionState,
    214              standardized_ice_connection_state,
    215              (),
    216              (override));
    217  MOCK_METHOD(PeerConnectionState, peer_connection_state, (), (override));
    218  MOCK_METHOD(IceGatheringState, ice_gathering_state, (), (override));
    219  MOCK_METHOD(void,
    220              AddAdaptationResource,
    221              (scoped_refptr<Resource>),
    222              (override));
    223  MOCK_METHOD(std::optional<bool>, can_trickle_ice_candidates, (), (override));
    224  MOCK_METHOD(bool,
    225              StartRtcEventLog,
    226              (std::unique_ptr<RtcEventLogOutput>, int64_t),
    227              (override));
    228  MOCK_METHOD(bool,
    229              StartRtcEventLog,
    230              (std::unique_ptr<RtcEventLogOutput>),
    231              (override));
    232  MOCK_METHOD(void,
    233              SetDataChannelEventObserver,
    234              (std::unique_ptr<DataChannelEventObserverInterface>),
    235              (override));
    236  MOCK_METHOD(void, StopRtcEventLog, (), (override));
    237  MOCK_METHOD(void, Close, (), (override));
    238  MOCK_METHOD(Thread*, signaling_thread, (), (const, override));
    239 };
    240 
    241 static_assert(
    242    !std::is_abstract_v<RefCountedObject<MockPeerConnectionInterface>>,
    243    "");
    244 
    245 }  // namespace webrtc
    246 
    247 #endif  // API_TEST_MOCK_PEERCONNECTIONINTERFACE_H_