• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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" {
LnnSendSyncInfoMsg(LnnSyncInfoType type,const char * networkId,const uint8_t * msg,uint32_t len,LnnSyncInfoMsgComplete complete)39 int32_t LnnSendSyncInfoMsg(
40     LnnSyncInfoType type, const char *networkId, const uint8_t *msg, uint32_t len, LnnSyncInfoMsgComplete complete)
41 {
42     return GetSyncInterface()->LnnSendSyncInfoMsg(type, networkId, msg, len, complete);
43 }
44 
LnnRegSyncInfoHandler(LnnSyncInfoType type,LnnSyncInfoMsgHandler handler)45 int32_t LnnRegSyncInfoHandler(LnnSyncInfoType type, LnnSyncInfoMsgHandler handler)
46 {
47     return GetSyncInterface()->LnnRegSyncInfoHandler(type, handler);
48 }
49 
LnnUnregSyncInfoHandler(LnnSyncInfoType type,LnnSyncInfoMsgHandler handler)50 int32_t LnnUnregSyncInfoHandler(LnnSyncInfoType type, LnnSyncInfoMsgHandler handler)
51 {
52     return GetSyncInterface()->LnnUnregSyncInfoHandler(type, handler);
53 }
54 
LnnSendP2pSyncInfoMsg(const char * networkId,uint32_t netCapability)55 int32_t LnnSendP2pSyncInfoMsg(const char *networkId, uint32_t netCapability)
56 {
57     return GetSyncInterface()->LnnSendP2pSyncInfoMsg(networkId, netCapability);
58 }
59 
LnnSendAsyncInfoMsg(void * param)60 void LnnSendAsyncInfoMsg(void *param)
61 {
62     return GetSyncInterface()->LnnSendAsyncInfoMsg(param);
63 }
64 
CreateSyncInfoParam(LnnSyncInfoType type,const char * networkId,const uint8_t * msg,uint32_t len,LnnSyncInfoMsgComplete complete)65 SendSyncInfoParam *CreateSyncInfoParam(
66     LnnSyncInfoType type, const char *networkId, const uint8_t *msg, uint32_t len, LnnSyncInfoMsgComplete complete)
67 {
68     return GetSyncInterface()->CreateSyncInfoParam(type, networkId, msg, len, complete);
69 }
70 }
71 } // namespace OHOS
72