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_CLIENT_PROXY_MANAGER_D2D_MOCK_H 17 #define TRANS_CLIENT_PROXY_MANAGER_D2D_MOCK_H 18 19 #include <gmock/gmock.h> 20 21 #include "softbus_def.h" 22 #include "softbus_utils.h" 23 #include "client_trans_session_manager.h" 24 #include "trans_proxy_process_data.h" 25 #include "client_trans_proxy_manager.h" 26 #include "softbus_def.h" 27 #include "client_trans_session_manager_struct.h" 28 29 namespace OHOS { 30 class TransClientProxyManagerD2DInterface { 31 public: TransClientProxyManagerD2DInterface()32 TransClientProxyManagerD2DInterface() {}; ~TransClientProxyManagerD2DInterface()33 virtual ~TransClientProxyManagerD2DInterface() {}; 34 35 virtual int32_t ClientGetChannelBusinessTypeByChannelId(int32_t channelId, int32_t *businessType) = 0; 36 virtual int32_t TransProxyPackD2DBytes(ProxyDataInfo *dataInfo, const char *sessionKey, 37 const char *sessionIv, SessionPktType flag) = 0; 38 virtual uint8_t *TransProxyPackD2DData( 39 ProxyDataInfo *dataInfo, uint32_t sliceNum, SessionPktType pktType, uint32_t cnt, uint32_t *dataLen) = 0; 40 virtual int32_t ServerIpcSendMessage( 41 int32_t channelId, int32_t channelType, const void *data, uint32_t len, int32_t msgType) = 0; 42 virtual int32_t TransProxyProcessD2DData( 43 ProxyDataInfo *dataInfo, const PacketD2DHead *dataHead, const char *data, int32_t businessType) = 0; 44 virtual int32_t TransProxyDecryptD2DData(int32_t businessType, ProxyDataInfo *dataInfo, const char *sessionKey, 45 const unsigned char *sessionCommonIv) = 0; 46 virtual int32_t TransProxySessionDataLenCheck(uint32_t dataLen, SessionPktType type); 47 virtual int32_t ClientGetSessionIdByChannelId(int32_t channelId, int32_t channelType, 48 int32_t *sessionId, bool isClosing) = 0; 49 virtual int32_t ClientGetSessionCallbackAdapterById(int32_t sessionId, SessionListenerAdapter *callbackAdapter, 50 bool *isServer) = 0; 51 virtual int32_t DeleteDataSeqInfoList(uint32_t dataSeq, int32_t channelId) = 0; 52 virtual int32_t GetSupportTlvAndNeedAckById(int32_t channelId, int32_t channelType, 53 bool *supportTlv, bool *needAck) = 0; 54 virtual int32_t DataSeqInfoListAddItem(uint32_t dataSeq, int32_t channelId, int32_t socketId, 55 int32_t channelType) = 0; 56 }; 57 58 class TransClientProxyD2DInterfaceMock : public TransClientProxyManagerD2DInterface { 59 public: 60 TransClientProxyD2DInterfaceMock(); 61 ~TransClientProxyD2DInterfaceMock() override; 62 MOCK_METHOD2(ClientGetChannelBusinessTypeByChannelId, int32_t(int32_t channelId, int32_t *businessType)); 63 MOCK_METHOD4(TransProxyPackD2DBytes, int32_t(ProxyDataInfo *dataInfo, const char *sessionKey, 64 const char *sessionIv, SessionPktType flag)); 65 MOCK_METHOD5(TransProxyPackD2DData, uint8_t *(ProxyDataInfo *dataInfo, uint32_t sliceNum, 66 SessionPktType pktType, uint32_t cnt, uint32_t *dataLen)); 67 MOCK_METHOD5(ServerIpcSendMessage, int32_t(int32_t channelId, int32_t channelType, const void *data, 68 uint32_t len, int32_t msgType)); 69 MOCK_METHOD4(TransProxyProcessD2DData, int32_t(ProxyDataInfo *dataInfo, const PacketD2DHead *dataHead, 70 const char *data, int32_t businessType)); 71 MOCK_METHOD4(TransProxyDecryptD2DData, int32_t(int32_t businessType, ProxyDataInfo *dataInfo, 72 const char *sessionKey, const unsigned char *sessionCommonIv)); 73 MOCK_METHOD2(TransProxySessionDataLenCheck, int32_t(uint32_t dataLen, SessionPktType type)); 74 MOCK_METHOD4(ClientGetSessionIdByChannelId, int32_t (int32_t channelId, int32_t channelType, 75 int32_t *sessionId, bool isClosing)); 76 MOCK_METHOD3(ClientGetSessionCallbackAdapterById, int32_t(int32_t sessionId, 77 SessionListenerAdapter *callbackAdapter, bool *isServer)); 78 MOCK_METHOD2(DeleteDataSeqInfoList, int32_t(uint32_t dataSeq, int32_t channelId)); 79 MOCK_METHOD4(GetSupportTlvAndNeedAckById, int32_t (int32_t channelId, int32_t channelType, 80 bool *supportTlv, bool *needAck)); 81 MOCK_METHOD4(DataSeqInfoListAddItem, int32_t(uint32_t dataSeq, int32_t channelId, int32_t socketId, 82 int32_t channelType)); 83 }; 84 } // namespace OHOS 85 #endif // TRANS_CLIENT_PROXY_FILE_MANAGER_MOCK_H 86