mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2024-11-23 16:59:54 +00:00
!8194 fix:trans add ut cases
Merge pull request !8194 from gouwenbo/addutcases
This commit is contained in:
commit
9197b93492
@ -191,6 +191,14 @@ HWTEST_F(TransPendingPktTest, ProcPendingPacket002, TestSize.Level1)
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
ret = ProcPendingPacket(channelId, seqNum, type);
|
||||
EXPECT_EQ(SOFTBUS_NOT_FIND, ret);
|
||||
PendingDeinit(type);
|
||||
|
||||
ret = PendingInit(PENDING_TYPE_UDP);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
type = PENDING_TYPE_UDP;
|
||||
ret = ProcPendingPacket(channelId, seqNum, type);
|
||||
EXPECT_EQ(SOFTBUS_NOT_FIND, ret);
|
||||
PendingDeinit(type);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -251,4 +259,42 @@ HWTEST_F(TransPendingPktTest, DelPendingPacket002, TestSize.Level1)
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PendingPacketTestAll001
|
||||
* @tc.desc: PendingPacketTestAll001, use the wrong parameter.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(TransPendingPktTest, PendingPacketTestAll001, TestSize.Level1)
|
||||
{
|
||||
int32_t channelId = 1;
|
||||
int32_t type = PENDING_TYPE_UDP;
|
||||
int32_t seqNum = 0;
|
||||
|
||||
int32_t ret = PendingInit(type);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
ret = ProcPendingPacket(channelId, seqNum, type);
|
||||
EXPECT_EQ(SOFTBUS_NOT_FIND, ret);
|
||||
|
||||
ret = AddPendingPacket(channelId, seqNum, type);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
ret = AddPendingPacket(channelId, seqNum, type);
|
||||
EXPECT_EQ(SOFTBUS_TRANS_TDC_CHANNEL_ALREADY_PENDING, ret);
|
||||
|
||||
PendingPktInfo *pkgInfo = GetPendingPacket(channelId, seqNum, PENDING_TYPE_BUTT + 1);
|
||||
EXPECT_EQ(pkgInfo, nullptr);
|
||||
pkgInfo = GetPendingPacket(channelId, seqNum, type);
|
||||
EXPECT_NE(pkgInfo, nullptr);
|
||||
|
||||
ret = ProcPendingPacket(channelId, seqNum, type);
|
||||
EXPECT_EQ(SOFTBUS_TIMOUT, ret);
|
||||
|
||||
ret = SetPendingPacket(channelId, seqNum, type);
|
||||
EXPECT_EQ(SOFTBUS_TRANS_NODE_NOT_FOUND, ret);
|
||||
|
||||
ret = DelPendingPacket(channelId, type);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
ret = DelPendingPacket(channelId, type);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
}
|
||||
} // OHOS
|
||||
|
@ -105,7 +105,7 @@ HWTEST_F(TransClientProxyTest, ClientIpcOnChannelOpenedTest001, TestSize.Level0)
|
||||
ChannelInfo channel;
|
||||
char strTmp[] = "ABCDEFG";
|
||||
channel.channelId = TEST_CHANNELID;
|
||||
channel.channelType = TEST_CHANNELTYPE;
|
||||
channel.channelType = CHANNEL_TYPE_TCP_DIRECT;
|
||||
channel.fd = TEST_DATA_TYPE;
|
||||
channel.isServer = true;
|
||||
channel.isEnabled = true;
|
||||
@ -326,6 +326,20 @@ HWTEST_F(TransClientProxyTest, ClientIpcOnChannelBindTest001, TestSize.Level0)
|
||||
data->msgPid = TEST_PID;
|
||||
ret = ClientIpcOnChannelBind(data);
|
||||
EXPECT_EQ(SOFTBUS_TRANS_GET_CLIENT_PROXY_NULL, ret);
|
||||
|
||||
static const uint32_t SOFTBUS_SA_ID = 4700;
|
||||
sptr<ISystemAbilityManager> saManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
ASSERT_TRUE(saManager != nullptr);
|
||||
sptr<IRemoteObject> remoteObject = saManager->GetSystemAbility(SOFTBUS_SA_ID);
|
||||
ASSERT_TRUE(remoteObject != nullptr);
|
||||
sptr<IRemoteObject::DeathRecipient> abilityDeath = new (std::nothrow) SoftBusDeathRecipient();
|
||||
ASSERT_TRUE(abilityDeath != nullptr);
|
||||
ret = SoftbusClientInfoManager::GetInstance().SoftbusAddService(g_pkgName, remoteObject, abilityDeath, TEST_PID);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
|
||||
data->msgPkgName = g_pkgName;
|
||||
ret = ClientIpcOnChannelBind(data);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
SoftBusFree(data);
|
||||
}
|
||||
|
||||
@ -411,6 +425,19 @@ HWTEST_F(TransClientProxyTest, ClientIpcSetChannelInfoTest001, TestSize.Level0)
|
||||
transInfo->channelType = TEST_CHANNELTYPE;
|
||||
ret = ClientIpcSetChannelInfo("iShare", "HWiShare", sessionId, transInfo, pid);
|
||||
EXPECT_EQ(SOFTBUS_TRANS_PROXY_REMOTE_NULL, ret);
|
||||
|
||||
static const uint32_t SOFTBUS_SA_ID = 4700;
|
||||
sptr<ISystemAbilityManager> saManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
ASSERT_TRUE(saManager != nullptr);
|
||||
sptr<IRemoteObject> remoteObject = saManager->GetSystemAbility(SOFTBUS_SA_ID);
|
||||
ASSERT_TRUE(remoteObject != nullptr);
|
||||
sptr<IRemoteObject::DeathRecipient> abilityDeath = new (std::nothrow) SoftBusDeathRecipient();
|
||||
ASSERT_TRUE(abilityDeath != nullptr);
|
||||
ret = SoftbusClientInfoManager::GetInstance().SoftbusAddService(g_pkgName, remoteObject, abilityDeath, TEST_PID);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
|
||||
ret = ClientIpcSetChannelInfo(g_pkgName, g_sessionName, sessionId, transInfo, pid);
|
||||
EXPECT_EQ(SOFTBUS_TRANS_PROXY_SEND_REQUEST_FAILED, ret);
|
||||
SoftBusFree(transInfo);
|
||||
}
|
||||
|
||||
@ -455,6 +482,9 @@ HWTEST_F(TransClientProxyTest, ClientIpcOnTransLimitChangeTest001, TestSize.Leve
|
||||
int32_t ret = ClientIpcOnTransLimitChange(nullptr, TEST_PID, TEST_CHANNELID, tos);
|
||||
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
|
||||
|
||||
ret = ClientIpcOnTransLimitChange(g_pkgName, 1, TEST_CHANNELID, tos);
|
||||
EXPECT_NE(SOFTBUS_TRANS_GET_CLIENT_PROXY_NULL, ret);
|
||||
|
||||
ret = ClientIpcOnTransLimitChange(g_pkgName, TEST_PID, TEST_CHANNELID, tos);
|
||||
EXPECT_NE(SOFTBUS_OK, ret);
|
||||
}
|
||||
|
@ -163,8 +163,13 @@ HWTEST_F(TransLaneManagerTest, TransLaneMgrAddLane001, TestSize.Level1)
|
||||
|
||||
transInfo.channelId = 1;
|
||||
transInfo.channelType = 2;
|
||||
isQosLane = true;
|
||||
ret = TransLaneMgrAddLane(&transInfo, connInfo, laneHandle, isQosLane, myData);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
ret = TransLaneMgrAddLane(&transInfo, connInfo, laneHandle, isQosLane, myData);
|
||||
EXPECT_EQ(SOFTBUS_ALREADY_EXISTED, ret);
|
||||
ret = TransGetChannelInfoByLaneHandle(laneHandle, &transInfo.channelId, &transInfo.channelType);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
if (myData != NULL) {
|
||||
SoftBusFree(myData);
|
||||
}
|
||||
@ -181,21 +186,51 @@ HWTEST_F(TransLaneManagerTest, TransLaneMgrAddLane001, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(TransLaneManagerTest, TransLaneMgrDelLane001, TestSize.Level1)
|
||||
{
|
||||
int32_t channelId = 12;
|
||||
int32_t channelType = 22;
|
||||
uint32_t laneHandle = 1;
|
||||
uint64_t laneId = 1;
|
||||
int32_t pid = 1;
|
||||
int32_t isQosLane = false;
|
||||
int32_t channelId = 1;
|
||||
int32_t channelType = 1;
|
||||
TransInfo transInfo = { .channelId = channelId, .channelType = channelType };
|
||||
ConnectType connectType;
|
||||
AppInfoData *myData = (AppInfoData *)SoftBusCalloc(sizeof(AppInfoData));
|
||||
ASSERT_TRUE(myData != nullptr);
|
||||
int32_t ret = strcpy_s(myData->pkgName, PKG_NAME_SIZE_MAX, TEST_PKG_NAME);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
myData->pid = pid;
|
||||
LaneConnInfo *connInfo = (LaneConnInfo *)SoftBusCalloc(sizeof(LaneConnInfo));
|
||||
ASSERT_TRUE(connInfo != nullptr);
|
||||
TRANS_LOGI(TRANS_TEST, "TransLaneMgrDelLane001 start");
|
||||
TransLaneMgrDeinit();
|
||||
int32_t ret = TransLaneMgrDelLane(channelId, channelType, true);
|
||||
ret = TransLaneMgrDelLane(channelId, channelType, true);
|
||||
EXPECT_EQ(SOFTBUS_NO_INIT, ret);
|
||||
|
||||
ret = TransLaneMgrInit();
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
ret = TransLaneMgrAddLane(&transInfo, connInfo, laneHandle, isQosLane, myData);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
ret = TransGetLaneHandleByChannelId(channelId, &laneHandle);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
ret = TransGetLaneIdByChannelId(channelId, &laneId);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
ret = TransGetConnectTypeByChannelId(channelId, &connectType);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
ret = TransLaneMgrDelLane(channelId, channelType, true);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
ret = TransLaneMgrAddLane(&transInfo, connInfo, laneHandle, isQosLane, myData);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
TransLaneMgrDeathCallback(TEST_PKG_NAME, pid);
|
||||
TransLaneMgrDeinit();
|
||||
channelId = -1;
|
||||
channelType = 9999999;
|
||||
ret = TransLaneMgrDelLane(channelId, channelType, true);
|
||||
EXPECT_EQ(SOFTBUS_NO_INIT, ret);
|
||||
TRANS_LOGI(TRANS_TEST, "TransLaneMgrDelLane001 end");
|
||||
if (myData != NULL) {
|
||||
SoftBusFree(myData);
|
||||
}
|
||||
if (connInfo != NULL) {
|
||||
SoftBusFree(connInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -326,6 +361,49 @@ HWTEST_F(TransLaneManagerTest, TransSocketChannelInfoTest001, TestSize.Level1)
|
||||
EXPECT_EQ(SOFTBUS_NO_INIT, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: TransGetSocketChannelStateBySession001
|
||||
* @tc.desc: TransGetSocketChannelStateBySession001.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(TransLaneManagerTest, TransGetSocketChannelStateBySession001, TestSize.Level1)
|
||||
{
|
||||
char sessionName[SESSION_NAME_SIZE_MAX] = "testSessionName";
|
||||
int32_t sessionId = 1;
|
||||
uint32_t laneHandle = 1;
|
||||
int32_t pid = 1;
|
||||
uint64_t laneId = 1;
|
||||
CoreSessionState state;
|
||||
int32_t ret = TransGetSocketChannelStateBySession(sessionName, sessionId, &state);
|
||||
EXPECT_EQ(SOFTBUS_NO_INIT, ret);
|
||||
ret = TransGetSocketChannelLaneInfoBySession(sessionName, sessionId, &laneHandle, NULL, NULL);
|
||||
EXPECT_EQ(SOFTBUS_NO_INIT, ret);
|
||||
ret = TransGetPidFromSocketChannelInfoBySession(sessionName, sessionId, &pid);
|
||||
EXPECT_EQ(SOFTBUS_NO_INIT, ret);
|
||||
ret = TransSocketLaneMgrInit();
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
ret = TransAddSocketChannelInfo(
|
||||
sessionName, sessionId, INVALID_CHANNEL_ID, CHANNEL_TYPE_BUTT, CORE_SESSION_STATE_INIT);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
ret = TransAddSocketChannelInfo(
|
||||
sessionName, sessionId, INVALID_CHANNEL_ID, CHANNEL_TYPE_BUTT, CORE_SESSION_STATE_INIT);
|
||||
EXPECT_EQ(SOFTBUS_OK, ret);
|
||||
ret = TransGetSocketChannelStateBySession(sessionName, sessionId, NULL);
|
||||
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
|
||||
ret = TransGetPidFromSocketChannelInfoBySession(sessionName, sessionId, NULL);
|
||||
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
|
||||
ret = TransGetSocketChannelStateBySession(sessionName, sessionId + 1, &state);
|
||||
EXPECT_EQ(SOFTBUS_NOT_FIND, ret);
|
||||
ret = TransGetPidFromSocketChannelInfoBySession(sessionName, sessionId + 1, &pid);
|
||||
EXPECT_EQ(SOFTBUS_NOT_FIND, ret);
|
||||
ret = TransGetSocketChannelLaneInfoBySession(sessionName, sessionId + 1, &laneHandle, NULL, NULL);
|
||||
EXPECT_EQ(SOFTBUS_NOT_FIND, ret);
|
||||
ret = TransGetLaneIdByChannelId(0, &laneId);
|
||||
EXPECT_EQ(SOFTBUS_NOT_FIND, ret);
|
||||
TransSocketLaneMgrDeinit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CopyAppInfoFromSessionParam001
|
||||
* @tc.desc: CopyAppInfoFromSessionParam, use the wrong parameter.
|
||||
|
Loading…
Reference in New Issue
Block a user