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_BT_NETWORK_IMPL_MOCK_H 17 #define LNN_BT_NETWORK_IMPL_MOCK_H 18 19 #include <gmock/gmock.h> 20 #include <mutex> 21 22 #include "bus_center_event.h" 23 #include "lnn_network_manager.h" 24 #include "lnn_physical_subnet_manager.h" 25 #include "softbus_adapter_bt_common.h" 26 #include "softbus_common.h" 27 #include "softbus_protocol_def.h" 28 29 namespace OHOS { 30 class LnnBtNetworkImplInterface { 31 public: LnnBtNetworkImplInterface()32 LnnBtNetworkImplInterface() {}; ~LnnBtNetworkImplInterface()33 virtual ~LnnBtNetworkImplInterface() {}; 34 virtual int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType) = 0; 35 virtual int32_t LnnRequestLeaveByAddrType(const bool *type, uint32_t typeLen) = 0; 36 virtual int SoftBusGetBtState(void) = 0; 37 virtual int SoftBusGetBtMacAddr(SoftBusBtAddr *mac) = 0; 38 virtual int32_t ConvertBtMacToStr(char *strMac, uint32_t strMacLen, const uint8_t *binMac, uint32_t binMacLen) = 0; 39 virtual int32_t LnnRegisterEventHandler(LnnEventType event, LnnEventHandler handler) = 0; 40 virtual int32_t LnnGetNetIfTypeByName(const char *ifName, LnnNetIfType *type) = 0; 41 virtual bool LnnVisitNetif(VisitNetifCallback callback, void *data) = 0; 42 virtual int32_t LnnRegistPhysicalSubnet(LnnPhysicalSubnet *manager) = 0; 43 virtual void LnnNotifyPhysicalSubnetStatusChanged(const char *ifName, ProtocolType protocolType, void *status) = 0; 44 }; 45 46 class LnnBtNetworkImplInterfaceMock : public LnnBtNetworkImplInterface { 47 public: 48 LnnBtNetworkImplInterfaceMock(); 49 ~LnnBtNetworkImplInterfaceMock() override; 50 MOCK_METHOD2(LnnRequestLeaveSpecific, int32_t (const char *, ConnectionAddrType)); 51 MOCK_METHOD2(LnnRequestLeaveByAddrType, int32_t (const bool *, uint32_t)); 52 MOCK_METHOD0(SoftBusGetBtState, int (void)); 53 MOCK_METHOD1(SoftBusGetBtMacAddr, int (SoftBusBtAddr *)); 54 MOCK_METHOD4(ConvertBtMacToStr, int32_t (char *, uint32_t, const uint8_t *, uint32_t)); 55 MOCK_METHOD2(LnnRegisterEventHandler, int32_t (LnnEventType, LnnEventHandler)); 56 MOCK_METHOD2(LnnGetNetIfTypeByName, int32_t (const char *, LnnNetIfType *)); 57 MOCK_METHOD2(LnnVisitNetif, bool (VisitNetifCallback, void *)); 58 MOCK_METHOD1(LnnRegistPhysicalSubnet, int32_t (LnnPhysicalSubnet *)); 59 MOCK_METHOD3(LnnNotifyPhysicalSubnetStatusChanged, void (const char *, ProtocolType, void *)); 60 static int32_t ActionOfLnnGetNetIfTypeByNameBr(const char *ifName, LnnNetIfType *type); 61 static int32_t ActionOfLnnGetNetIfTypeByNameBle(const char *ifName, LnnNetIfType *type); 62 }; 63 } // namespace OHOS 64 #endif // LNN_BT_NETWORK_IMPL_MOCK_H