!7197 Add UT cases

Merge pull request !7197 from Zhangzi/master
This commit is contained in:
openharmony_ci 2024-08-11 10:04:46 +00:00 committed by Gitee
commit 0888f2e680
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 668 additions and 56 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -28,6 +28,7 @@
#include "softbus_trans_def.h"
#include "session.h"
#include "softbus_adapter_mem.h"
#include "trans_client_proxy_standard.h"
using namespace std;
@ -316,4 +317,154 @@ HWTEST_F(TransClientProxyTest, ClientIpcOnChannelQosEventTest001, TestSize.Level
ret = ClientIpcOnChannelQosEvent(g_pkgName, &param);
EXPECT_EQ(SOFTBUS_OK, ret);
}
} // namespace OHOS
/**
* @tc.name: ClientIpcOnChannelBindTest001
* @tc.desc: ClientIpcOnChannelBind test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransClientProxyTest, ClientIpcOnChannelBindTest001, TestSize.Level0)
{
ChannelMsg *data = nullptr;
int32_t ret = ClientIpcOnChannelBind(data);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
data = (ChannelMsg *)SoftBusCalloc(sizeof(ChannelMsg));
ASSERT_NE(nullptr, data);
data->msgPid = TEST_PID;
ret = ClientIpcOnChannelBind(data);
EXPECT_EQ(SOFTBUS_TRANS_GET_CLIENT_PROXY_NULL, ret);
SoftBusFree(data);
}
/**
* @tc.name: ClientIpcOnChannelOpenFailedTest002
* @tc.desc: ClientIpcOnChannelOpenFailed test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransClientProxyTest, ClientIpcOnChannelOpenFailedTest002, TestSize.Level0)
{
ChannelMsg *data = nullptr;
int32_t errCode = 0;
int32_t ret = ClientIpcOnChannelOpenFailed(data, errCode);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
data = (ChannelMsg *)SoftBusCalloc(sizeof(ChannelMsg));
ASSERT_NE(nullptr, data);
data->msgPid = TEST_PID;
ret = ClientIpcOnChannelOpenFailed(data, errCode);
EXPECT_EQ(SOFTBUS_TRANS_GET_CLIENT_PROXY_NULL, ret);
SoftBusFree(data);
}
/**
* @tc.name: ClientIpcOnChannelLinkDownTest002
* @tc.desc: ClientIpcOnChannelLinkDown test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransClientProxyTest, ClientIpcOnChannelLinkDownTest002, TestSize.Level0)
{
const char *peerIp = "1234"; // test value
int32_t routeType = TEST_REMOTE_TYPE;
int32_t ret = ClientIpcOnChannelLinkDown(nullptr, nullptr, peerIp, routeType);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
const char *networkId = "1234"; // test value
ChannelMsg *data = (ChannelMsg *)SoftBusCalloc(sizeof(ChannelMsg));
ASSERT_NE(nullptr, data);
ret = ClientIpcOnChannelLinkDown(data, networkId, peerIp, routeType);
EXPECT_EQ(SOFTBUS_TRANS_GET_CLIENT_PROXY_NULL, ret);
SoftBusFree(data);
data = nullptr;
}
/**
* @tc.name: ClientIpcOnChannelClosedTest002
* @tc.desc: ClientIpcOnChannelClosed test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransClientProxyTest, ClientIpcOnChannelClosedTest002, TestSize.Level0)
{
ChannelMsg *data = nullptr;
int32_t ret = ClientIpcOnChannelClosed(data);
EXPECT_EQ(SOFTBUS_TRANS_GET_CLIENT_PROXY_NULL, ret);
data = (ChannelMsg *)SoftBusCalloc(sizeof(ChannelMsg));
ASSERT_NE(nullptr, data);
data->msgPid = TEST_PID;
ret = ClientIpcOnChannelClosed(data);
EXPECT_EQ(SOFTBUS_TRANS_GET_CLIENT_PROXY_NULL, ret);
SoftBusFree(data);
}
/**
* @tc.name: ClientIpcSetChannelInfoTest001
* @tc.desc: ClientIpcSetChannelInfo test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransClientProxyTest, ClientIpcSetChannelInfoTest001, TestSize.Level0)
{
int32_t sessionId = TEST_PID;
int32_t pid = TEST_PID;
int32_t ret = ClientIpcSetChannelInfo(nullptr, nullptr, sessionId, nullptr, pid);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
TransInfo *transInfo = (TransInfo *)SoftBusCalloc(sizeof(TransInfo));
ASSERT_NE(nullptr, transInfo);
transInfo->channelId = TEST_CHANNELID;
transInfo->channelType = TEST_CHANNELTYPE;
ret = ClientIpcSetChannelInfo("iShare", "HWiShare", sessionId, transInfo, pid);
EXPECT_EQ(SOFTBUS_TRANS_PROXY_REMOTE_NULL, ret);
SoftBusFree(transInfo);
}
/**
* @tc.name: ClientIpcOnChannelMsgReceivedTest002
* @tc.desc: ClientIpcOnChannelMsgReceived test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransClientProxyTest, ClientIpcOnChannelMsgReceivedTest002, TestSize.Level0)
{
int32_t ret = ClientIpcOnChannelMsgReceived(nullptr, nullptr);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
ChannelMsg *data = (ChannelMsg *)SoftBusCalloc(sizeof(ChannelMsg));
ASSERT_NE(nullptr, data);
data->msgChannelId = TEST_CHANNELID;
data->msgChannelType = TEST_CHANNELTYPE;
data->msgPkgName = "iShare";
data->msgPid = TEST_PID;
data->msgMessageType = TEST_CHANNELTYPE;
TransReceiveData *receiveData = (TransReceiveData *)SoftBusCalloc(sizeof(TransReceiveData));
ASSERT_NE(nullptr, receiveData);
receiveData->dataLen = TEST_LEN;
receiveData->dataType = TEST_DATA_TYPE;
ret = ClientIpcOnChannelMsgReceived(data, receiveData);
EXPECT_EQ(SOFTBUS_OK, ret);
SoftBusFree(data);
SoftBusFree(receiveData);
}
/**
* @tc.name: ClientIpcOnTransLimitChangeTest001
* @tc.desc: ClientIpcOnTransLimitChange test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransClientProxyTest, ClientIpcOnTransLimitChangeTest001, TestSize.Level0)
{
uint8_t tos = 0;
int32_t ret = ClientIpcOnTransLimitChange(nullptr, TEST_PID, TEST_CHANNELID, tos);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
ret = ClientIpcOnTransLimitChange(g_pkgName, TEST_PID, TEST_CHANNELID, tos);
EXPECT_NE(SOFTBUS_OK, ret);
}
} // namespace OHOS

View File

@ -173,6 +173,44 @@ ohos_unittest("TransUdpNegotiationExchangeTest") {
}
}
ohos_unittest("TransUdpStaticTest") {
module_out_path = module_output_path
sources = [ "trans_udp_static_test.cpp" ]
include_dirs = [
"$dsoftbus_root_path/core/authentication/interface",
"$dsoftbus_root_path/core/bus_center/interface",
"$dsoftbus_root_path/core/bus_center/lnn/lane_hub/lane_manager/include",
"$dsoftbus_root_path/core/bus_center/lnn/net_ledger/common/include",
"$dsoftbus_root_path/core/bus_center/lnn/net_ledger/distributed_ledger/include",
"$dsoftbus_root_path/core/bus_center/service/include",
"$dsoftbus_root_path/core/common/security/permission/include",
"$dsoftbus_root_path/core/connection/wifi_direct_cpp",
"$dsoftbus_root_path/core/discovery/interface",
"$dsoftbus_root_path/core/discovery/manager/include",
"$dsoftbus_root_path/core/transmission/common/include",
"$dsoftbus_root_path/core/transmission/session/include",
"$dsoftbus_root_path/core/transmission/trans_channel/common/include",
"$dsoftbus_root_path/core/transmission/trans_channel/manager/include",
"$dsoftbus_root_path/core/transmission/trans_channel/udp_negotiation/include",
"$dsoftbus_root_path/core/transmission/trans_channel/udp_negotiation/src",
"$dsoftbus_root_path/third_party/dfinder/include",
]
deps = [
"$dsoftbus_dfx_path/log:softbus_dfx_log",
"$dsoftbus_root_path/core/common:softbus_utils",
"$dsoftbus_root_path/core/frame:softbus_server",
]
if (is_standard_system) {
external_deps = [
"c_utils:utils",
"hilog:libhilog",
]
}
}
ohos_unittest("TransUdpManagerTest") {
module_out_path = module_output_path
sources = [ "trans_udp_manager_test.cpp" ]
@ -256,5 +294,6 @@ group("unittest") {
":TransUdpNegoTest",
":TransUdpNegotiationExchangeTest",
":TransUdpNegotiationTest",
":TransUdpStaticTest",
]
}

View File

@ -37,6 +37,8 @@ using namespace testing::ext;
namespace OHOS {
#define TEST_CHANNEL_ID 1000
#define TEST_LEN 64
#define TEST_AUTH_PORT (6000)
#define INVALID_CHANNEL_SEQ (22579)
#define INVALID_CHAN_ID (-1)
@ -200,7 +202,6 @@ HWTEST_F(TransUdpManagerTest, TransUdpManagerTest005, TestSize.Level1)
Channel->seq = 20;
UdpChannelInfo *newChannel = (UdpChannelInfo *)SoftBusCalloc(sizeof(UdpChannelInfo));
ASSERT_TRUE(newChannel != nullptr);
(void)memset_s(newChannel, sizeof(UdpChannelInfo), 0, sizeof(UdpChannelInfo));
newChannel->seq = 20;
ret = TransAddUdpChannel(Channel);
EXPECT_EQ(ret, SOFTBUS_OK);
@ -225,22 +226,21 @@ HWTEST_F(TransUdpManagerTest, TransUdpManagerTest006, TestSize.Level1)
int64_t seq = INVALID_CHANNEL_SEQ;
UdpChannelInfo *newChannel = (UdpChannelInfo *)SoftBusCalloc(sizeof(UdpChannelInfo));
ASSERT_TRUE(newChannel != nullptr);
(void)memset_s(newChannel, sizeof(UdpChannelInfo), 0, sizeof(UdpChannelInfo));
newChannel->seq = 20;
TransUdpChannelMgrDeinit();
int32_t ret = TransGetUdpChannelBySeq(Channel->seq, newChannel);
EXPECT_EQ(ret, SOFTBUS_NO_INIT);
EXPECT_EQ(SOFTBUS_NO_INIT, ret);
ret = TransUdpChannelMgrInit();
EXPECT_EQ(ret, SOFTBUS_OK);
EXPECT_EQ(SOFTBUS_OK, ret);
ret = TransAddUdpChannel(Channel);
EXPECT_EQ(ret, SOFTBUS_OK);
EXPECT_EQ(SOFTBUS_OK, ret);
ret = TransGetUdpChannelBySeq(seq, NULL);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
ret = TransGetUdpChannelBySeq(seq, newChannel);
EXPECT_EQ(ret, SOFTBUS_TRANS_UDP_CHANNEL_NOT_FOUND);
EXPECT_EQ(SOFTBUS_TRANS_UDP_CHANNEL_NOT_FOUND, ret);
SoftBusFree(newChannel);
TransUdpChannelMgrDeinit();
}
@ -259,7 +259,6 @@ HWTEST_F(TransUdpManagerTest, TransUdpManagerTest007, TestSize.Level1)
ASSERT_TRUE(Channel != nullptr);
UdpChannelInfo *newChannel = (UdpChannelInfo *)SoftBusCalloc(sizeof(UdpChannelInfo));
ASSERT_TRUE(newChannel != nullptr);
(void)memset_s(newChannel, sizeof(UdpChannelInfo), 0, sizeof(UdpChannelInfo));
newChannel->seq = 20;
ret = TransAddUdpChannel(Channel);
EXPECT_EQ(ret, SOFTBUS_OK);
@ -284,7 +283,6 @@ HWTEST_F(TransUdpManagerTest, TransUdpManagerTest008, TestSize.Level1)
int64_t channlId = INVALID_CHAN_ID;
UdpChannelInfo *newChannel = (UdpChannelInfo *)SoftBusCalloc(sizeof(UdpChannelInfo));
ASSERT_TRUE(newChannel != nullptr);
(void)memset_s(newChannel, sizeof(UdpChannelInfo), 0, sizeof(UdpChannelInfo));
newChannel->seq = 20;
UdpChannelInfo *Channel = GetPackTest();
ASSERT_TRUE(Channel != nullptr);
@ -320,7 +318,6 @@ HWTEST_F(TransUdpManagerTest, TransUdpManagerTest009, TestSize.Level1)
ASSERT_TRUE(Channel != nullptr);
UdpChannelInfo *newChannel = (UdpChannelInfo *)SoftBusCalloc(sizeof(UdpChannelInfo));
ASSERT_TRUE(newChannel != nullptr);
(void)memset_s(newChannel, sizeof(UdpChannelInfo), 0, sizeof(UdpChannelInfo));
newChannel->seq = 20;
ret = TransAddUdpChannel(Channel);
EXPECT_EQ(ret, SOFTBUS_OK);
@ -343,7 +340,6 @@ HWTEST_F(TransUdpManagerTest, TransUdpManagerTest010, TestSize.Level1)
uint32_t requestId = INVALID_CHANNEL_REQUETID;
UdpChannelInfo *newChannel = (UdpChannelInfo *)SoftBusCalloc(sizeof(UdpChannelInfo));
ASSERT_TRUE(newChannel != nullptr);
(void)memset_s(newChannel, sizeof(UdpChannelInfo), 0, sizeof(UdpChannelInfo));
newChannel->seq = 20;
UdpChannelInfo *Channel = GetPackTest();
ASSERT_TRUE(Channel != nullptr);
@ -435,7 +431,6 @@ HWTEST_F(TransUdpManagerTest, TransUdpManagerTest013, TestSize.Level1)
ASSERT_TRUE(Channel != nullptr);
AppInfo *appInfo = (AppInfo *)SoftBusCalloc(sizeof(AppInfo));
ASSERT_TRUE(appInfo != nullptr);
(void)memset_s(appInfo, sizeof(AppInfo), 0, sizeof(AppInfo));
appInfo->myData.channelId = 20;
ret = TransAddUdpChannel(Channel);
EXPECT_EQ(ret, SOFTBUS_OK);
@ -455,7 +450,6 @@ HWTEST_F(TransUdpManagerTest, TransUdpManagerTest014, TestSize.Level1)
int64_t seq = INVALID_CHANNEL_SEQ;
AppInfo *appInfo = (AppInfo *)SoftBusCalloc(sizeof(AppInfo));
ASSERT_TRUE(appInfo != nullptr);
(void)memset_s(appInfo, sizeof(AppInfo), 0, sizeof(AppInfo));
appInfo->myData.channelId = 20;
UdpChannelInfo *Channel = GetPackTest();
ASSERT_TRUE(Channel != nullptr);
@ -576,7 +570,6 @@ HWTEST_F(TransUdpManagerTest, TransUdpManagerTest018, TestSize.Level1)
ASSERT_TRUE(Channel != nullptr);
AppInfo *appInfo = (AppInfo *)SoftBusCalloc(sizeof(AppInfo));
ASSERT_TRUE(appInfo != nullptr);
(void)memset_s(appInfo, sizeof(AppInfo), 0, sizeof(AppInfo));
appInfo->myData.channelId = 20;
ret = TransAddUdpChannel(Channel);
EXPECT_EQ(ret, SOFTBUS_OK);
@ -602,7 +595,6 @@ HWTEST_F(TransUdpManagerTest, TransUdpManagerTest019, TestSize.Level1)
ASSERT_TRUE(Channel != nullptr);
AppInfo *appInfo = (AppInfo *)SoftBusCalloc(sizeof(AppInfo));
ASSERT_TRUE(appInfo != nullptr);
(void)memset_s(appInfo, sizeof(AppInfo), 0, sizeof(AppInfo));
appInfo->myData.channelId = 20;
ret = TransAddUdpChannel(Channel);
EXPECT_EQ(ret, SOFTBUS_OK);
@ -718,6 +710,63 @@ HWTEST_F(TransUdpManagerTest, TransUdpManagerTest024, TestSize.Level1)
TransUdpChannelMgrDeinit();
}
/**
* @tc.name: TransUdpManagerTest025
* @tc.desc: TransUdpGetLocalIpAndConnectTypeById test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransUdpManagerTest, TransUdpManagerTest025, TestSize.Level1)
{
int32_t ret = TransUdpChannelMgrInit();
EXPECT_EQ(SOFTBUS_OK, ret);
int32_t channelId = TEST_CHANNEL_ID;
uint32_t maxIpLen = TEST_LEN;
int32_t connectType = CONNECT_TYPE_MAX;
ret = TransUdpGetLocalIpAndConnectTypeById(channelId, nullptr, maxIpLen, &connectType);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
char localIp[IP_LEN] = { 0 };
ret = TransUdpGetLocalIpAndConnectTypeById(channelId, localIp, maxIpLen, &connectType);
EXPECT_EQ(SOFTBUS_NOT_FIND, ret);
UdpChannelInfo *channel = (UdpChannelInfo *)SoftBusCalloc(sizeof(UdpChannelInfo));
ASSERT_TRUE(channel != nullptr);
channel->info.myData.channelId = channelId;
ret = TransAddUdpChannel(channel);
EXPECT_EQ(SOFTBUS_OK, ret);
ret = TransUdpGetLocalIpAndConnectTypeById(channelId, localIp, maxIpLen, &connectType);
EXPECT_EQ(SOFTBUS_OK, ret);
TransDelUdpChannel(channelId);
TransUdpChannelMgrDeinit();
}
/**
* @tc.name: TransUdpManagerTest026
* @tc.desc: IsUdpRecoveryTransLimit test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransUdpManagerTest, TransUdpManagerTest026, TestSize.Level1)
{
int32_t ret = TransUdpChannelMgrInit();
EXPECT_EQ(SOFTBUS_OK, ret);
UdpChannelInfo *channel = (UdpChannelInfo *)SoftBusCalloc(sizeof(UdpChannelInfo));
ASSERT_TRUE(channel != nullptr);
bool flag = IsUdpRecoveryTransLimit();
EXPECT_EQ(true, flag);
channel->info.myData.channelId = TEST_CHANNEL_ID;
channel->info.businessType = BUSINESS_TYPE_STREAM;
ret = TransAddUdpChannel(channel);
EXPECT_EQ(SOFTBUS_OK, ret);
flag = IsUdpRecoveryTransLimit();
EXPECT_EQ(false, flag);
TransDelUdpChannel(TEST_CHANNEL_ID);
TransUdpChannelMgrDeinit();
}
/**
* @tc.name: TransUdpGetLocalIpAndConnectTypeById
* @tc.desc: Get localIp and connectType wiht channelId
@ -742,6 +791,98 @@ HWTEST_F(TransUdpManagerTest, TransUdpGetLocalIpAndConnectTypeById001, TestSize.
TransUdpChannelMgrDeinit();
}
/**
* @tc.name: TransUdpManagerTest027
* @tc.desc: UdpChannelFileTransLimit test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransUdpManagerTest, TransUdpManagerTest027, TestSize.Level1)
{
TransUdpChannelMgrInit();
ChannelInfo *channel = nullptr;
int32_t ret = UdpChannelFileTransLimit(channel, FILE_PRIORITY_BK);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
channel = (ChannelInfo *)SoftBusCalloc(sizeof(ChannelInfo));
ASSERT_TRUE(channel != nullptr);
channel->channelType = CHANNEL_TYPE_PROXY;
ret = UdpChannelFileTransLimit(channel, FILE_PRIORITY_BK);
EXPECT_EQ(SOFTBUS_OK, ret);
(void)memset_s(channel, sizeof(ChannelInfo), 0, sizeof(ChannelInfo));
channel->businessType = BUSINESS_TYPE_MESSAGE;
ret = UdpChannelFileTransLimit(channel, FILE_PRIORITY_BK);
EXPECT_EQ(SOFTBUS_OK, ret);
(void)memset_s(channel, sizeof(ChannelInfo), 0, sizeof(ChannelInfo));
ret = UdpChannelFileTransLimit(channel, FILE_PRIORITY_BK);
EXPECT_EQ(SOFTBUS_OK, ret);
TransUdpChannelMgrDeinit();
SoftBusFree(channel);
}
/**
* @tc.name: TransUdpManagerTest028
* @tc.desc: ModifyUpdChannelTos test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransUdpManagerTest, TransUdpManagerTest028, TestSize.Level1)
{
uint8_t tos = FILE_PRIORITY_BK;
int32_t ret = ModifyUdpChannelTos(tos);
EXPECT_EQ(SOFTBUS_NO_INIT, ret);
TransUdpChannelMgrInit();
UdpChannelInfo *channel = (UdpChannelInfo *)SoftBusCalloc(sizeof(UdpChannelInfo));
ASSERT_TRUE(channel != nullptr);
channel->info.myData.channelId = TEST_CHANNEL_ID;
channel->info.businessType = BUSINESS_TYPE_FILE;
channel->info.isClient = true;
channel->tos = FILE_PRIORITY_BE;
ret = TransAddUdpChannel(channel);
EXPECT_EQ(SOFTBUS_OK, ret);
ret = ModifyUdpChannelTos(tos);
EXPECT_NE(SOFTBUS_OK, ret);
TransDelUdpChannel(TEST_CHANNEL_ID);
TransUdpChannelMgrDeinit();
}
/**
* @tc.name: TransUdpManagerTest029
* @tc.desc: UdpChannelFileTransLimit test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransUdpManagerTest, TransUdpManagerTest029, TestSize.Level1)
{
int32_t ret = TransUdpGetChannelIdByAddr(nullptr);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
AppInfo *appInfo = (AppInfo *)SoftBusCalloc(sizeof(AppInfo));
ASSERT_TRUE(appInfo != nullptr);
ret = TransUdpGetChannelIdByAddr(appInfo);
EXPECT_EQ(SOFTBUS_NO_INIT, ret);
ret = TransUdpChannelMgrInit();
EXPECT_NE(SOFTBUS_OK, ret);
ret = TransUdpGetChannelIdByAddr(appInfo);
EXPECT_EQ(SOFTBUS_NOT_FIND, ret);
appInfo->peerData.channelId = TEST_CHANNEL_ID;
UdpChannelInfo *channel = (UdpChannelInfo *)SoftBusCalloc(sizeof(UdpChannelInfo));
channel->info.peerData.channelId = TEST_CHANNEL_ID;
ret = TransAddUdpChannel(channel);
EXPECT_EQ(SOFTBUS_OK, ret);
ret = TransUdpGetChannelIdByAddr(appInfo);
EXPECT_EQ(SOFTBUS_OK, ret);
TransDelUdpChannel(TEST_CHANNEL_ID);
TransUdpChannelMgrDeinit();
SoftBusFree(appInfo);
appInfo = nullptr;
}
/**
* @tc.name: TransUdpGetLocalIpAndConnectTypeById002
* @tc.desc: Get localIp and connectType with 'localIp' parameter

View File

@ -157,13 +157,19 @@ HWTEST_F(TransUdpNegotiationExchangeTest, TransUdpNegotiationExchangeTest003, Te
memset_s(appInfo, sizeof(AppInfo), 0, sizeof(AppInfo));
cJSON *msg = cJSON_CreateObject();
int32_t ret = TransPackReplyUdpInfo(NULL, appInfo);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
ret = TransUnpackReplyUdpInfo(NULL, appInfo);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
ret = TransPackReplyUdpInfo(msg, NULL);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
appInfo->udpChannelOptType = TYPE_UDP_CHANNEL_OPEN;
ret = TransPackReplyUdpInfo(msg, appInfo);
EXPECT_EQ(SOFTBUS_OK, ret);
appInfo->udpChannelOptType = TYPE_INVALID_CHANNEL;
ret = TransPackReplyUdpInfo(msg, appInfo);
EXPECT_EQ(SOFTBUS_TRANS_INVALID_CHANNEL_TYPE, ret);
ret = TransUnpackReplyUdpInfo(msg, NULL);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
cJSON_Delete(msg);
SoftBusFree(appInfo);
}

View File

@ -92,12 +92,10 @@ void TransUdpNegotiationTest::TearDownTestCase(void)
*/
HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest01, TestSize.Level1)
{
AppInfo* appInfo = (AppInfo*)SoftBusMalloc(sizeof(AppInfo));
AppInfo* appInfo = (AppInfo *)SoftBusCalloc(sizeof(AppInfo));
EXPECT_TRUE(appInfo != NULL);
memset_s(appInfo, sizeof(AppInfo), 0, sizeof(AppInfo));
ConnectOption *connOpt = (ConnectOption*)SoftBusMalloc(sizeof(ConnectOption));
ConnectOption *connOpt = (ConnectOption *)SoftBusCalloc(sizeof(ConnectOption));
EXPECT_TRUE(connOpt != NULL);
memset_s(connOpt, sizeof(ConnectOption), 0, sizeof(ConnectOption));
int32_t channelId = 0;
int32_t ret = TransOpenUdpChannel(NULL, connOpt, &channelId);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
@ -116,12 +114,10 @@ HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest01, TestSize.Level1)
*/
HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest02, TestSize.Level1)
{
AppInfo* appInfo = (AppInfo*)SoftBusMalloc(sizeof(AppInfo));
AppInfo* appInfo = (AppInfo *)SoftBusCalloc(sizeof(AppInfo));
EXPECT_TRUE(appInfo != NULL);
memset_s(appInfo, sizeof(AppInfo), 0, sizeof(AppInfo));
ConnectOption *connOpt = (ConnectOption*)SoftBusMalloc(sizeof(ConnectOption));
ConnectOption *connOpt = (ConnectOption *)SoftBusCalloc(sizeof(ConnectOption));
EXPECT_TRUE(connOpt != NULL);
memset_s(connOpt, sizeof(ConnectOption), 0, sizeof(ConnectOption));
connOpt->socketOption.port = TEST_SOCKET_PORT;
connOpt->type = CONNECT_TYPE_MAX;
int32_t channelId = 0;
@ -139,22 +135,19 @@ HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest02, TestSize.Level1)
*/
HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest03, TestSize.Level1)
{
UdpChannelInfo *newChannel = (UdpChannelInfo*)SoftBusCalloc(sizeof(UdpChannelInfo));
UdpChannelInfo *newChannel = (UdpChannelInfo *)SoftBusCalloc(sizeof(UdpChannelInfo));
EXPECT_TRUE(newChannel != NULL);
(void)memset_s(newChannel, sizeof(UdpChannelInfo), 0, sizeof(UdpChannelInfo));
newChannel->seq = 1;
newChannel->info.myData.channelId = TEST_CHANNEL_ID;
int32_t ret = TransAddUdpChannel(newChannel);
EXPECT_EQ(ret, SOFTBUS_OK);
AppInfo* appInfo = (AppInfo*)SoftBusMalloc(sizeof(AppInfo));
AppInfo* appInfo = (AppInfo *)SoftBusCalloc(sizeof(AppInfo));
EXPECT_TRUE(appInfo != NULL);
memset_s(appInfo, sizeof(AppInfo), 0, sizeof(AppInfo));
appInfo->myData.channelId = TEST_CHANNEL_ID;
appInfo->linkType = LANE_BLE;
strcpy_s(appInfo->myData.sessionName, sizeof(appInfo->myData.sessionName), g_sessionName);
ConnectOption *connOpt = (ConnectOption*)SoftBusMalloc(sizeof(ConnectOption));
ConnectOption *connOpt = (ConnectOption *)SoftBusCalloc(sizeof(ConnectOption));
EXPECT_TRUE(connOpt != NULL);
memset_s(connOpt, sizeof(ConnectOption), 0, sizeof(ConnectOption));
connOpt->type = CONNECT_TYPE_MAX;
connOpt->socketOption.port = TEST_SOCKET_PORT;
int32_t channelId = 0;
@ -174,13 +167,11 @@ HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest03, TestSize.Level1)
*/
HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest04, TestSize.Level1)
{
AppInfo* appInfo = (AppInfo*)SoftBusMalloc(sizeof(AppInfo));
AppInfo* appInfo = (AppInfo *)SoftBusCalloc(sizeof(AppInfo));
EXPECT_TRUE(appInfo != NULL);
memset_s(appInfo, sizeof(AppInfo), 0, sizeof(AppInfo));
appInfo->myData.channelId = TEST_CHANNEL_ID;
ConnectOption *connOpt = (ConnectOption*)SoftBusMalloc(sizeof(ConnectOption));
ConnectOption *connOpt = (ConnectOption *)SoftBusCalloc(sizeof(ConnectOption));
EXPECT_TRUE(connOpt != NULL);
memset_s(connOpt, sizeof(ConnectOption), 0, sizeof(ConnectOption));
connOpt->type = CONNECT_TCP;
connOpt->socketOption.port = TEST_SOCKET_PORT;
int32_t channelId = 0;
@ -200,9 +191,8 @@ HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest05, TestSize.Level1)
{
int32_t ret = TransCloseUdpChannel(TEST_CHANNEL_ID);
EXPECT_NE(ret, SOFTBUS_OK);
UdpChannelInfo *newChannel = (UdpChannelInfo*)SoftBusCalloc(sizeof(UdpChannelInfo));
UdpChannelInfo *newChannel = (UdpChannelInfo *)SoftBusCalloc(sizeof(UdpChannelInfo));
EXPECT_TRUE(newChannel != NULL);
(void)memset_s(newChannel, sizeof(UdpChannelInfo), 0, sizeof(UdpChannelInfo));
newChannel->seq = 1;
newChannel->info.myData.channelId = TEST_CHANNEL_ID;
ret = TransAddUdpChannel(newChannel);
@ -221,9 +211,8 @@ HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest05, TestSize.Level1)
*/
HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest06, TestSize.Level1)
{
AppInfo* appInfo = (AppInfo*)SoftBusMalloc(sizeof(AppInfo));
AppInfo* appInfo = (AppInfo *)SoftBusCalloc(sizeof(AppInfo));
EXPECT_TRUE(appInfo != NULL);
memset_s(appInfo, sizeof(AppInfo), 0, sizeof(AppInfo));
int res = strcpy_s(appInfo->myData.pkgName, sizeof(appInfo->myData.pkgName), g_pkgName);
EXPECT_EQ(res, EOK);
appInfo->myData.pid = INVALID_PID;
@ -241,13 +230,15 @@ HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest06, TestSize.Level1)
*/
HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest07, TestSize.Level1)
{
AppInfo* appInfo = (AppInfo*)SoftBusMalloc(sizeof(AppInfo));
AppInfo* appInfo = nullptr;
int32_t ret = NotifyUdpChannelOpenFailed(appInfo, SOFTBUS_TRANS_INVALID_SESSION_NAME);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
appInfo = (AppInfo *)SoftBusCalloc(sizeof(AppInfo));
EXPECT_TRUE(appInfo != NULL);
memset_s(appInfo, sizeof(AppInfo), 0, sizeof(AppInfo));
int res = strcpy_s(appInfo->myData.sessionName, sizeof(appInfo->myData.sessionName),
g_sessionName);
EXPECT_EQ(res, EOK);
int32_t ret = NotifyUdpChannelOpenFailed(appInfo, SOFTBUS_TRANS_INVALID_SESSION_NAME);
ret = NotifyUdpChannelOpenFailed(appInfo, SOFTBUS_TRANS_INVALID_SESSION_NAME);
EXPECT_EQ(ret, SOFTBUS_OK);
SoftBusFree(appInfo);
}
@ -260,9 +251,8 @@ HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest07, TestSize.Level1)
*/
HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest08, TestSize.Level1)
{
AppInfo* appInfo = (AppInfo*)SoftBusMalloc(sizeof(AppInfo));
AppInfo* appInfo = (AppInfo *)SoftBusCalloc(sizeof(AppInfo));
EXPECT_TRUE(appInfo != NULL);
memset_s(appInfo, sizeof(AppInfo), 0, sizeof(AppInfo));
int res = strcpy_s(appInfo->myData.sessionName, sizeof(appInfo->myData.sessionName),
g_sessionName);
EXPECT_EQ(res, EOK);
@ -281,9 +271,8 @@ HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest08, TestSize.Level1)
*/
HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest09, TestSize.Level1)
{
AppInfo* appInfo = (AppInfo*)SoftBusMalloc(sizeof(AppInfo));
AppInfo* appInfo = (AppInfo *)SoftBusCalloc(sizeof(AppInfo));
EXPECT_TRUE(appInfo != NULL);
memset_s(appInfo, sizeof(AppInfo), 0, sizeof(AppInfo));
int res = strcpy_s(appInfo->myData.sessionName, sizeof(appInfo->myData.sessionName),
g_sessionName);
EXPECT_EQ(res, EOK);
@ -300,9 +289,8 @@ HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest09, TestSize.Level1)
*/
HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest10, TestSize.Level1)
{
AppInfo* appInfo = (AppInfo*)SoftBusMalloc(sizeof(AppInfo));
AppInfo* appInfo = (AppInfo *)SoftBusCalloc(sizeof(AppInfo));
EXPECT_TRUE(appInfo != NULL);
memset_s(appInfo, sizeof(AppInfo), 0, sizeof(AppInfo));
int res = strcpy_s(appInfo->myData.sessionName, sizeof(appInfo->myData.sessionName),
g_sessionName);
EXPECT_EQ(res, EOK);
@ -320,9 +308,8 @@ HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest10, TestSize.Level1)
*/
HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest11, TestSize.Level1)
{
UdpChannelInfo *newChannel = (UdpChannelInfo*)SoftBusCalloc(sizeof(UdpChannelInfo));
UdpChannelInfo *newChannel = (UdpChannelInfo *)SoftBusCalloc(sizeof(UdpChannelInfo));
EXPECT_TRUE(newChannel != NULL);
(void)memset_s(newChannel, sizeof(UdpChannelInfo), 0, sizeof(UdpChannelInfo));
newChannel->seq = 1;
newChannel->info.myData.channelId = TEST_CHANNEL_ID;
int32_t ret = TransAddUdpChannel(newChannel);
@ -340,9 +327,8 @@ HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest11, TestSize.Level1)
*/
HWTEST_F(TransUdpNegotiationTest, TransUdpNegotiationTest12, TestSize.Level1)
{
UdpChannelInfo *newChannel = (UdpChannelInfo*)SoftBusCalloc(sizeof(UdpChannelInfo));
UdpChannelInfo *newChannel = (UdpChannelInfo *)SoftBusCalloc(sizeof(UdpChannelInfo));
EXPECT_TRUE(newChannel != NULL);
(void)memset_s(newChannel, sizeof(UdpChannelInfo), 0, sizeof(UdpChannelInfo));
newChannel->seq = 1;
newChannel->info.myData.channelId = TEST_CHANNEL_ID;
int res = strcpy_s(newChannel->info.myData.pkgName, sizeof(newChannel->info.myData.pkgName),

View File

@ -0,0 +1,289 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <securec.h>
#include "gtest/gtest.h"
#include "softbus_app_info.h"
#include "trans_channel_callback.h"
#include "trans_channel_manager.h"
#include "trans_udp_negotiation.c"
#include "trans_udp_negotiation.h"
using namespace testing::ext;
namespace OHOS {
#define TEST_RET 2
#define TEST_AUTH_ID 1
#define TEST_CHANNEL_ID 100
#define TEST_PID 10
#define TEST_SEQ 100
#define TEST_SIZE 64
#define TEST_TYPE 10
static IServerChannelCallBack g_testchannelCallBack;
class TransUdpStaticTest : public testing::Test {
public:
TransUdpStaticTest()
{}
~TransUdpStaticTest()
{}
static void SetUpTestCase(void);
static void TearDownTestCase(void);
void SetUp() override
{}
void TearDown() override
{}
};
void TransUdpStaticTest::SetUpTestCase(void) { }
void TransUdpStaticTest::TearDownTestCase(void) { }
static int32_t TransServerOnChannelClosed(
const char *pkgName, int32_t pid, int32_t channelId, int32_t channelType, int32_t messageType)
{
return SOFTBUS_OK;
}
IServerChannelCallBack *TestTransServerGetChannelCb(void)
{
g_testchannelCallBack.OnChannelClosed = TransServerOnChannelClosed;
return &g_testchannelCallBack;
}
/**
* @tc.name: TransUdpStaticTest001
* @tc.desc: NotifyUdpChannelBind test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransUdpStaticTest, TransUdpStaticTest001, TestSize.Level1)
{
AppInfo *info = nullptr;
int32_t ret = NotifyUdpChannelBind(info);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
ret = NotifyUdpChannelClosed(info, TEST_TYPE);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
IServerChannelCallBack *cb = TransServerGetChannelCb();
ret = TransUdpChannelInit(cb);
EXPECT_EQ(SOFTBUS_OK, ret);
info = (AppInfo *)SoftBusCalloc(sizeof(AppInfo));
ASSERT_NE(nullptr, info);
(void)strcpy_s(info->myData.pkgName, sizeof(info->myData.pkgName), "IShare");
info->myData.pid = TEST_PID;
info->myData.channelId = TEST_CHANNEL_ID;
ret = NotifyUdpChannelBind(info);
EXPECT_EQ(SOFTBUS_TRANS_PROXY_REMOTE_NULL, ret);
SoftBusFree(info);
TransUdpChannelDeinit();
}
/**
* @tc.name: TransUdpStaticTest002
* @tc.desc: ProcessUdpChannelState test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransUdpStaticTest, TransUdpStaticTest002, TestSize.Level1)
{
IServerChannelCallBack *cb = TestTransServerGetChannelCb();
int32_t ret = TransUdpChannelInit(cb);
EXPECT_EQ(SOFTBUS_OK, ret);
AppInfo *appInfo = (AppInfo *)SoftBusCalloc(sizeof(AppInfo));
ASSERT_NE(nullptr, appInfo);
appInfo->streamType = COMMON_AUDIO_STREAM;
appInfo->myData.pid = TEST_PID;
appInfo->udpChannelOptType = TYPE_UDP_CHANNEL_CLOSE;
ret = ProcessUdpChannelState(appInfo, true);
EXPECT_EQ(SOFTBUS_OK, ret);
TransUdpChannelDeinit();
}
/**
* @tc.name: TransUdpStaticTest003
* @tc.desc: CloseUdpChannel test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransUdpStaticTest, TransUdpStaticTest003, TestSize.Level1)
{
IServerChannelCallBack *cb = TestTransServerGetChannelCb();
int32_t ret = TransUdpChannelInit(cb);
EXPECT_EQ(SOFTBUS_OK, ret);
AppInfo *appInfo = (AppInfo *)SoftBusCalloc(sizeof(AppInfo));
ASSERT_NE(nullptr, appInfo);
appInfo->myData.channelId = TEST_CHANNEL_ID;
ret = CloseUdpChannel(appInfo, false);
EXPECT_EQ(SOFTBUS_OK, ret);
SoftBusFree(appInfo);
TransUdpChannelDeinit();
}
/**
* @tc.name: TransUdpStaticTest004
* @tc.desc: TransSetUdpConnectTypeByAuthType test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransUdpStaticTest, TransUdpStaticTest004, TestSize.Level1)
{
int32_t connectType = 0;
AuthHandle authHandle;
authHandle.type = AUTH_LINK_TYPE_P2P;
TransSetUdpConnectTypeByAuthType(&connectType, authHandle);
EXPECT_EQ(CONNECT_P2P, connectType);
authHandle.type = AUTH_LINK_TYPE_ENHANCED_P2P;
TransSetUdpConnectTypeByAuthType(&connectType, authHandle);
EXPECT_EQ(CONNECT_HML, connectType);
authHandle.type = AUTH_LINK_TYPE_MAX;
TransSetUdpConnectTypeByAuthType(&connectType, authHandle);
EXPECT_EQ(CONNECT_HML, connectType);
}
/**
* @tc.name: TransUdpStaticTest005
* @tc.desc: CheckAuthConnStatus test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransUdpStaticTest, TransUdpStaticTest005, TestSize.Level1)
{
TransUdpChannelMgrInit();
uint32_t requestId = 0;
int32_t ret = CheckAuthConnStatus(requestId);
EXPECT_EQ(SOFTBUS_TRANS_UDP_GET_CHANNEL_FAILED, ret);
UdpChannelInfo *channel = (UdpChannelInfo *)SoftBusCalloc(sizeof(UdpChannelInfo));
ASSERT_NE(nullptr, channel);
channel->seq = TEST_SEQ;
ret = TransAddUdpChannel(channel);
EXPECT_EQ(SOFTBUS_OK, ret);
ret = CheckAuthConnStatus(requestId);
EXPECT_EQ(SOFTBUS_OK, ret);
ret = TransDelUdpChannel(channel->info.myData.channelId);
EXPECT_EQ(SOFTBUS_OK, ret);
TransUdpChannelMgrDeinit();
}
/**
* @tc.name: TransUdpStaticTest006
* @tc.desc: UpdOpenAuthConn test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransUdpStaticTest, TransUdpStaticTest006, TestSize.Level1)
{
const char *peerUdid = "1234"; // test value
uint32_t requestId = TEST_SEQ;
bool isMeta = true;
int32_t linkType = LANE_P2P_REUSE;
int32_t ret = UdpOpenAuthConn(peerUdid, requestId, isMeta, linkType);
EXPECT_NE(SOFTBUS_OK, ret);
}
/**
* @tc.name: TransUdpStaticTest007
* @tc.desc: ReportUdpRequestHandShakeReplyEvent test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransUdpStaticTest, TransUdpStaticTest007, TestSize.Level1)
{
AppInfo info;
(void)memset_s(&info, sizeof(AppInfo), 0, sizeof(AppInfo));
info.udpChannelOptType = TYPE_UDP_CHANNEL_OPEN;
TransEventExtra extra;
(void)memset_s(&extra, sizeof(TransEventExtra), 0, sizeof(TransEventExtra));
extra.socketName = "iShare";
int32_t result = EVENT_STAGE_RESULT_OK;
int32_t errCode = SOFTBUS_OK;
ReportUdpRequestHandShakeReplyEvent(&info, &extra, result, errCode);
EXPECT_EQ(result, extra.result);
EXPECT_EQ(errCode, extra.errcode);
}
/**
* @tc.name: TransUdpStaticTest008
* @tc.desc: ReportUdpRequestHandShakeStartEvent test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransUdpStaticTest, TransUdpStaticTest008, TestSize.Level1)
{
AppInfo *info = (AppInfo *)SoftBusCalloc(sizeof(AppInfo));
ASSERT_NE(nullptr, info);
info->peerData.channelId = TEST_CHANNEL_ID;
info->udpChannelOptType = TYPE_UDP_CHANNEL_OPEN;
NodeInfo nodeInfo;
(void)memset_s(&nodeInfo, sizeof(NodeInfo), 0, sizeof(NodeInfo));
TransEventExtra extra;
(void)memset_s(&extra, sizeof(TransEventExtra), 0, sizeof(TransEventExtra));
int64_t authId = TEST_AUTH_ID;
ReportUdpRequestHandShakeStartEvent(info, &nodeInfo, &extra, authId);
EXPECT_EQ(extra.peerChannelId, info->peerData.channelId);
EXPECT_EQ(extra.result, EVENT_STAGE_RESULT_OK);
info->udpChannelOptType = TYPE_UDP_CHANNEL_CLOSE;
(void)memset_s(&extra, sizeof(TransEventExtra), 0, sizeof(TransEventExtra));
ReportUdpRequestHandShakeStartEvent(info, &nodeInfo, &extra, authId);
EXPECT_NE(extra.result, EVENT_STAGE_RESULT_OK);
SoftBusFree(info);
info = nullptr;
}
/**
* @tc.name: TransUdpStaticTest009
* @tc.desc: CopyAppInfoFastTransData test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransUdpStaticTest, TransUdpStaticTest009, TestSize.Level1)
{
AppInfo appInfo;
(void)memset_s(&appInfo, sizeof(appInfo), 0, sizeof(appInfo));
appInfo.fastTransDataSize = TEST_SIZE;
UdpChannelInfo *newChannel = (UdpChannelInfo *)SoftBusCalloc(sizeof(UdpChannelInfo));
ASSERT_NE(nullptr, newChannel);
int32_t ret = CopyAppInfoFastTransData(newChannel, &appInfo);
EXPECT_EQ(SOFTBUS_OK, ret);
SoftBusFree(newChannel);
newChannel = nullptr;
}
/**
* @tc.name: TransUdpStaticTest010
* @tc.desc: CopyAppInfoFastTransData test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransUdpStaticTest, TransUdpStaticTest010, TestSize.Level1)
{
g_seq = INT64_MAX;
GenerateSeq(true);
EXPECT_EQ(TEST_RET, g_seq);
}
}