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_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_distributed_net_ledger.h" 26 #include "lnn_async_callback_utils.h" 27 #include "message_handler.h" 28 #include "softbus_adapter_bt_common.h" 29 #include "softbus_common.h" 30 #include "softbus_config_type.h" 31 32 namespace OHOS { 33 class LnnNetworkManagerInterface { 34 public: LnnNetworkManagerInterface()35 LnnNetworkManagerInterface() {}; ~LnnNetworkManagerInterface()36 virtual ~LnnNetworkManagerInterface() {}; 37 virtual int32_t RegistIPProtocolManager(void) = 0; 38 virtual int32_t LnnInitPhysicalSubnetManager(void) = 0; 39 virtual void LnnOnOhosAccountChanged(void) =0; 40 virtual void LnnStopDiscovery(void) = 0; 41 virtual int32_t LnnStartDiscovery(void) = 0; 42 virtual int SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len) = 0; 43 virtual void DiscLinkStatusChanged(LinkStatus status, ExchangeMedium medium) = 0; 44 virtual void LnnStopPublish(void) = 0; 45 virtual int32_t LnnStartPublish(void) = 0; 46 virtual void LnnUpdateOhosAccount(bool isNeedUpdateHeartbeat) = 0; 47 virtual void LnnOnOhosAccountLogout(void) = 0; 48 virtual bool LnnGetOnlineStateById(const char *id, IdCategory type) = 0; 49 virtual int32_t LnnNotifyDiscoveryDevice(const ConnectionAddr *addr, const LnnDfxDeviceInfoReport *infoReport, 50 bool isNeedConnect) = 0; 51 virtual int32_t LnnRequestLeaveByAddrType(const bool *type, uint32_t typeLen) = 0; 52 virtual int32_t LnnAsyncCallbackDelayHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback, 53 void *para, uint64_t delayMillis) = 0; 54 virtual int32_t LnnRegisterEventHandler(LnnEventType event, LnnEventHandler handler) = 0; 55 virtual void LnnNotifyOOBEStateChangeEvent(SoftBusOOBEState state) = 0; 56 virtual void LnnNotifyAccountStateChangeEvent(SoftBusAccountState state) = 0; 57 }; 58 59 class LnnNetworkManagerInterfaceMock : public LnnNetworkManagerInterface { 60 public: 61 LnnNetworkManagerInterfaceMock(); 62 ~LnnNetworkManagerInterfaceMock() override; 63 MOCK_METHOD0(RegistIPProtocolManager, int32_t (void)); 64 MOCK_METHOD0(LnnInitPhysicalSubnetManager, int32_t (void)); 65 MOCK_METHOD0(LnnOnOhosAccountChanged, void (void)); 66 MOCK_METHOD0(LnnStopDiscovery, void (void)); 67 MOCK_METHOD0(LnnStartDiscovery, int32_t (void)); 68 MOCK_METHOD1(SetCallLnnStatus, void (bool)); 69 MOCK_METHOD3(SoftbusGetConfig, int (ConfigType, unsigned char *, uint32_t)); 70 MOCK_METHOD2(DiscLinkStatusChanged, void (LinkStatus, ExchangeMedium)); 71 MOCK_METHOD0(LnnStopPublish, void (void)); 72 MOCK_METHOD0(LnnStartPublish, int32_t (void)); 73 MOCK_METHOD1(LnnUpdateOhosAccount, void (bool)); 74 MOCK_METHOD0(LnnOnOhosAccountLogout, void (void)); 75 MOCK_METHOD2(LnnGetOnlineStateById, bool(const char *, IdCategory)); 76 MOCK_METHOD3(LnnNotifyDiscoveryDevice, int32_t(const ConnectionAddr *, const LnnDfxDeviceInfoReport *, bool)); 77 MOCK_METHOD2(LnnRequestLeaveByAddrType, int32_t (const bool *, uint32_t)); 78 MOCK_METHOD4(LnnAsyncCallbackDelayHelper, int32_t (SoftBusLooper *, LnnAsyncCallbackFunc, void *, uint64_t)); 79 MOCK_METHOD2(LnnRegisterEventHandler, int32_t (LnnEventType, LnnEventHandler)); 80 MOCK_METHOD1(LnnNotifyOOBEStateChangeEvent, void (SoftBusOOBEState)); 81 MOCK_METHOD1(LnnNotifyAccountStateChangeEvent, void (SoftBusAccountState)); 82 }; 83 } // namespace OHOS 84 #endif // LNN_NETWORK_MANAGER_MOCK_H 85