1 /*
2 * Copyright (c) 2024 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 "bus_center_event_deps_mock.h"
17 #include "softbus_error_code.h"
18
19 using namespace testing::ext;
20 using namespace testing;
21
22 namespace OHOS {
23 void *g_busCenterEventDepsInterface = nullptr;
BusCenterEventDepsInterfaceMock()24 BusCenterEventDepsInterfaceMock::BusCenterEventDepsInterfaceMock()
25 {
26 g_busCenterEventDepsInterface = reinterpret_cast<void *>(this);
27 }
28
~BusCenterEventDepsInterfaceMock()29 BusCenterEventDepsInterfaceMock::~BusCenterEventDepsInterfaceMock()
30 {
31 g_busCenterEventDepsInterface = nullptr;
32 }
33
GetBusCenterEventDepsInterface()34 static BusCenterEventDepsInterface *GetBusCenterEventDepsInterface()
35 {
36 return reinterpret_cast<BusCenterEventDepsInterface *>(g_busCenterEventDepsInterface);
37 }
38
39 extern "C" {
Anonymize(const char * plainStr,char ** anonymizedStr)40 void Anonymize(const char *plainStr, char **anonymizedStr)
41 {
42 return GetBusCenterEventDepsInterface()->Anonymize(plainStr, anonymizedStr);
43 }
44
AnonymizeFree(char * anonymizedStr)45 void AnonymizeFree(char *anonymizedStr)
46 {
47 return GetBusCenterEventDepsInterface()->AnonymizeFree(anonymizedStr);
48 }
49
SetDefaultQdisc(void)50 int32_t SetDefaultQdisc(void)
51 {
52 return GetBusCenterEventDepsInterface()->SetDefaultQdisc();
53 }
54
LnnGetAllOnlineNodeNum(int32_t * nodeNum)55 int32_t LnnGetAllOnlineNodeNum(int32_t *nodeNum)
56 {
57 return GetBusCenterEventDepsInterface()->LnnGetAllOnlineNodeNum(nodeNum);
58 }
59
LnnGetLocalNum64Info(InfoKey key,int64_t * info)60 int32_t LnnGetLocalNum64Info(InfoKey key, int64_t *info)
61 {
62 return GetBusCenterEventDepsInterface()->LnnGetLocalNum64Info(key, info);
63 }
64
LnnIpcNotifyDeviceNotTrusted(const char * msg)65 int32_t LnnIpcNotifyDeviceNotTrusted(const char *msg)
66 {
67 return GetBusCenterEventDepsInterface()->LnnIpcNotifyDeviceNotTrusted(msg);
68 }
69
LnnIpcNotifyJoinResult(void * addr,uint32_t addrTypeLen,const char * networkId,int32_t retCode)70 int32_t LnnIpcNotifyJoinResult(void *addr, uint32_t addrTypeLen, const char *networkId,
71 int32_t retCode)
72 {
73 return GetBusCenterEventDepsInterface()->LnnIpcNotifyJoinResult(addr, addrTypeLen, networkId, retCode);
74 }
75
LnnIpcNotifyLeaveResult(const char * networkId,int32_t retCode)76 int32_t LnnIpcNotifyLeaveResult(const char *networkId, int32_t retCode)
77 {
78 return GetBusCenterEventDepsInterface()->LnnIpcNotifyLeaveResult(networkId, retCode);
79 }
80
LnnIpcNotifyTimeSyncResult(const char * pkgName,int32_t pid,const void * info,uint32_t infoTypeLen,int32_t retCode)81 int32_t LnnIpcNotifyTimeSyncResult(const char *pkgName, int32_t pid, const void *info,
82 uint32_t infoTypeLen, int32_t retCode)
83 {
84 return GetBusCenterEventDepsInterface()->LnnIpcNotifyTimeSyncResult(pkgName, pid, info, infoTypeLen, retCode);
85 }
86
LnnGetRemoteNodeInfoById(const char * id,IdCategory type,NodeInfo * info)87 int32_t LnnGetRemoteNodeInfoById(const char *id, IdCategory type, NodeInfo *info)
88 {
89 return GetBusCenterEventDepsInterface()->LnnGetRemoteNodeInfoById(id, type, info);
90 }
91
LnnHasDiscoveryType(const NodeInfo * info,DiscoveryType type)92 bool LnnHasDiscoveryType(const NodeInfo *info, DiscoveryType type)
93 {
94 return GetBusCenterEventDepsInterface()->LnnHasDiscoveryType(info, type);
95 }
96
LnnConvAddrTypeToDiscType(ConnectionAddrType type)97 DiscoveryType LnnConvAddrTypeToDiscType(ConnectionAddrType type)
98 {
99 return GetBusCenterEventDepsInterface()->LnnConvAddrTypeToDiscType(type);
100 }
101
CreateNewLooper(const char * name)102 SoftBusLooper *CreateNewLooper(const char *name)
103 {
104 return GetBusCenterEventDepsInterface()->CreateNewLooper(name);
105 }
106
LnnIpcNotifyOnlineState(bool isOnline,void * info,uint32_t infoTypeLen)107 int32_t LnnIpcNotifyOnlineState(bool isOnline, void *info, uint32_t infoTypeLen)
108 {
109 return GetBusCenterEventDepsInterface()->LnnIpcNotifyOnlineState(isOnline, info, infoTypeLen);
110 }
111
LnnDCProcessOnlineState(bool isOnline,const NodeBasicInfo * info)112 void LnnDCProcessOnlineState(bool isOnline, const NodeBasicInfo *info)
113 {
114 return GetBusCenterEventDepsInterface()->LnnDCProcessOnlineState(isOnline, info);
115 }
116
LnnIpcNotifyBasicInfoChanged(void * info,uint32_t infoTypeLen,int32_t type)117 int32_t LnnIpcNotifyBasicInfoChanged(void *info, uint32_t infoTypeLen, int32_t type)
118 {
119 return GetBusCenterEventDepsInterface()->LnnIpcNotifyBasicInfoChanged(info, infoTypeLen, type);
120 }
121
LnnGenLocalNetworkId(char * networkId,uint32_t len)122 int32_t LnnGenLocalNetworkId(char *networkId, uint32_t len)
123 {
124 return GetBusCenterEventDepsInterface()->LnnGenLocalNetworkId(networkId, len);
125 }
126
LnnIpcLocalNetworkIdChanged(void)127 int32_t LnnIpcLocalNetworkIdChanged(void)
128 {
129 return GetBusCenterEventDepsInterface()->LnnIpcLocalNetworkIdChanged();
130 }
131
LnnSetLocalStrInfo(InfoKey key,const char * info)132 int32_t LnnSetLocalStrInfo(InfoKey key, const char *info)
133 {
134 return GetBusCenterEventDepsInterface()->LnnSetLocalStrInfo(key, info);
135 }
136
LnnUpdateAuthExchangeUdid(void)137 void LnnUpdateAuthExchangeUdid(void)
138 {
139 return GetBusCenterEventDepsInterface()->LnnUpdateAuthExchangeUdid();
140 }
141 }
142 } // namespace OHOS
143