!7823 fix : fix ut

Merge pull request !7823 from 薛雨晴/master
This commit is contained in:
openharmony_ci 2024-09-20 09:42:50 +00:00 committed by Gitee
commit 89bb9e80d1
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 21 additions and 55 deletions

View File

@ -1844,6 +1844,9 @@ HWTEST_F(LNNLaneMockTest, LNN_BUILD_LINK_009, TestSize.Level1)
*/
HWTEST_F(LNNLaneMockTest, LNN_BUILD_LINK_010, TestSize.Level1)
{
const char *networkId = "testnetworkid123";
const char *ipAddr = "127.0.0.1";
uint16_t port = 1022;
NiceMock<LaneDepsInterfaceMock> mock;
LinkRequest reqInfo = {};
int32_t ret;
@ -1862,6 +1865,9 @@ HWTEST_F(LNNLaneMockTest, LNN_BUILD_LINK_010, TestSize.Level1)
if (strcpy_s(reqInfo.peerBleMac, MAX_MAC_LEN, bleMac) != EOK) {
return;
}
LaneAddP2pAddress(networkId, ipAddr, port);
LaneAddP2pAddressByIp(ipAddr, port);
LaneUpdateP2pAddressByIp(ipAddr, networkId);
ON_CALL(mock, ConnBleGetConnectionByUdid).WillByDefault(Return(connection));
ON_CALL(mock, ConnBleReturnConnection).WillByDefault(Return());
EXPECT_CALL(mock, LnnConvertDLidToUdid).WillRepeatedly(Return(udid));
@ -1876,22 +1882,6 @@ HWTEST_F(LNNLaneMockTest, LNN_BUILD_LINK_010, TestSize.Level1)
SoftBusFree(connection);
}
/*
* @tc.name: LANE_ADD_P2P_ADDRESS_TEST_001
* @tc.desc: LANE ADD P2P ADDRESS TEST
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(LNNLaneMockTest, LANE_ADD_P2P_ADDRESS_TEST_001, TestSize.Level1)
{
const char *networkId = "testnetworkid123";
const char *ipAddr = "127.0.0.1";
uint16_t port = 1022;
LaneAddP2pAddress(networkId, ipAddr, port);
LaneAddP2pAddressByIp(ipAddr, port);
LaneUpdateP2pAddressByIp(ipAddr, networkId);
}
/*
* @tc.name: LNN_SELECT_EXPECT_LANES_BY_QOS_001
* @tc.desc: SelectExpectLanesByQos
@ -2944,37 +2934,6 @@ HWTEST_F(LNNLaneMockTest, LNN_LANE_SELECT_RULE_05, TestSize.Level1)
EXPECT_EQ(ret, SOFTBUS_LANE_WIFI_OFF);
}
/*
* @tc.name: LNN_LANE_01
* @tc.desc: SelectLaneRule
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(LNNLaneMockTest, LNN_LANE_01, TestSize.Level1)
{
ILaneIdStateListener listener;
RegisterLaneIdListener(nullptr);
listener.OnLaneIdEnabled = nullptr;
listener.OnLaneIdDisabled = nullptr;
RegisterLaneIdListener(&listener);
UnregisterLaneIdListener(nullptr);
}
/*
* @tc.name: LNN_LANE_02
* @tc.desc: SelectLaneRule
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(LNNLaneMockTest, LNN_LANE_02, TestSize.Level1)
{
uint32_t laneReqId = 0;
FreeLaneReqId(laneReqId);
laneReqId = 0xfffffff;
FreeLaneReqId(laneReqId);
}
/*
* @tc.name: LNN_LANE_03
* @tc.desc: SelectLaneRule
@ -2983,8 +2942,19 @@ HWTEST_F(LNNLaneMockTest, LNN_LANE_02, TestSize.Level1)
*/
HWTEST_F(LNNLaneMockTest, LNN_LANE_03, TestSize.Level1)
{
uint32_t laneReqId = 0;
LaneRequestOption request;
ILaneListener listener;
ILaneIdStateListener laneListener;
RegisterLaneIdListener(nullptr);
laneListener.OnLaneIdEnabled = nullptr;
laneListener.OnLaneIdDisabled = nullptr;
RegisterLaneIdListener(&laneListener);
UnregisterLaneIdListener(nullptr);
FreeLaneReqId(laneReqId);
laneReqId = 0xfffffff;
FreeLaneReqId(laneReqId);
request.type = LANE_TYPE_BUTT;
int32_t ret = LnnRequestLane(0, &request, &listener);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);

View File

@ -570,22 +570,18 @@ HWTEST_F(LNNDisctributedLedgerTest, IS_META_NODE_Test_001, TestSize.Level1)
EXPECT_TRUE(ret == true);
}
HWTEST_F(LNNDisctributedLedgerTest, POST_ONLINE_NODESTOCB_Test_001, TestSize.Level1)
HWTEST_F(LNNDisctributedLedgerTest, LNN_GET_NODEINFO_BYID_Test_001, TestSize.Level1)
{
INodeStateCb callBack;
IdCategory type = CATEGORY_UDID;
NodeInfo *ret = LnnGetNodeInfoById(nullptr, type);
EXPECT_TRUE(ret == nullptr);
callBack.onNodeOnline = nullptr;
(void)PostOnlineNodesToCb(&callBack);
callBack.onNodeOnline = TestFunc;
(void)PostOnlineNodesToCb(&callBack);
}
HWTEST_F(LNNDisctributedLedgerTest, LNN_GET_NODEINFO_BYID_Test_001, TestSize.Level1)
{
IdCategory type = CATEGORY_UDID;
NodeInfo *ret = LnnGetNodeInfoById(nullptr, type);
EXPECT_TRUE(ret == nullptr);
}
HWTEST_F(LNNDisctributedLedgerTest, LNN_GET_REMOTE_NODE_Test_001, TestSize.Level1)
{
int32_t ret = LnnGetRemoteNodeInfoByKey(nullptr, nullptr);