# Copyright (c) 2022 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/background_task_mgr/bgtaskmgr.gni") module_output_path = "background_task_mgr/unittest" ohos_unittest("bgtask_unit_test") { module_out_path = module_output_path cflags = [ "-Dprivate=public", "-Dprotected=public", ] cflags_cc = [] include_dirs = [ "${bgtaskmgr_services_path}/transient_task/include", "${bgtaskmgr_services_path}/core/inlcude", "${bgtaskmgr_services_path}/test/unittest/mock/include", "${bgtaskmgr_interfaces_path}/innerkits/transient_task/include", "//third_party/icu/icu4c/source/i18n", ] sources = [ "background_task_mgr_service_test.cpp", "bg_continuous_task_mgr_test.cpp", "bg_transient_task_mgr_test.cpp", "mock/mock_bundle_manager_helper.cpp", "mock/mock_event_handler.cpp", "mock/mock_ipc.cpp", "mock/mock_notification_tools.cpp", ] deps = [ "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits", "${bgtaskmgr_services_path}:bgtaskmgr_service_static", "//third_party/googletest:gtest_main", ] external_deps = [ "ability_base:want", "ability_base:zuri", "ability_runtime:app_manager", "ability_runtime:wantagent_innerkits", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", "hisysevent:libhisysevent", "image_framework:image_native", "ipc:ipc_single", "relational_store:native_rdb", "resource_management:global_resmgr", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] if (has_os_account_part) { cflags_cc += [ "-DHAS_OS_ACCOUNT_PART" ] external_deps += [ "os_account:os_account_innerkits" ] } if (distributed_notification_enable) { cflags_cc += [ "-DDISTRIBUTED_NOTIFICATION_ENABLE" ] external_deps += [ "distributed_notification_service:ans_innerkits" ] } subsystem_name = "resourceschedule" part_name = "background_task_mgr" } ohos_unittest("efficiency_mgr_unit_test") { module_out_path = module_output_path cflags = [ "-Dprivate=public", "-Dprotected=public", ] cflags_cc = [] include_dirs = [ "${bgtaskmgr_services_path}/transient_task/include", "${bgtaskmgr_services_path}/core/inlcude", "${bgtaskmgr_interfaces_path}/innerkits/transient_task/include", "//third_party/icu/icu4c/source/i18n", ] sources = [ "bg_efficiency_resources_mgr_test.cpp", "mock/mock_bundle_manager_helper.cpp", "mock/mock_ipc.cpp", ] deps = [ "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits", "${bgtaskmgr_services_path}:bgtaskmgr_service_static", "//third_party/googletest:gtest_main", ] external_deps = [ "ability_base:want", "ability_base:zuri", "ability_runtime:app_manager", "ability_runtime:wantagent_innerkits", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", "hisysevent:libhisysevent", "image_framework:image_native", "ipc:ipc_single", "relational_store:native_rdb", "resource_management:global_resmgr", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] if (has_os_account_part) { cflags_cc += [ "-DHAS_OS_ACCOUNT_PART" ] external_deps += [ "os_account:os_account_innerkits" ] } subsystem_name = "resourceschedule" part_name = "background_task_mgr" } ohos_unittest("mock_efficiency_mgr_unit_test") { module_out_path = module_output_path cflags_cc = [ "-Dprivate=public", "-Dprotected=public", ] include_dirs = [ "${bgtaskmgr_services_path}/common/include", "${bgtaskmgr_services_path}/efficiency_resources/inlcude", "${bgtaskmgr_services_path}/core/include", "${bgtaskmgr_services_path}/test/unittest/mock/include", ] sources = [ "mock/mock_bundle_manager_helper.cpp", "mock_efficiency_resources_mgr_test.cpp", ] deps = [ "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits", "${bgtaskmgr_services_path}:bgtaskmgr_service_static", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", ] external_deps = [ "ability_base:want", "ability_base:zuri", "ability_runtime:app_manager", "ability_runtime:wantagent_innerkits", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", "hisysevent:libhisysevent", "image_framework:image_native", "ipc:ipc_single", "relational_store:native_rdb", "resource_management:global_resmgr", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] if (has_os_account_part) { cflags_cc += [ "-DHAS_OS_ACCOUNT_PART" ] external_deps += [ "os_account:os_account_innerkits" ] } subsystem_name = "resourceschedule" part_name = "background_task_mgr" } ohos_unittest("bgtask_manager_unit_test") { module_out_path = module_output_path cflags_cc = [ "-Dprivate=public", "-Dprotected=public", ] include_dirs = [ "${bgtaskmgr_services_path}/transient_task/include", "${bgtaskmgr_services_path}/core/inlcude", "${bgtaskmgr_services_path}/test/unittest/mock/include", "${bgtaskmgr_interfaces_path}/innerkits/transient_task/include", "//third_party/icu/icu4c/source/i18n", ] sources = [ "bgtask_manager_unit_test.cpp", "mock/mock_bundle_manager_helper.cpp", "mock/mock_ipc_skeleton.cpp", "mock/mock_transient_task_mgr.cpp", ] deps = [ "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits", "${bgtaskmgr_services_path}:bgtaskmgr_service_static", "//third_party/googletest:gtest_main", ] external_deps = [ "ability_base:configuration", "ability_base:want", "ability_base:zuri", "ability_runtime:app_manager", "ability_runtime:wantagent_innerkits", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", "hisysevent:libhisysevent", "image_framework:image_native", "ipc:ipc_single", "relational_store:native_rdb", "resource_management:global_resmgr", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] if (has_os_account_part) { cflags_cc += [ "-DHAS_OS_ACCOUNT_PART" ] external_deps += [ "os_account:os_account_innerkits" ] } if (distributed_notification_enable) { cflags_cc += [ "-DDISTRIBUTED_NOTIFICATION_ENABLE" ] external_deps += [ "distributed_notification_service:ans_innerkits" ] sources += [ "mock/mock_notification_helper.cpp" ] } subsystem_name = "resourceschedule" part_name = "background_task_mgr" } ohos_unittest("bgtask_misc_unit_test") { module_out_path = module_output_path cflags_cc = [ "-Dprivate=public", "-Dprotected=public", ] include_dirs = [ "${bgtaskmgr_services_path}/transient_task/include", "${bgtaskmgr_services_path}/core/inlcude", "${bgtaskmgr_interfaces_path}/innerkits/transient_task/include", "//third_party/icu/icu4c/source/i18n", ] sources = [ "bgtask_misc_unit_test.cpp" ] deps = [ "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits", "${bgtaskmgr_services_path}:bgtaskmgr_service_static", "//third_party/googletest:gtest_main", ] external_deps = [ "ability_base:base", "ability_base:configuration", "ability_base:want", "ability_base:zuri", "ability_runtime:app_manager", "ability_runtime:wantagent_innerkits", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", "hisysevent:libhisysevent", "image_framework:image_native", "ipc:ipc_single", "relational_store:native_rdb", "resource_management:global_resmgr", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] if (has_os_account_part) { cflags_cc += [ "-DHAS_OS_ACCOUNT_PART" ] external_deps += [ "os_account:os_account_innerkits" ] } if (distributed_notification_enable) { cflags_cc += [ "-DDISTRIBUTED_NOTIFICATION_ENABLE" ] external_deps += [ "distributed_notification_service:ans_innerkits" ] sources += [ "mock/mock_notification_helper.cpp" ] } subsystem_name = "resourceschedule" part_name = "background_task_mgr" } group("unittest") { testonly = true deps = [ ":bgtask_manager_unit_test", ":bgtask_misc_unit_test", ":bgtask_unit_test", ":efficiency_mgr_unit_test", ":mock_efficiency_mgr_unit_test", "bgtask_manager_abnormal_unit_test:bgtask_manager_abnormal_unit_test", ] }