• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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_distributed_net_ledger_manager_mock.h"
17 #include "lnn_log.h"
18 
19 using namespace testing;
20 using namespace testing::ext;
21 
22 namespace OHOS {
23 void *g_lnnNetLedgerManagerInterface;
LnnDistributedNetLedgerManagerInterfaceMock()24 LnnDistributedNetLedgerManagerInterfaceMock::LnnDistributedNetLedgerManagerInterfaceMock()
25 {
26     g_lnnNetLedgerManagerInterface = reinterpret_cast<void *>(this);
27 }
28 
~LnnDistributedNetLedgerManagerInterfaceMock()29 LnnDistributedNetLedgerManagerInterfaceMock::~LnnDistributedNetLedgerManagerInterfaceMock()
30 {
31     g_lnnNetLedgerManagerInterface = nullptr;
32 }
33 
GetLnnDistributedNetLedgerManagerInterface()34 static LnnDistributedNetLedgerManagerInterfaceMock *GetLnnDistributedNetLedgerManagerInterface()
35 {
36     return reinterpret_cast<LnnDistributedNetLedgerManagerInterfaceMock *>(g_lnnNetLedgerManagerInterface);
37 }
38 
39 extern "C" {
LnnGetNodeInfoById(const char * id,IdCategory type)40 NodeInfo *LnnGetNodeInfoById(const char *id, IdCategory type)
41 {
42     return GetLnnDistributedNetLedgerManagerInterface()->LnnGetNodeInfoById(id, type);
43 }
44 
LnnSaveRemoteDeviceInfo(const NodeInfo * deviceInfo)45 int32_t LnnSaveRemoteDeviceInfo(const NodeInfo *deviceInfo)
46 {
47     return GetLnnDistributedNetLedgerManagerInterface()->LnnSaveRemoteDeviceInfo(deviceInfo);
48 }
49 
LnnSetWifiDirectAddr(NodeInfo * info,const char * wifiDirectAddr)50 int32_t LnnSetWifiDirectAddr(NodeInfo *info, const char *wifiDirectAddr)
51 {
52     return GetLnnDistributedNetLedgerManagerInterface()->LnnSetWifiDirectAddr(info, wifiDirectAddr);
53 }
54 
SoftBusGenerateStrHash(const unsigned char * str,uint32_t len,unsigned char * hash)55 int32_t SoftBusGenerateStrHash(const unsigned char *str, uint32_t len, unsigned char *hash)
56 {
57     return GetLnnDistributedNetLedgerManagerInterface()->SoftBusGenerateStrHash(str, len, hash);
58 }
59 
ConvertBytesToHexString(char * outBuf,uint32_t outBufLen,const unsigned char * inBuf,uint32_t inLen)60 int32_t ConvertBytesToHexString(char *outBuf, uint32_t outBufLen, const unsigned char *inBuf, uint32_t inLen)
61 {
62     return GetLnnDistributedNetLedgerManagerInterface()->ConvertBytesToHexString(outBuf, outBufLen, inBuf, inLen);
63 }
64 
LnnIsNodeOnline(const NodeInfo * info)65 bool LnnIsNodeOnline(const NodeInfo *info)
66 {
67     return GetLnnDistributedNetLedgerManagerInterface()->LnnIsNodeOnline(info);
68 }
69 
GetNodeInfoFromMap(const DoubleHashMap * map,const char * id)70 NodeInfo *GetNodeInfoFromMap(const DoubleHashMap *map, const char *id)
71 {
72     return GetLnnDistributedNetLedgerManagerInterface()->GetNodeInfoFromMap(map, id);
73 }
74 
LnnRetrieveDeviceInfo(const char * udidHash,NodeInfo * deviceInfo)75 int32_t LnnRetrieveDeviceInfo(const char *udidHash, NodeInfo *deviceInfo)
76 {
77     return GetLnnDistributedNetLedgerManagerInterface()->LnnRetrieveDeviceInfo(udidHash, deviceInfo);
78 }
79 } // extern "C"
80 } // namespace OHOS
81