• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef LNN_LOCAL_LEDGER_DEPS_MOCK_H
17 #define LNN_LOCAL_LEDGER_DEPS_MOCK_H
18 
19 #include <gmock/gmock.h>
20 #include <mutex>
21 
22 #include "lnn_device_info.h"
23 #include "lnn_feature_capability.h"
24 #include "lnn_net_capability.h"
25 #include "softbus_adapter_crypto.h"
26 #include "bus_center_adapter.h"
27 #include "lnn_p2p_info.h"
28 #include "softbus_adapter_bt_common.h"
29 #include "softbus_adapter_thread.h"
30 #include "softbus_hidumper_buscenter.h"
31 #include "lnn_ohos_account.h"
32 
33 namespace OHOS {
34 class LocalLedgerDepsInterface {
35 public:
LocalLedgerDepsInterface()36     LocalLedgerDepsInterface() {};
~LocalLedgerDepsInterface()37     virtual ~LocalLedgerDepsInterface() {};
38 
39     virtual uint32_t LnnGetNetCapabilty(void);
40     virtual int32_t SoftBusGenerateRandomArray(unsigned char *randStr, uint32_t len);
41     virtual int32_t GetCommonDevInfo(const CommonDeviceKey key, char *value, uint32_t len);
42     virtual int32_t LnnInitLocalP2pInfo(NodeInfo *info);
43     virtual int32_t SoftBusRegBusCenterVarDump(char *dumpVar, SoftBusVarDumpCb cb);
44     virtual int32_t LnnInitOhosAccount(void);
45     virtual uint64_t LnnGetFeatureCapabilty(void);
46     virtual bool IsFeatureSupport(uint64_t feature, FeatureCapability capaBit);
47     virtual int32_t GetCommonOsType(int32_t *value);
48     virtual int32_t GetCommonOsVersion(char *value, uint32_t len);
49     virtual int32_t GetCommonDeviceVersion(char *value, uint32_t len);
50     virtual int32_t GetDeviceSecurityLevel(int32_t *level);
51     virtual int SoftBusGetBtState(void) = 0;
52     virtual int SoftBusGetBtMacAddr(SoftBusBtAddr *mac) = 0;
53 };
54 class LocalLedgerDepsInterfaceMock : public LocalLedgerDepsInterface {
55 public:
56     LocalLedgerDepsInterfaceMock();
57     ~LocalLedgerDepsInterfaceMock() override;
58     MOCK_METHOD0(LnnGetNetCapabilty, uint32_t ());
59     MOCK_METHOD2(SoftBusGenerateRandomArray, int32_t (unsigned char *, uint32_t));
60     MOCK_METHOD3(GetCommonDevInfo, int32_t (const CommonDeviceKey, char *, uint32_t));
61     MOCK_METHOD1(LnnInitLocalP2pInfo, int32_t (NodeInfo *info));
62     MOCK_METHOD2(SoftBusRegBusCenterVarDump, int32_t (char *, SoftBusVarDumpCb));
63     MOCK_METHOD0(LnnInitOhosAccount, int32_t ());
64     MOCK_METHOD0(LnnGetFeatureCapabilty, uint64_t ());
65     MOCK_METHOD2(IsFeatureSupport, bool (uint64_t, FeatureCapability));
66     MOCK_METHOD1(GetCommonOsType, int32_t (int32_t *));
67     MOCK_METHOD2(GetCommonOsVersion, int32_t (char *, uint32_t));
68     MOCK_METHOD2(GetCommonDeviceVersion, int32_t (char *, uint32_t));
69     MOCK_METHOD1(GetDeviceSecurityLevel, int32_t (int32_t *));
70     MOCK_METHOD0(SoftBusGetBtState, int (void));
71     MOCK_METHOD1(SoftBusGetBtMacAddr, int (SoftBusBtAddr *));
72 
73     static int32_t LedgerGetCommonDevInfo(const CommonDeviceKey key, char *value, uint32_t len);
74     static int32_t LedgerSoftBusRegBusCenterVarDump(char *dumpVar, SoftBusVarDumpCb cb);
75 };
76 } // namespace OHOS
77 #endif // LNN_LOCAL_LEDGER_DEPS_MOCK_H
78