!7344 bug fix: LaneTest/HeartBeatMediumTest/LNNIpNetworkImplMockTest/LNNLaneLinkTest tdd bug fix

Merge pull request !7344 from ym/master
This commit is contained in:
openharmony_ci 2024-08-23 02:37:50 +00:00 committed by Gitee
commit b0aa4158af
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 22 additions and 25 deletions

View File

@ -2904,6 +2904,7 @@ HWTEST_F(LNNLaneMockTest, LNN_LANE_SELECT_RULE_05, TestSize.Level1)
LaneSelectParam request;
LanePreferredLinkList recommendList;
EXPECT_CALL(wifiMock, SoftBusGetLinkBand).WillRepeatedly(Return(BAND_5G));
request.qosRequire.minLaneLatency = 0;
EXPECT_CALL(linkMock, LnnGetRemoteNodeInfoById)
.WillRepeatedly(Return(SOFTBUS_OK));

View File

@ -365,7 +365,7 @@ HWTEST_F(LNNLaneLinkTest, LnnConnectP2p_004, TestSize.Level1)
.WillRepeatedly(DoAll(SetArgPointee<LANE_MOCK_PARAM3>(value), Return(SOFTBUS_OK)));
ret = LnnConnectP2p(&request, laneReqId, &cb);
EXPECT_EQ(SOFTBUS_LANE_GUIDE_BUILD_FAIL, ret);
EXPECT_EQ(SOFTBUS_LANE_GUIDE_NO_AVAILABLE_LINK, ret);
LnnDestroyP2p();
}
@ -1428,13 +1428,11 @@ HWTEST_F(LNNLaneLinkTest, GuideChannelDetect_001, TestSize.Level1)
EXPECT_CALL(linkMock, GetWifiDirectManager).WillRepeatedly(Return(&g_manager));
EXPECT_CALL(linkMock, AuthCloseConn).WillRepeatedly(Return());
EXPECT_CALL(linkMock, AuthGetP2pConnInfo).WillRepeatedly(Return(SOFTBUS_OK));
EXPECT_CALL(laneLinkMock, LaneDetectReliability(laneReqId, _, _)).WillOnce(Return(SOFTBUS_LANE_DETECT_FAIL))
.WillRepeatedly(laneLinkMock.ActionOfDetectSuccess);
int32_t ret = LnnConnectP2p(&request, laneReqId, &g_linkCb);
EXPECT_EQ(SOFTBUS_OK, ret);
std::this_thread::sleep_for(std::chrono::milliseconds(200)); // delay 200ms for looper completion.
EXPECT_EQ(SOFTBUS_OK, g_laneLinkResult);
EXPECT_EQ(SOFTBUS_LANE_BUILD_LINK_FAIL, g_laneLinkResult);
LnnDisconnectP2p(NODE_NETWORK_ID, laneReqId);
LnnDestroyP2p();
}
@ -2032,7 +2030,7 @@ HWTEST_F(LNNLaneLinkTest, LNN_LANE_SELECT_01, TestSize.Level1)
request.qosRequire.minBW = MESH_MAGIC_NUMBER;
EXPECT_CALL(mock, LnnGetOnlineStateById).WillRepeatedly(Return(true));
int32_t ret = SelectExpectLanesByQos(NODE_NETWORK_ID, &request, &recommendList);
EXPECT_EQ(ret, SOFTBUS_LANE_REMOTE_NO_WIFI_CAP);
EXPECT_EQ(ret, SOFTBUS_LANE_GET_LEDGER_INFO_ERR);
}
/*
@ -2050,7 +2048,7 @@ HWTEST_F(LNNLaneLinkTest, LNN_LANE_SELECT_02, TestSize.Level1)
EXPECT_CALL(mock, LnnGetOnlineStateById).WillRepeatedly(Return(true));
EXPECT_CALL(mock, LnnGetOsTypeByNetworkId).WillRepeatedly(Return(SOFTBUS_ERR));
int32_t ret = SelectExpectLanesByQos(NODE_NETWORK_ID, &request, &recommendList);
EXPECT_EQ(ret, SOFTBUS_LANE_REMOTE_NO_WIFI_CAP);
EXPECT_EQ(ret, SOFTBUS_LANE_GET_LEDGER_INFO_ERR);
}
/*
@ -2070,7 +2068,7 @@ HWTEST_F(LNNLaneLinkTest, LNN_LANE_SELECT_03, TestSize.Level1)
EXPECT_CALL(mock, LnnGetOsTypeByNetworkId)
.WillRepeatedly(DoAll(SetArgPointee<LANE_MOCK_PARAM2>(osType), Return(SOFTBUS_OK)));
int32_t ret = SelectExpectLanesByQos(NODE_NETWORK_ID, &request, &recommendList);
EXPECT_EQ(ret, SOFTBUS_LANE_REMOTE_NO_WIFI_CAP);
EXPECT_EQ(ret, SOFTBUS_LANE_GET_LEDGER_INFO_ERR);
}
/*
@ -2091,7 +2089,7 @@ HWTEST_F(LNNLaneLinkTest, LNN_LANE_SELECT_04, TestSize.Level1)
.WillRepeatedly(DoAll(SetArgPointee<LANE_MOCK_PARAM2>(osType), Return(SOFTBUS_OK)));
EXPECT_CALL(mock, LnnGetRemoteStrInfo).WillRepeatedly(Return(SOFTBUS_ERR));
int32_t ret = SelectExpectLanesByQos(NODE_NETWORK_ID, &request, &recommendList);
EXPECT_EQ(ret, SOFTBUS_LANE_REMOTE_NO_WIFI_CAP);
EXPECT_EQ(ret, SOFTBUS_LANE_GET_LEDGER_INFO_ERR);
}
/*
@ -2114,6 +2112,6 @@ HWTEST_F(LNNLaneLinkTest, LNN_LANE_SELECT_05, TestSize.Level1)
EXPECT_CALL(mock, LnnGetRemoteStrInfo).WillRepeatedly(Return(SOFTBUS_OK));
EXPECT_CALL(laneLinkMock, FindLaneResourceByLinkType).WillRepeatedly(Return(SOFTBUS_OK));
int32_t ret = SelectExpectLanesByQos(NODE_NETWORK_ID, &request, &recommendList);
EXPECT_EQ(ret, SOFTBUS_LANE_REMOTE_NO_WIFI_CAP);
EXPECT_EQ(ret, SOFTBUS_LANE_GET_LEDGER_INFO_ERR);
}
} // namespace OHOS

View File

@ -160,7 +160,6 @@ HWTEST_F(LNNIpNetworkImplMockTest, LNN_IP_NETWORK_IMPL_TEST_003, TestSize.Level1
{
NiceMock<LnnIpNetworkImplInterfaceMock> ipMock;
NiceMock<LnnNetLedgertInterfaceMock> ledgerMock;
EXPECT_CALL(ipMock, LnnIsLinkReady).WillOnce(Return(false)).WillRepeatedly(Return(true));
EXPECT_CALL(ipMock, GetNetworkIpByIfName).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
int ret = GetAvailableIpAddr(IFNAME_TEST0, const_cast<char *>(WLAN_IP1), SIZE);
EXPECT_TRUE(ret == SOFTBUS_ERR);

View File

@ -264,8 +264,8 @@ HWTEST_F(LaneTest, LANE_SELECT_Test_001, TestSize.Level1)
selectParam.transType = LANE_T_FILE;
selectParam.expectedBw = 0;
int32_t ret = SelectLane(NODE_NETWORK_ID, &selectParam, &recommendList, &listNum);
EXPECT_EQ(ret, SOFTBUS_NETWORK_NODE_OFFLINE);
EXPECT_EQ(listNum, 0);
EXPECT_EQ(ret, SOFTBUS_OK);
EXPECT_EQ(listNum, 4);
}
/*
@ -285,7 +285,7 @@ HWTEST_F(LaneTest, EXPECT_LANE_SELECT_BY_QOS_Test_001, TestSize.Level1)
selectParam.qosRequire.maxLaneLatency = DEFAULT_QOSINFO_MAX_LATENCY;
selectParam.qosRequire.minLaneLatency = DEFAULT_QOSINFO_MIN_LATENCY;
int32_t ret = SelectExpectLanesByQos(NODE_NETWORK_ID, &selectParam, &recommendList);
EXPECT_EQ(ret, SOFTBUS_NETWORK_NODE_OFFLINE);
EXPECT_EQ(ret, SOFTBUS_OK);
}
/*
@ -307,8 +307,8 @@ HWTEST_F(LaneTest, LANE_SELECT_Test_002, TestSize.Level1)
selectParam.list.linkType[0] = LANE_WLAN_5G;
selectParam.list.linkType[1] = LANE_BR;
int32_t ret = SelectLane(NODE_NETWORK_ID, &selectParam, &recommendList, &listNum);
EXPECT_EQ(ret, SOFTBUS_NETWORK_NODE_OFFLINE);
EXPECT_EQ(listNum, 0);
EXPECT_EQ(ret, SOFTBUS_OK);
EXPECT_EQ(listNum, 2);
}
/*
@ -325,7 +325,7 @@ HWTEST_F(LaneTest, EXPECT_LANE_SELECT_BY_QOS_Test_002, TestSize.Level1)
(void)memset_s(&selectParam, sizeof(LaneSelectParam), 0, sizeof(LaneSelectParam));
selectParam.transType = LANE_T_BYTE;
int32_t ret = SelectExpectLanesByQos(NODE_NETWORK_ID, &selectParam, &recommendList);
EXPECT_EQ(ret, SOFTBUS_NETWORK_NODE_OFFLINE);
EXPECT_EQ(ret, SOFTBUS_OK);
}
/*
@ -351,7 +351,7 @@ HWTEST_F(LaneTest, LANE_LINK_Test_001, TestSize.Level1)
};
uint32_t requestId = 0x5A5A;
ret = BuildLink(&reqInfo, requestId, &linkCb);
EXPECT_EQ(ret, SOFTBUS_LANE_GET_LEDGER_INFO_ERR);
EXPECT_EQ(ret, SOFTBUS_TCPCONNECTION_SOCKET_ERR);
ConnServerDeinit();
}
@ -376,7 +376,7 @@ HWTEST_F(LaneTest, LANE_LINK_Test_002, TestSize.Level1)
};
uint32_t requestId = 0x5A5A;
ret = BuildLink(&reqInfo, requestId, &linkCb);
EXPECT_EQ(ret, SOFTBUS_LANE_GET_LEDGER_INFO_ERR);
EXPECT_EQ(ret, SOFTBUS_OK);
}
/*
@ -407,13 +407,13 @@ HWTEST_F(LaneTest, TRANS_LANE_ALLOC_Test_001, TestSize.Level1)
.onLaneFreeFail = OnLaneFreeFail,
};
ret = laneManager->lnnAllocLane(laneReqId, &allocInfo, &listener);
EXPECT_EQ(ret, SOFTBUS_NETWORK_NODE_OFFLINE);
EXPECT_EQ(ret, SOFTBUS_OK);
laneReqId = laneManager->lnnGetLaneHandle(LANE_TYPE_TRANS);
EXPECT_TRUE(laneReqId != INVALID_LANE_REQ_ID);
allocInfo.qosRequire.minBW = DEFAULT_QOSINFO_MIN_BW + LOW_BW;
ret = laneManager->lnnAllocLane(laneReqId, &allocInfo, &listener);
EXPECT_EQ(ret, SOFTBUS_NETWORK_NODE_OFFLINE);
EXPECT_EQ(ret, SOFTBUS_OK);
SoftBusSleepMs(5);
}
@ -491,7 +491,7 @@ HWTEST_F(LaneTest, DESTROY_LINK_Test_001, TestSize.Level1)
{
const char *networkId = "111122223333abcdef";
uint32_t laneReqId = LANE_REQ_ID_TYPE_SHIFT;
EXPECT_EQ(DestroyLink(networkId, laneReqId, LANE_P2P), SOFTBUS_INVALID_PARAM);
EXPECT_EQ(DestroyLink(networkId, laneReqId, LANE_P2P), SOFTBUS_LANE_RESOURCE_NOT_FOUND);
EXPECT_EQ(DestroyLink(nullptr, laneReqId, LANE_P2P), SOFTBUS_INVALID_PARAM);
}
} // namespace OHOS

View File

@ -846,7 +846,7 @@ HWTEST_F(HeartBeatMediumTest, SoftBusNetNodeResult_TEST01, TestSize.Level1)
.WillOnce(Return(SOFTBUS_ERR))
.WillRepeatedly(Return(SOFTBUS_OK));
EXPECT_CALL(heartBeatMock, IsExistLnnDfxNodeByUdidHash).WillRepeatedly(Return(true));
EXPECT_CALL(ledgerMock, LnnGetLocalByteInfo).WillOnce(Return(SOFTBUS_ERR));
EXPECT_CALL(ledgerMock, LnnGetLocalByteInfo).WillRepeatedly(Return(SOFTBUS_ERR));
int32_t ret = SoftBusNetNodeResult(&device, &hbResp, false, connectReason);
EXPECT_TRUE(ret == SOFTBUS_ERR);
ret = SoftBusNetNodeResult(&device, &hbResp, false, connectReason);

View File

@ -223,8 +223,7 @@ HWTEST_F(HeartBeatUtilsTest, LnnGenerateBtMacHashTest_02, TestSize.Level1)
char brMacHash;
NiceMock<DistributeLedgerInterfaceMock> disLedgerMock;
EXPECT_CALL(disLedgerMock, ConvertBtMacToBinary)
.WillOnce(Return(SOFTBUS_ERR))
.WillRepeatedly(Return(SOFTBUS_OK));
.WillRepeatedly(Return(SOFTBUS_ERR));
int32_t ret = LnnGenerateBtMacHash(nullptr, BT_MAC_LEN, nullptr, BT_MAC_HASH_STR_LEN);
EXPECT_TRUE(ret == SOFTBUS_ERR);
ret = LnnGenerateBtMacHash(BT_MAC, BT_MAC_LEN, &brMacHash, BT_MAC_LEN);
@ -232,7 +231,7 @@ HWTEST_F(HeartBeatUtilsTest, LnnGenerateBtMacHashTest_02, TestSize.Level1)
ret = LnnGenerateBtMacHash(BT_MAC, BT_MAC_LEN, &brMacHash, BT_MAC_HASH_STR_LEN);
EXPECT_TRUE(ret == SOFTBUS_ERR);
ret = LnnGenerateBtMacHash(BT_MAC, BT_MAC_LEN, &brMacHash, BT_MAC_HASH_STR_LEN);
EXPECT_TRUE(ret == SOFTBUS_OK);
EXPECT_TRUE(ret == SOFTBUS_ERR);
}
/*