# Copyright (c) 2022-2023 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/test.gni") import("../../../../batterystats.gni") module_output_path = "${batterystats_part_name}/batterystats" config("module_private_config") { visibility = [ ":*" ] include_dirs = [ "${batterystats_root_path}/test/unittest/include", "${batterystats_root_path}/test/unittest/include/servicetest", "${batterystats_root_path}/test/unittest/include/servicetest/utils", "${batterystats_service_native}/include", ] } config("module_mock_private_config") { include_dirs = [ "${batterystats_root_path}/test/unittest/include/servicetest/mock", "${batterystats_root_path}/test/unittest/mock/include", "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include/", "//commonlibrary/c_utils/base/include/", ] } deps_ex = [ "ability_base:base", "ability_base:want", "battery_manager:batterysrv_client", "call_manager:tel_call_manager_api", "common_event_service:cesfwk_innerkits", "config_policy:configpolicy_util", "c_utils:utils", "display_manager:displaymgr", "hisysevent:libhisysevent", "hisysevent:libhisyseventmanager", "hilog:libhilog", "ipc:ipc_core", "power_manager:powermgr_client", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] ############################service_alarm_test############################# ohos_unittest("stats_service_alarm_test") { module_out_path = module_output_path sources = [ "${batterystats_service_path}/native/src/battery_stats_parser.cpp", "stats_service_alarm_test.cpp", "utils/hisysevent_operation.cpp", "utils/stats_service_test_proxy.cpp", "utils/string_filter.cpp", ] configs = [ ":module_private_config", "${batterystats_utils_path}:coverage_flags", ] defines = [ "STATS_SERVICE_UT_TEST" ] deps = [ "${batterystats_inner_api}:batterystats_client", "${batterystats_service_path}:batterystats_service", "${batterystats_utils_path}:batterystats_utils", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", ] external_deps = deps_ex } ############################service_audio_test############################# ohos_unittest("stats_service_audio_test") { module_out_path = module_output_path sources = [ "${batterystats_service_path}/native/src/battery_stats_parser.cpp", "stats_service_audio_test.cpp", "utils/hisysevent_operation.cpp", "utils/stats_service_test_proxy.cpp", "utils/string_filter.cpp", ] configs = [ ":module_private_config", "${batterystats_utils_path}:coverage_flags", ] defines = [ "STATS_SERVICE_UT_TEST" ] deps = [ "${batterystats_inner_api}:batterystats_client", "${batterystats_service_path}:batterystats_service", "${batterystats_utils_path}:batterystats_utils", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", ] external_deps = deps_ex } ############################service_bluetooth_test############################# ohos_unittest("stats_service_bluetooth_test") { module_out_path = module_output_path sources = [ "${batterystats_service_path}/native/src/battery_stats_parser.cpp", "stats_service_bluetooth_test.cpp", "utils/hisysevent_operation.cpp", "utils/stats_service_test_proxy.cpp", "utils/string_filter.cpp", ] configs = [ ":module_private_config", "${batterystats_utils_path}:coverage_flags", ] defines = [ "STATS_SERVICE_UT_TEST" ] deps = [ "${batterystats_inner_api}:batterystats_client", "${batterystats_service_path}:batterystats_service", "${batterystats_utils_path}:batterystats_utils", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", ] external_deps = deps_ex external_deps += [ "bluetooth:btframework" ] } ############################service_camera_test############################# ohos_unittest("stats_service_camera_test") { module_out_path = module_output_path sources = [ "${batterystats_service_path}/native/src/battery_stats_parser.cpp", "stats_service_camera_test.cpp", "utils/hisysevent_operation.cpp", "utils/stats_service_test_proxy.cpp", "utils/string_filter.cpp", ] configs = [ ":module_private_config", "${batterystats_utils_path}:coverage_flags", ] defines = [ "STATS_SERVICE_UT_TEST" ] deps = [ "${batterystats_inner_api}:batterystats_client", "${batterystats_service_path}:batterystats_service", "${batterystats_utils_path}:batterystats_utils", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", ] external_deps = deps_ex } ############################service_display_test############################# ohos_unittest("stats_service_display_test") { module_out_path = module_output_path sources = [ "${batterystats_service_path}/native/src/battery_stats_parser.cpp", "stats_service_display_test.cpp", "utils/hisysevent_operation.cpp", "utils/stats_service_test_proxy.cpp", "utils/string_filter.cpp", ] configs = [ ":module_private_config", "${batterystats_utils_path}:coverage_flags", ] defines = [ "STATS_SERVICE_UT_TEST" ] deps = [ "${batterystats_inner_api}:batterystats_client", "${batterystats_service_path}:batterystats_service", "${batterystats_utils_path}:batterystats_utils", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", ] external_deps = deps_ex } ############################service_dump_test############################# ohos_unittest("stats_service_dump_test") { module_out_path = module_output_path sources = [ "${batterystats_service_path}/native/src/battery_stats_parser.cpp", "stats_service_dump_test.cpp", "utils/hisysevent_operation.cpp", "utils/stats_service_test_proxy.cpp", "utils/string_filter.cpp", ] configs = [ ":module_private_config", "${batterystats_utils_path}:coverage_flags", ] defines = [ "STATS_SERVICE_UT_TEST" ] deps = [ "${batterystats_inner_api}:batterystats_client", "${batterystats_service_path}:batterystats_service", "${batterystats_utils_path}:batterystats_utils", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", ] external_deps = deps_ex } ############################service_location_test############################# ohos_unittest("stats_service_location_test") { module_out_path = module_output_path sources = [ "${batterystats_service_path}/native/src/battery_stats_parser.cpp", "stats_service_location_test.cpp", "utils/hisysevent_operation.cpp", "utils/stats_service_test_proxy.cpp", "utils/string_filter.cpp", ] configs = [ ":module_private_config", "${batterystats_utils_path}:coverage_flags", ] defines = [ "STATS_SERVICE_UT_TEST" ] deps = [ "${batterystats_inner_api}:batterystats_client", "${batterystats_service_path}:batterystats_service", "${batterystats_utils_path}:batterystats_utils", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", ] external_deps = deps_ex } ############################service_phone_test############################# ohos_unittest("stats_service_phone_test") { module_out_path = module_output_path sources = [ "${batterystats_service_path}/native/src/battery_stats_parser.cpp", "stats_service_phone_test.cpp", "utils/hisysevent_operation.cpp", "utils/stats_service_test_proxy.cpp", "utils/string_filter.cpp", ] configs = [ ":module_private_config", "${batterystats_utils_path}:coverage_flags", ] defines = [ "STATS_SERVICE_UT_TEST" ] deps = [ "${batterystats_inner_api}:batterystats_client", "${batterystats_service_path}:batterystats_service", "${batterystats_utils_path}:batterystats_utils", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", ] external_deps = deps_ex } ############################service_powermgr_test############################# ohos_unittest("stats_service_powermgr_test") { module_out_path = module_output_path sources = [ "${batterystats_service_path}/native/src/battery_stats_parser.cpp", "stats_service_powermgr_test.cpp", "utils/hisysevent_operation.cpp", "utils/stats_service_test_proxy.cpp", "utils/string_filter.cpp", ] configs = [ ":module_private_config", "${batterystats_utils_path}:coverage_flags", ] defines = [ "STATS_SERVICE_UT_TEST" ] deps = [ "${batterystats_inner_api}:batterystats_client", "${batterystats_service_path}:batterystats_service", "${batterystats_utils_path}:batterystats_utils", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", ] external_deps = deps_ex } ############################service_wifi_test############################# ohos_unittest("stats_service_wifi_test") { module_out_path = module_output_path sources = [ "${batterystats_service_path}/native/src/battery_stats_parser.cpp", "stats_service_wifi_test.cpp", "utils/hisysevent_operation.cpp", "utils/stats_service_test_proxy.cpp", "utils/string_filter.cpp", ] configs = [ ":module_private_config", "${batterystats_utils_path}:coverage_flags", ] defines = [ "STATS_SERVICE_UT_TEST" ] deps = [ "${batterystats_inner_api}:batterystats_client", "${batterystats_service_path}:batterystats_service", "${batterystats_utils_path}:batterystats_utils", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", ] external_deps = deps_ex external_deps += [ "wifi:wifi_sdk" ] } ############################service_subscriber_test############################# ohos_unittest("stats_service_subscriber_test") { module_out_path = module_output_path sources = [ "${batterystats_service_path}/native/src/battery_stats_parser.cpp", "stats_service_subscriber_test.cpp", "utils/hisysevent_operation.cpp", "utils/stats_service_test_proxy.cpp", "utils/string_filter.cpp", ] configs = [ ":module_private_config", "${batterystats_utils_path}:coverage_flags", ] defines = [ "STATS_SERVICE_UT_TEST" ] deps = [ "${batterystats_inner_api}:batterystats_client", "${batterystats_service_path}:batterystats_service", "${batterystats_utils_path}:batterystats_utils", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", ] external_deps = deps_ex } ############################service_stub_test############################# ohos_unittest("stats_service_stub_test") { module_out_path = module_output_path sources = [ "stats_service_stub_test.cpp" ] configs = [ ":module_private_config", "${batterystats_utils_path}:coverage_flags", ] deps = [ "${batterystats_inner_api}:batterystats_client", "${batterystats_service_path}:batterystats_service", "${batterystats_utils_path}:batterystats_utils", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", ] external_deps = deps_ex } ############################service_core_test############################# ohos_unittest("stats_service_core_test") { module_out_path = module_output_path sources = [ "stats_service_core_test.cpp" ] configs = [ ":module_private_config", "${batterystats_utils_path}:coverage_flags", ] deps = [ "${batterystats_inner_api}:batterystats_client", "${batterystats_service_path}:batterystats_service", "${batterystats_utils_path}:batterystats_utils", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", ] external_deps = deps_ex } ############################service_test_mock_parcel############################# ohos_unittest("stats_service_test_mock_parcel") { module_out_path = module_output_path sources = [ "${batterystats_root_path}/test/unittest/mock/source/mock_message_parcel.cpp", "${batterystats_root_path}/test/unittest/mock/source/mock_parcel.cpp", "mock/stats_service_test_mock_parcel.cpp", "utils/stats_service_test_proxy.cpp", ] configs = [ ":module_mock_private_config", ":module_private_config", "${batterystats_utils_path}:coverage_flags", ] defines = [ "MESSAGE_PARCEL_WRITE_TOKEN_NORMAL" ] deps = [ "${batterystats_inner_api}:batterystats_client", "${batterystats_service_path}:batterystats_service", "${batterystats_utils_path}:batterystats_utils", "//third_party/googletest:gtest_main", "//third_party/jsoncpp:jsoncpp", ] external_deps = deps_ex } group("unittest") { testonly = true deps = [ ":stats_service_alarm_test", ":stats_service_audio_test", ":stats_service_bluetooth_test", ":stats_service_camera_test", ":stats_service_core_test", ":stats_service_display_test", ":stats_service_dump_test", ":stats_service_location_test", ":stats_service_phone_test", ":stats_service_powermgr_test", ":stats_service_stub_test", ":stats_service_subscriber_test", ":stats_service_test_mock_parcel", ":stats_service_wifi_test", ] }