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 CLIENT_TRANS_PROXY_MANAGER_MOCK_H 17 #define CLIENT_TRANS_PROXY_MANAGER_MOCK_H 18 19 #include <gmock/gmock.h> 20 #include "client_trans_pending.h" 21 #include "client_trans_proxy_manager.h" 22 #include "client_trans_proxy_file_manager.h" 23 #include "client_trans_session_manager.h" 24 #include "client_trans_socket_manager.h" 25 #include "trans_proxy_process_data.h" 26 #include "trans_server_proxy.h" 27 28 namespace OHOS { 29 class ClientTransProxyManagerInterface { 30 public: ClientTransProxyManagerInterface()31 ClientTransProxyManagerInterface() {}; ~ClientTransProxyManagerInterface()32 virtual ~ClientTransProxyManagerInterface() {}; 33 virtual int32_t ClinetTransProxyFileManagerInit(void) = 0; 34 virtual SoftBusList *CreateSoftBusList(void) = 0; 35 virtual int32_t PendingInit(int32_t type) = 0; 36 virtual uint32_t SoftBusHtoLl(uint32_t value) = 0; 37 virtual uint32_t SoftBusHtoNl(uint32_t value) = 0; 38 virtual uint32_t SoftBusNtoHl(uint32_t netlong) = 0; 39 virtual int32_t ClientGetSessionIdByChannelId( 40 int32_t channelId, int32_t channelType, int32_t *sessionId, bool isClosing) = 0; 41 virtual int32_t ClientGetSessionCallbackAdapterById( 42 int32_t sessionId, SessionListenerAdapter *callbackAdapter, bool *isServer) = 0; 43 virtual int32_t DeleteDataSeqInfoList(uint32_t dataSeq, int32_t channelId) = 0; 44 virtual int32_t GetSupportTlvAndNeedAckById( 45 int32_t channelId, int32_t channelType, bool *supportTlv, bool *needAck) = 0; 46 virtual int32_t ServerIpcSendMessage( 47 int32_t channelId, int32_t channelType, const void *data, uint32_t len, int32_t msgType) = 0; 48 virtual int32_t TransProxySessionDataLenCheck(uint32_t dataLen, SessionPktType type) = 0; 49 virtual int32_t TransProxyPackTlvBytes(ProxyDataInfo *dataInfo, const char *sessionKey, 50 SessionPktType flag, int32_t seq, DataHeadTlvPacketHead *info) = 0; 51 virtual uint8_t *TransProxyPackData( 52 ProxyDataInfo *dataInfo, uint32_t sliceNum, SessionPktType pktType, uint32_t cnt, uint32_t *dataLen) = 0; 53 virtual int32_t ProcPendingPacket(int32_t channelId, int32_t seqNum, int32_t type) = 0; 54 virtual int32_t AddPendingPacket(int32_t channelId, int32_t seqNum, int32_t type) = 0; 55 virtual int32_t TransProxyDecryptPacketData(int32_t seq, ProxyDataInfo *dataInfo, const char *sessionKey) = 0; 56 virtual int32_t DataSeqInfoListAddItem(uint32_t dataSeq, int32_t channelId, 57 int32_t socketId, int32_t channelType); 58 virtual int32_t ClientGetChannelBusinessTypeByChannelId(int32_t channelId, int32_t *businessType) = 0; 59 }; 60 61 class ClientTransProxyManagerInterfaceMock : public ClientTransProxyManagerInterface { 62 public: 63 ClientTransProxyManagerInterfaceMock(); 64 ~ClientTransProxyManagerInterfaceMock() override; 65 MOCK_METHOD0(ClinetTransProxyFileManagerInit, int32_t (void)); 66 MOCK_METHOD0(CreateSoftBusList, SoftBusList* (void)); 67 MOCK_METHOD1(PendingInit, int32_t (int32_t type)); 68 MOCK_METHOD1(SoftBusHtoLl, uint32_t (uint32_t value)); 69 MOCK_METHOD1(SoftBusHtoNl, uint32_t (uint32_t value)); 70 MOCK_METHOD1(SoftBusNtoHl, uint32_t (uint32_t netlong)); 71 MOCK_METHOD4(ClientGetSessionIdByChannelId, int32_t ( 72 int32_t channelId, int32_t channelType, int32_t *sessionId, bool isClosing)); 73 MOCK_METHOD3(ClientGetSessionCallbackAdapterById, int32_t ( 74 int32_t sessionId, SessionListenerAdapter *callbackAdapter, bool *isServer)); 75 MOCK_METHOD2(DeleteDataSeqInfoList, int32_t (uint32_t dataSeq, int32_t channelId)); 76 MOCK_METHOD4(GetSupportTlvAndNeedAckById, int32_t ( 77 int32_t channelId, int32_t channelType, bool *supportTlv, bool *needAck)); 78 MOCK_METHOD5(ServerIpcSendMessage, int32_t ( 79 int32_t channelId, int32_t channelType, const void *data, uint32_t len, int32_t msgType)); 80 MOCK_METHOD2(TransProxySessionDataLenCheck, int32_t (uint32_t dataLen, SessionPktType type)); 81 MOCK_METHOD5(TransProxyPackTlvBytes, int32_t (ProxyDataInfo *dataInfo, const char *sessionKey, 82 SessionPktType flag, int32_t seq, DataHeadTlvPacketHead *info)); 83 MOCK_METHOD5(TransProxyPackData, uint8_t* ( 84 ProxyDataInfo *dataInfo, uint32_t sliceNum, SessionPktType pktType, uint32_t cnt, uint32_t *dataLen)); 85 MOCK_METHOD3(ProcPendingPacket, int32_t (int32_t channelId, int32_t seqNum, int32_t type)); 86 MOCK_METHOD3(AddPendingPacket, int32_t (int32_t channelId, int32_t seqNum, int32_t type)); 87 MOCK_METHOD3(TransProxyDecryptPacketData, int32_t (int32_t seq, ProxyDataInfo *dataInfo, const char *sessionKey)); 88 MOCK_METHOD4(DataSeqInfoListAddItem, int32_t (uint32_t dataSeq, int32_t channelId, 89 int32_t socketId, int32_t channelType)); 90 MOCK_METHOD2(ClientGetChannelBusinessTypeByChannelId, int32_t(int32_t channelId, int32_t *businessType)); 91 }; 92 } 93 #endif