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_net_capability.h" 24 #include "softbus_adapter_crypto.h" 25 #include "bus_center_adapter.h" 26 #include "lnn_p2p_info.h" 27 #include "softbus_adapter_thread.h" 28 #include "softbus_hidumper_buscenter.h" 29 #include "lnn_ohos_account.h" 30 31 namespace OHOS { 32 class LocalLedgerDepsInterface { 33 public: LocalLedgerDepsInterface()34 LocalLedgerDepsInterface() {}; ~LocalLedgerDepsInterface()35 virtual ~LocalLedgerDepsInterface() {}; 36 37 virtual uint32_t LnnGetNetCapabilty(void); 38 virtual int32_t SoftBusGenerateRandomArray(unsigned char *randStr, uint32_t len); 39 virtual int32_t GetCommonDevInfo(const CommonDeviceKey key, char *value, uint32_t len); 40 virtual int32_t LnnInitLocalP2pInfo(NodeInfo *info); 41 virtual int32_t SoftBusRegBusCenterVarDump(char *dumpVar, SoftBusVarDumpCb cb); 42 virtual int32_t LnnInitOhosAccount(void); 43 }; 44 class LocalLedgerDepsInterfaceMock : public LocalLedgerDepsInterface { 45 public: 46 LocalLedgerDepsInterfaceMock(); 47 ~LocalLedgerDepsInterfaceMock() override; 48 MOCK_METHOD0(LnnGetNetCapabilty, uint32_t ()); 49 MOCK_METHOD2(SoftBusGenerateRandomArray, int32_t (unsigned char *, uint32_t)); 50 MOCK_METHOD3(GetCommonDevInfo, int32_t (const CommonDeviceKey, char *, uint32_t)); 51 MOCK_METHOD1(LnnInitLocalP2pInfo, int32_t (NodeInfo *info)); 52 MOCK_METHOD2(SoftBusRegBusCenterVarDump, int32_t (char *, SoftBusVarDumpCb)); 53 MOCK_METHOD0(LnnInitOhosAccount, int32_t ()); 54 55 static int32_t LedgerGetCommonDevInfo(const CommonDeviceKey key, char *value, uint32_t len); 56 static int32_t LedgerSoftBusRegBusCenterVarDump(char *dumpVar, SoftBusVarDumpCb cb); 57 }; 58 } // namespace OHOS 59 #endif // LNN_LOCAL_LEDGER_DEPS_MOCK_H 60