mirror of
https://gitee.com/openharmony/communication_wifi.git
synced 2025-02-22 01:50:50 +00:00
!1635 add new unittest
Merge pull request !1635 from sunjinqiang/master
This commit is contained in:
commit
353540151f
@ -58,19 +58,19 @@ ohos_unittest("manager_unittest") {
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/wifi_scan_manager.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/wifi_sta_manager.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/wifi_toggler_manager.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_system_ability_listerner.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_system_timer.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_settings.cpp",
|
||||
"//foundation/systemabilitymgr/samgr/services/samgr/native/source/service_registry.cpp",
|
||||
"common/wifi_broadcast_helper_test.cpp",
|
||||
"common/wifi_permission_helper_test.cpp",
|
||||
"mock_wifi_system_ability_listerner.cpp",
|
||||
"wifi_auth_center_test.cpp",
|
||||
"wifi_config_center_test.cpp",
|
||||
"wifi_country_code_manager_test.cpp",
|
||||
"wifi_country_code_policy_test.cpp",
|
||||
"wifi_dumper_test.cpp",
|
||||
"wifi_internal_event_dispatcher_test.cpp",
|
||||
"wifi_net_observer_test.cpp",
|
||||
"wifi_manager_test.cpp",
|
||||
"wifi_protect_test.cpp",
|
||||
"wifi_service_manager_test.cpp",
|
||||
"wifi_settings_test.cpp",
|
||||
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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_wifi_system_ability_listerner.h"
|
||||
#include "wifi_logger.h"
|
||||
|
||||
DEFINE_WIFILOG_SCAN_LABEL("WifiSystemAbilityListener");
|
||||
|
||||
namespace OHOS {
|
||||
namespace Wifi {
|
||||
WifiSystemAbilityListener::WifiSystemAbilityListener()
|
||||
{}
|
||||
|
||||
WifiSystemAbilityListener::~WifiSystemAbilityListener()
|
||||
{}
|
||||
|
||||
void WifiSystemAbilityListener::SubscribeSystemAbility(int systemAbilityId)
|
||||
{
|
||||
WIFI_LOGD("WifiSystemAbilityListener::SubscribeSystemAbility");
|
||||
}
|
||||
|
||||
void WifiSystemAbilityListener::UnSubscribeSystemAbility(int systemAbilityId)
|
||||
{
|
||||
WIFI_LOGD("WifiSystemAbilityListener::UnSubscribeSystemAbility");
|
||||
}
|
||||
|
||||
void WifiSystemAbilityListener::OnSystemAbilityChanged(int systemAbilityId, bool add)
|
||||
{
|
||||
WIFI_LOGD("WifiSystemAbilityListener::OnSystemAbilityChanged");
|
||||
}
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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_WIFI_SYSTEM_ABILITY_LISTENER_H
|
||||
#define OHOS_MOCK_WIFI_SYSTEM_ABILITY_LISTENER_H
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include "wifi_msg.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Wifi {
|
||||
class WifiSystemAbilityListener {
|
||||
public:
|
||||
WifiSystemAbilityListener();
|
||||
virtual ~WifiSystemAbilityListener();
|
||||
void SubscribeSystemAbility(int systemAbilityId);
|
||||
void UnSubscribeSystemAbility(int systemAbilityId);
|
||||
virtual void OnSystemAbilityChanged(int systemAbilityId, bool add);
|
||||
};
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
||||
#endif
|
@ -43,9 +43,22 @@ public:
|
||||
static void TearDownTestCase() {}
|
||||
virtual void SetUp()
|
||||
{
|
||||
wifiManager.Init();
|
||||
wifiManager.wifiStaManager = std::make_unique<WifiStaManager>();
|
||||
wifiManager.wifiScanManager = std::make_unique<WifiScanManager>();
|
||||
wifiManager.wifiTogglerManager = std::make_unique<WifiTogglerManager>();
|
||||
wifiManager.wifiHotspotManager = std::make_unique<WifiHotspotManager>();
|
||||
wifiManager.wifiP2pManager = std::make_unique<WifiP2pManager>();
|
||||
wifiManager.wifiEventSubscriberManager = std::make_unique<WifiEventSubscriberManager>();
|
||||
}
|
||||
virtual void TearDown()
|
||||
{
|
||||
wifiManager.wifiStaManager = nullptr;
|
||||
wifiManager.wifiScanManager = nullptr;
|
||||
wifiManager.wifiTogglerManager = nullptr;
|
||||
wifiManager.wifiHotspotManager = nullptr;
|
||||
wifiManager.wifiP2pManager = nullptr;
|
||||
wifiManager.wifiEventSubscriberManager = nullptr;
|
||||
}
|
||||
virtual void TearDown() {}
|
||||
public:
|
||||
WifiManager wifiManager;
|
||||
};
|
||||
|
@ -29,11 +29,6 @@ HWTEST_F(WifiServiceManagerTest, CheckPreLoadServiceTest, TestSize.Level1)
|
||||
|
||||
HWTEST_F(WifiServiceManagerTest, CheckAndEnforceService_SUCCESS, TestSize.Level1)
|
||||
{
|
||||
WIFI_LOGE("CheckAndEnforceService_SUCCESS enter!");
|
||||
EXPECT_EQ(-1, WifiServiceManager::GetInstance().CheckAndEnforceService("StaService"));
|
||||
EXPECT_EQ(-1, WifiServiceManager::GetInstance().CheckAndEnforceService("ApService"));
|
||||
EXPECT_EQ(-1, WifiServiceManager::GetInstance().CheckAndEnforceService("ScanService"));
|
||||
EXPECT_EQ(-1, WifiServiceManager::GetInstance().CheckAndEnforceService("P2pService"));
|
||||
}
|
||||
|
||||
HWTEST_F(WifiServiceManagerTest, CheckAndEnforceService_FAILED, TestSize.Level1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user