1# Copyright (c) 2022 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import("//build/ohos.gni") 15import("//build/test.gni") 16import("//foundation/resourceschedule/background_task_mgr/bgtaskmgr.gni") 17 18module_output_path = "background_task_mgr/background_task_mgr" 19 20ohos_unittest("bgtask_unit_test") { 21 module_out_path = module_output_path 22 23 cflags = [ 24 "-Dprivate=public", 25 "-Dprotected=public", 26 ] 27 28 cflags_cc = [] 29 include_dirs = [ 30 "${bgtaskmgr_services_path}/transient_task/include", 31 "${bgtaskmgr_services_path}/core/inlcude", 32 "${bgtaskmgr_services_path}/test/unittest/mock/include", 33 "${bgtaskmgr_interfaces_path}/innerkits/transient_task/include", 34 ] 35 36 sources = [ 37 "background_task_mgr_service_test.cpp", 38 "bg_continuous_task_mgr_test.cpp", 39 "bg_transient_task_mgr_test.cpp", 40 "mock/mock_bundle_manager_helper.cpp", 41 "mock/mock_event_handler.cpp", 42 "mock/mock_ipc.cpp", 43 "mock/mock_notification_tools.cpp", 44 ] 45 46 deps = [ 47 "${bgtaskmgr_interfaces_path}/innerkits:background_task_mgr_proxy", 48 "${bgtaskmgr_interfaces_path}/innerkits:background_task_mgr_stub", 49 "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits", 50 "${bgtaskmgr_services_path}:bgtaskmgr_service_static", 51 ] 52 53 external_deps = [ 54 "ability_base:want", 55 "ability_base:zuri", 56 "ability_runtime:app_manager", 57 "ability_runtime:wantagent_innerkits", 58 "bundle_framework:appexecfwk_base", 59 "bundle_framework:appexecfwk_core", 60 "c_utils:utils", 61 "common_event_service:cesfwk_innerkits", 62 "eventhandler:libeventhandler", 63 "googletest:gtest_main", 64 "hilog:libhilog", 65 "hisysevent:libhisysevent", 66 "hitrace:libhitracechain", 67 "i18n:intl_util", 68 "image_framework:image_native", 69 "ipc:ipc_single", 70 "relational_store:native_rdb", 71 "resource_management:global_resmgr", 72 "safwk:system_ability_fwk", 73 "samgr:samgr_proxy", 74 ] 75 76 if (has_os_account_part) { 77 cflags_cc += [ "-DHAS_OS_ACCOUNT_PART" ] 78 external_deps += [ "os_account:os_account_innerkits" ] 79 } 80 81 if (distributed_notification_enable) { 82 cflags_cc += [ "-DDISTRIBUTED_NOTIFICATION_ENABLE" ] 83 external_deps += [ "distributed_notification_service:ans_innerkits" ] 84 } 85 86 subsystem_name = "resourceschedule" 87 part_name = "background_task_mgr" 88} 89 90ohos_unittest("efficiency_mgr_unit_test") { 91 module_out_path = module_output_path 92 93 cflags = [ 94 "-Dprivate=public", 95 "-Dprotected=public", 96 ] 97 98 cflags_cc = [] 99 include_dirs = [ 100 "${bgtaskmgr_services_path}/transient_task/include", 101 "${bgtaskmgr_services_path}/core/inlcude", 102 "${bgtaskmgr_interfaces_path}/innerkits/transient_task/include", 103 ] 104 105 sources = [ 106 "bg_efficiency_resources_mgr_test.cpp", 107 "mock/mock_bundle_manager_helper.cpp", 108 "mock/mock_ipc.cpp", 109 ] 110 111 deps = [ 112 "${bgtaskmgr_interfaces_path}/innerkits:background_task_mgr_proxy", 113 "${bgtaskmgr_interfaces_path}/innerkits:background_task_mgr_stub", 114 "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits", 115 "${bgtaskmgr_services_path}:bgtaskmgr_service_static", 116 ] 117 118 external_deps = [ 119 "ability_base:want", 120 "ability_base:zuri", 121 "ability_runtime:app_manager", 122 "ability_runtime:wantagent_innerkits", 123 "bundle_framework:appexecfwk_base", 124 "bundle_framework:appexecfwk_core", 125 "c_utils:utils", 126 "common_event_service:cesfwk_innerkits", 127 "eventhandler:libeventhandler", 128 "googletest:gtest_main", 129 "hilog:libhilog", 130 "hisysevent:libhisysevent", 131 "hitrace:libhitracechain", 132 "i18n:intl_util", 133 "image_framework:image_native", 134 "ipc:ipc_single", 135 "relational_store:native_rdb", 136 "resource_management:global_resmgr", 137 "safwk:system_ability_fwk", 138 "samgr:samgr_proxy", 139 ] 140 141 if (has_os_account_part) { 142 cflags_cc += [ "-DHAS_OS_ACCOUNT_PART" ] 143 external_deps += [ "os_account:os_account_innerkits" ] 144 } 145 146 subsystem_name = "resourceschedule" 147 part_name = "background_task_mgr" 148} 149 150ohos_unittest("mock_efficiency_mgr_unit_test") { 151 module_out_path = module_output_path 152 cflags_cc = [ 153 "-Dprivate=public", 154 "-Dprotected=public", 155 ] 156 include_dirs = [ 157 "${bgtaskmgr_services_path}/common/include", 158 "${bgtaskmgr_services_path}/efficiency_resources/inlcude", 159 "${bgtaskmgr_services_path}/core/include", 160 "${bgtaskmgr_services_path}/test/unittest/mock/include", 161 ] 162 163 sources = [ 164 "mock/mock_bundle_manager_helper.cpp", 165 "mock_efficiency_resources_mgr_test.cpp", 166 ] 167 168 deps = [ 169 "${bgtaskmgr_interfaces_path}/innerkits:background_task_mgr_proxy", 170 "${bgtaskmgr_interfaces_path}/innerkits:background_task_mgr_stub", 171 "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits", 172 "${bgtaskmgr_services_path}:bgtaskmgr_service_static", 173 ] 174 175 external_deps = [ 176 "ability_base:want", 177 "ability_base:zuri", 178 "ability_runtime:app_manager", 179 "ability_runtime:wantagent_innerkits", 180 "bundle_framework:appexecfwk_base", 181 "bundle_framework:appexecfwk_core", 182 "c_utils:utils", 183 "common_event_service:cesfwk_innerkits", 184 "eventhandler:libeventhandler", 185 "googletest:gmock_main", 186 "googletest:gtest_main", 187 "hilog:libhilog", 188 "hisysevent:libhisysevent", 189 "hitrace:libhitracechain", 190 "image_framework:image_native", 191 "ipc:ipc_single", 192 "relational_store:native_rdb", 193 "resource_management:global_resmgr", 194 "safwk:system_ability_fwk", 195 "samgr:samgr_proxy", 196 ] 197 198 if (has_os_account_part) { 199 cflags_cc += [ "-DHAS_OS_ACCOUNT_PART" ] 200 external_deps += [ "os_account:os_account_innerkits" ] 201 } 202 203 subsystem_name = "resourceschedule" 204 part_name = "background_task_mgr" 205} 206 207ohos_unittest("bgtask_manager_unit_test") { 208 module_out_path = module_output_path 209 cflags_cc = [ 210 "-Dprivate=public", 211 "-Dprotected=public", 212 ] 213 214 sanitize = { 215 cfi = true 216 cfi_cross_dso = true 217 debug = false 218 } 219 220 include_dirs = [ 221 "${bgtaskmgr_services_path}/transient_task/include", 222 "${bgtaskmgr_services_path}/core/inlcude", 223 "${bgtaskmgr_services_path}/test/unittest/mock/include", 224 "${bgtaskmgr_interfaces_path}/innerkits/transient_task/include", 225 "${target_gen_dir}", 226 ] 227 228 sources = [ 229 "bgtask_manager_unit_test.cpp", 230 "mock/mock_bundle_manager_helper.cpp", 231 "mock/mock_ipc_skeleton.cpp", 232 "mock/mock_transient_task_mgr.cpp", 233 ] 234 235 deps = [ 236 "${bgtaskmgr_interfaces_path}/innerkits:background_task_mgr_proxy", 237 "${bgtaskmgr_interfaces_path}/innerkits:background_task_mgr_stub", 238 "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits", 239 "${bgtaskmgr_services_path}:bgtaskmgr_service_static", 240 ] 241 242 external_deps = [ 243 "ability_base:configuration", 244 "ability_base:want", 245 "ability_base:zuri", 246 "ability_runtime:app_manager", 247 "ability_runtime:wantagent_innerkits", 248 "bundle_framework:appexecfwk_base", 249 "bundle_framework:appexecfwk_core", 250 "c_utils:utils", 251 "common_event_service:cesfwk_innerkits", 252 "eventhandler:libeventhandler", 253 "googletest:gtest_main", 254 "hilog:libhilog", 255 "hisysevent:libhisysevent", 256 "hitrace:libhitracechain", 257 "i18n:intl_util", 258 "image_framework:image_native", 259 "ipc:ipc_single", 260 "relational_store:native_rdb", 261 "resource_management:global_resmgr", 262 "safwk:system_ability_fwk", 263 "samgr:samgr_proxy", 264 ] 265 266 if (has_os_account_part) { 267 cflags_cc += [ "-DHAS_OS_ACCOUNT_PART" ] 268 external_deps += [ "os_account:os_account_innerkits" ] 269 } 270 271 if (distributed_notification_enable) { 272 cflags_cc += [ "-DDISTRIBUTED_NOTIFICATION_ENABLE" ] 273 external_deps += [ "distributed_notification_service:ans_innerkits" ] 274 sources += [ "mock/mock_notification_helper.cpp" ] 275 } 276 277 subsystem_name = "resourceschedule" 278 part_name = "background_task_mgr" 279} 280 281ohos_unittest("bgtask_misc_unit_test") { 282 module_out_path = module_output_path 283 cflags_cc = [ 284 "-Dprivate=public", 285 "-Dprotected=public", 286 ] 287 288 include_dirs = [ 289 "${bgtaskmgr_services_path}/transient_task/include", 290 "${bgtaskmgr_services_path}/core/inlcude", 291 "${bgtaskmgr_interfaces_path}/innerkits/transient_task/include", 292 ] 293 294 sources = [ "bgtask_misc_unit_test.cpp" ] 295 296 deps = [ 297 "${bgtaskmgr_interfaces_path}/innerkits:background_task_mgr_proxy", 298 "${bgtaskmgr_interfaces_path}/innerkits:background_task_mgr_stub", 299 "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits", 300 "${bgtaskmgr_services_path}:bgtaskmgr_service_static", 301 ] 302 303 external_deps = [ 304 "ability_base:base", 305 "ability_base:configuration", 306 "ability_base:want", 307 "ability_base:zuri", 308 "ability_runtime:app_manager", 309 "ability_runtime:wantagent_innerkits", 310 "bundle_framework:appexecfwk_base", 311 "bundle_framework:appexecfwk_core", 312 "c_utils:utils", 313 "common_event_service:cesfwk_innerkits", 314 "eventhandler:libeventhandler", 315 "googletest:gtest_main", 316 "hilog:libhilog", 317 "hisysevent:libhisysevent", 318 "hitrace:libhitracechain", 319 "i18n:intl_util", 320 "image_framework:image_native", 321 "ipc:ipc_single", 322 "relational_store:native_rdb", 323 "resource_management:global_resmgr", 324 "safwk:system_ability_fwk", 325 "samgr:samgr_proxy", 326 ] 327 328 if (has_os_account_part) { 329 cflags_cc += [ "-DHAS_OS_ACCOUNT_PART" ] 330 external_deps += [ "os_account:os_account_innerkits" ] 331 } 332 333 if (distributed_notification_enable) { 334 cflags_cc += [ "-DDISTRIBUTED_NOTIFICATION_ENABLE" ] 335 external_deps += [ "distributed_notification_service:ans_innerkits" ] 336 sources += [ "mock/mock_notification_helper.cpp" ] 337 } 338 339 subsystem_name = "resourceschedule" 340 part_name = "background_task_mgr" 341} 342 343group("unittest") { 344 testonly = true 345 346 deps = [ 347 ":bgtask_manager_unit_test", 348 ":bgtask_misc_unit_test", 349 ":bgtask_unit_test", 350 ":efficiency_mgr_unit_test", 351 ":mock_efficiency_mgr_unit_test", 352 "bgtask_manager_abnormal_unit_test:bgtask_manager_abnormal_unit_test", 353 ] 354} 355