1 /* 2 * Copyright 2018 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_CONTROLLER_H_ 12 #define P2P_BASE_MOCK_ICE_CONTROLLER_H_ 13 14 #include <memory> 15 #include <vector> 16 17 #include "p2p/base/ice_controller_factory_interface.h" 18 #include "p2p/base/ice_controller_interface.h" 19 #include "test/gmock.h" 20 21 namespace cricket { 22 23 class MockIceController : public cricket::IceControllerInterface { 24 public: MockIceController(const cricket::IceControllerFactoryArgs & args)25 explicit MockIceController(const cricket::IceControllerFactoryArgs& args) {} 26 ~MockIceController() override = default; 27 28 MOCK_METHOD(void, SetIceConfig, (const cricket::IceConfig&), (override)); 29 MOCK_METHOD(void, 30 SetSelectedConnection, 31 (const cricket::Connection*), 32 (override)); 33 MOCK_METHOD(void, AddConnection, (const cricket::Connection*), (override)); 34 MOCK_METHOD(void, 35 OnConnectionDestroyed, 36 (const cricket::Connection*), 37 (override)); 38 MOCK_METHOD(rtc::ArrayView<const cricket::Connection*>, 39 connections, 40 (), 41 (const, override)); 42 MOCK_METHOD(bool, HasPingableConnection, (), (const, override)); 43 MOCK_METHOD(cricket::IceControllerInterface::PingResult, 44 SelectConnectionToPing, 45 (int64_t), 46 (override)); 47 MOCK_METHOD(bool, 48 GetUseCandidateAttr, 49 (const cricket::Connection*, 50 cricket::NominationMode, 51 cricket::IceMode), 52 (const, override)); 53 MOCK_METHOD(const cricket::Connection*, 54 FindNextPingableConnection, 55 (), 56 (override)); 57 MOCK_METHOD(void, 58 MarkConnectionPinged, 59 (const cricket::Connection*), 60 (override)); 61 MOCK_METHOD(cricket::IceControllerInterface::SwitchResult, 62 ShouldSwitchConnection, 63 (cricket::IceSwitchReason, const cricket::Connection*), 64 (override)); 65 MOCK_METHOD(cricket::IceControllerInterface::SwitchResult, 66 SortAndSwitchConnection, 67 (cricket::IceSwitchReason), 68 (override)); 69 MOCK_METHOD(std::vector<const cricket::Connection*>, 70 PruneConnections, 71 (), 72 (override)); 73 }; 74 75 class MockIceControllerFactory : public cricket::IceControllerFactoryInterface { 76 public: 77 ~MockIceControllerFactory() override = default; 78 Create(const cricket::IceControllerFactoryArgs & args)79 std::unique_ptr<cricket::IceControllerInterface> Create( 80 const cricket::IceControllerFactoryArgs& args) override { 81 RecordIceControllerCreated(); 82 return std::make_unique<MockIceController>(args); 83 } 84 85 MOCK_METHOD(void, RecordIceControllerCreated, ()); 86 }; 87 88 } // namespace cricket 89 90 #endif // P2P_BASE_MOCK_ICE_CONTROLLER_H_ 91