1# Copyright (c) 2021-2023 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/test.gni") 15import("../../thermalmgr.gni") 16 17module_output_path = "thermal_manager/thermal_native" 18 19############################################################################### 20config("module_private_config") { 21 visibility = [ ":*" ] 22 include_dirs = [ 23 "include", 24 "mock_action/include", 25 "mock/include", 26 "${utils_path}/native/include", 27 "${thermal_manager_path}/services/native/include/thermal_action", 28 "${thermal_manager_path}/test/common/include", 29 "${thermal_service_zidl}/include", 30 "${ability_runtime_services_path}/appmgr/include", 31 "${thermal_inner_api}/native/include", 32 ] 33} 34 35deps_ex = [ 36 "ability_base:base", 37 "ability_base:want", 38 "ability_runtime:ability_manager", 39 "ability_runtime:app_manager", 40 "battery_manager:batterysrv_client", 41 "bundle_framework:appexecfwk_base", 42 "c_utils:utils", 43 "config_policy:configpolicy_util", 44 "ipc:ipc_core", 45 "hdf_core:libhdi", 46 "hdf_core:libpub_utils", 47 "hilog:libhilog", 48 "power_manager:powermgr_client", 49 "safwk:system_ability_fwk", 50 "samgr:samgr_proxy", 51 "common_event_service:cesfwk_innerkits", 52 "appspawn:appspawn_socket_client", 53 "window_manager:libwm", 54 "drivers_interface_battery:libbattery_proxy_1.2", 55 "drivers_interface_thermal:libthermal_proxy_1.1", 56 "time_service:time_client", 57] 58 59# thermal mock action test 60ohos_unittest("ThermalMockActionTest") { 61 module_out_path = module_output_path 62 63 sources = [ 64 "${thermal_manager_path}/test/common/src/thermal_test.cpp", 65 "${thermal_manager_path}/test/unittest/mock_action/src/mock_soc_action_base.cpp", 66 "${thermal_manager_path}/test/unittest/mock_action/src/mock_socperf_action.cpp", 67 "src/thermal_mock_action_test.cpp", 68 ] 69 70 configs = [ 71 "${utils_path}:utils_config", 72 ":module_private_config", 73 "${utils_path}:coverage_flags", 74 ] 75 76 defines = [ "THERMAL_GTEST" ] 77 78 deps = [ 79 "${thermal_inner_api}:thermalsrv_client", 80 "${thermal_manager_path}/services:thermalservice", 81 "${thermal_manager_path}/test/common:mock_thermalsrv_client", 82 "//third_party/googletest:gtest_main", 83 ] 84 85 external_deps = deps_ex 86} 87 88# thermal policy test 89ohos_unittest("ThermalPolicyTest") { 90 module_out_path = module_output_path 91 92 sources = [ 93 "${thermal_manager_path}/test/common/src/thermal_test.cpp", 94 "src/thermal_mgr_policy_test.cpp", 95 ] 96 97 configs = [ 98 "${utils_path}:utils_config", 99 ":module_private_config", 100 ] 101 102 deps = [ 103 "${thermal_inner_api}:thermalsrv_client", 104 "${thermal_manager_path}/services:thermalservice", 105 "${thermal_manager_path}/test/common:mock_thermalsrv_client", 106 "//third_party/googletest:gtest_main", 107 ] 108 109 external_deps = deps_ex 110} 111 112# thermal level event test 113ohos_unittest("ThermalLevelEventTest") { 114 module_out_path = module_output_path 115 116 sources = [ 117 "${thermal_manager_path}/test/common/src/thermal_test.cpp", 118 "src/thermal_level_event_test.cpp", 119 ] 120 121 configs = [ 122 "${utils_path}:utils_config", 123 ":module_private_config", 124 "${utils_path}:coverage_flags", 125 ] 126 127 deps = [ 128 "${thermal_inner_api}:thermalsrv_client", 129 "${thermal_manager_path}/services:thermalservice", 130 "${thermal_manager_path}/test/common:mock_thermalsrv_client", 131 "//third_party/googletest:gtest_main", 132 ] 133 134 external_deps = deps_ex 135} 136 137# thermal client api test 138ohos_unittest("ThermalClientApiTest") { 139 module_out_path = module_output_path 140 141 sources = [ "src/thermal_client_api_test.cpp" ] 142 143 configs = [ 144 "${utils_path}:utils_config", 145 ":module_private_config", 146 "${utils_path}:coverage_flags", 147 ] 148 149 deps = [ 150 "${thermal_inner_api}:thermalsrv_client", 151 "${thermal_manager_path}/services:thermalservice", 152 "${thermal_manager_path}/test/common:mock_thermalsrv_client", 153 "//third_party/googletest:gtest_main", 154 ] 155 156 external_deps = deps_ex 157} 158 159# thermal action hub test 160ohos_unittest("ThermalActionHubTest") { 161 module_out_path = module_output_path 162 163 sources = [ 164 "${thermal_manager_path}/test/common/src/thermal_test.cpp", 165 "src/thermal_action_hub_test.cpp", 166 ] 167 168 configs = [ 169 "${utils_path}:utils_config", 170 ":module_private_config", 171 "${utils_path}:coverage_flags", 172 ] 173 174 deps = [ 175 "${thermal_inner_api}:thermalsrv_client", 176 "${thermal_manager_path}/services:thermalservice", 177 "${thermal_manager_path}/test/common:mock_thermalsrv_client", 178 "${thermal_service_zidl}:thermalmgr_proxy", 179 "${thermal_service_zidl}:thermalmgr_stub", 180 "//third_party/googletest:gtest_main", 181 ] 182 183 external_deps = deps_ex 184} 185 186# thermal action report test 187ohos_unittest("ThermalActionReportTest") { 188 module_out_path = module_output_path 189 190 sources = [ 191 "${thermal_manager_path}/test/common/src/thermal_test.cpp", 192 "src/thermal_action_report_test.cpp", 193 "src/thermal_config_file_parser.cpp", 194 ] 195 196 configs = [ 197 "${utils_path}:utils_config", 198 ":module_private_config", 199 "${utils_path}:coverage_flags", 200 ] 201 202 deps = [ 203 "${batterystats_utils_path}:batterystats_utils", 204 "${thermal_inner_api}:thermalsrv_client", 205 "${thermal_manager_path}/services:thermalservice", 206 "${thermal_manager_path}/test/common:mock_thermalsrv_client", 207 "//third_party/googletest:gtest_main", 208 "//third_party/libxml2:libxml2", 209 ] 210 211 external_deps = [ "battery_statistics:batterystats_client" ] 212 213 external_deps += deps_ex 214} 215 216# thermal mock proxy test 217ohos_unittest("ThermalMockProxyTest") { 218 module_out_path = module_output_path 219 220 sources = [ 221 "mock/src/mock_thermal_remote_object.cpp", 222 "src/thermal_mock_proxy_test.cpp", 223 ] 224 225 configs = [ 226 "${utils_path}:utils_config", 227 ":module_private_config", 228 "${utils_path}:coverage_flags", 229 ] 230 231 deps = [ 232 "${thermal_inner_api}:thermalsrv_client", 233 "${thermal_manager_path}/services:thermalservice", 234 "${thermal_service_zidl}:thermalmgr_proxy", 235 "${thermal_service_zidl}:thermalmgr_stub", 236 "//third_party/googletest:gtest_main", 237 ] 238 239 external_deps = deps_ex 240} 241 242# thermal mock proxy remote test 243ohos_unittest("ThermalMockProxyRemoteTest") { 244 module_out_path = module_output_path 245 246 sources = [ 247 "mock/src/mock_peer_holder.cpp", 248 "mock/src/mock_thermal_remote_object.cpp", 249 "src/thermal_mock_proxy_remote_test.cpp", 250 ] 251 252 configs = [ 253 "${utils_path}:utils_config", 254 ":module_private_config", 255 "${utils_path}:coverage_flags", 256 ] 257 258 deps = [ 259 "${thermal_inner_api}:thermalsrv_client", 260 "${thermal_manager_path}/services:thermalservice", 261 "${thermal_service_zidl}:thermalmgr_proxy", 262 "${thermal_service_zidl}:thermalmgr_stub", 263 "//third_party/googletest:gtest_main", 264 ] 265 266 external_deps = deps_ex 267} 268 269# thermal mock proxy writeinterfacetoken test 270ohos_unittest("ThermalMockProxyWriteinterfacetokenTest") { 271 module_out_path = module_output_path 272 273 sources = [ 274 "mock/src/mock_message_parcel.cpp", 275 "mock/src/mock_thermal_remote_object.cpp", 276 "src/thermal_mock_proxy_writeinterfacetoken_test.cpp", 277 ] 278 279 configs = [ 280 "${utils_path}:utils_config", 281 ":module_private_config", 282 "${utils_path}:coverage_flags", 283 ] 284 285 defines = [ "MOCK_WRITE_INTERFACE_TOKEN_RETURN_FALSE" ] 286 287 deps = [ 288 "${thermal_inner_api}:thermalsrv_client", 289 "${thermal_manager_path}/services:thermalservice", 290 "${thermal_service_zidl}:thermalmgr_proxy", 291 "${thermal_service_zidl}:thermalmgr_stub", 292 "//third_party/googletest:gtest_main", 293 ] 294 295 external_deps = deps_ex 296} 297 298# thermal mock proxy writeremoteobject test 299ohos_unittest("ThermalMockProxyWriteremoteobjectTest") { 300 module_out_path = module_output_path 301 302 sources = [ 303 "mock/src/mock_message_parcel.cpp", 304 "mock/src/mock_parcel.cpp", 305 "mock/src/mock_thermal_remote_object.cpp", 306 "src/thermal_mock_proxy_writeremoteobject_test.cpp", 307 ] 308 309 configs = [ 310 "${utils_path}:utils_config", 311 ":module_private_config", 312 "${utils_path}:coverage_flags", 313 ] 314 315 defines = [ "MOCK_WRITE_REMOTE_OBJECT_RETURN_FALSE" ] 316 317 deps = [ 318 "${thermal_inner_api}:thermalsrv_client", 319 "${thermal_manager_path}/services:thermalservice", 320 "${thermal_service_zidl}:thermalmgr_proxy", 321 "${thermal_service_zidl}:thermalmgr_stub", 322 "//third_party/googletest:gtest_main", 323 ] 324 325 external_deps = deps_ex 326} 327 328# thermal mock proxy writevector test 329ohos_unittest("ThermalMockProxyWritevectorTest") { 330 module_out_path = module_output_path 331 332 sources = [ 333 "mock/src/mock_message_parcel.cpp", 334 "mock/src/mock_parcel.cpp", 335 "mock/src/mock_thermal_remote_object.cpp", 336 "src/thermal_mock_proxy_writevector_test.cpp", 337 ] 338 339 configs = [ 340 "${utils_path}:utils_config", 341 ":module_private_config", 342 "${utils_path}:coverage_flags", 343 ] 344 345 defines = [ "MOCK_WRITEVECTOR_RETURN_FALSE" ] 346 347 deps = [ 348 "${thermal_inner_api}:thermalsrv_client", 349 "${thermal_manager_path}/services:thermalservice", 350 "${thermal_service_zidl}:thermalmgr_proxy", 351 "${thermal_service_zidl}:thermalmgr_stub", 352 "//third_party/googletest:gtest_main", 353 ] 354 355 external_deps = deps_ex 356} 357 358# thermal mock proxy sendrequest test 359ohos_unittest("ThermalMockProxySendrequestTest") { 360 module_out_path = module_output_path 361 362 sources = [ 363 "mock/src/mock_message_parcel.cpp", 364 "mock/src/mock_thermal_remote_object.cpp", 365 "src/thermal_mock_proxy_sendrequest_test.cpp", 366 ] 367 368 configs = [ 369 "${utils_path}:utils_config", 370 ":module_private_config", 371 "${utils_path}:coverage_flags", 372 ] 373 374 defines = [ "MOCK_SEND_REQUEST_RETURN_ONE" ] 375 376 deps = [ 377 "${thermal_inner_api}:thermalsrv_client", 378 "${thermal_manager_path}/services:thermalservice", 379 "${thermal_service_zidl}:thermalmgr_proxy", 380 "${thermal_service_zidl}:thermalmgr_stub", 381 "//third_party/googletest:gtest_main", 382 ] 383 384 external_deps = deps_ex 385} 386 387# thermal utils test 388ohos_unittest("ThermalUtilsTest") { 389 module_out_path = module_output_path 390 391 sources = [ "src/thermal_utils_test.cpp" ] 392 393 configs = [ 394 "${utils_path}:utils_config", 395 ":module_private_config", 396 "${utils_path}:coverage_flags", 397 ] 398 399 deps = [ 400 "${thermal_inner_api}:thermalsrv_client", 401 "${thermal_manager_path}/services:thermalservice", 402 "${thermal_service_zidl}:thermalmgr_proxy", 403 "${thermal_service_zidl}:thermalmgr_stub", 404 "//third_party/googletest:gtest_main", 405 ] 406 407 external_deps = deps_ex 408} 409 410# thermal service death test 411ohos_unittest("ThermalServiceDeathTest") { 412 module_out_path = module_output_path 413 414 sources = [ 415 "mock/src/mock_thermal_remote_object.cpp", 416 "src/thermal_service_death_test.cpp", 417 ] 418 419 configs = [ 420 "${utils_path}:utils_config", 421 ":module_private_config", 422 "${utils_path}:coverage_flags", 423 ] 424 425 defines = [ "THERMAL_SERVICE_DEATH_UT" ] 426 427 deps = [ 428 "${thermal_inner_api}:thermalsrv_client", 429 "${thermal_manager_path}/services:thermalservice", 430 "${thermal_service_zidl}:thermalmgr_proxy", 431 "${thermal_service_zidl}:thermalmgr_stub", 432 "//third_party/googletest:gtest_main", 433 ] 434 435 external_deps = deps_ex 436} 437 438# thermal listener test 439ohos_unittest("ThermalListenerTest") { 440 module_out_path = module_output_path 441 442 sources = [ 443 "${thermal_manager_path}/test/common/src/thermal_test.cpp", 444 "src/thermal_listener_test.cpp", 445 ] 446 447 configs = [ 448 "${utils_path}:utils_config", 449 ":module_private_config", 450 "${utils_path}:coverage_flags", 451 ] 452 453 deps = [ 454 "${thermal_inner_api}:thermalmgr_listener", 455 "${thermal_inner_api}:thermalsrv_client", 456 "${thermal_manager_path}/services:thermalservice", 457 "${thermal_manager_path}/test/common:mock_thermalsrv_client", 458 "${thermal_service_zidl}:thermalmgr_proxy", 459 "${thermal_service_zidl}:thermalmgr_stub", 460 "//third_party/googletest:gtest_main", 461 ] 462 463 external_deps = deps_ex 464} 465 466# thermal client test 467ohos_unittest("ThermalClientTest") { 468 module_out_path = module_output_path 469 470 sources = [ 471 "mock/src/mock_thermal_remote_object.cpp", 472 "src/thermal_client_test.cpp", 473 ] 474 475 configs = [ 476 "${utils_path}:utils_config", 477 ":module_private_config", 478 "${utils_path}:coverage_flags", 479 ] 480 481 deps = [ 482 "${thermal_inner_api}:thermalmgr_listener", 483 "${thermal_inner_api}:thermalsrv_client", 484 "${thermal_manager_path}/services:thermalservice", 485 "${thermal_service_zidl}:thermalmgr_proxy", 486 "${thermal_service_zidl}:thermalmgr_stub", 487 "//third_party/googletest:gtest_main", 488 "//third_party/libxml2:libxml2", 489 ] 490 491 external_deps = [ 492 "ability_base:base", 493 "ability_base:want", 494 "appspawn:appspawn_socket_client", 495 "battery_manager:batterysrv_client", 496 "bundle_framework:appexecfwk_base", 497 "c_utils:utils", 498 "common_event_service:cesfwk_innerkits", 499 "drivers_interface_thermal:libthermal_proxy_1.1", 500 "hdf_core:libhdi", 501 "hdf_core:libpub_utils", 502 "hilog:libhilog", 503 "hisysevent:libhisysevent", 504 "ipc:ipc_core", 505 "power_manager:powermgr_client", 506 "safwk:system_ability_fwk", 507 "samgr:samgr_proxy", 508 "window_manager:libwm", 509 ] 510} 511 512# thermal mock stub test 513ohos_unittest("ThermalMockStubTest") { 514 module_out_path = module_output_path 515 defines = [ "THERMAL_GTEST" ] 516 sources = [ "src/thermal_mock_stub_test.cpp" ] 517 518 configs = [ 519 "${utils_path}:utils_config", 520 ":module_private_config", 521 "${utils_path}:coverage_flags", 522 ] 523 524 deps = [ 525 "${thermal_inner_api}:thermalsrv_client", 526 "${thermal_manager_path}/services:thermalservice", 527 "${thermal_service_zidl}:thermalmgr_proxy", 528 "${thermal_service_zidl}:thermalmgr_stub", 529 "//third_party/googletest:gtest_main", 530 ] 531 532 external_deps = deps_ex 533} 534 535# thermal mock stub getdescriptor test 536ohos_unittest("ThermalMockStubGetdescriptorTest") { 537 module_out_path = module_output_path 538 539 sources = [ "src/thermal_mock_stub_getdescriptor_test.cpp" ] 540 541 configs = [ 542 "${utils_path}:utils_config", 543 ":module_private_config", 544 "${utils_path}:coverage_flags", 545 ] 546 547 deps = [ 548 "${thermal_inner_api}:thermalsrv_client", 549 "${thermal_manager_path}/services:thermalservice", 550 "${thermal_service_zidl}:thermalmgr_proxy", 551 "${thermal_service_zidl}:thermalmgr_stub", 552 "//third_party/googletest:gtest_main", 553 ] 554 555 external_deps = deps_ex 556} 557 558# thermal action test 559ohos_unittest("ThermalActionTest") { 560 module_out_path = module_output_path 561 562 sources = [ 563 "mock/src/mock_thermal_remote_object.cpp", 564 "src/thermal_action_test.cpp", 565 ] 566 567 configs = [ 568 "${utils_path}:utils_config", 569 ":module_private_config", 570 "${utils_path}:coverage_flags", 571 ] 572 573 defines = [ "THERMAL_GTEST" ] 574 575 deps = [ 576 "${thermal_inner_api}:thermalsrv_client", 577 "${thermal_manager_path}/services:thermalservice", 578 "${thermal_service_zidl}:thermalmgr_proxy", 579 "${thermal_service_zidl}:thermalmgr_stub", 580 "//third_party/googletest:gtest_main", 581 ] 582 583 external_deps = deps_ex 584} 585 586# thermal observer test 587ohos_unittest("ThermalObserverTest") { 588 module_out_path = module_output_path 589 590 sources = [ 591 "mock/src/mock_thermal_remote_object.cpp", 592 "src/thermal_observer_test.cpp", 593 ] 594 595 configs = [ 596 "${utils_path}:utils_config", 597 ":module_private_config", 598 "${utils_path}:coverage_flags", 599 ] 600 601 defines = [ "THERMAL_OBSERVER_UT_TEST" ] 602 603 deps = [ 604 "${thermal_inner_api}:thermalsrv_client", 605 "${thermal_manager_path}/services:thermalservice", 606 "${thermal_service_zidl}:thermalmgr_proxy", 607 "${thermal_service_zidl}:thermalmgr_stub", 608 "//third_party/googletest:gtest_main", 609 ] 610 611 external_deps = deps_ex 612} 613 614# thermal service test 615ohos_unittest("ThermalServiceTest") { 616 module_out_path = module_output_path 617 defines = [ "THERMAL_GTEST" ] 618 sources = [ "src/thermal_service_test.cpp" ] 619 620 configs = [ 621 "${utils_path}:utils_config", 622 ":module_private_config", 623 "${utils_path}:coverage_flags", 624 ] 625 626 deps = [ 627 "${thermal_inner_api}:thermalsrv_client", 628 "${thermal_manager_path}/services:thermalservice", 629 "${thermal_service_zidl}:thermalmgr_proxy", 630 "${thermal_service_zidl}:thermalmgr_stub", 631 "//third_party/googletest:gmock_main", 632 "//third_party/googletest:gtest_main", 633 ] 634 635 external_deps = deps_ex 636} 637 638# fan fault detect test 639ohos_unittest("FanFaultDetectTest") { 640 module_out_path = module_output_path 641 defines = [ "THERMAL_GTEST" ] 642 sources = [ "src/fan_fault_detect_test.cpp" ] 643 644 configs = [ 645 "${utils_path}:utils_config", 646 ":module_private_config", 647 "${utils_path}:coverage_flags", 648 ] 649 650 deps = [ 651 "${thermal_inner_api}:thermalsrv_client", 652 "${thermal_manager_path}/services:thermalservice", 653 "${thermal_service_zidl}:thermalmgr_proxy", 654 "${thermal_service_zidl}:thermalmgr_stub", 655 "//third_party/googletest:gmock_main", 656 "//third_party/googletest:gtest_main", 657 ] 658 659 external_deps = [ 660 "hisysevent:libhisysevent", 661 "hisysevent:libhisyseventmanager", 662 ] 663 664 external_deps += deps_ex 665} 666 667group("unittest") { 668 testonly = true 669 deps = [ 670 ":FanFaultDetectTest", 671 ":ThermalActionHubTest", 672 ":ThermalActionReportTest", 673 ":ThermalActionTest", 674 ":ThermalClientApiTest", 675 ":ThermalClientTest", 676 ":ThermalLevelEventTest", 677 ":ThermalListenerTest", 678 ":ThermalMockActionTest", 679 ":ThermalMockProxyRemoteTest", 680 ":ThermalMockProxySendrequestTest", 681 ":ThermalMockProxyTest", 682 ":ThermalMockProxyWriteinterfacetokenTest", 683 ":ThermalMockProxyWriteremoteobjectTest", 684 ":ThermalMockProxyWritevectorTest", 685 ":ThermalMockStubGetdescriptorTest", 686 ":ThermalMockStubTest", 687 ":ThermalObserverTest", 688 ":ThermalPolicyTest", 689 ":ThermalServiceDeathTest", 690 ":ThermalServiceTest", 691 ":ThermalUtilsTest", 692 ] 693} 694