Signed-off-by: yangpengfei <yangpengfei34@huawei.com>
This commit is contained in:
yangpengfei 2024-11-19 13:35:08 +00:00 committed by Gitee
parent 04c083990d
commit 291e1cc2ae
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 85 additions and 4 deletions

View File

@ -250,11 +250,11 @@
"OHOS::Wifi::WifiSettings::AddDeviceConfig(OHOS::Wifi::WifiDeviceConfig const&)";
"OHOS::Wifi::WifiSettings::RemoveDevice(int)";
"OHOS::Wifi::WifiSettings::ClearDeviceConfig()";
"OHOS::Wifi::WifiSettings::GetCandidateConfigWithoutUid(std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const&, std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const&, OHOS::Wifi::WifiDeviceConfig&)";
"OHOS::Wifi::WifiSettings::GetDeviceConfig(std::__h::vector<OHOS::Wifi::WifiDeviceConfig, std::__h::allocator<OHOS::Wifi::WifiDeviceConfig>>&, int)";
"OHOS::Wifi::WifiSettings::GetDeviceConfig(int const&, OHOS::Wifi::WifiDeviceConfig&, int)";
"OHOS::Wifi::WifiSettings::GetDeviceConfig(std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const&, int const&, OHOS::Wifi::WifiDeviceConfig&, int)";
"OHOS::Wifi::WifiSettings::GetDeviceConfig(std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const&, std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const&, OHOS::Wifi::WifiDeviceConfig&, int)";
"OHOS::Wifi::WifiSettings::SetDeviceState(int, int, bool)";
"OHOS::Wifi::WifiSettings::SetDeviceEphemeral(int, bool)";
"OHOS::Wifi::WifiSettings::SetDeviceAfterConnect(int)";
"OHOS::Wifi::WifiSettings::SetDeviceRandomizedMacSuccessEver(int)";

View File

@ -46,7 +46,8 @@ public:
const std::string &ssid, const std::string &keymgmt, WifiDeviceConfig &config, int instId = 0) = 0;
virtual int GetDeviceConfig(
const std::string &index, const int &indexType, WifiDeviceConfig &config, int instId = 0) = 0;
virtual int SetDeviceState(int networkId, int state, bool bSetOther = false) = 0;
virtual int GetCandidateConfigWithoutUid(const std::string &ssid, const std::string &keymgmt,
WifiDeviceConfig &config) = 0;
virtual int SyncDeviceConfig() = 0;
virtual int ReloadDeviceConfig() = 0;
virtual int GetIpInfo(IpInfo &info, int instId = 0) = 0;
@ -219,7 +220,8 @@ public:
GetDeviceConfig, int(const std::string &ssid, const std::string &keymgmt, WifiDeviceConfig &config, int));
MOCK_METHOD4(
GetDeviceConfig, int(const std::string &index, const int &indexType, WifiDeviceConfig &config, int));
MOCK_METHOD3(SetDeviceState, int(int networkId, int state, bool bSetOther));
MOCK_METHOD3(GetCandidateConfigWithoutUid, int(const std::string &ssid, const std::string &keymgmt,
WifiDeviceConfig &config));
MOCK_METHOD0(SyncDeviceConfig, int());
MOCK_METHOD0(ReloadDeviceConfig, int());
MOCK_METHOD2(GetIpInfo, int(IpInfo &info, int));

View File

@ -42,7 +42,6 @@ local_base_sources = [
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/network_select/wifi_scorer_impl.cpp",
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/app_network_speed_limit/app_network_speed_limit_service.cpp",
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/app_network_speed_limit/speed_limit_configs_writer.cpp",
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/block_connect_service.cpp",
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/network_black_list/network_black_list_manager.cpp",
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/network_status_history/network_status_history_manager.cpp",
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_app_state_aware.cpp",
@ -78,6 +77,7 @@ local_base_sources = [
"Mock/mock_state_machine.cpp",
"Mock/mock_wifi_chip_hal_interface.cpp",
"Mock/mock_wifi_settings.cpp",
"Mock/mock_block_connect_service.cpp",
]
local_base_include_dirs = [

View File

@ -0,0 +1,25 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "mock_block_connect_service.h"
namespace OHOS {
namespace Wifi {
BlockConnectService &BlockConnectService::GetInstance(void)
{
static BlockConnectService inst;
return inst;
}
} // namespace Wifi
} // namespace OHOS

View File

@ -0,0 +1,54 @@
/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_MOCK_BLOCKCONNECTSERVICE_H
#define OHOS_MOCK_BLOCKCONNECTSERVICE_H
#include "wifi_ap_msg.h"
#include "wifi_msg.h"
#include <gmock/gmock.h>
#include "wifi_internal_msg.h"
namespace OHOS {
namespace Wifi {
class MockBlockConnectService {
public:
virtual ~MockBlockConnectService() = default;
virtual bool ShouldAutoConnect(const WifiDeviceConfig &config) = 0;
virtual bool UpdateAllNetworkSelectStatus() = 0;
virtual bool UpdateNetworkSelectStatus(int targetNetworkId, DisabledReason disableReason, int wpaReason) = 0;
virtual bool UpdateNetworkSelectStatus(int targetNetworkId, DisabledReason disableReason) = 0;
virtual bool EnableNetworkSelectStatus(int targetNetworkId) = 0;
virtual bool IsFrequentDisconnect(std::string bssid, int wpaReason) = 0;
virtual bool IsWrongPassword(int targetNetworkId) = 0;
};
class BlockConnectService : public MockBlockConnectService {
public:
BlockConnectService() = default;
~BlockConnectService() = default;
static BlockConnectService &GetInstance(void);
MOCK_METHOD1(ShouldAutoConnect, bool(const WifiDeviceConfig &config));
MOCK_METHOD0(UpdateAllNetworkSelectStatus, bool());
MOCK_METHOD3(UpdateNetworkSelectStatus, bool(int targetNetworkId, DisabledReason disableReason, int wpaReason));
MOCK_METHOD2(UpdateNetworkSelectStatus, bool(int targetNetworkId, DisabledReason disableReason));
MOCK_METHOD1(EnableNetworkSelectStatus, bool(int targetNetworkId));
MOCK_METHOD2(IsFrequentDisconnect, bool(std::string bssid, int wpaReason));
MOCK_METHOD1(IsWrongPassword, bool(int targetNetworkId));
};
} // namespace OHOS
} // namespace Wifi
#endif