# Copyright (c) 2023-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/ohos.gni") import("//build/test.gni") import("//foundation/resourceschedule/device_standby/standby_service.gni") module_output_path = "${standby_service_part_name}/unittest" ohos_unittest("standby_service_unit_test") { module_out_path = module_output_path cflags_cc = [ "-Dprivate=public", "-Dprotected=public", ] include_dirs = [ "${standby_service_path}/test/unittest/mock/include" ] sources = [ "mock/mock_common_event.cpp", "mock/mock_helper.cpp", "mock/mock_ipc.cpp", "standby_service_unit_test.cpp", ] deps = [ "${standby_innerkits_path}:standby_innerkits", "${standby_plugins_path}:standby_plugin_static", "${standby_service_frameworks_path}:standby_fwk", "${standby_service_path}:standby_service_static", "${standby_utils_common_path}:standby_utils_common", "${standby_utils_policy_path}:standby_utils_policy_static", ] external_deps = [ "ability_base:base", "ability_base:want", "ability_base:zuri", "ability_runtime:app_manager", "ability_runtime:wantagent_innerkits", "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", "bundle_framework:appexecfwk_base", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", "init:libbegetutil", "ipc:ipc_single", "safwk:system_ability_fwk", "samgr:samgr_proxy", "time_service:time_client", ] defines = [] if (enable_background_task_mgr) { external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] defines += [ "ENABLE_BACKGROUND_TASK_MGR" ] } if (standby_power_manager_enable) { external_deps += [ "power_manager:powermgr_client" ] defines += [ "STANDBY_POWER_MANAGER_ENABLE" ] } subsystem_name = "resourceschedule" part_name = "${standby_service_part_name}" } ohos_unittest("standby_utils_unit_test") { module_out_path = module_output_path cflags_cc = [ "-Dprivate=public", "-Dprotected=public", ] sources = [ "standby_utils_unit_test.cpp" ] deps = [ "${standby_service_path}:standby_service_static", "${standby_utils_common_path}:standby_utils_common", "${standby_utils_policy_path}:standby_utils_policy_static", ] external_deps = [ "ability_base:base", "ability_base:want", "ability_base:zuri", "ability_runtime:app_manager", "ability_runtime:wantagent_innerkits", "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", "bundle_framework:appexecfwk_base", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", "init:libbegetutil", "ipc:ipc_single", "safwk:system_ability_fwk", "samgr:samgr_proxy", "time_service:time_client", ] defines = [] if (enable_background_task_mgr) { external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] defines += [ "ENABLE_BACKGROUND_TASK_MGR" ] } if (standby_power_manager_enable) { external_deps += [ "power_manager:powermgr_client" ] defines += [ "STANDBY_POWER_MANAGER_ENABLE" ] } subsystem_name = "resourceschedule" part_name = "${standby_service_part_name}" } ohos_unittest("standby_helper_unit_test") { module_out_path = module_output_path cflags_cc = [ "-Dprivate=public", "-Dprotected=public", ] include_dirs = [ "${standby_service_path}/test/unittest/mock/include" ] sources = [ "allow_record_unit_test.cpp", "mock/mock_helper.cpp", "standby_helper_unit_test.cpp", ] deps = [ "${standby_service_path}:standby_service_static", "${standby_utils_common_path}:standby_utils_common", "${standby_utils_policy_path}:standby_utils_policy_static", ] external_deps = [ "ability_base:base", "ability_base:want", "ability_base:zuri", "ability_runtime:app_manager", "ability_runtime:wantagent_innerkits", "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", "bundle_framework:appexecfwk_base", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", "init:libbegetutil", "ipc:ipc_single", "safwk:system_ability_fwk", "samgr:samgr_proxy", "time_service:time_client", ] defines = [] if (enable_background_task_mgr) { external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] defines += [ "ENABLE_BACKGROUND_TASK_MGR" ] } if (standby_power_manager_enable) { external_deps += [ "power_manager:powermgr_client" ] defines += [ "STANDBY_POWER_MANAGER_ENABLE" ] } subsystem_name = "resourceschedule" part_name = "${standby_service_part_name}" } ohos_unittest("mock_standby_helper_unit_test") { module_out_path = module_output_path cflags_cc = [ "-Dprivate=public", "-Dprotected=public", ] sources = [ "mock/mock_connect.cpp", "mock/mock_standby_helper_unit_test.cpp", ] deps = [ "${standby_service_path}:standby_service_static", "${standby_utils_common_path}:standby_utils_common", "${standby_utils_policy_path}:standby_utils_policy_static", ] external_deps = [ "ability_base:base", "ability_base:want", "ability_base:zuri", "ability_runtime:app_manager", "ability_runtime:wantagent_innerkits", "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", "bundle_framework:appexecfwk_base", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", "init:libbegetutil", "ipc:ipc_single", "safwk:system_ability_fwk", "samgr:samgr_proxy", "time_service:time_client", ] defines = [] if (enable_background_task_mgr) { external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] defines += [ "ENABLE_BACKGROUND_TASK_MGR" ] } if (standby_power_manager_enable) { external_deps += [ "power_manager:powermgr_client" ] defines += [ "STANDBY_POWER_MANAGER_ENABLE" ] } subsystem_name = "resourceschedule" part_name = "${standby_service_part_name}" } ohos_unittest("mock_standby_service_unit_test") { module_out_path = module_output_path cflags_cc = [ "-Dprivate=public", "-Dprotected=public", ] include_dirs = [ "${standby_service_path}/test/unittest/mock/include" ] sources = [ "mock/mock_helper.cpp", "mock_standby_service_unit_test.cpp", ] deps = [ "${standby_innerkits_path}:standby_innerkits", "${standby_service_frameworks_path}:standby_fwk", "${standby_service_path}:standby_service_static", "${standby_utils_common_path}:standby_utils_common", "${standby_utils_policy_path}:standby_utils_policy_static", "//third_party/googletest:gmock_main", ] external_deps = [ "ability_base:base", "ability_base:want", "ability_base:zuri", "ability_runtime:app_manager", "ability_runtime:wantagent_innerkits", "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", "bundle_framework:appexecfwk_base", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", "init:libbegetutil", "ipc:ipc_single", "safwk:system_ability_fwk", "samgr:samgr_proxy", "time_service:time_client", ] defines = [] if (enable_background_task_mgr) { external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] defines += [ "ENABLE_BACKGROUND_TASK_MGR" ] } if (standby_power_manager_enable) { external_deps += [ "power_manager:powermgr_client" ] defines += [ "STANDBY_POWER_MANAGER_ENABLE" ] } subsystem_name = "resourceschedule" part_name = "${standby_service_part_name}" } group("unittest") { testonly = true deps = [ ":mock_standby_helper_unit_test", ":mock_standby_service_unit_test", ":standby_helper_unit_test", ":standby_utils_unit_test", ] if (device_standby_plugin_enable) { deps += [ ":standby_service_unit_test" ] } }