• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_ACTIVE_ICE_CONTROLLER_H_
12 #define P2P_BASE_MOCK_ACTIVE_ICE_CONTROLLER_H_
13 
14 #include <memory>
15 
16 #include "p2p/base/active_ice_controller_factory_interface.h"
17 #include "p2p/base/active_ice_controller_interface.h"
18 #include "test/gmock.h"
19 
20 namespace cricket {
21 
22 class MockActiveIceController : public cricket::ActiveIceControllerInterface {
23  public:
MockActiveIceController(const cricket::ActiveIceControllerFactoryArgs & args)24   explicit MockActiveIceController(
25       const cricket::ActiveIceControllerFactoryArgs& args) {}
26   ~MockActiveIceController() override = default;
27 
28   MOCK_METHOD(void, SetIceConfig, (const cricket::IceConfig&), (override));
29   MOCK_METHOD(void,
30               OnConnectionAdded,
31               (const cricket::Connection*),
32               (override));
33   MOCK_METHOD(void,
34               OnConnectionSwitched,
35               (const cricket::Connection*),
36               (override));
37   MOCK_METHOD(void,
38               OnConnectionDestroyed,
39               (const cricket::Connection*),
40               (override));
41   MOCK_METHOD(void,
42               OnConnectionPinged,
43               (const cricket::Connection*),
44               (override));
45   MOCK_METHOD(void,
46               OnConnectionUpdated,
47               (const cricket::Connection*),
48               (override));
49   MOCK_METHOD(bool,
50               GetUseCandidateAttribute,
51               (const cricket::Connection*,
52                cricket::NominationMode,
53                cricket::IceMode),
54               (const, override));
55   MOCK_METHOD(void,
56               OnSortAndSwitchRequest,
57               (cricket::IceSwitchReason),
58               (override));
59   MOCK_METHOD(void,
60               OnImmediateSortAndSwitchRequest,
61               (cricket::IceSwitchReason),
62               (override));
63   MOCK_METHOD(bool,
64               OnImmediateSwitchRequest,
65               (cricket::IceSwitchReason, const cricket::Connection*),
66               (override));
67   MOCK_METHOD(const cricket::Connection*,
68               FindNextPingableConnection,
69               (),
70               (override));
71 };
72 
73 class MockActiveIceControllerFactory
74     : public cricket::ActiveIceControllerFactoryInterface {
75  public:
76   ~MockActiveIceControllerFactory() override = default;
77 
Create(const cricket::ActiveIceControllerFactoryArgs & args)78   std::unique_ptr<cricket::ActiveIceControllerInterface> Create(
79       const cricket::ActiveIceControllerFactoryArgs& args) {
80     RecordActiveIceControllerCreated();
81     return std::make_unique<MockActiveIceController>(args);
82   }
83 
84   MOCK_METHOD(void, RecordActiveIceControllerCreated, ());
85 };
86 
87 }  // namespace cricket
88 
89 #endif  // P2P_BASE_MOCK_ACTIVE_ICE_CONTROLLER_H_
90