1 /* 2 * Copyright (c) 2024 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_NETWORK_MANAGER_MOCK_H 17 #define LNN_NETWORK_MANAGER_MOCK_H 18 19 #include <gmock/gmock.h> 20 #include <mutex> 21 22 #include "bus_center_event.h" 23 #include "disc_interface.h" 24 #include "form/lnn_event_form.h" 25 #include "lnn_async_callback_utils.h" 26 #include "lnn_connection_fsm.h" 27 #include "lnn_distributed_net_ledger.h" 28 #include "lnn_async_callback_utils.h" 29 #include "lnn_ohos_account.h" 30 #include "lnn_network_manager.h" 31 #include "message_handler.h" 32 #include "softbus_adapter_bt_common.h" 33 #include "softbus_common.h" 34 #include "softbus_config_type.h" 35 36 namespace OHOS { 37 class LnnNetworkManagerInterface { 38 public: LnnNetworkManagerInterface()39 LnnNetworkManagerInterface() {}; ~LnnNetworkManagerInterface()40 virtual ~LnnNetworkManagerInterface() {}; 41 virtual int32_t RegistIPProtocolManager(void) = 0; 42 virtual int32_t LnnInitPhysicalSubnetManager(void) = 0; 43 virtual void LnnOnOhosAccountChanged(void) = 0; 44 virtual void LnnStopDiscovery(void) = 0; 45 virtual int32_t LnnStartDiscovery(void) = 0; 46 virtual int32_t SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len) = 0; 47 virtual void DiscLinkStatusChanged(LinkStatus status, ExchangeMedium medium, int32_t ifnameIdx) = 0; 48 virtual void LnnStopPublish(void) = 0; 49 virtual int32_t LnnStartPublish(void) = 0; 50 virtual void LnnUpdateOhosAccount(UpdateAccountReason reason) = 0; 51 virtual void LnnOnOhosAccountLogout(void) = 0; 52 virtual bool LnnGetOnlineStateById(const char *id, IdCategory type) = 0; 53 virtual int32_t LnnNotifyDiscoveryDevice( 54 const ConnectionAddr *addr, const LnnDfxDeviceInfoReport *infoReport, bool isNeedConnect) = 0; 55 virtual int32_t LnnRequestLeaveByAddrType(const bool *type, uint32_t typeLen) = 0; 56 virtual int32_t LnnAsyncCallbackDelayHelper( 57 SoftBusLooper *looper, LnnAsyncCallbackFunc callback, void *para, uint64_t delayMillis) = 0; 58 virtual int32_t LnnRegisterEventHandler(LnnEventType event, LnnEventHandler handler) = 0; 59 virtual void LnnNotifyOOBEStateChangeEvent(SoftBusOOBEState state) = 0; 60 virtual void LnnNotifyAccountStateChangeEvent(SoftBusAccountState state) = 0; 61 virtual void DfxRecordTriggerTime(LnnTriggerReason reason, LnnEventLnnStage stage) = 0; 62 virtual void LnnDeinitPhysicalSubnetManager(void) = 0; 63 virtual void LnnUnregisterEventHandler(LnnEventType event, LnnEventHandler handler) = 0; 64 virtual int32_t LnnInitDeviceNameMonitorImpl(void) = 0; 65 virtual int32_t RegistUsbProtocolManager(void) = 0; 66 }; 67 68 class LnnNetworkManagerInterfaceMock : public LnnNetworkManagerInterface { 69 public: 70 LnnNetworkManagerInterfaceMock(); 71 ~LnnNetworkManagerInterfaceMock() override; 72 MOCK_METHOD0(RegistIPProtocolManager, int32_t(void)); 73 MOCK_METHOD0(LnnInitPhysicalSubnetManager, int32_t(void)); 74 MOCK_METHOD0(LnnOnOhosAccountChanged, void(void)); 75 MOCK_METHOD0(LnnStopDiscovery, void(void)); 76 MOCK_METHOD0(LnnStartDiscovery, int32_t(void)); 77 MOCK_METHOD3(SoftbusGetConfig, int32_t(ConfigType, unsigned char *, uint32_t)); 78 MOCK_METHOD3(DiscLinkStatusChanged, void(LinkStatus, ExchangeMedium, int32_t)); 79 MOCK_METHOD0(LnnStopPublish, void(void)); 80 MOCK_METHOD0(LnnStartPublish, int32_t(void)); 81 MOCK_METHOD1(LnnUpdateOhosAccount, void(UpdateAccountReason)); 82 MOCK_METHOD0(LnnOnOhosAccountLogout, void(void)); 83 MOCK_METHOD2(LnnGetOnlineStateById, bool(const char *, IdCategory)); 84 MOCK_METHOD3(LnnNotifyDiscoveryDevice, int32_t(const ConnectionAddr *, const LnnDfxDeviceInfoReport *, bool)); 85 MOCK_METHOD2(LnnRequestLeaveByAddrType, int32_t(const bool *, uint32_t)); 86 MOCK_METHOD4(LnnAsyncCallbackDelayHelper, int32_t(SoftBusLooper *, LnnAsyncCallbackFunc, void *, uint64_t)); 87 MOCK_METHOD2(LnnRegisterEventHandler, int32_t(LnnEventType, LnnEventHandler)); 88 MOCK_METHOD1(LnnNotifyOOBEStateChangeEvent, void(SoftBusOOBEState)); 89 MOCK_METHOD1(LnnNotifyAccountStateChangeEvent, void(SoftBusAccountState)); 90 MOCK_METHOD2(DfxRecordTriggerTime, void(LnnTriggerReason, LnnEventLnnStage)); 91 MOCK_METHOD0(LnnDeinitPhysicalSubnetManager, void(void)); 92 MOCK_METHOD2(LnnUnregisterEventHandler, void(LnnEventType, LnnEventHandler)); 93 MOCK_METHOD0(LnnInitDeviceNameMonitorImpl, int32_t(void)); 94 MOCK_METHOD0(RegistUsbProtocolManager, int32_t(void)); 95 }; 96 } // namespace OHOS 97 #endif // LNN_NETWORK_MANAGER_MOCK_H