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 P2P_BASE_MOCK_ICE_TRANSPORT_H_ 12 #define P2P_BASE_MOCK_ICE_TRANSPORT_H_ 13 14 #include <memory> 15 #include <string> 16 #include <vector> 17 18 #include "p2p/base/ice_transport_internal.h" 19 #include "rtc_base/gunit.h" 20 #include "test/gmock.h" 21 22 using ::testing::_; 23 using ::testing::Return; 24 25 namespace cricket { 26 27 // Used in Chromium/remoting/protocol/channel_socket_adapter_unittest.cc 28 class MockIceTransport : public IceTransportInternal { 29 public: MockIceTransport()30 MockIceTransport() { 31 SignalReadyToSend(this); 32 SignalWritableState(this); 33 } 34 35 MOCK_METHOD(int, 36 SendPacket, 37 (const char* data, 38 size_t len, 39 const rtc::PacketOptions& options, 40 int flags), 41 (override)); 42 MOCK_METHOD(int, SetOption, (rtc::Socket::Option opt, int value), (override)); 43 MOCK_METHOD(int, GetError, (), (override)); 44 MOCK_METHOD(cricket::IceRole, GetIceRole, (), (const, override)); 45 MOCK_METHOD(bool, 46 GetStats, 47 (cricket::IceTransportStats * ice_transport_stats), 48 (override)); 49 GetState()50 IceTransportState GetState() const override { 51 return IceTransportState::STATE_INIT; 52 } GetIceTransportState()53 webrtc::IceTransportState GetIceTransportState() const override { 54 return webrtc::IceTransportState::kNew; 55 } 56 transport_name()57 const std::string& transport_name() const override { return transport_name_; } component()58 int component() const override { return 0; } SetIceRole(IceRole role)59 void SetIceRole(IceRole role) override {} SetIceTiebreaker(uint64_t tiebreaker)60 void SetIceTiebreaker(uint64_t tiebreaker) override {} 61 // The ufrag and pwd in |ice_params| must be set 62 // before candidate gathering can start. SetIceParameters(const IceParameters & ice_params)63 void SetIceParameters(const IceParameters& ice_params) override {} SetRemoteIceParameters(const IceParameters & ice_params)64 void SetRemoteIceParameters(const IceParameters& ice_params) override {} SetRemoteIceMode(IceMode mode)65 void SetRemoteIceMode(IceMode mode) override {} SetIceConfig(const IceConfig & config)66 void SetIceConfig(const IceConfig& config) override {} GetRttEstimate()67 absl::optional<int> GetRttEstimate() override { return absl::nullopt; } selected_connection()68 const Connection* selected_connection() const override { return nullptr; } GetSelectedCandidatePair()69 absl::optional<const CandidatePair> GetSelectedCandidatePair() 70 const override { 71 return absl::nullopt; 72 } MaybeStartGathering()73 void MaybeStartGathering() override {} AddRemoteCandidate(const Candidate & candidate)74 void AddRemoteCandidate(const Candidate& candidate) override {} RemoveRemoteCandidate(const Candidate & candidate)75 void RemoveRemoteCandidate(const Candidate& candidate) override {} RemoveAllRemoteCandidates()76 void RemoveAllRemoteCandidates() override {} gathering_state()77 IceGatheringState gathering_state() const override { 78 return IceGatheringState::kIceGatheringComplete; 79 } 80 receiving()81 bool receiving() const override { return true; } writable()82 bool writable() const override { return true; } 83 84 private: 85 std::string transport_name_; 86 }; 87 88 } // namespace cricket 89 90 #endif // P2P_BASE_MOCK_ICE_TRANSPORT_H_ 91