diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/BUILD.gn b/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/BUILD.gn index b2d85c11e..8a6c1f76a 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/BUILD.gn +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/BUILD.gn @@ -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", diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/mock_wifi_system_ability_listerner.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/mock_wifi_system_ability_listerner.cpp new file mode 100644 index 000000000..914ee9ea3 --- /dev/null +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/mock_wifi_system_ability_listerner.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 \ No newline at end of file diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/mock_wifi_system_ability_listerner.h b/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/mock_wifi_system_ability_listerner.h new file mode 100644 index 000000000..13aeaff9a --- /dev/null +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/mock_wifi_system_ability_listerner.h @@ -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 +#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 \ No newline at end of file diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/wifi_manager_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/wifi_manager_test.cpp index cc3d064d9..873a41f53 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/wifi_manager_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/wifi_manager_test.cpp @@ -43,9 +43,22 @@ public: static void TearDownTestCase() {} virtual void SetUp() { - wifiManager.Init(); + wifiManager.wifiStaManager = std::make_unique(); + wifiManager.wifiScanManager = std::make_unique(); + wifiManager.wifiTogglerManager = std::make_unique(); + wifiManager.wifiHotspotManager = std::make_unique(); + wifiManager.wifiP2pManager = std::make_unique(); + wifiManager.wifiEventSubscriberManager = std::make_unique(); + } + 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; }; diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/wifi_service_manager_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/wifi_service_manager_test.cpp index a278f242b..3021fc95b 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/wifi_service_manager_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/wifi_service_manager_test.cpp @@ -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)