TDD异常用例处理

Signed-off-by: sunjinqiang <17319862417@163.com>
This commit is contained in:
sunjinqiang 2022-11-18 06:43:34 +00:00
parent 9aee838a27
commit 7260541709
5 changed files with 13 additions and 3 deletions

View File

@ -92,9 +92,6 @@ HWTEST_F(P2pEnabledStateTest, GoInState, TestSize.Level1)
EXPECT_CALL(WifiP2PHalInterface::GetInstance(), SetServiceDiscoveryExternal(Eq(false)))
.WillOnce(Return(WifiErrorNo::WIFI_IDL_OPT_FAILED))
.WillOnce(Return(WifiErrorNo::WIFI_IDL_OPT_OK));
EXPECT_CALL(WifiP2PHalInterface::GetInstance(), ListNetworks(_))
.WillOnce(Return(WifiErrorNo::WIFI_IDL_OPT_FAILED))
.WillOnce(Return(WifiErrorNo::WIFI_IDL_OPT_FAILED));
EXPECT_CALL(WifiP2PHalInterface::GetInstance(), SetPersistentReconnect(Eq(1)))
.WillOnce(Return(WifiErrorNo::WIFI_IDL_OPT_FAILED))
.WillOnce(Return(WifiErrorNo::WIFI_IDL_OPT_OK));

View File

@ -183,6 +183,8 @@ HWTEST_F(P2pGroupOperatingStateTest, ExecuteStateMsg3, TestSize.Level1)
EXPECT_CALL(WifiP2PHalInterface::GetInstance(), GroupRemove(_))
.WillOnce(Return(WifiErrorNo::WIFI_IDL_OPT_FAILED))
.WillOnce(Return(WifiErrorNo::WIFI_IDL_OPT_OK));
EXPECT_CALL(WifiP2PHalInterface::GetInstance(), P2pFlush())
.WillOnce(Return(WifiErrorNo::WIFI_IDL_OPT_OK));
EXPECT_TRUE(pP2pGroupOperatingState->ExecuteStateMsg(&msg));
AddGroupManager();
EXPECT_TRUE(pP2pGroupOperatingState->ExecuteStateMsg(&msg));
@ -237,6 +239,8 @@ HWTEST_F(P2pGroupOperatingStateTest, ProcessGroupRemovedEvt, TestSize.Level1)
InternalMessage msg;
msg.SetMessageName(static_cast<int>(P2P_STATE_MACHINE_CMD::P2P_EVENT_GROUP_REMOVED));
AddGroupManager();
EXPECT_CALL(WifiP2PHalInterface::GetInstance(), P2pFlush(_))
.WillOnce(Return(WifiErrorNo::WIFI_IDL_OPT_OK));
EXPECT_TRUE(pP2pGroupOperatingState->ExecuteStateMsg(&msg));
EXPECT_FALSE(pP2pGroupOperatingState->ExecuteStateMsg(nullptr));

View File

@ -454,6 +454,8 @@ HWTEST_F(P2pStateMachineTest, P2pConnectWithPinDisplay_SUCCESS, TestSize.Level1)
HWTEST_F(P2pStateMachineTest, DealGroupCreationFailed, TestSize.Level1)
{
EXPECT_CALL(WifiP2PHalInterface::GetInstance(), P2pFlush(_))
.WillOnce(Return(WifiErrorNo::WIFI_IDL_OPT_FAILED));
WarpDealGroupCreationFailed();
}
@ -813,6 +815,8 @@ HWTEST_F(P2pStateMachineTest, DealCreateNewGroupWithConfig2, TestSize.Level1)
EXPECT_CALL(WifiP2PHalInterface::GetInstance(), GroupAdd(_, _, _))
.WillOnce(Return(WifiErrorNo::WIFI_IDL_OPT_FAILED));
EXPECT_CALL(WifiP2PHalInterface::GetInstance(), RemoveNetwork(_)).WillOnce(Return(WifiErrorNo::WIFI_IDL_OPT_OK));
EXPECT_CALL(WifiP2PHalInterface::GetInstance(), ListNetworks(_))
.WillOnce(Return(WifiErrorNo::WIFI_IDL_OPT_OK));
EXPECT_FALSE(WarpDealCreateNewGroupWithConfig(config, freq));
}
@ -828,6 +832,8 @@ HWTEST_F(P2pStateMachineTest, DealCreateNewGroupWithConfig3, TestSize.Level1)
EXPECT_CALL(WifiP2PHalInterface::GetInstance(), RemoveNetwork(_))
.WillOnce(Return(WifiErrorNo::WIFI_IDL_OPT_OK))
.WillRepeatedly(Return(WifiErrorNo::WIFI_IDL_OPT_OK));
EXPECT_CALL(WifiP2PHalInterface::GetInstance(), ListNetworks(_))
.WillOnce(Return(WifiErrorNo::WIFI_IDL_OPT_OK));
EXPECT_TRUE(WarpDealCreateNewGroupWithConfig(config, freq));
}

View File

@ -67,6 +67,7 @@ public:
virtual int GetScanInfoList(std::vector<WifiScanInfo> &results) = 0;
virtual std::string GetConnectTimeoutBssid() = 0;
virtual int SetConnectTimeoutBssid(std::string &bssid) = 0;
virtual int SetDeviceAfterConnect(int networkId) = 0;
};
class WifiSettings : public MockWifiSettings {
@ -118,6 +119,7 @@ public:
MOCK_METHOD1(GetScanInfoList, int(std::vector<WifiScanInfo> &results));
MOCK_METHOD0(GetConnectTimeoutBssid, std::string());
MOCK_METHOD1(SetConnectTimeoutBssid, int(std::string &bssid));
MOCK_METHOD1(SetDeviceAfterConnect, int(int networkId));
};
} // namespace OHOS
} // namespace Wifi

View File

@ -387,6 +387,7 @@ public:
EXPECT_CALL(WifiSettings::GetInstance(), EnableNetwork(_, _)).Times(AtLeast(0));
EXPECT_CALL(WifiSettings::GetInstance(), SetDeviceState(_, _, _)).Times(AtLeast(0));
EXPECT_CALL(WifiSettings::GetInstance(), SaveLinkedInfo(_)).Times(testing::AtLeast(0));
EXPECT_CALL(WifiSettings::GetInstance(), SetDeviceAfterConnect(_)).Times(AtLeast(0));
EXPECT_CALL(WifiStaHalInterface::GetInstance(), EnableNetwork(_)).WillRepeatedly(Return(WIFI_IDL_OPT_OK));
EXPECT_CALL(WifiStaHalInterface::GetInstance(), Connect(_)).WillRepeatedly(Return(WIFI_IDL_OPT_OK));
EXPECT_CALL(WifiStaHalInterface::GetInstance(), SaveDeviceConfig()).WillRepeatedly(Return(WIFI_IDL_OPT_OK));