You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
6.4 KiB

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