webrtc_m130/pc/test/mock_peer_connection_internal.h
Tommi aa3c9f2972 Reland "Add param to DCC::SetupDataChannelTransport_n, simplify DCC* setup code."
This reverts commit 298313534df2420e079ffc6fc9c6019d01d29a88.

Changes from the original commit:
* Call OnTransportClosed() from TeardownDataChannelTransport_n()
  (same as before the original commit)
* Not call OnTransportClosed() from OnTransportChanged() when its
  called with nullptr (also preserving the behaviour from before
  the original commit).

Original change's description:
> Revert "Add param to DCC::SetupDataChannelTransport_n, simplify DCC* setup code."
>
> This reverts commit 2ec6a6c57830e06f601607c1b9473ad821b57e07.
>
> Reason for revert: It breaks WPT tests (e.g. https://ci.chromium.org/ui/p/chromium/builders/try/linux-rel/1361972/overview) blocking the roll into Chromium.
>
> Original change's description:
> > Add param to DCC::SetupDataChannelTransport_n, simplify DCC* setup code.
> >
> > * DCC = DataChannelController.
> >
> > * Consolidate steps to set the mid and transport name. They're now
> >   set at the same time and without a separate PostTask.
> > * Transport sink is now consistently set in DCC
> > * Order of notifications for setting up the transport is now the same
> >   regardless of the first time the transport is being set or if it's
> >   being replaced.
> > * Made set_data_channel_transport() private.
> >
> > Bug: webrtc:11547
> > Change-Id: I39e89c6e269e6f06d55981d7944678bf23c8817a
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/300562
> > Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
> > Cr-Commit-Position: refs/heads/main@{#39859}
>
> Bug: webrtc:11547
> Change-Id: I0d8d7453b71be80fbf1b7eba7d161336e29de091
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/301360
> Auto-Submit: Mirko Bonadei <mbonadei@webrtc.org>
> Owners-Override: Mirko Bonadei <mbonadei@webrtc.org>
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
> Cr-Commit-Position: refs/heads/main@{#39864}

Bug: webrtc:11547
Change-Id: I8ebbc3d3a12786dff2096350a77e03e98466ff00
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/301702
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39884}
2023-04-18 12:12:52 +00:00

332 lines
13 KiB
C++

/*
* Copyright 2022 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_MOCK_PEER_CONNECTION_INTERNAL_H_
#define PC_TEST_MOCK_PEER_CONNECTION_INTERNAL_H_
#include <map>
#include <memory>
#include <set>
#include <string>
#include <vector>
#include "modules/audio_device/include/audio_device.h"
#include "pc/peer_connection_internal.h"
#include "test/gmock.h"
namespace webrtc {
class MockPeerConnectionInternal : public PeerConnectionInternal {
public:
MockPeerConnectionInternal() {}
~MockPeerConnectionInternal() = default;
// PeerConnectionInterface
MOCK_METHOD(rtc::scoped_refptr<StreamCollectionInterface>,
local_streams,
(),
(override));
MOCK_METHOD(rtc::scoped_refptr<StreamCollectionInterface>,
remote_streams,
(),
(override));
MOCK_METHOD(bool, AddStream, (MediaStreamInterface*), (override));
MOCK_METHOD(void, RemoveStream, (MediaStreamInterface*), (override));
MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>>,
AddTrack,
(rtc::scoped_refptr<MediaStreamTrackInterface>,
const std::vector<std::string>&),
(override));
MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>>,
AddTrack,
(rtc::scoped_refptr<MediaStreamTrackInterface>,
const std::vector<std::string>&,
const std::vector<RtpEncodingParameters>&),
(override));
MOCK_METHOD(RTCError,
RemoveTrackOrError,
(rtc::scoped_refptr<RtpSenderInterface>),
(override));
MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
AddTransceiver,
(rtc::scoped_refptr<MediaStreamTrackInterface>),
(override));
MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
AddTransceiver,
(rtc::scoped_refptr<MediaStreamTrackInterface>,
const RtpTransceiverInit&),
(override));
MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
AddTransceiver,
(cricket::MediaType),
(override));
MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
AddTransceiver,
(cricket::MediaType, const RtpTransceiverInit&),
(override));
MOCK_METHOD(rtc::scoped_refptr<RtpSenderInterface>,
CreateSender,
(const std::string&, const std::string&),
(override));
MOCK_METHOD(std::vector<rtc::scoped_refptr<RtpSenderInterface>>,
GetSenders,
(),
(const, override));
MOCK_METHOD(std::vector<rtc::scoped_refptr<RtpReceiverInterface>>,
GetReceivers,
(),
(const, override));
MOCK_METHOD(std::vector<rtc::scoped_refptr<RtpTransceiverInterface>>,
GetTransceivers,
(),
(const, override));
MOCK_METHOD(bool,
GetStats,
(StatsObserver*, MediaStreamTrackInterface*, StatsOutputLevel),
(override));
MOCK_METHOD(void, GetStats, (RTCStatsCollectorCallback*), (override));
MOCK_METHOD(void,
GetStats,
(rtc::scoped_refptr<RtpSenderInterface>,
rtc::scoped_refptr<RTCStatsCollectorCallback>),
(override));
MOCK_METHOD(void,
GetStats,
(rtc::scoped_refptr<RtpReceiverInterface>,
rtc::scoped_refptr<RTCStatsCollectorCallback>),
(override));
MOCK_METHOD(void, ClearStatsCache, (), (override));
MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<DataChannelInterface>>,
CreateDataChannelOrError,
(const std::string&, const DataChannelInit*),
(override));
MOCK_METHOD(SessionDescriptionInterface*,
local_description,
(),
(const, override));
MOCK_METHOD(SessionDescriptionInterface*,
remote_description,
(),
(const, override));
MOCK_METHOD(SessionDescriptionInterface*,
current_local_description,
(),
(const, override));
MOCK_METHOD(SessionDescriptionInterface*,
current_remote_description,
(),
(const, override));
MOCK_METHOD(SessionDescriptionInterface*,
pending_local_description,
(),
(const, override));
MOCK_METHOD(SessionDescriptionInterface*,
pending_remote_description,
(),
(const, override));
MOCK_METHOD(void, RestartIce, (), (override));
MOCK_METHOD(void,
CreateOffer,
(CreateSessionDescriptionObserver*, const RTCOfferAnswerOptions&),
(override));
MOCK_METHOD(void,
CreateAnswer,
(CreateSessionDescriptionObserver*, const RTCOfferAnswerOptions&),
(override));
MOCK_METHOD(void,
SetLocalDescription,
(SetSessionDescriptionObserver*, SessionDescriptionInterface*),
(override));
MOCK_METHOD(void,
SetRemoteDescription,
(SetSessionDescriptionObserver*, SessionDescriptionInterface*),
(override));
MOCK_METHOD(void,
SetRemoteDescription,
(std::unique_ptr<SessionDescriptionInterface>,
rtc::scoped_refptr<SetRemoteDescriptionObserverInterface>),
(override));
MOCK_METHOD(PeerConnectionInterface::RTCConfiguration,
GetConfiguration,
(),
(override));
MOCK_METHOD(RTCError,
SetConfiguration,
(const PeerConnectionInterface::RTCConfiguration&),
(override));
MOCK_METHOD(bool,
AddIceCandidate,
(const IceCandidateInterface*),
(override));
MOCK_METHOD(bool,
RemoveIceCandidates,
(const std::vector<cricket::Candidate>&),
(override));
MOCK_METHOD(RTCError, SetBitrate, (const BitrateSettings&), (override));
MOCK_METHOD(void, SetAudioPlayout, (bool), (override));
MOCK_METHOD(void, SetAudioRecording, (bool), (override));
MOCK_METHOD(rtc::scoped_refptr<DtlsTransportInterface>,
LookupDtlsTransportByMid,
(const std::string&),
(override));
MOCK_METHOD(rtc::scoped_refptr<SctpTransportInterface>,
GetSctpTransport,
(),
(const, override));
MOCK_METHOD(SignalingState, signaling_state, (), (override));
MOCK_METHOD(IceConnectionState, ice_connection_state, (), (override));
MOCK_METHOD(IceConnectionState,
standardized_ice_connection_state,
(),
(override));
MOCK_METHOD(PeerConnectionState, peer_connection_state, (), (override));
MOCK_METHOD(IceGatheringState, ice_gathering_state, (), (override));
MOCK_METHOD(absl::optional<bool>, can_trickle_ice_candidates, (), (override));
MOCK_METHOD(bool,
StartRtcEventLog,
(std::unique_ptr<RtcEventLogOutput>, int64_t),
(override));
MOCK_METHOD(bool,
StartRtcEventLog,
(std::unique_ptr<RtcEventLogOutput>),
(override));
MOCK_METHOD(void, StopRtcEventLog, (), (override));
MOCK_METHOD(void, Close, (), (override));
MOCK_METHOD(rtc::Thread*, signaling_thread, (), (const, override));
// PeerConnectionSdpMethods
MOCK_METHOD(std::string, session_id, (), (const, override));
MOCK_METHOD(bool, NeedsIceRestart, (const std::string&), (const, override));
MOCK_METHOD(absl::optional<std::string>, sctp_mid, (), (const, override));
MOCK_METHOD(PeerConnectionInterface::RTCConfiguration*,
configuration,
(),
(const, override));
MOCK_METHOD(void,
ReportSdpBundleUsage,
(const SessionDescriptionInterface&),
(override));
MOCK_METHOD(PeerConnectionMessageHandler*, message_handler, (), (override));
MOCK_METHOD(RtpTransmissionManager*, rtp_manager, (), (override));
MOCK_METHOD(const RtpTransmissionManager*,
rtp_manager,
(),
(const, override));
MOCK_METHOD(bool, dtls_enabled, (), (const, override));
MOCK_METHOD(const PeerConnectionFactoryInterface::Options*,
options,
(),
(const, override));
MOCK_METHOD(CryptoOptions, GetCryptoOptions, (), (override));
MOCK_METHOD(JsepTransportController*, transport_controller_s, (), (override));
MOCK_METHOD(JsepTransportController*, transport_controller_n, (), (override));
MOCK_METHOD(DataChannelController*, data_channel_controller, (), (override));
MOCK_METHOD(cricket::PortAllocator*, port_allocator, (), (override));
MOCK_METHOD(LegacyStatsCollector*, legacy_stats, (), (override));
MOCK_METHOD(PeerConnectionObserver*, Observer, (), (const, override));
MOCK_METHOD(absl::optional<rtc::SSLRole>, GetSctpSslRole_n, (), (override));
MOCK_METHOD(PeerConnectionInterface::IceConnectionState,
ice_connection_state_internal,
(),
(override));
MOCK_METHOD(void,
SetIceConnectionState,
(PeerConnectionInterface::IceConnectionState),
(override));
MOCK_METHOD(void, NoteUsageEvent, (UsageEvent), (override));
MOCK_METHOD(bool, IsClosed, (), (const, override));
MOCK_METHOD(bool, IsUnifiedPlan, (), (const, override));
MOCK_METHOD(bool,
ValidateBundleSettings,
(const cricket::SessionDescription*,
(const std::map<std::string, const cricket::ContentGroup*>&)),
(override));
MOCK_METHOD(absl::optional<std::string>, GetDataMid, (), (const, override));
MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
AddTransceiver,
(cricket::MediaType,
rtc::scoped_refptr<MediaStreamTrackInterface>,
const RtpTransceiverInit&,
bool),
(override));
MOCK_METHOD(void, StartSctpTransport, (int, int, int), (override));
MOCK_METHOD(void,
AddRemoteCandidate,
(const std::string&, const cricket::Candidate&),
(override));
MOCK_METHOD(Call*, call_ptr, (), (override));
MOCK_METHOD(bool, SrtpRequired, (), (const, override));
MOCK_METHOD(absl::optional<std::string>,
SetupDataChannelTransport_n,
(absl::string_view mid),
(override));
MOCK_METHOD(void, TeardownDataChannelTransport_n, (RTCError), (override));
MOCK_METHOD(void,
SetSctpDataInfo,
(absl::string_view, absl::string_view),
(override));
MOCK_METHOD(void, ResetSctpDataInfo, (), (override));
MOCK_METHOD(const FieldTrialsView&, trials, (), (const, override));
// PeerConnectionInternal
MOCK_METHOD(rtc::Thread*, network_thread, (), (const, override));
MOCK_METHOD(rtc::Thread*, worker_thread, (), (const, override));
MOCK_METHOD(bool, initial_offerer, (), (const, override));
MOCK_METHOD(
std::vector<
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>,
GetTransceiversInternal,
(),
(const, override));
MOCK_METHOD(std::vector<DataChannelStats>,
GetDataChannelStats,
(),
(const, override));
MOCK_METHOD(absl::optional<std::string>,
sctp_transport_name,
(),
(const, override));
MOCK_METHOD(cricket::CandidateStatsList,
GetPooledCandidateStats,
(),
(const, override));
MOCK_METHOD((std::map<std::string, cricket::TransportStats>),
GetTransportStatsByNames,
(const std::set<std::string>&),
(override));
MOCK_METHOD(Call::Stats, GetCallStats, (), (override));
MOCK_METHOD(absl::optional<AudioDeviceModule::Stats>,
GetAudioDeviceStats,
(),
(override));
MOCK_METHOD(bool,
GetLocalCertificate,
(const std::string&, rtc::scoped_refptr<rtc::RTCCertificate>*),
(override));
MOCK_METHOD(std::unique_ptr<rtc::SSLCertChain>,
GetRemoteSSLCertChain,
(const std::string&),
(override));
MOCK_METHOD(bool, IceRestartPending, (const std::string&), (const, override));
MOCK_METHOD(bool,
GetSslRole,
(const std::string&, rtc::SSLRole*),
(override));
MOCK_METHOD(void, NoteDataAddedEvent, (), (override));
MOCK_METHOD(void,
OnSctpDataChannelStateChanged,
(int channel_id, DataChannelInterface::DataState),
(override));
};
} // namespace webrtc
#endif // PC_TEST_MOCK_PEER_CONNECTION_INTERNAL_H_