• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef LNN_IP_NETWORK_IMPL_MOCK_H
17 #define LNN_IP_NETWORK_IMPL_MOCK_H
18 
19 #include <gmock/gmock.h>
20 #include <mutex>
21 
22 #include "auth_interface.h"
23 #include "bus_center_event.h"
24 #include "disc_interface.h"
25 #include "lnn_network_manager.h"
26 #include "lnn_physical_subnet_manager.h"
27 #include "softbus_adapter_bt_common.h"
28 #include "softbus_common.h"
29 #include "softbus_conn_interface.h"
30 #include "softbus_protocol_def.h"
31 
32 namespace OHOS {
33 class LnnIpNetworkImplInterface {
34 public:
LnnIpNetworkImplInterface()35     LnnIpNetworkImplInterface() {};
~LnnIpNetworkImplInterface()36     virtual ~LnnIpNetworkImplInterface() {};
37     virtual int32_t LnnRegisterEventHandler(LnnEventType event, LnnEventHandler handler) = 0;
38     virtual int32_t LnnRegistPhysicalSubnet(LnnPhysicalSubnet *manager) = 0;
39     virtual void DiscLinkStatusChanged(LinkStatus status, ExchangeMedium medium) = 0;
40     virtual bool LnnVisitPhysicalSubnet(LnnVisitPhysicalSubnetCallback callback, void *data) = 0;
41     virtual void LnnStopPublish(void) = 0;
42     virtual void LnnStopDiscovery(void) = 0;
43     virtual void LnnIpAddrChangeEventHandler(void) = 0;
44     virtual void AuthStopListening(AuthLinkType type) = 0;
45     virtual int32_t TransTdcStopSessionListener(ListenerModule module) = 0;
46     virtual int32_t ConnStopLocalListening(const LocalListenerInfo *info) = 0;
47     virtual int32_t LnnGetAddrTypeByIfName(const char *ifName, ConnectionAddrType *type) = 0;
48     virtual int32_t LnnStartPublish(void) = 0;
49     virtual bool LnnIsAutoNetWorkingEnabled(void) = 0;
50     virtual int32_t LnnStartDiscovery(void) = 0;
51     virtual int32_t AuthStartListening(AuthLinkType type, const char *ip, int32_t port) = 0;
52     virtual int32_t TransTdcStartSessionListener(ListenerModule module, const LocalListenerInfo *info) = 0;
53     virtual int32_t ConnStartLocalListening(const LocalListenerInfo *info) = 0;
54     virtual bool LnnIsLinkReady(const char *iface) = 0;
55     virtual void LnnNotifyPhysicalSubnetStatusChanged(const char *ifName, ProtocolType protocolType, void *status) = 0;
56     virtual bool LnnVisitNetif(VisitNetifCallback callback, void *data) = 0;
57     virtual int32_t LnnRequestLeaveByAddrType(const bool *type, uint32_t typeLen) = 0;
58     virtual int32_t GetNetworkIpByIfName(const char *ifName, char *ip, char *netmask, uint32_t len) = 0;
59     virtual int32_t LnnRegistProtocol(LnnProtocolManager *protocolMgr) = 0;
60     virtual int32_t GetWlanIpv4Addr(char *ip, uint32_t size) = 0;
61     virtual int32_t ConnCoapStartServerListen(void) = 0;
62     virtual void ConnCoapStopServerListen(void) = 0;
63 };
64 
65 class LnnIpNetworkImplInterfaceMock : public LnnIpNetworkImplInterface {
66 public:
67     LnnIpNetworkImplInterfaceMock();
68     ~LnnIpNetworkImplInterfaceMock() override;
69     MOCK_METHOD2(LnnRegisterEventHandler, int32_t(LnnEventType, LnnEventHandler));
70     MOCK_METHOD1(LnnRegistPhysicalSubnet, int32_t(LnnPhysicalSubnet *));
71     MOCK_METHOD2(DiscLinkStatusChanged, void(LinkStatus, ExchangeMedium));
72     MOCK_METHOD2(LnnVisitPhysicalSubnet, bool(LnnVisitPhysicalSubnetCallback, void *));
73     MOCK_METHOD0(LnnStopPublish, void(void));
74     MOCK_METHOD0(LnnStopDiscovery, void(void));
75     MOCK_METHOD0(LnnIpAddrChangeEventHandler, void(void));
76     MOCK_METHOD1(AuthStopListening, void(AuthLinkType));
77     MOCK_METHOD1(TransTdcStopSessionListener, int32_t(ListenerModule));
78     MOCK_METHOD1(ConnStopLocalListening, int32_t(const LocalListenerInfo *));
79     MOCK_METHOD2(LnnGetAddrTypeByIfName, int32_t(const char *, ConnectionAddrType *));
80     MOCK_METHOD0(LnnStartPublish, int32_t(void));
81     MOCK_METHOD0(LnnIsAutoNetWorkingEnabled, bool(void));
82     MOCK_METHOD0(LnnStartDiscovery, int32_t(void));
83     MOCK_METHOD3(AuthStartListening, int32_t(AuthLinkType, const char *, int32_t));
84     MOCK_METHOD2(TransTdcStartSessionListener, int32_t(ListenerModule, const LocalListenerInfo *));
85     MOCK_METHOD1(ConnStartLocalListening, int32_t(const LocalListenerInfo *));
86     MOCK_METHOD1(LnnIsLinkReady, bool(const char *));
87     MOCK_METHOD3(LnnNotifyPhysicalSubnetStatusChanged, void(const char *, ProtocolType, void *));
88     MOCK_METHOD2(LnnVisitNetif, bool(VisitNetifCallback, void *));
89     MOCK_METHOD2(LnnRequestLeaveByAddrType, int32_t(const bool *, uint32_t));
90     MOCK_METHOD4(GetNetworkIpByIfName, int32_t(const char *, char *, char *, uint32_t));
91     MOCK_METHOD1(LnnRegistProtocol, int32_t(LnnProtocolManager *));
92     MOCK_METHOD2(GetWlanIpv4Addr, int32_t(char *, uint32_t));
93     MOCK_METHOD0(ConnCoapStartServerListen, int32_t(void));
94     MOCK_METHOD0(ConnCoapStopServerListen, void(void));
95     static int32_t ActionOfGetNetworkIpByIfName(const char *ifName, char *ip, char *netmask, uint32_t len);
96 };
97 } // namespace OHOS
98 #endif // LNN_IP_NETWORK_IMPL_MOCK_H