mock_ice_transport.h 3.0 KB

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