1# Copyright (c) 2021-2022 Huawei Device Co., Ltd.module_private_config 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/test.gni") 15import("../../../../batterystats.gni") 16 17module_output_path = "battery_statistics/battery_statistics" 18 19config("module_private_config") { 20 visibility = [ ":*" ] 21 22 include_dirs = [ 23 "${batterystats_root_path}/test/unittest/include", 24 "${batterystats_root_path}/test/unittest/include/clienttest", 25 "${batterystats_service_native}/include", 26 ] 27} 28 29config("module_mock_private_config") { 30 include_dirs = [ 31 "${batterystats_root_path}/test/unittest/include/clienttest/mock", 32 "${batterystats_root_path}/test/unittest/mock/include", 33 ] 34} 35 36deps_ex = [ 37 "ability_base:base", 38 "ability_base:want", 39 "call_manager:tel_call_manager_api", 40 "common_event_service:cesfwk_innerkits", 41 "config_policy:configpolicy_util", 42 "cJSON:cjson", 43 "c_utils:utils", 44 "display_manager:displaymgr", 45 "hisysevent:libhisysevent", 46 "hisysevent:libhisyseventmanager", 47 "hilog:libhilog", 48 "ipc:ipc_core", 49 "power_manager:powermgr_client", 50 "safwk:system_ability_fwk", 51 "samgr:samgr_proxy", 52] 53 54############################service_test############################# 55ohos_unittest("stats_service_test") { 56 module_out_path = module_output_path 57 58 sanitize = { 59 cfi = true 60 cfi_cross_dso = true 61 debug = false 62 } 63 64 sources = [ "stats_service_test.cpp" ] 65 66 configs = [ 67 "${batterystats_utils_path}:batterystats_utils_config", 68 ":module_private_config", 69 "${batterystats_utils_path}:coverage_flags", 70 ] 71 72 deps = [ 73 "${batterystats_service_path}:batterystats_service", 74 "${batterystats_service_path}:batterystats_stub", 75 ] 76 77 external_deps = deps_ex 78 external_deps += [ "googletest:gtest_main" ] 79} 80 81############################service_death_test############################# 82ohos_unittest("stats_service_death_test") { 83 module_out_path = module_output_path 84 85 sanitize = { 86 cfi = true 87 cfi_cross_dso = true 88 debug = false 89 } 90 91 sources = [ 92 "${batterystats_root_path}/test/unittest/mock/source/mock_battery_stats_parser.cpp", 93 "stats_service_death_test.cpp", 94 ] 95 96 configs = [ 97 ":module_private_config", 98 "${batterystats_utils_path}:coverage_flags", 99 ] 100 101 defines = [ "STATS_SERVICE_DEATH_UT" ] 102 103 deps = [ 104 "${batterystats_inner_api}:batterystats_client", 105 "${batterystats_service_path}:batterystats_service", 106 "${batterystats_service_path}:batterystats_stub", 107 "${batterystats_utils_path}:batterystats_utils", 108 ] 109 110 external_deps = deps_ex 111 external_deps += [ "googletest:gtest_main" ] 112} 113 114############################wifi_test############################# 115ohos_unittest("stats_wifi_test") { 116 module_out_path = module_output_path 117 118 sanitize = { 119 cfi = true 120 cfi_cross_dso = true 121 debug = false 122 } 123 124 sources = [ 125 "${batterystats_service_path}/native/src/battery_stats_parser.cpp", 126 "stats_wifi_test.cpp", 127 ] 128 129 configs = [ 130 "${batterystats_utils_path}:batterystats_utils_config", 131 ":module_private_config", 132 "${batterystats_utils_path}:coverage_flags", 133 ] 134 135 deps = [ 136 "${batterystats_inner_api}:batterystats_client", 137 "${batterystats_service_path}:batterystats_service", 138 "${batterystats_utils_path}:batterystats_utils", 139 ] 140 141 external_deps = deps_ex 142 external_deps += [ 143 "googletest:gtest_main", 144 "wifi:wifi_sdk", 145 ] 146} 147 148############################camera_test############################# 149ohos_unittest("stats_camera_test") { 150 module_out_path = module_output_path 151 152 sanitize = { 153 cfi = true 154 cfi_cross_dso = true 155 debug = false 156 } 157 158 sources = [ 159 "${batterystats_service_path}/native/src/battery_stats_parser.cpp", 160 "stats_camera_test.cpp", 161 ] 162 163 configs = [ 164 "${batterystats_utils_path}:batterystats_utils_config", 165 ":module_private_config", 166 "${batterystats_utils_path}:coverage_flags", 167 ] 168 169 deps = [ 170 "${batterystats_inner_api}:batterystats_client", 171 "${batterystats_service_path}:batterystats_service", 172 "${batterystats_utils_path}:batterystats_utils", 173 ] 174 175 external_deps = deps_ex 176 external_deps += [ "googletest:gtest_main" ] 177} 178 179############################audio_test############################# 180ohos_unittest("stats_audio_test") { 181 module_out_path = module_output_path 182 183 sanitize = { 184 cfi = true 185 cfi_cross_dso = true 186 debug = false 187 } 188 189 sources = [ 190 "${batterystats_service_path}/native/src/battery_stats_parser.cpp", 191 "stats_audio_test.cpp", 192 ] 193 194 configs = [ 195 ":module_private_config", 196 "${batterystats_utils_path}:coverage_flags", 197 ] 198 199 deps = [ 200 "${batterystats_inner_api}:batterystats_client", 201 "${batterystats_service_path}:batterystats_service", 202 "${batterystats_utils_path}:batterystats_utils", 203 ] 204 205 external_deps = deps_ex 206 external_deps += [ "googletest:gtest_main" ] 207} 208 209############################powermgr_test############################# 210ohos_unittest("stats_powermgr_test") { 211 module_out_path = module_output_path 212 213 sanitize = { 214 cfi = true 215 cfi_cross_dso = true 216 debug = false 217 } 218 219 sources = [ 220 "${batterystats_service_path}/native/src/battery_stats_parser.cpp", 221 "stats_powermgr_test.cpp", 222 ] 223 224 configs = [ 225 "${batterystats_utils_path}:batterystats_utils_config", 226 ":module_private_config", 227 "${batterystats_utils_path}:coverage_flags", 228 ] 229 230 deps = [ 231 "${batterystats_inner_api}:batterystats_client", 232 "${batterystats_service_path}:batterystats_service", 233 "${batterystats_utils_path}:batterystats_utils", 234 ] 235 236 external_deps = deps_ex 237 external_deps += [ "googletest:gtest_main" ] 238} 239 240############################location_test############################# 241ohos_unittest("stats_location_test") { 242 module_out_path = module_output_path 243 244 sanitize = { 245 cfi = true 246 cfi_cross_dso = true 247 debug = false 248 } 249 250 sources = [ 251 "${batterystats_service_path}/native/src/battery_stats_parser.cpp", 252 "stats_location_test.cpp", 253 ] 254 255 configs = [ 256 "${batterystats_utils_path}:batterystats_utils_config", 257 ":module_private_config", 258 "${batterystats_utils_path}:coverage_flags", 259 ] 260 261 deps = [ 262 "${batterystats_inner_api}:batterystats_client", 263 "${batterystats_service_path}:batterystats_service", 264 "${batterystats_utils_path}:batterystats_utils", 265 ] 266 267 external_deps = deps_ex 268 external_deps += [ "googletest:gtest_main" ] 269} 270 271############################dump_test############################# 272ohos_unittest("stats_dump_test") { 273 module_out_path = module_output_path 274 275 sanitize = { 276 cfi = true 277 cfi_cross_dso = true 278 debug = false 279 } 280 281 sources = [ "stats_dump_test.cpp" ] 282 283 configs = [ 284 "${batterystats_utils_path}:batterystats_utils_config", 285 ":module_private_config", 286 "${batterystats_utils_path}:coverage_flags", 287 ] 288 289 deps = [ 290 "${batterystats_inner_api}:batterystats_client", 291 "${batterystats_service_path}:batterystats_service", 292 "${batterystats_utils_path}:batterystats_utils", 293 ] 294 295 external_deps = deps_ex 296 external_deps += [ "googletest:gtest_main" ] 297} 298 299############################display_test############################# 300ohos_unittest("stats_display_test") { 301 module_out_path = module_output_path 302 303 sanitize = { 304 cfi = true 305 cfi_cross_dso = true 306 debug = false 307 } 308 309 sources = [ 310 "${batterystats_service_path}/native/src/battery_stats_parser.cpp", 311 "stats_display_test.cpp", 312 ] 313 314 configs = [ 315 ":module_private_config", 316 "${batterystats_utils_path}:coverage_flags", 317 ] 318 319 deps = [ 320 "${batterystats_inner_api}:batterystats_client", 321 "${batterystats_service_path}:batterystats_service", 322 "${batterystats_utils_path}:batterystats_utils", 323 ] 324 325 external_deps = deps_ex 326 external_deps += [ "googletest:gtest_main" ] 327} 328 329############################phone_test############################# 330ohos_unittest("stats_phone_test") { 331 module_out_path = module_output_path 332 333 sanitize = { 334 cfi = true 335 cfi_cross_dso = true 336 debug = false 337 } 338 339 sources = [ 340 "${batterystats_service_path}/native/src/battery_stats_parser.cpp", 341 "stats_phone_test.cpp", 342 ] 343 344 configs = [ 345 ":module_private_config", 346 "${batterystats_utils_path}:coverage_flags", 347 ] 348 349 deps = [ 350 "${batterystats_inner_api}:batterystats_client", 351 "${batterystats_service_path}:batterystats_service", 352 "${batterystats_utils_path}:batterystats_utils", 353 ] 354 355 external_deps = deps_ex 356 357 external_deps += [ "googletest:gtest_main" ] 358} 359 360############################bluetooth_test############################# 361ohos_unittest("stats_bluetooth_test") { 362 module_out_path = module_output_path 363 364 sanitize = { 365 cfi = true 366 cfi_cross_dso = true 367 debug = false 368 } 369 370 sources = [ 371 "${batterystats_service_path}/native/src/battery_stats_parser.cpp", 372 "stats_bluetooth_test.cpp", 373 ] 374 375 configs = [ 376 ":module_private_config", 377 "${batterystats_utils_path}:coverage_flags", 378 ] 379 380 deps = [ 381 "${batterystats_inner_api}:batterystats_client", 382 "${batterystats_service_path}:batterystats_service", 383 "${batterystats_utils_path}:batterystats_utils", 384 ] 385 386 external_deps = deps_ex 387 external_deps += [ 388 "bluetooth:btframework", 389 "googletest:gtest_main", 390 ] 391} 392 393############################alarm_test############################# 394ohos_unittest("stats_alarm_test") { 395 module_out_path = module_output_path 396 397 sanitize = { 398 cfi = true 399 cfi_cross_dso = true 400 debug = false 401 } 402 403 sources = [ 404 "${batterystats_service_path}/native/src/battery_stats_parser.cpp", 405 "stats_alarm_test.cpp", 406 ] 407 408 configs = [ 409 ":module_private_config", 410 "${batterystats_utils_path}:coverage_flags", 411 ] 412 413 deps = [ 414 "${batterystats_inner_api}:batterystats_client", 415 "${batterystats_service_path}:batterystats_service", 416 "${batterystats_utils_path}:batterystats_utils", 417 ] 418 419 external_deps = deps_ex 420 421 external_deps += [ "googletest:gtest_main" ] 422} 423 424############################util_test############################# 425ohos_unittest("stats_util_test") { 426 module_out_path = module_output_path 427 428 sanitize = { 429 cfi = true 430 cfi_cross_dso = true 431 debug = false 432 } 433 434 sources = [ "stats_util_test.cpp" ] 435 436 configs = [ 437 "${batterystats_utils_path}:coverage_flags", 438 ":module_private_config", 439 "${batterystats_utils_path}:batterystats_utils_config", 440 ] 441 442 deps = [ 443 "${batterystats_service_path}:batterystats_service", 444 "${batterystats_service_path}:batterystats_stub", 445 "${batterystats_utils_path}:batterystats_utils", 446 ] 447 448 external_deps = deps_ex 449 external_deps += [ "googletest:gtest_main" ] 450} 451 452############################client_test_mock_parcel############################# 453ohos_unittest("stats_client_test_mock_parcel") { 454 module_out_path = module_output_path 455 456 sanitize = { 457 cfi = true 458 cfi_cross_dso = true 459 debug = false 460 } 461 462 sources = [ 463 "${batterystats_root_path}/test/unittest/mock/source/mock_message_parcel.cpp", 464 "${batterystats_root_path}/test/unittest/mock/source/mock_parcel.cpp", 465 "mock/stats_client_test_mock_parcel.cpp", 466 ] 467 468 configs = [ 469 ":module_mock_private_config", 470 ":module_private_config", 471 "${batterystats_utils_path}:coverage_flags", 472 ] 473 474 deps = [ 475 "${batterystats_inner_api}:batterystats_client", 476 "${batterystats_service_path}:batterystats_proxy", 477 "${batterystats_service_path}:batterystats_service", 478 "${batterystats_utils_path}:batterystats_utils", 479 ] 480 481 external_deps = deps_ex 482 483 external_deps += [ "googletest:gtest_main" ] 484} 485 486############################client_test_mock_object############################# 487ohos_unittest("stats_client_test_mock_object") { 488 module_out_path = module_output_path 489 490 sanitize = { 491 cfi = true 492 cfi_cross_dso = true 493 debug = false 494 } 495 496 sources = [ 497 "${batterystats_root_path}/test/unittest/mock/source/mock_stats_remote_object.cpp", 498 "mock/stats_client_test_mock_object.cpp", 499 ] 500 501 configs = [ 502 ":module_mock_private_config", 503 ":module_private_config", 504 "${batterystats_utils_path}:coverage_flags", 505 ] 506 507 deps = [ 508 "${batterystats_inner_api}:batterystats_client", 509 "${batterystats_service_path}:batterystats_proxy", 510 "${batterystats_service_path}:batterystats_service", 511 "${batterystats_utils_path}:batterystats_utils", 512 ] 513 514 external_deps = deps_ex 515 external_deps += [ "googletest:gtest_main" ] 516} 517 518############################mock_peer_test############################# 519ohos_unittest("stats_client_test_mock_peer") { 520 module_out_path = module_output_path 521 522 sanitize = { 523 cfi = true 524 cfi_cross_dso = true 525 debug = false 526 } 527 528 sources = [ 529 "${batterystats_root_path}/test/unittest/mock/source/mock_peer_holder.cpp", 530 "mock/stats_client_test_mock_peer.cpp", 531 ] 532 533 configs = [ 534 ":module_mock_private_config", 535 ":module_private_config", 536 "${batterystats_utils_path}:coverage_flags", 537 ] 538 539 deps = [ 540 "${batterystats_inner_api}:batterystats_client", 541 "${batterystats_service_path}:batterystats_proxy", 542 "${batterystats_service_path}:batterystats_service", 543 "${batterystats_utils_path}:batterystats_utils", 544 ] 545 546 external_deps = deps_ex 547 external_deps += [ "googletest:gtest_main" ] 548} 549group("unittest") { 550 testonly = true 551 deps = [ 552 ":stats_alarm_test", 553 ":stats_audio_test", 554 ":stats_bluetooth_test", 555 ":stats_camera_test", 556 ":stats_client_test_mock_object", 557 ":stats_client_test_mock_parcel", 558 ":stats_client_test_mock_peer", 559 ":stats_display_test", 560 ":stats_dump_test", 561 ":stats_location_test", 562 ":stats_phone_test", 563 ":stats_powermgr_test", 564 ":stats_service_death_test", 565 ":stats_service_test", 566 ":stats_util_test", 567 ":stats_wifi_test", 568 ] 569} 570