!8125 modify p2p ut failed

Merge pull request !8125 from liwenqiang/master
This commit is contained in:
openharmony_ci 2024-10-23 03:45:23 +00:00 committed by Gitee
commit f0360ca535
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 10 additions and 3 deletions

View File

@ -53,8 +53,10 @@ public:
*/
HWTEST_F(P2pAdapterTest, IsWifiEnableTest, TestSize.Level1)
{
WifiDirectInterfaceMock mock;
EXPECT_CALL(mock, IsWifiActive).WillOnce(Return(1));
bool flag = P2pAdapter::IsWifiEnable();
EXPECT_FALSE(flag);
EXPECT_TRUE(flag);
}
/*
@ -348,8 +350,6 @@ HWTEST_F(P2pAdapterTest, GetIpAddressTest001, TestSize.Level1)
.WillOnce(DoAll(SetArgPointee<0>(info), Return(WIFI_SUCCESS)));
int32_t ret = P2pAdapter::GetIpAddress(ipString);
EXPECT_EQ(ret, ToSoftBusErrorCode(static_cast<int32_t>(ERROR_WIFI_UNKNOWN)));
ret = P2pAdapter::GetIpAddress(ipString);
EXPECT_TRUE((ret != SOFTBUS_OK));
}
/*

View File

@ -193,6 +193,11 @@ int32_t GetInterfaceIpString(const std::string &interface, std::string &ip)
return OHOS::SoftBus::WifiDirectInterfaceMock::GetMock()->GetInterfaceIpString(interface, ip);
}
int IsWifiActive()
{
return OHOS::SoftBus::WifiDirectInterfaceMock::GetMock()->IsWifiActive();
}
WifiErrorCode GetLinkedInfo(WifiLinkedInfo *info)
{
return OHOS::SoftBus::WifiDirectInterfaceMock::GetMock()->GetLinkedInfo(info);

View File

@ -75,6 +75,7 @@ public:
virtual int32_t LnnGetRemoteDefaultPtkByUuid(const char *uuid, char *remotePtk, uint32_t len) = 0;
// Defines dependencies short-reach interface here
virtual int IsWifiActive() = 0;
virtual WifiErrorCode GetLinkedInfo(WifiLinkedInfo *info) = 0;
virtual WifiErrorCode Hid2dGetRecommendChannel(const RecommendChannelRequest *request,
RecommendChannelResponse *response) = 0;
@ -165,6 +166,7 @@ public:
MOCK_METHOD(uint64_t, LnnGetFeatureCapabilty, (), (override));
MOCK_METHOD(bool, IsFeatureSupport, (uint64_t, FeatureCapability), (override));
MOCK_METHOD(int, IsWifiActive, (), (override));
MOCK_METHOD(WifiErrorCode, GetLinkedInfo, (WifiLinkedInfo *), (override));
MOCK_METHOD(WifiErrorCode, Hid2dGetRecommendChannel,
(const RecommendChannelRequest *, RecommendChannelResponse *), (override));