# Copyright (c) 2021-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. import("//build/test.gni") import("../../thermalmgr.gni") module_output_path = "thermal_manager/thermal_native" ############################################################################### config("module_private_config") { visibility = [ ":*" ] include_dirs = [ "include", "mock_action/include", "mock/include", "${utils_path}/native/include", "${thermal_manager_path}/services/native/include/thermal_action", "${thermal_manager_path}/test/common/include", "${thermal_service_zidl}/include", "${ability_runtime_services_path}/appmgr/include", "${thermal_inner_api}/native/include", ] } deps_ex = [ "ability_base:base", "ability_base:want", "ability_runtime:ability_manager", "ability_runtime:app_manager", "bundle_framework:appexecfwk_base", "c_utils:utils", "config_policy:configpolicy_util", "ipc:ipc_core", "hdf_core:libhdi", "hdf_core:libpub_utils", "hilog:libhilog", "libxml2:libxml2", "power_manager:powermgr_client", "safwk:system_ability_fwk", "samgr:samgr_proxy", "common_event_service:cesfwk_innerkits", "window_manager:libwm", "drivers_interface_battery:libbattery_proxy_2.0", "drivers_interface_thermal:libthermal_proxy_1.1", "time_service:time_client", ] # thermal mock action test ohos_unittest("ThermalMockActionTest") { module_out_path = module_output_path sources = [ "${thermal_manager_path}/test/common/src/thermal_test.cpp", "${thermal_manager_path}/test/unittest/mock_action/src/mock_socperf_action.cpp", "src/thermal_mock_action_test.cpp", ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] defines = [ "THERMAL_GTEST" ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_manager_path}/test/common:mock_thermalsrv_client", "//third_party/googletest:gtest_main", ] external_deps = deps_ex if (defined(global_parts_info) && defined(global_parts_info.powermgr_battery_manager)) { defines += [ "BATTERY_MANAGER_ENABLE" ] external_deps += [ "battery_manager:batterysrv_client" ] } } # thermal policy test ohos_unittest("ThermalMgrPolicyTest") { module_out_path = module_output_path sources = [ "${thermal_manager_path}/test/common/src/thermal_test.cpp", "src/thermal_mgr_policy_test.cpp", ] configs = [ "${utils_path}:utils_config", ":module_private_config", ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_manager_path}/test/common:mock_thermalsrv_client", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gtest_main", ] external_deps = deps_ex } # thermal level event test ohos_unittest("ThermalLevelEventTest") { module_out_path = module_output_path sources = [ "${thermal_manager_path}/test/common/src/thermal_test.cpp", "src/thermal_config_file_parser.cpp", "src/thermal_level_event_test.cpp", ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_manager_path}/test/common:mock_thermalsrv_client", "//third_party/googletest:gtest_main", ] external_deps = deps_ex external_deps += [ "access_token:libaccesstoken_sdk", "access_token:libnativetoken", "access_token:libprivacy_sdk", "access_token:libtoken_setproc", ] } # thermal client api test ohos_unittest("ThermalClientApiTest") { module_out_path = module_output_path sources = [ "src/thermal_client_api_test.cpp" ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_manager_path}/test/common:mock_thermalsrv_client", "//third_party/googletest:gtest_main", ] external_deps = deps_ex } # thermal action hub test ohos_unittest("ThermalActionHubTest") { module_out_path = module_output_path sources = [ "${thermal_manager_path}/test/common/src/thermal_test.cpp", "src/thermal_action_hub_test.cpp", ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_manager_path}/test/common:mock_thermalsrv_client", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gtest_main", ] external_deps = deps_ex } # thermal action report test ohos_unittest("ThermalActionReportTest") { module_out_path = module_output_path sources = [ "${thermal_manager_path}/test/common/src/thermal_test.cpp", "src/thermal_action_report_test.cpp", "src/thermal_config_file_parser.cpp", ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_manager_path}/test/common:mock_thermalsrv_client", "//third_party/googletest:gtest_main", ] defines = [] if (defined(global_parts_info) && defined(global_parts_info.powermgr_battery_statistics)) { defines = [ "BATTERY_STATS_ENABLE" ] deps += [ "${batterystats_utils_path}:batterystats_utils" ] external_deps = [ "battery_statistics:batterystats_client" ] external_deps += deps_ex } else { external_deps = deps_ex } if (defined(global_parts_info) && defined(global_parts_info.powermgr_battery_manager)) { defines += [ "BATTERY_MANAGER_ENABLE" ] external_deps += [ "battery_manager:batterysrv_client" ] } } # thermal mock proxy test ohos_unittest("ThermalMockProxyTest") { module_out_path = module_output_path sources = [ "mock/src/mock_thermal_remote_object.cpp", "src/thermal_mock_proxy_test.cpp", ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gtest_main", ] external_deps = deps_ex } # thermal mock proxy remote test ohos_unittest("ThermalMockProxyRemoteTest") { module_out_path = module_output_path sources = [ "mock/src/mock_peer_holder.cpp", "mock/src/mock_thermal_remote_object.cpp", "src/thermal_mock_proxy_remote_test.cpp", ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gtest_main", ] external_deps = deps_ex } # thermal mock proxy writeinterfacetoken test ohos_unittest("ThermalMockProxyWriteinterfacetokenTest") { module_out_path = module_output_path sources = [ "mock/src/mock_message_parcel.cpp", "mock/src/mock_thermal_remote_object.cpp", "src/thermal_mock_proxy_writeinterfacetoken_test.cpp", ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] defines = [ "MOCK_WRITE_INTERFACE_TOKEN_RETURN_FALSE" ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gtest_main", ] external_deps = deps_ex } # thermal mock proxy writeremoteobject test ohos_unittest("ThermalMockProxyWriteremoteobjectTest") { module_out_path = module_output_path sources = [ "mock/src/mock_message_parcel.cpp", "mock/src/mock_parcel.cpp", "mock/src/mock_thermal_remote_object.cpp", "src/thermal_mock_proxy_writeremoteobject_test.cpp", ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] defines = [ "MOCK_WRITE_REMOTE_OBJECT_RETURN_FALSE" ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gtest_main", ] external_deps = deps_ex } # thermal mock proxy writevector test ohos_unittest("ThermalMockProxyWritevectorTest") { module_out_path = module_output_path sources = [ "mock/src/mock_message_parcel.cpp", "mock/src/mock_parcel.cpp", "mock/src/mock_thermal_remote_object.cpp", "src/thermal_mock_proxy_writevector_test.cpp", ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] defines = [ "MOCK_WRITEVECTOR_RETURN_FALSE" ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gtest_main", ] external_deps = deps_ex } # thermal mock proxy sendrequest test ohos_unittest("ThermalMockProxySendrequestTest") { module_out_path = module_output_path sources = [ "mock/src/mock_message_parcel.cpp", "mock/src/mock_thermal_remote_object.cpp", "src/thermal_mock_proxy_sendrequest_test.cpp", ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] defines = [ "MOCK_SEND_REQUEST_RETURN_ONE" ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gtest_main", ] external_deps = deps_ex } # thermal utils test ohos_unittest("ThermalUtilsTest") { module_out_path = module_output_path sources = [ "src/thermal_utils_test.cpp" ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gtest_main", ] external_deps = deps_ex } # thermal service death test ohos_unittest("ThermalServiceDeathTest") { module_out_path = module_output_path sources = [ "mock/src/mock_thermal_remote_object.cpp", "src/thermal_service_death_test.cpp", ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] defines = [ "THERMAL_SERVICE_DEATH_UT" ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gtest_main", ] external_deps = deps_ex } # thermal listener test ohos_unittest("ThermalListenerTest") { module_out_path = module_output_path sources = [ "${thermal_manager_path}/test/common/src/thermal_test.cpp", "src/thermal_listener_test.cpp", ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] deps = [ "${thermal_inner_api}:thermalmgr_listener", "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_manager_path}/test/common:mock_thermalsrv_client", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gtest_main", ] external_deps = deps_ex } # thermal client test ohos_unittest("ThermalClientTest") { module_out_path = module_output_path sources = [ "mock/src/mock_thermal_remote_object.cpp", "src/thermal_client_test.cpp", ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] deps = [ "${thermal_inner_api}:thermalmgr_listener", "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gtest_main", ] external_deps = [ "ability_base:base", "ability_base:want", "bundle_framework:appexecfwk_base", "c_utils:utils", "common_event_service:cesfwk_innerkits", "drivers_interface_thermal:libthermal_proxy_1.1", "hdf_core:libhdi", "hdf_core:libpub_utils", "hilog:libhilog", "hisysevent:libhisysevent", "ipc:ipc_core", "libxml2:libxml2", "power_manager:powermgr_client", "safwk:system_ability_fwk", "samgr:samgr_proxy", "window_manager:libwm", ] } # thermal mock stub test ohos_unittest("ThermalMockStubTest") { module_out_path = module_output_path defines = [ "THERMAL_GTEST" ] sources = [ "src/thermal_mock_stub_test.cpp" ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gtest_main", ] external_deps = deps_ex } # thermal mock stub getdescriptor test ohos_unittest("ThermalMockStubGetdescriptorTest") { module_out_path = module_output_path sources = [ "src/thermal_mock_stub_getdescriptor_test.cpp" ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gtest_main", ] external_deps = deps_ex } # thermal action test ohos_unittest("ThermalActionTest") { module_out_path = module_output_path sources = [ "mock/src/mock_thermal_remote_object.cpp", "src/thermal_action_test.cpp", ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] defines = [ "THERMAL_GTEST" ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gtest_main", ] external_deps = deps_ex } # thermal observer test ohos_unittest("ThermalObserverTest") { module_out_path = module_output_path sources = [ "mock/src/mock_thermal_remote_object.cpp", "src/thermal_observer_test.cpp", ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] defines = [ "THERMAL_OBSERVER_UT_TEST" ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gtest_main", ] external_deps = deps_ex if (defined(global_parts_info) && defined(global_parts_info.powermgr_battery_manager)) { defines += [ "BATTERY_MANAGER_ENABLE" ] external_deps += [ "battery_manager:batterysrv_client" ] } } # thermal service test ohos_unittest("ThermalServiceTest") { module_out_path = module_output_path defines = [ "THERMAL_GTEST" ] sources = [ "src/thermal_service_test.cpp" ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", ] external_deps = deps_ex } # thermal config sensor cluster test ohos_unittest("ThermalConfigSensorClusterTest") { module_out_path = module_output_path defines = [ "THERMAL_GTEST" ] sources = [ "src/thermal_config_sensor_cluster_test.cpp" ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", ] external_deps = deps_ex } # thermal mgr dump test ohos_unittest("ThermalMgrDumpTest") { module_out_path = module_output_path defines = [ "THERMAL_GTEST" ] sources = [ "src/thermal_mgr_dump_test.cpp" ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", ] external_deps = deps_ex } # thermal policy test ohos_unittest("ThermalPolicyTest") { module_out_path = module_output_path defines = [ "THERMAL_GTEST" ] sources = [ "src/thermal_policy_test.cpp" ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", ] external_deps = deps_ex } # fan fault detect test ohos_unittest("FanFaultDetectTest") { module_out_path = module_output_path defines = [ "THERMAL_GTEST" ] sources = [ "src/fan_fault_detect_test.cpp" ] configs = [ "${utils_path}:utils_config", ":module_private_config", "${utils_path}:coverage_flags", ] deps = [ "${thermal_inner_api}:thermalsrv_client", "${thermal_manager_path}/services:thermalservice", "${thermal_service_zidl}:thermalmgr_proxy", "${thermal_service_zidl}:thermalmgr_stub", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", ] external_deps = [ "hisysevent:libhisysevent", "hisysevent:libhisyseventmanager", ] external_deps += deps_ex } group("unittest") { testonly = true deps = [ ":FanFaultDetectTest", ":ThermalActionHubTest", ":ThermalActionReportTest", ":ThermalActionTest", ":ThermalClientApiTest", ":ThermalClientTest", ":ThermalConfigSensorClusterTest", ":ThermalLevelEventTest", ":ThermalListenerTest", ":ThermalMgrDumpTest", ":ThermalMgrPolicyTest", ":ThermalMockActionTest", ":ThermalMockProxyRemoteTest", ":ThermalMockProxySendrequestTest", ":ThermalMockProxyTest", ":ThermalMockProxyWriteinterfacetokenTest", ":ThermalMockProxyWriteremoteobjectTest", ":ThermalMockProxyWritevectorTest", ":ThermalMockStubGetdescriptorTest", ":ThermalMockStubTest", ":ThermalObserverTest", ":ThermalPolicyTest", ":ThermalServiceDeathTest", ":ThermalServiceTest", ":ThermalUtilsTest", ] }