Signed-off-by: yangpengfei <yangpengfei34@huawei.com>
This commit is contained in:
yangpengfei 2024-11-19 13:34:56 +00:00 committed by Gitee
parent 41ce37dd70
commit 04c083990d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 36 additions and 27 deletions

View File

@ -122,8 +122,6 @@ public:
int GetDeviceConfig(const std::string &ssid, const std::string &keymgmt, WifiDeviceConfig &config, int instId = 0);
int SetDeviceState(int networkId, int state, bool bSetOther = false);
int SetDeviceEphemeral(int networkId, bool isEphemeral);
int SetDeviceAfterConnect(int networkId);
@ -138,6 +136,9 @@ public:
bool GetAcceptUnvalidated(int networkId);
int GetCandidateConfigWithoutUid(const std::string &ssid, const std::string &keymgmt,
WifiDeviceConfig &config);
int GetCandidateConfig(const int uid, const std::string &ssid, const std::string &keymgmt,
WifiDeviceConfig &config);
@ -322,6 +323,7 @@ private:
bool EncryptionWapiConfig(const WifiEncryptionInfo &wifiEncryptionInfo, WifiDeviceConfig &config) const;
#endif
void SyncAfterDecryped(WifiDeviceConfig &config);
int GetAllCandidateConfigWithoutUid(std::vector<WifiDeviceConfig> &configs);
private:
// STA
std::mutex mStaMutex;

View File

@ -80,20 +80,6 @@ HWTEST_F(WifiSettingsTest, GetDeviceConfig3Test, TestSize.Level1)
EXPECT_EQ(result, WIFI_OPT_RETURN);
}
HWTEST_F(WifiSettingsTest, SetDeviceStateTest, TestSize.Level1)
{
WIFI_LOGE("SetDeviceStateTest enter!");
int result = WifiSettings::GetInstance().SetDeviceState(NETWORK_ID, WIFI_OPT_RETURN, true);
EXPECT_EQ(result, WIFI_OPT_RETURN);
result = WifiSettings::GetInstance().SetDeviceState(NETWORK_ID, NETWORK_ID, true);
EXPECT_EQ(result, WIFI_OPT_RETURN);
result = WifiSettings::GetInstance().SetDeviceState(NETWORK_ID, STATE, true);
EXPECT_EQ(result, WIFI_OPT_RETURN);
result = WifiSettings::GetInstance().SetDeviceState(SCORE, STATE, true);
WIFI_LOGE("SetDeviceStateTest result(%{public}d)", result);
EXPECT_EQ(result, WIFI_OPT_RETURN);
}
HWTEST_F(WifiSettingsTest, SetDeviceEphemeralTest, TestSize.Level1)
{
WIFI_LOGE("SetDeviceEphemeralTest enter!");
@ -142,6 +128,38 @@ HWTEST_F(WifiSettingsTest, IncreaseDeviceConnFailedCountTest, TestSize.Level1)
EXPECT_EQ(result, WIFI_OPT_RETURN);
}
HWTEST_F(WifiSettingsTest, GetCandidateConfigWithoutUidTest, TestSize.Level1)
{
WIFI_LOGI("GetCandidateConfigWithoutUidTest enter!");
WifiDeviceConfig config1;
config1.ssid = "test";
config1.keyMgmt = "SAE";
config1.uid = 1;
config1.isShared = false;
WifiSettings::GetInstance().AddDeviceConfig(config1);
WifiDeviceConfig config2;
int result = WifiSettings::GetInstance().GetCandidateConfigWithoutUid("test", "SAE", config2);
WIFI_LOGI("GetCandidateConfigWithoutUidTest result(%{public}d)", result);
EXPECT_NE(result, WIFI_OPT_RETURN);
}
HWTEST_F(WifiSettingsTest, GetAllCandidateConfigWithoutUidTest, TestSize.Level1)
{
WIFI_LOGI("GetAllCandidateConfigWithoutUidTest enter!");
WifiDeviceConfig config1;
config1.ssid = "test";
config1.keyMgmt = "SAE";
config1.uid = 1;
config1.isShared = false;
WifiSettings::GetInstance().AddDeviceConfig(config1);
std::vector<WifiDeviceConfig> config2;
int result = WifiSettings::GetInstance().GetAllCandidateConfigWithoutUid(config2);
WIFI_LOGI("GetAllCandidateConfigWithoutUidTest result(%{public}d)", result);
EXPECT_NE(result, WIFI_OPT_RETURN);
}
HWTEST_F(WifiSettingsTest, SetDeviceConnFailedCountTest, TestSize.Level1)
{
WIFI_LOGE("SetDeviceConnFailedCountTest enter!");
@ -507,17 +525,6 @@ HWTEST_F(WifiSettingsTest, ClearHotspotConfigTest, TestSize.Level1)
WifiSettings::GetInstance().ClearHotspotConfig();
}
HWTEST_F(WifiSettingsTest, SetDeviceStateTest1, TestSize.Level1)
{
WIFI_LOGI("SetDeviceStateTest enter");
WifiDeviceConfig config;
WifiSettings::GetInstance().mWifiDeviceConfig.emplace(SCORE, config);
int result = WifiSettings::GetInstance().SetDeviceState(SCORE, SCORE, true);
EXPECT_EQ(result, 0);
result = WifiSettings::GetInstance().SetDeviceState(SCORE, SCORE, false);
EXPECT_EQ(result, 0);
}
HWTEST_F(WifiSettingsTest, GetDeviceConfigTest, TestSize.Level1)
{
WIFI_LOGI("GetDeviceConfigTest enter");