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 #include "lnn_sync_info_mock.h"
17
18 using namespace testing;
19 using namespace testing::ext;
20
21 namespace OHOS {
22 void *g_syncInterface;
LnnSyncInfoInterfaceMock()23 LnnSyncInfoInterfaceMock::LnnSyncInfoInterfaceMock()
24 {
25 g_syncInterface = reinterpret_cast<void *>(this);
26 }
27
~LnnSyncInfoInterfaceMock()28 LnnSyncInfoInterfaceMock::~LnnSyncInfoInterfaceMock()
29 {
30 g_syncInterface = nullptr;
31 }
32
GetSyncInterface()33 static LnnSyncInfoInterface *GetSyncInterface()
34 {
35 return reinterpret_cast<LnnSyncInfoInterface *>(g_syncInterface);
36 }
37
38 extern "C" {
LnnInitSyncInfoManager(void)39 int32_t LnnInitSyncInfoManager(void)
40 {
41 return GetSyncInterface()->LnnInitSyncInfoManager();
42 }
43
LnnRegSyncInfoHandler(LnnSyncInfoType type,LnnSyncInfoMsgHandler handler)44 int32_t LnnRegSyncInfoHandler(LnnSyncInfoType type, LnnSyncInfoMsgHandler handler)
45 {
46 return GetSyncInterface()->LnnRegSyncInfoHandler(type, handler);
47 }
48
LnnUnregSyncInfoHandler(LnnSyncInfoType type,LnnSyncInfoMsgHandler handler)49 int32_t LnnUnregSyncInfoHandler(LnnSyncInfoType type, LnnSyncInfoMsgHandler handler)
50 {
51 return GetSyncInterface()->LnnUnregSyncInfoHandler(type, handler);
52 }
53
LnnSendSyncInfoMsg(LnnSyncInfoType type,const char * networkId,const uint8_t * msg,uint32_t len,LnnSyncInfoMsgComplete complete)54 int32_t LnnSendSyncInfoMsg(LnnSyncInfoType type, const char *networkId, const uint8_t *msg,
55 uint32_t len, LnnSyncInfoMsgComplete complete)
56 {
57 return GetSyncInterface()->LnnSendSyncInfoMsg(type, networkId, msg, len, complete);
58 }
59
LnnSendP2pSyncInfoMsg(const char * networkId,uint32_t netCapability)60 int32_t LnnSendP2pSyncInfoMsg(const char *networkId, uint32_t netCapability)
61 {
62 return GetSyncInterface()->LnnSendP2pSyncInfoMsg(networkId, netCapability);
63 }
64 }
65 } // namespace OHOS
66