Add FakePeerConnectionBase
This provides an intermediate class for defining default, null
implementations of all the PeerConnectionInterface/
PeerConnectionInternal methods. Specific fake PeerConnections then can
inherit from this and only override the methods pertaining to the
scenarios it will be used in.
Bug: webrtc:8764
Change-Id: I7614303b5673747244053b54b839e58aada43d10
Reviewed-on: https://webrtc-review.googlesource.com/43245
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21752}diff --git a/pc/test/fakepeerconnectionbase.h b/pc/test/fakepeerconnectionbase.h
new file mode 100644
index 0000000..a42b6e3
--- /dev/null
+++ b/pc/test/fakepeerconnectionbase.h
@@ -0,0 +1,319 @@
+/*
+ * Copyright 2018 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef PC_TEST_FAKEPEERCONNECTIONBASE_H_
+#define PC_TEST_FAKEPEERCONNECTIONBASE_H_
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "pc/peerconnectioninternal.h"
+
+namespace webrtc {
+
+// Customized PeerConnection fakes can be created by subclassing
+// FakePeerConnectionBase then overriding the interesting methods. This class
+// takes care of providing default implementations for all the pure virtual
+// functions specified in the interfaces.
+class FakePeerConnectionBase : public PeerConnectionInternal {
+ public:
+ // PeerConnectionInterface implementation.
+
+ rtc::scoped_refptr<StreamCollectionInterface> local_streams() override {
+ return nullptr;
+ }
+
+ rtc::scoped_refptr<StreamCollectionInterface> remote_streams() override {
+ return nullptr;
+ }
+
+ bool AddStream(MediaStreamInterface* stream) override { return false; }
+
+ void RemoveStream(MediaStreamInterface* stream) override {}
+
+ RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrack(
+ rtc::scoped_refptr<MediaStreamTrackInterface> track,
+ const std::vector<std::string>& stream_labels) override {
+ return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
+ }
+
+ rtc::scoped_refptr<RtpSenderInterface> AddTrack(
+ MediaStreamTrackInterface* track,
+ std::vector<MediaStreamInterface*> streams) override {
+ return nullptr;
+ }
+
+ bool RemoveTrack(RtpSenderInterface* sender) override { return false; }
+
+ RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
+ rtc::scoped_refptr<MediaStreamTrackInterface> track) override {
+ return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
+ }
+
+ RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
+ rtc::scoped_refptr<MediaStreamTrackInterface> track,
+ const RtpTransceiverInit& init) override {
+ return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
+ }
+
+ RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
+ cricket::MediaType media_type) override {
+ return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
+ }
+
+ RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
+ cricket::MediaType media_type,
+ const RtpTransceiverInit& init) override {
+ return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
+ }
+
+ rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender(
+ AudioTrackInterface* track) override {
+ return nullptr;
+ }
+
+ rtc::scoped_refptr<RtpSenderInterface> CreateSender(
+ const std::string& kind,
+ const std::string& stream_id) override {
+ return nullptr;
+ }
+
+ std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders()
+ const override {
+ return {};
+ }
+
+ std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers()
+ const override {
+ return {};
+ }
+
+ std::vector<rtc::scoped_refptr<RtpTransceiverInterface>> GetTransceivers()
+ const override {
+ return {};
+ }
+
+ bool GetStats(StatsObserver* observer,
+ MediaStreamTrackInterface* track,
+ StatsOutputLevel level) override {
+ return false;
+ }
+
+ void GetStats(RTCStatsCollectorCallback* callback) override {}
+
+ void ClearStatsCache() override {}
+
+ rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
+ const std::string& label,
+ const DataChannelInit* config) override {
+ return nullptr;
+ }
+
+ const SessionDescriptionInterface* local_description() const override {
+ return nullptr;
+ }
+ const SessionDescriptionInterface* remote_description() const override {
+ return nullptr;
+ }
+
+ const SessionDescriptionInterface* current_local_description()
+ const override {
+ return nullptr;
+ }
+ const SessionDescriptionInterface* current_remote_description()
+ const override {
+ return nullptr;
+ }
+
+ const SessionDescriptionInterface* pending_local_description()
+ const override {
+ return nullptr;
+ }
+ const SessionDescriptionInterface* pending_remote_description()
+ const override {
+ return nullptr;
+ }
+
+ void CreateOffer(CreateSessionDescriptionObserver* observer,
+ const MediaConstraintsInterface* constraints) override {}
+
+ void CreateOffer(CreateSessionDescriptionObserver* observer,
+ const RTCOfferAnswerOptions& options) override {}
+
+ void CreateAnswer(CreateSessionDescriptionObserver* observer,
+ const RTCOfferAnswerOptions& options) override {}
+
+ void CreateAnswer(CreateSessionDescriptionObserver* observer,
+ const MediaConstraintsInterface* constraints) override {}
+
+ void SetLocalDescription(SetSessionDescriptionObserver* observer,
+ SessionDescriptionInterface* desc) override {}
+
+ void SetRemoteDescription(SetSessionDescriptionObserver* observer,
+ SessionDescriptionInterface* desc) override {}
+
+ void SetRemoteDescription(
+ std::unique_ptr<SessionDescriptionInterface> desc,
+ rtc::scoped_refptr<SetRemoteDescriptionObserverInterface> observer)
+ override {}
+
+ bool UpdateIce(const IceServers& configuration,
+ const MediaConstraintsInterface* constraints) override {
+ return false;
+ }
+
+ bool UpdateIce(const IceServers& configuration) override { return false; }
+
+ RTCConfiguration GetConfiguration() override { return RTCConfiguration(); }
+
+ bool SetConfiguration(const PeerConnectionInterface::RTCConfiguration& config,
+ RTCError* error) override {
+ return false;
+ }
+
+ bool SetConfiguration(
+ const PeerConnectionInterface::RTCConfiguration& config) override {
+ return false;
+ }
+
+ bool AddIceCandidate(const IceCandidateInterface* candidate) override {
+ return false;
+ }
+
+ bool RemoveIceCandidates(
+ const std::vector<cricket::Candidate>& candidates) override {
+ return false;
+ }
+
+ void RegisterUMAObserver(UMAObserver* observer) override {}
+
+ RTCError SetBitrate(const BitrateParameters& bitrate) override {
+ return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
+ }
+
+ void SetBitrateAllocationStrategy(
+ std::unique_ptr<rtc::BitrateAllocationStrategy>
+ bitrate_allocation_strategy) override {}
+
+ void SetAudioPlayout(bool playout) override {}
+
+ void SetAudioRecording(bool recording) override {}
+
+ SignalingState signaling_state() override { return SignalingState::kStable; }
+
+ IceConnectionState ice_connection_state() override {
+ return IceConnectionState::kIceConnectionNew;
+ }
+
+ IceGatheringState ice_gathering_state() override {
+ return IceGatheringState::kIceGatheringNew;
+ }
+
+ bool StartRtcEventLog(rtc::PlatformFile file,
+ int64_t max_size_bytes) override {
+ return false;
+ }
+
+ bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output,
+ int64_t output_period_ms) override {
+ return false;
+ }
+
+ void StopRtcEventLog() override {}
+
+ void Close() override {}
+
+ // PeerConnectionInternal implementation.
+
+ rtc::Thread* network_thread() const override { return nullptr; }
+ rtc::Thread* worker_thread() const override { return nullptr; }
+ rtc::Thread* signaling_thread() const override { return nullptr; }
+
+ std::string session_id() const override { return ""; }
+
+ bool initial_offerer() const override { return false; }
+
+ cricket::VoiceChannel* voice_channel() const override { return nullptr; }
+
+ cricket::VideoChannel* video_channel() const override { return nullptr; }
+
+ std::vector<
+ rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
+ GetTransceiversForTesting() const override {
+ return {};
+ }
+
+ bool GetLocalTrackIdBySsrc(uint32_t ssrc, std::string* track_id) override {
+ return false;
+ }
+ bool GetRemoteTrackIdBySsrc(uint32_t ssrc, std::string* track_id) override {
+ return false;
+ }
+
+ sigslot::signal1<DataChannel*>& SignalDataChannelCreated() override {
+ return SignalDataChannelCreated_;
+ }
+
+ cricket::RtpDataChannel* rtp_data_channel() const override { return nullptr; }
+
+ std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels()
+ const override {
+ return {};
+ }
+
+ rtc::Optional<std::string> sctp_content_name() const override {
+ return rtc::nullopt;
+ }
+
+ rtc::Optional<std::string> sctp_transport_name() const override {
+ return rtc::nullopt;
+ }
+
+ std::unique_ptr<SessionStats> GetSessionStats_s() override { return nullptr; }
+
+ std::unique_ptr<SessionStats> GetSessionStats(
+ const ChannelNamePairs& channel_name_pairs) override {
+ return nullptr;
+ }
+
+ Call::Stats GetCallStats() override { return Call::Stats(); }
+
+ bool GetLocalCertificate(
+ const std::string& transport_name,
+ rtc::scoped_refptr<rtc::RTCCertificate>* certificate) override {
+ return false;
+ }
+
+ std::unique_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate(
+ const std::string& transport_name) override {
+ return nullptr;
+ }
+
+ bool IceRestartPending(const std::string& content_name) const override {
+ return false;
+ }
+
+ bool NeedsIceRestart(const std::string& content_name) const override {
+ return false;
+ }
+
+ bool GetSslRole(const std::string& content_name,
+ rtc::SSLRole* role) override {
+ return false;
+ }
+
+ protected:
+ sigslot::signal1<DataChannel*> SignalDataChannelCreated_;
+};
+
+} // namespace webrtc
+
+#endif // PC_TEST_FAKEPEERCONNECTIONBASE_H_