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_TCP_DIRECT_TLV_MOCK_H 17 #define TRANS_TCP_DIRECT_TLV_MOCK_H 18 19 #include <gmock/gmock.h> 20 21 #include "client_trans_session_manager.h" 22 #include "client_trans_tcp_direct_manager.h" 23 #include "trans_assemble_tlv.h" 24 25 namespace OHOS { 26 class TransTcpDirectInterface { 27 public: TransTcpDirectInterface()28 TransTcpDirectInterface() {}; ~TransTcpDirectInterface()29 virtual ~TransTcpDirectInterface() {}; 30 virtual int32_t TransAssembleTlvData(DataHead *pktHead, uint8_t type, uint8_t *buffer, uint8_t bufferLen, 31 int32_t *bufferSize) = 0; 32 virtual int32_t ClientGetSessionIdByChannelId(int32_t channelId, int32_t channelType, int32_t *sessionId, 33 bool isClosing) = 0; 34 virtual int32_t ClientGetSessionCallbackAdapterById(int32_t sessionId, SessionListenerAdapter *callbackAdapter, 35 bool *isServer) = 0; 36 virtual int32_t DeleteDataSeqInfoList(uint32_t dataSeq, int32_t channelId) = 0; 37 virtual int32_t ClientGetSessionNameByChannelId(int32_t channelId, int32_t channelType, char *sessionName, 38 int32_t len) = 0; 39 virtual int32_t SetIpTos(int fd, uint32_t tos) = 0; 40 virtual int32_t AddPendingPacket(int32_t channelId, int32_t seqNum, int32_t type) = 0; 41 virtual int32_t GetSupportTlvAndNeedAckById(int32_t channelId, int32_t channelType, bool *supportTlv, 42 bool *needAck) = 0; 43 virtual void ReleaseTlvValueBuffer(DataHead *pktHead) = 0; 44 virtual int32_t DataSeqInfoListAddItem(uint32_t dataSeq, int32_t channelId, int32_t socketId, 45 int32_t channelType) = 0; 46 virtual int32_t ClientTransTdcOnDataReceived(int32_t channelId, const void *data, uint32_t len, 47 SessionPktType type) = 0; 48 virtual int32_t SetMintpSocketTos(int32_t fd, uint32_t tos) = 0; 49 }; 50 51 class TransTcpDirectInterfaceMock : public TransTcpDirectInterface { 52 public: 53 TransTcpDirectInterfaceMock(); 54 ~TransTcpDirectInterfaceMock() override; 55 MOCK_METHOD5(TransAssembleTlvData, int32_t(DataHead *pktHead, uint8_t type, uint8_t *buffer, uint8_t bufferLen, 56 int32_t *bufferSize)); 57 MOCK_METHOD4(ClientGetSessionIdByChannelId, int32_t(int32_t channelId, int32_t channelType, int32_t *sessionId, 58 bool isClosing)); 59 MOCK_METHOD3(ClientGetSessionCallbackAdapterById, int32_t(int32_t sessionId, 60 SessionListenerAdapter *callbackAdapter, bool *isServer)); 61 MOCK_METHOD2(DeleteDataSeqInfoList, int32_t(uint32_t dataSeq, int32_t channelId)); 62 MOCK_METHOD4(ClientGetSessionNameByChannelId, int32_t(int32_t channelId, int32_t channelType, char *sessionName, 63 int32_t len)); 64 MOCK_METHOD2(SetIpTos, int32_t(int fd, uint32_t tos)); 65 MOCK_METHOD3(AddPendingPacket, int32_t(int32_t channelId, int32_t seqNum, int32_t type)); 66 MOCK_METHOD4(GetSupportTlvAndNeedAckById, int32_t(int32_t channelId, int32_t channelType, bool *supportTlv, 67 bool *needAck)); 68 MOCK_METHOD1(ReleaseTlvValueBuffer, void (DataHead *pktHead)); 69 MOCK_METHOD4(DataSeqInfoListAddItem, int32_t(uint32_t dataSeq, int32_t channelId, int32_t socketId, 70 int32_t channelType)); 71 MOCK_METHOD4(ClientTransTdcOnDataReceived, int32_t(int32_t channelId, const void *data, uint32_t len, 72 SessionPktType type)); 73 MOCK_METHOD2(SetMintpSocketTos, int32_t(int32_t fd, uint32_t tos)); 74 }; 75 } // namespace OHOS 76 #endif // TRANS_TCP_DIRECT_TLV_MOCK_H 77