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 #ifndef TRANS_COMMON_MOCK_H 17 #define TRANS_COMMON_MOCK_H 18 19 #include <gmock/gmock.h> 20 21 #include "g_enhance_sdk_func.h" 22 #include "softbus_bus_center.h" 23 #include "softbus_config_type.h" 24 #include "softbus_def.h" 25 #include "softbus_error_code.h" 26 #include "softbus_utils.h" 27 28 namespace OHOS { 29 class TransCommInterface { 30 public: TransCommInterface()31 TransCommInterface() {}; ~TransCommInterface()32 virtual ~TransCommInterface() {}; 33 34 virtual int SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len) = 0; 35 virtual ClientEnhanceFuncList *ClientEnhanceFuncListGet(void) = 0; 36 virtual int32_t WriteInt32ToBuf(uint8_t *buf, uint32_t dataLen, int32_t *offSet, int32_t data) = 0; 37 virtual int32_t WriteUint64ToBuf(uint8_t *buf, uint32_t bufLen, int32_t *offSet, uint64_t data) = 0; 38 virtual int32_t WriteStringToBuf(uint8_t *buf, uint32_t bufLen, int32_t *offSet, char *data, uint32_t dataLen) = 0; 39 virtual int32_t ServerIpcProcessInnerEvent(int32_t eventType, uint8_t *buf, uint32_t len) = 0; 40 virtual SoftBusList *CreateSoftBusList(void) = 0; 41 virtual int32_t TransServerProxyInit(void) = 0; 42 virtual int32_t ClientTransChannelInit(void) = 0; 43 virtual int32_t RegisterTimeoutCallback(int32_t timerFunId, TimerFunCallback callback) = 0; 44 virtual int32_t RegNodeDeviceStateCbInner(const char *pkgName, INodeStateCb *callback) = 0; 45 virtual int32_t SoftBusCondSignal(SoftBusCond *cond) = 0; 46 virtual int32_t SoftBusGetTime(SoftBusSysTime *sysTime) = 0; 47 virtual int32_t SoftBusCondWait(SoftBusCond *cond, SoftBusMutex *mutex, SoftBusSysTime *time) = 0; 48 }; 49 50 class TransCommInterfaceMock : public TransCommInterface { 51 public: 52 TransCommInterfaceMock(); 53 ~TransCommInterfaceMock() override; 54 55 MOCK_METHOD3(SoftbusGetConfig, int(ConfigType type, unsigned char *val, uint32_t len)); 56 MOCK_METHOD0(ClientEnhanceFuncListGet, ClientEnhanceFuncList *(void)); 57 MOCK_METHOD4(WriteInt32ToBuf, int32_t(uint8_t *buf, uint32_t dataLen, int32_t *offSet, int32_t data)); 58 MOCK_METHOD4(WriteUint64ToBuf, int32_t(uint8_t *buf, uint32_t bufLen, int32_t *offSet, uint64_t data)); 59 MOCK_METHOD5(WriteStringToBuf, int32_t( 60 uint8_t *buf, uint32_t bufLen, int32_t *offSet, char *data, uint32_t dataLen)); 61 MOCK_METHOD3(ServerIpcProcessInnerEvent, int32_t(int32_t eventType, uint8_t *buf, uint32_t len)); 62 MOCK_METHOD0(CreateSoftBusList, SoftBusList *(void)); 63 MOCK_METHOD0(TransServerProxyInit, int32_t(void)); 64 MOCK_METHOD0(ClientTransChannelInit, int32_t(void)); 65 MOCK_METHOD2(RegisterTimeoutCallback, int32_t(int32_t timerFunId, TimerFunCallback callback)); 66 MOCK_METHOD2(RegNodeDeviceStateCbInner, int32_t(const char *pkgName, INodeStateCb *callback)); 67 MOCK_METHOD1(SoftBusCondSignal, int32_t(SoftBusCond *cond)); 68 MOCK_METHOD1(SoftBusGetTime, int32_t(SoftBusSysTime *sysTime)); 69 MOCK_METHOD3(SoftBusCondWait, int32_t(SoftBusCond *cond, SoftBusMutex *mutex, SoftBusSysTime *time)); 70 71 static int ActionOfSoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len); 72 }; 73 74 } // namespace OHOS 75 #endif // TRANS_COMMON_MOCK_H 76