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