1# Copyright (c) 2024 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("//base/notification/distributed_notification_service/notification.gni") 15import("//build/ohos.gni") 16import("//build/test.gni") 17 18module_output_path = 19 "${component_name}/distributed_notification_service/unittest" 20 21ohos_unittest("reminder_unit_test") { 22 module_out_path = module_output_path 23 include_dirs = [ 24 ".", 25 "include", 26 "/${services_path}/ans/include", 27 "/${services_path}/reminder/include", 28 "${services_path}/reminder/test/unittest/mock/include", 29 ] 30 31 defines = [] 32 33 sources = [ 34 "mock/mock_access_token_helper.cpp", 35 "mock/mock_bundle_manager_helper.cpp", 36 "mock/mock_ipc.cpp", 37 "reminder_data_manager_test.cpp", 38 ] 39 40 deps = [ 41 "${frameworks_module_ans_path}:ans_innerkits", 42 "${frameworks_module_reminder_path}:reminder_innerkits", 43 "${services_path}/reminder:libreminder", 44 ] 45 46 if (distributed_notification_supported) { 47 defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] 48 deps += [ "${services_path}/distributed:libans_distributed" ] 49 include_dirs += [ "${services_path}/distributed/include" ] 50 } 51 52 external_deps = [ 53 "ability_base:want", 54 "ability_base:zuri", 55 "ability_runtime:ability_manager", 56 "ability_runtime:abilitykit_native", 57 "ability_runtime:app_manager", 58 "ability_runtime:wantagent_innerkits", 59 "access_token:libaccesstoken_sdk", 60 "bundle_framework:appexecfwk_base", 61 "bundle_framework:appexecfwk_core", 62 "c_utils:utils", 63 "common_event_service:cesfwk_innerkits", 64 "data_share:datashare_common", 65 "data_share:datashare_consumer", 66 "device_manager:devicemanagersdk", 67 "eventhandler:libeventhandler", 68 "ffrt:libffrt", 69 "hilog:libhilog", 70 "hitrace:hitrace_meter", 71 "hitrace:libhitracechain", 72 "image_framework:image_native", 73 "ipc:ipc_core", 74 "kv_store:distributeddata_inner", 75 "os_account:os_account_innerkits", 76 "relational_store:native_rdb", 77 "safwk:system_ability_fwk", 78 "samgr:samgr_proxy", 79 "time_service:time_client", 80 ] 81 82 if (device_usage) { 83 external_deps += [ "device_usage_statistics:usagestatsinner" ] 84 defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] 85 } 86 87 if (player_framework) { 88 external_deps += [ "player_framework:media_client" ] 89 defines += [ "PLAYER_FRAMEWORK_ENABLE" ] 90 } 91 92 cflags = [ 93 "-Dprivate=public", 94 "-Dprotected=public", 95 ] 96 if (hisysevent_usage) { 97 external_deps += [ "hisysevent:libhisysevent" ] 98 cflags += [ "-DHAS_HISYSEVENT_PART" ] 99 } 100 101 sanitize = { 102 integer_overflow = true 103 ubsan = true 104 boundary_sanitize = true 105 cfi = true 106 cfi_cross_dso = true 107 debug = false 108 } 109 110 subsystem_name = "${subsystem_name}" 111 part_name = "${component_name}" 112} 113 114ohos_unittest("reminder_agent_service_test") { 115 sanitize = { 116 integer_overflow = true 117 ubsan = true 118 boundary_sanitize = true 119 cfi = true 120 cfi_cross_dso = true 121 debug = false 122 } 123 module_out_path = module_output_path 124 include_dirs = [ 125 ".", 126 "include", 127 "/${services_path}/reminder/include", 128 "${services_path}/reminder/test/unittest/mock/include", 129 ] 130 131 defines = [] 132 133 sources = [ 134 "${services_path}/reminder/src/reminder_agent_service.cpp", 135 "mock/mock_accesstoken_kit.cpp", 136 "mock/mock_notification_helper.cpp", 137 "mock/mock_os_account_manager.cpp", 138 "mock/mock_reminder_bundle_manager_helper.cpp", 139 "mock/mock_reminder_data_manager.cpp", 140 "reminder_agent_service_test.cpp", 141 ] 142 143 deps = [ 144 "${frameworks_module_ans_path}:ans_innerkits", 145 "${frameworks_module_reminder_path}:reminder_innerkits", 146 ] 147 148 external_deps = [ 149 "ability_base:zuri", 150 "ability_runtime:abilitykit_native", 151 "access_token:libaccesstoken_sdk", 152 "c_utils:utils", 153 "data_share:datashare_common", 154 "ffrt:libffrt", 155 "hilog:libhilog", 156 "ipc:ipc_core", 157 "os_account:os_account_innerkits", 158 "relational_store:native_rdb", 159 "samgr:samgr_proxy", 160 "time_service:time_client", 161 ] 162 163 cflags = [ 164 "-Dprivate=public", 165 "-Dprotected=public", 166 ] 167 168 subsystem_name = "${subsystem_name}" 169 part_name = "${component_name}" 170} 171 172ohos_unittest("reminder_access_token_helper_test") { 173 module_out_path = module_output_path 174 include_dirs = [ 175 ".", 176 "include", 177 "/${services_path}/reminder/include", 178 "${services_path}/reminder/test/unittest/mock/include", 179 ] 180 181 sources = [ 182 "${services_path}/reminder/src/reminder_access_token_helper.cpp", 183 "${services_path}/reminder/test/unittest/mock/mock_accesstoken_kit.cpp", 184 "access_token_helper_test/access_token_helper_test.cpp", 185 ] 186 187 deps = [ "${frameworks_module_reminder_path}:reminder_innerkits" ] 188 189 external_deps = [ 190 "ability_base:want", 191 "ability_base:zuri", 192 "ability_runtime:abilitykit_native", 193 "ability_runtime:app_manager", 194 "ability_runtime:wantagent_innerkits", 195 "access_token:libaccesstoken_sdk", 196 "access_token:libtokenid_sdk", 197 "bundle_framework:appexecfwk_base", 198 "bundle_framework:appexecfwk_core", 199 "c_utils:utils", 200 "common_event_service:cesfwk_innerkits", 201 "eventhandler:libeventhandler", 202 "hilog:libhilog", 203 "hitrace:hitrace_meter", 204 "hitrace:libhitracechain", 205 "image_framework:image_native", 206 "init:libbegetutil", 207 "ipc:ipc_core", 208 "kv_store:distributeddata_inner", 209 "os_account:os_account_innerkits", 210 "relational_store:native_rdb", 211 "safwk:system_ability_fwk", 212 "samgr:samgr_proxy", 213 "time_service:time_client", 214 ] 215 216 if (player_framework) { 217 external_deps += [ "player_framework:media_client" ] 218 defines = [ "PLAYER_FRAMEWORK_ENABLE" ] 219 } 220 cflags = [ 221 "-Dprivate=public", 222 "-Dprotected=public", 223 ] 224 subsystem_name = "${subsystem_name}" 225 part_name = "${component_name}" 226} 227 228ohos_unittest("reminder_bundle_manager_helper_branch_test") { 229 module_out_path = module_output_path 230 include_dirs = [ 231 ".", 232 "include", 233 "/${services_path}/reminder/include", 234 "${services_path}/reminder/test/unittest/mock/include", 235 "bundle_manager_helper_branch_test/include", 236 ] 237 238 sources = [ 239 "bundle_manager_helper_branch_test/bundle_manager_helper_branch_test.cpp", 240 "bundle_manager_helper_branch_test/mock_service_registry.cpp", 241 ] 242 243 deps = [ 244 "${frameworks_module_reminder_path}:reminder_innerkits", 245 "${services_path}/reminder:libreminder", 246 ] 247 248 external_deps = [ 249 "ability_base:want", 250 "ability_base:zuri", 251 "ability_runtime:abilitykit_native", 252 "ability_runtime:app_manager", 253 "ability_runtime:wantagent_innerkits", 254 "access_token:libaccesstoken_sdk", 255 "bundle_framework:appexecfwk_base", 256 "bundle_framework:appexecfwk_core", 257 "c_utils:utils", 258 "common_event_service:cesfwk_innerkits", 259 "eventhandler:libeventhandler", 260 "hilog:libhilog", 261 "hitrace:hitrace_meter", 262 "hitrace:libhitracechain", 263 "image_framework:image_native", 264 "ipc:ipc_core", 265 "kv_store:distributeddata_inner", 266 "os_account:os_account_innerkits", 267 "relational_store:native_rdb", 268 "safwk:system_ability_fwk", 269 "samgr:samgr_proxy", 270 "time_service:time_client", 271 ] 272 273 if (player_framework) { 274 external_deps += [ "player_framework:media_client" ] 275 defines = [ "PLAYER_FRAMEWORK_ENABLE" ] 276 } 277 cflags = [ 278 "-Dprivate=public", 279 "-Dprotected=public", 280 ] 281 subsystem_name = "${subsystem_name}" 282 part_name = "${component_name}" 283} 284 285ohos_unittest("reminder_os_account_manager_helper_test") { 286 module_out_path = module_output_path 287 include_dirs = [ 288 ".", 289 "include", 290 "/${services_path}/reminder/include", 291 "${services_path}/reminder/test/unittest/mock/include", 292 ] 293 294 sources = [ "os_account_manager_helper_test.cpp" ] 295 296 deps = [ 297 "${frameworks_module_reminder_path}:reminder_innerkits", 298 "${services_path}/reminder:libreminder", 299 ] 300 301 external_deps = [ 302 "ability_base:want", 303 "ability_base:zuri", 304 "ability_runtime:abilitykit_native", 305 "ability_runtime:app_manager", 306 "ability_runtime:wantagent_innerkits", 307 "access_token:libaccesstoken_sdk", 308 "bundle_framework:appexecfwk_base", 309 "bundle_framework:appexecfwk_core", 310 "c_utils:utils", 311 "common_event_service:cesfwk_innerkits", 312 "eventhandler:libeventhandler", 313 "hilog:libhilog", 314 "hitrace:hitrace_meter", 315 "hitrace:libhitracechain", 316 "image_framework:image_native", 317 "ipc:ipc_core", 318 "kv_store:distributeddata_inner", 319 "os_account:os_account_innerkits", 320 "relational_store:native_rdb", 321 "safwk:system_ability_fwk", 322 "samgr:samgr_proxy", 323 "time_service:time_client", 324 ] 325 326 if (player_framework) { 327 external_deps += [ "player_framework:media_client" ] 328 defines = [ "PLAYER_FRAMEWORK_ENABLE" ] 329 } 330 cflags = [ 331 "-Dprivate=public", 332 "-Dprotected=public", 333 ] 334 subsystem_name = "${subsystem_name}" 335 part_name = "${component_name}" 336} 337 338ohos_unittest("reminder_service_test") { 339 sanitize = { 340 integer_overflow = true 341 ubsan = true 342 boundary_sanitize = true 343 cfi = true 344 cfi_cross_dso = true 345 debug = false 346 } 347 module_out_path = module_output_path 348 include_dirs = [ 349 ".", 350 "include", 351 "/${services_path}/reminder/include", 352 "${services_path}/reminder/test/unittest/mock/include", 353 ] 354 355 defines = [] 356 357 sources = [ 358 "mock/mock_access_token_helper.cpp", 359 "mock/mock_accesstoken_kit.cpp", 360 "mock/mock_bundle_manager_helper.cpp", 361 "mock/mock_bundle_mgr.cpp", 362 "mock/mock_ipc.cpp", 363 "mock/mock_os_account_manager.cpp", 364 "reminder_store_test.cpp", 365 ] 366 367 deps = [ 368 "${frameworks_module_reminder_path}:reminder_innerkits", 369 "${services_path}/reminder:libreminder", 370 ] 371 372 if (distributed_notification_supported) { 373 defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] 374 deps += [ "${services_path}/distributed:libans_distributed" ] 375 include_dirs += [ "${services_path}/distributed/include" ] 376 } 377 378 external_deps = [ 379 "ability_base:base", 380 "ability_base:want", 381 "ability_base:zuri", 382 "ability_runtime:abilitykit_native", 383 "ability_runtime:app_manager", 384 "ability_runtime:wantagent_innerkits", 385 "access_token:libaccesstoken_sdk", 386 "bundle_framework:appexecfwk_base", 387 "bundle_framework:appexecfwk_core", 388 "c_utils:utils", 389 "common_event_service:cesfwk_innerkits", 390 "device_manager:devicemanagersdk", 391 "eventhandler:libeventhandler", 392 "ffrt:libffrt", 393 "hilog:libhilog", 394 "hitrace:hitrace_meter", 395 "hitrace:libhitracechain", 396 "image_framework:image_native", 397 "ipc:ipc_core", 398 "kv_store:distributeddata_inner", 399 "os_account:os_account_innerkits", 400 "relational_store:native_rdb", 401 "safwk:system_ability_fwk", 402 "samgr:samgr_proxy", 403 "time_service:time_client", 404 ] 405 406 if (device_usage) { 407 external_deps += [ "device_usage_statistics:usagestatsinner" ] 408 defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] 409 } 410 411 if (player_framework) { 412 external_deps += [ "player_framework:media_client" ] 413 defines += [ "PLAYER_FRAMEWORK_ENABLE" ] 414 } 415 416 cflags = [ 417 "-Dprivate=public", 418 "-Dprotected=public", 419 ] 420 if (hisysevent_usage) { 421 external_deps += [ "hisysevent:libhisysevent" ] 422 cflags += [ "-DHAS_HISYSEVENT_PART" ] 423 } 424 425 subsystem_name = "${subsystem_name}" 426 part_name = "${component_name}" 427} 428 429ohos_unittest("reminder_agent_service_ability_test") { 430 sanitize = { 431 integer_overflow = true 432 ubsan = true 433 boundary_sanitize = true 434 cfi = true 435 cfi_cross_dso = true 436 debug = false 437 } 438 module_out_path = module_output_path 439 include_dirs = [ 440 ".", 441 "include", 442 "/${services_path}/reminder/include", 443 "${services_path}/reminder/test/unittest/mock/include", 444 ] 445 446 defines = [] 447 448 sources = [ "reminder_agent_service_ability_test.cpp" ] 449 450 deps = [ 451 "${frameworks_module_reminder_path}:reminder_innerkits", 452 "${services_path}/reminder:libreminder", 453 ] 454 455 if (distributed_notification_supported) { 456 defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] 457 deps += [ "${services_path}/distributed:libans_distributed" ] 458 include_dirs += [ "${services_path}/distributed/include" ] 459 } 460 461 external_deps = [ 462 "ability_base:base", 463 "ability_base:want", 464 "ability_base:zuri", 465 "ability_runtime:abilitykit_native", 466 "ability_runtime:app_manager", 467 "ability_runtime:wantagent_innerkits", 468 "access_token:libaccesstoken_sdk", 469 "bundle_framework:appexecfwk_base", 470 "bundle_framework:appexecfwk_core", 471 "c_utils:utils", 472 "common_event_service:cesfwk_innerkits", 473 "data_share:datashare_common", 474 "data_share:datashare_consumer", 475 "device_manager:devicemanagersdk", 476 "eventhandler:libeventhandler", 477 "ffrt:libffrt", 478 "hilog:libhilog", 479 "hitrace:hitrace_meter", 480 "hitrace:libhitracechain", 481 "image_framework:image_native", 482 "ipc:ipc_core", 483 "kv_store:distributeddata_inner", 484 "os_account:os_account_innerkits", 485 "relational_store:native_rdb", 486 "safwk:system_ability_fwk", 487 "samgr:samgr_proxy", 488 "time_service:time_client", 489 ] 490 491 if (device_usage) { 492 external_deps += [ "device_usage_statistics:usagestatsinner" ] 493 defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] 494 } 495 496 if (player_framework) { 497 external_deps += [ "player_framework:media_client" ] 498 defines += [ "PLAYER_FRAMEWORK_ENABLE" ] 499 } 500 501 cflags = [ 502 "-Dprivate=public", 503 "-Dprotected=public", 504 ] 505 if (hisysevent_usage) { 506 external_deps += [ "hisysevent:libhisysevent" ] 507 cflags += [ "-DHAS_HISYSEVENT_PART" ] 508 } 509 510 subsystem_name = "${subsystem_name}" 511 part_name = "${component_name}" 512} 513 514group("unittest") { 515 testonly = true 516 deps = [ 517 ":reminder_access_token_helper_test", 518 ":reminder_agent_service_ability_test", 519 ":reminder_agent_service_test", 520 ":reminder_bundle_manager_helper_branch_test", 521 ":reminder_os_account_manager_helper_test", 522 ":reminder_service_test", 523 ":reminder_unit_test", 524 ] 525} 526