• 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 #ifndef LNN_DECISION_DB_DEPS_MOCK_H
17 #define LNN_DECISION_DB_DEPS_MOCK_H
18 
19 #include <gmock/gmock.h>
20 
21 #include "lnn_distributed_net_ledger_common.h"
22 #include "lnn_distributed_net_ledger.h"
23 #include "lnn_node_info.h"
24 
25 namespace OHOS {
26 class LnnDistributedNetLedgerManagerInterface {
27 public:
LnnDistributedNetLedgerManagerInterface()28     LnnDistributedNetLedgerManagerInterface() {};
~LnnDistributedNetLedgerManagerInterface()29     virtual ~LnnDistributedNetLedgerManagerInterface() {};
30 
31     virtual NodeInfo *LnnGetNodeInfoById(const char *id, IdCategory type) = 0;
32     virtual int32_t LnnSaveRemoteDeviceInfo(const NodeInfo *deviceInfo) = 0;
33     virtual int32_t LnnSetWifiDirectAddr(NodeInfo *info, const char *wifiDirectAddr) = 0;
34     virtual int32_t SoftBusGenerateStrHash(const unsigned char *str, uint32_t len, unsigned char *hash) = 0;
35     virtual int32_t ConvertBytesToHexString(
36         char *outBuf, uint32_t outBufLen, const unsigned char *inBuf, uint32_t inLen) = 0;
37     virtual bool LnnIsNodeOnline(const NodeInfo *info) = 0;
38     virtual NodeInfo *GetNodeInfoFromMap(const DoubleHashMap *map, const char *id) = 0;
39     virtual int32_t LnnRetrieveDeviceInfo(const char *udidHash, NodeInfo *deviceInfo) = 0;
40 };
41 
42 class LnnDistributedNetLedgerManagerInterfaceMock : public LnnDistributedNetLedgerManagerInterface {
43 public:
44     LnnDistributedNetLedgerManagerInterfaceMock();
45     ~LnnDistributedNetLedgerManagerInterfaceMock() override;
46 
47     MOCK_METHOD2(LnnGetNodeInfoById, NodeInfo *(const char *, IdCategory));
48     MOCK_METHOD1(LnnSaveRemoteDeviceInfo, int32_t(const NodeInfo *));
49     MOCK_METHOD2(LnnSetWifiDirectAddr, int32_t(NodeInfo *, const char *));
50     MOCK_METHOD3(SoftBusGenerateStrHash, int32_t(const unsigned char *, uint32_t, unsigned char *));
51     MOCK_METHOD4(ConvertBytesToHexString, int32_t(char *, uint32_t, const unsigned char *, uint32_t));
52     MOCK_METHOD1(LnnIsNodeOnline, bool(const NodeInfo *));
53     MOCK_METHOD2(GetNodeInfoFromMap, NodeInfo *(const DoubleHashMap *, const char *));
54     MOCK_METHOD2(LnnRetrieveDeviceInfo, int32_t(const char *, NodeInfo *));
55 };
56 extern "C" {
57     int32_t LnnSaveRemoteDeviceInfo(const NodeInfo *deviceInfo);
58     NodeInfo *LnnGetNodeInfoById(const char *id, IdCategory type);
59 }
60 } // namespace OHOS
61 #endif // LNN_DECISION_DB_DEPS_MOCK_H
62