• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
AnonymizeDeviceName(const char * plainStr,char ** anonymizedStr)45 void AnonymizeDeviceName(const char *plainStr, char **anonymizedStr)
46 {
47     return GetBusCenterEventDepsInterface()->AnonymizeDeviceName(plainStr, anonymizedStr);
48 }
49 
AnonymizeFree(char * anonymizedStr)50 void AnonymizeFree(char *anonymizedStr)
51 {
52     return GetBusCenterEventDepsInterface()->AnonymizeFree(anonymizedStr);
53 }
54 
SetDefaultQdisc(void)55 int32_t SetDefaultQdisc(void)
56 {
57     return GetBusCenterEventDepsInterface()->SetDefaultQdisc();
58 }
59 
LnnGetAllOnlineNodeNum(int32_t * nodeNum)60 int32_t LnnGetAllOnlineNodeNum(int32_t *nodeNum)
61 {
62     return GetBusCenterEventDepsInterface()->LnnGetAllOnlineNodeNum(nodeNum);
63 }
64 
LnnGetLocalNum64Info(InfoKey key,int64_t * info)65 int32_t LnnGetLocalNum64Info(InfoKey key, int64_t *info)
66 {
67     return GetBusCenterEventDepsInterface()->LnnGetLocalNum64Info(key, info);
68 }
69 
LnnIpcNotifyDeviceNotTrusted(const char * msg)70 int32_t LnnIpcNotifyDeviceNotTrusted(const char *msg)
71 {
72     return GetBusCenterEventDepsInterface()->LnnIpcNotifyDeviceNotTrusted(msg);
73 }
74 
LnnIpcNotifyJoinResult(void * addr,uint32_t addrTypeLen,const char * networkId,int32_t retCode)75 int32_t LnnIpcNotifyJoinResult(void *addr, uint32_t addrTypeLen, const char *networkId,
76     int32_t retCode)
77 {
78     return GetBusCenterEventDepsInterface()->LnnIpcNotifyJoinResult(addr, addrTypeLen, networkId, retCode);
79 }
80 
LnnIpcNotifyLeaveResult(const char * networkId,int32_t retCode)81 int32_t LnnIpcNotifyLeaveResult(const char *networkId, int32_t retCode)
82 {
83     return GetBusCenterEventDepsInterface()->LnnIpcNotifyLeaveResult(networkId, retCode);
84 }
85 
LnnIpcNotifyTimeSyncResult(const char * pkgName,int32_t pid,const void * info,uint32_t infoTypeLen,int32_t retCode)86 int32_t LnnIpcNotifyTimeSyncResult(const char *pkgName, int32_t pid, const void *info,
87     uint32_t infoTypeLen, int32_t retCode)
88 {
89     return GetBusCenterEventDepsInterface()->LnnIpcNotifyTimeSyncResult(pkgName, pid, info, infoTypeLen, retCode);
90 }
91 
LnnGetRemoteNodeInfoById(const char * id,IdCategory type,NodeInfo * info)92 int32_t LnnGetRemoteNodeInfoById(const char *id, IdCategory type, NodeInfo *info)
93 {
94     return GetBusCenterEventDepsInterface()->LnnGetRemoteNodeInfoById(id, type, info);
95 }
96 
LnnHasDiscoveryType(const NodeInfo * info,DiscoveryType type)97 bool LnnHasDiscoveryType(const NodeInfo *info, DiscoveryType type)
98 {
99     return GetBusCenterEventDepsInterface()->LnnHasDiscoveryType(info, type);
100 }
101 
LnnConvAddrTypeToDiscType(ConnectionAddrType type)102 DiscoveryType LnnConvAddrTypeToDiscType(ConnectionAddrType type)
103 {
104     return GetBusCenterEventDepsInterface()->LnnConvAddrTypeToDiscType(type);
105 }
106 
CreateNewLooper(const char * name)107 SoftBusLooper *CreateNewLooper(const char *name)
108 {
109     return GetBusCenterEventDepsInterface()->CreateNewLooper(name);
110 }
111 
LnnIpcNotifyOnlineState(bool isOnline,void * info,uint32_t infoTypeLen)112 int32_t  LnnIpcNotifyOnlineState(bool isOnline, void *info, uint32_t infoTypeLen)
113 {
114     return GetBusCenterEventDepsInterface()->LnnIpcNotifyOnlineState(isOnline, info, infoTypeLen);
115 }
116 
LnnDCProcessOnlineState(bool isOnline,const NodeBasicInfo * info)117 void LnnDCProcessOnlineState(bool isOnline, const NodeBasicInfo *info)
118 {
119     return GetBusCenterEventDepsInterface()->LnnDCProcessOnlineState(isOnline, info);
120 }
121 
LnnIpcNotifyBasicInfoChanged(void * info,uint32_t infoTypeLen,int32_t type)122 int32_t LnnIpcNotifyBasicInfoChanged(void *info, uint32_t infoTypeLen, int32_t type)
123 {
124     return GetBusCenterEventDepsInterface()->LnnIpcNotifyBasicInfoChanged(info, infoTypeLen, type);
125 }
126 
LnnGenLocalNetworkId(char * networkId,uint32_t len)127 int32_t LnnGenLocalNetworkId(char *networkId, uint32_t len)
128 {
129     return GetBusCenterEventDepsInterface()->LnnGenLocalNetworkId(networkId, len);
130 }
131 
LnnIpcLocalNetworkIdChanged(void)132 int32_t LnnIpcLocalNetworkIdChanged(void)
133 {
134     return GetBusCenterEventDepsInterface()->LnnIpcLocalNetworkIdChanged();
135 }
136 
LnnSetLocalStrInfo(InfoKey key,const char * info)137 int32_t LnnSetLocalStrInfo(InfoKey key, const char *info)
138 {
139     return GetBusCenterEventDepsInterface()->LnnSetLocalStrInfo(key, info);
140 }
141 
LnnUpdateAuthExchangeUdid(void)142 void LnnUpdateAuthExchangeUdid(void)
143 {
144     return GetBusCenterEventDepsInterface()->LnnUpdateAuthExchangeUdid();
145 }
146 }
147 } // namespace OHOS
148