1 /*
2 * Copyright (c) 2025 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 "trans_common_mock.h"
17
18 using namespace testing;
19 using namespace testing::ext;
20
21 namespace OHOS {
22
23 void *g_commonInterface = nullptr;
24
TransCommInterfaceMock()25 TransCommInterfaceMock::TransCommInterfaceMock()
26 {
27 g_commonInterface = reinterpret_cast<void *>(this);
28 }
29
~TransCommInterfaceMock()30 TransCommInterfaceMock::~TransCommInterfaceMock()
31 {
32 g_commonInterface = nullptr;
33 }
34
GetCommonInterface()35 static TransCommInterface *GetCommonInterface()
36 {
37 return reinterpret_cast<TransCommInterface *>(g_commonInterface);
38 }
39
ActionOfSoftbusGetConfig(ConfigType type,unsigned char * val,uint32_t len)40 int TransCommInterfaceMock::ActionOfSoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len)
41 {
42 (void)type;
43 (void)len;
44 *val = 1;
45 return SOFTBUS_OK;
46 }
47
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51
SoftbusGetConfig(ConfigType type,unsigned char * val,uint32_t len)52 int SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len)
53 {
54 return GetCommonInterface()->SoftbusGetConfig(type, val, len);
55 }
56
ClientEnhanceFuncListGet(void)57 ClientEnhanceFuncList *ClientEnhanceFuncListGet(void)
58 {
59 return GetCommonInterface()->ClientEnhanceFuncListGet();
60 }
61
WriteInt32ToBuf(uint8_t * buf,uint32_t dataLen,int32_t * offSet,int32_t data)62 int32_t WriteInt32ToBuf(uint8_t *buf, uint32_t dataLen, int32_t *offSet, int32_t data)
63 {
64 return GetCommonInterface()->WriteInt32ToBuf(buf, dataLen, offSet, data);
65 }
66
WriteUint64ToBuf(uint8_t * buf,uint32_t bufLen,int32_t * offSet,uint64_t data)67 int32_t WriteUint64ToBuf(uint8_t *buf, uint32_t bufLen, int32_t *offSet, uint64_t data)
68 {
69 return GetCommonInterface()->WriteUint64ToBuf(buf, bufLen, offSet, data);
70 }
71
WriteStringToBuf(uint8_t * buf,uint32_t bufLen,int32_t * offSet,char * data,uint32_t dataLen)72 int32_t WriteStringToBuf(uint8_t *buf, uint32_t bufLen, int32_t *offSet, char *data, uint32_t dataLen)
73 {
74 return GetCommonInterface()->WriteStringToBuf(buf, bufLen, offSet, data, dataLen);
75 }
76
ServerIpcProcessInnerEvent(int32_t eventType,uint8_t * buf,uint32_t len)77 int32_t ServerIpcProcessInnerEvent(int32_t eventType, uint8_t *buf, uint32_t len)
78 {
79 return GetCommonInterface()->ServerIpcProcessInnerEvent(eventType, buf, len);
80 }
81
CreateSoftBusList(void)82 SoftBusList *CreateSoftBusList(void)
83 {
84 return GetCommonInterface()->CreateSoftBusList();
85 }
86
TransServerProxyInit(void)87 int32_t TransServerProxyInit(void)
88 {
89 return GetCommonInterface()->TransServerProxyInit();
90 }
91
ClientTransChannelInit(void)92 int32_t ClientTransChannelInit(void)
93 {
94 return GetCommonInterface()->ClientTransChannelInit();
95 }
96
RegisterTimeoutCallback(int32_t timerFunId,TimerFunCallback callback)97 int32_t RegisterTimeoutCallback(int32_t timerFunId, TimerFunCallback callback)
98 {
99 return GetCommonInterface()->RegisterTimeoutCallback(timerFunId, callback);
100 }
101
RegNodeDeviceStateCbInner(const char * pkgName,INodeStateCb * callback)102 int32_t RegNodeDeviceStateCbInner(const char *pkgName, INodeStateCb *callback)
103 {
104 return GetCommonInterface()->RegNodeDeviceStateCbInner(pkgName, callback);
105 }
106
SoftBusCondSignal(SoftBusCond * cond)107 int32_t SoftBusCondSignal(SoftBusCond *cond)
108 {
109 return GetCommonInterface()->SoftBusCondSignal(cond);
110 }
111
SoftBusGetTime(SoftBusSysTime * sysTime)112 int32_t SoftBusGetTime(SoftBusSysTime *sysTime)
113 {
114 return GetCommonInterface()->SoftBusGetTime(sysTime);
115 }
116
SoftBusCondWait(SoftBusCond * cond,SoftBusMutex * mutex,SoftBusSysTime * time)117 int32_t SoftBusCondWait(SoftBusCond *cond, SoftBusMutex *mutex, SoftBusSysTime *time)
118 {
119 return GetCommonInterface()->SoftBusCondWait(cond, mutex, time);
120 }
121 #ifdef __cplusplus
122 }
123 #endif
124 }
125