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 #include "lnn_bt_network_impl_mock.h"
17 #include "softbus_error_code.h"
18
19 using namespace testing;
20 using namespace testing::ext;
21
22 namespace OHOS {
23 void *g_btNetworkImplInterface;
LnnBtNetworkImplInterfaceMock()24 LnnBtNetworkImplInterfaceMock::LnnBtNetworkImplInterfaceMock()
25 {
26 g_btNetworkImplInterface = reinterpret_cast<void *>(this);
27 }
28
~LnnBtNetworkImplInterfaceMock()29 LnnBtNetworkImplInterfaceMock::~LnnBtNetworkImplInterfaceMock()
30 {
31 g_btNetworkImplInterface = nullptr;
32 }
33
GetLnnBtNetworkImplInterface()34 static LnnBtNetworkImplInterface *GetLnnBtNetworkImplInterface()
35 {
36 return reinterpret_cast<LnnBtNetworkImplInterface *>(g_btNetworkImplInterface);
37 }
38
ActionOfLnnGetNetIfTypeByNameBr(const char * ifName,LnnNetIfType * type)39 int32_t LnnBtNetworkImplInterfaceMock::ActionOfLnnGetNetIfTypeByNameBr(const char *ifName, LnnNetIfType *type)
40 {
41 *type = (LnnNetIfType)LNN_NETIF_TYPE_BR;
42 return SOFTBUS_OK;
43 }
44
ActionOfLnnGetNetIfTypeByNameBle(const char * ifName,LnnNetIfType * type)45 int32_t LnnBtNetworkImplInterfaceMock::ActionOfLnnGetNetIfTypeByNameBle(const char *ifName, LnnNetIfType *type)
46 {
47 *type = (LnnNetIfType)LNN_NETIF_TYPE_BLE;
48 return SOFTBUS_OK;
49 }
50
51 extern "C" {
LnnRequestLeaveSpecific(const char * networkId,ConnectionAddrType addrType)52 int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType)
53 {
54 return GetLnnBtNetworkImplInterface()->LnnRequestLeaveSpecific(networkId, addrType);
55 }
56
LnnRequestLeaveByAddrType(const bool * type,uint32_t typeLen)57 int32_t LnnRequestLeaveByAddrType(const bool *type, uint32_t typeLen)
58 {
59 return GetLnnBtNetworkImplInterface()->LnnRequestLeaveByAddrType(type, typeLen);
60 }
61
SoftBusGetBtState(void)62 int SoftBusGetBtState(void)
63 {
64 return GetLnnBtNetworkImplInterface()->SoftBusGetBtState();
65 }
66
SoftBusGetBtMacAddr(SoftBusBtAddr * mac)67 int SoftBusGetBtMacAddr(SoftBusBtAddr *mac)
68 {
69 return GetLnnBtNetworkImplInterface()->SoftBusGetBtMacAddr(mac);
70 }
71
ConvertBtMacToStr(char * strMac,uint32_t strMacLen,const uint8_t * binMac,uint32_t binMacLen)72 int32_t ConvertBtMacToStr(char *strMac, uint32_t strMacLen, const uint8_t *binMac, uint32_t binMacLen)
73 {
74 return GetLnnBtNetworkImplInterface()->ConvertBtMacToStr(strMac, strMacLen, binMac, binMacLen);
75 }
76
LnnRegisterEventHandler(LnnEventType event,LnnEventHandler handler)77 int32_t LnnRegisterEventHandler(LnnEventType event, LnnEventHandler handler)
78 {
79 return GetLnnBtNetworkImplInterface()->LnnRegisterEventHandler(event, handler);
80 }
81
LnnGetNetIfTypeByName(const char * ifName,LnnNetIfType * type)82 int32_t LnnGetNetIfTypeByName(const char *ifName, LnnNetIfType *type)
83 {
84 return GetLnnBtNetworkImplInterface()->LnnGetNetIfTypeByName(ifName, type);
85 }
86
LnnVisitNetif(VisitNetifCallback callback,void * data)87 bool LnnVisitNetif(VisitNetifCallback callback, void *data)
88 {
89 return GetLnnBtNetworkImplInterface()->LnnVisitNetif(callback, data);
90 }
91
LnnRegistPhysicalSubnet(LnnPhysicalSubnet * manager)92 int32_t LnnRegistPhysicalSubnet(LnnPhysicalSubnet *manager)
93 {
94 return GetLnnBtNetworkImplInterface()->LnnRegistPhysicalSubnet(manager);
95 }
96
LnnNotifyPhysicalSubnetStatusChanged(const char * ifName,ProtocolType protocolType,void * status)97 void LnnNotifyPhysicalSubnetStatusChanged(const char *ifName, ProtocolType protocolType, void *status)
98 {
99 return GetLnnBtNetworkImplInterface()->LnnNotifyPhysicalSubnetStatusChanged(ifName, protocolType, status);
100 }
101 }
102 }
103