# Copyright (c) 2022 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("../../device_usage_statistics.gni") module_output_path = "device_usage_statistics/deviceusagestatisticstest" config("module_private_config") { visibility = [ ":*" ] include_dirs = [ "../../interfaces/innerkits/include", "../../services/common/include", "../../services/packageusage/include", "../../services/packagegroup/include", "../../utils/include", "//third_party/jsoncpp/include", ] } ohos_unittest("BundleActiveTotalTest") { module_out_path = module_output_path cflags = [ "-Dprivate=public", "-Dprotected=public", ] sources = [ "bundle_active_total_test.cpp", "bundle_active_usage_database_test.cpp", ] configs = [ ":module_private_config" ] deps = [ "../../:usagestatservice_static", "../../:usagestatsinner", "../../:usagestatsutils", "//third_party/jsoncpp:jsoncpp", ] external_deps = [ "ability_base:want", "ability_runtime:app_manager", "ability_runtime:wantagent_innerkits", "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ffrt:libffrt", "hilog:libhilog", "init:libbegetutil", "ipc:ipc_single", "relational_store:native_rdb", "safwk:system_ability_fwk", "samgr:samgr_proxy", "time_service:time_client", ] defines = [] if (device_usage_statistics_with_powermgr_power_manager_enable) { defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] external_deps += [ "power_manager:powermgr_client" ] } branch_protector_ret = "pac_ret" sanitize = { cfi = true cfi_cross_dso = true debug = false } } ohos_unittest("DeviceUsageStatsTest") { module_out_path = module_output_path cflags = [ "-Dprivate=public", "-Dprotected=public", ] sources = [ "device_usage_statistics_test.cpp" ] configs = [ ":module_private_config" ] deps = [ "../../:usagestatservice_static", "../../:usagestatsinner", "../../:usagestatsutils", "//third_party/jsoncpp:jsoncpp", ] external_deps = [ "access_token:libaccesstoken_sdk", "access_token:libnativetoken", "access_token:libtoken_setproc", "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", "hilog:libhilog", "ipc:ipc_single", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] defines = [] if (device_usage_statistics_with_powermgr_power_manager_enable) { defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] external_deps += [ "power_manager:powermgr_client" ] } branch_protector_ret = "pac_ret" sanitize = { cfi = true cfi_cross_dso = true debug = false } } ohos_unittest("DeviceUsageStatsMultiTest") { module_out_path = module_output_path cflags = [ "-Dprivate=public", "-Dprotected=public", ] sources = [ "device_usage_statistics_multi_test.cpp" ] configs = [ ":module_private_config" ] deps = [ "../../:usagestatservice_static", "../../:usagestatsinner", "../../:usagestatsutils", "//third_party/jsoncpp:jsoncpp", ] external_deps = [ "access_token:libaccesstoken_sdk", "access_token:libnativetoken", "access_token:libtoken_setproc", "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", "hilog:libhilog", "ipc:ipc_single", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] defines = [] if (device_usage_statistics_with_powermgr_power_manager_enable) { defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] external_deps += [ "power_manager:powermgr_client" ] } branch_protector_ret = "pac_ret" sanitize = { cfi = true cfi_cross_dso = true debug = false } } ohos_unittest("DeviceUsageStatsServiceTest") { module_out_path = module_output_path cflags = [ "-Dprivate=public", "-Dprotected=public", ] sources = [ "device_usage_statistics_service_test.cpp" ] configs = [ ":module_private_config" ] deps = [ "../../:usagestatservice_static", "../../:usagestatsinner", "../../:usagestatsutils", "//third_party/jsoncpp:jsoncpp", ] external_deps = [ "ability_runtime:app_manager", "ability_runtime:wantagent_innerkits", "access_token:libaccesstoken_sdk", "access_token:libnativetoken", "access_token:libtoken_setproc", "bundle_framework:appexecfwk_core", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ffrt:libffrt", "hilog:libhilog", "ipc:ipc_single", "relational_store:native_rdb", "safwk:system_ability_fwk", "samgr:samgr_proxy", "time_service:time_client", ] defines = [] if (device_usage_statistics_with_powermgr_power_manager_enable) { defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] external_deps += [ "power_manager:powermgr_client" ] } sanitize = { cfi = true cfi_cross_dso = true debug = false } branch_protector_ret = "pac_ret" } ohos_unittest("DeviceUsageStatsMockTest") { module_out_path = module_output_path cflags = [ "-Dprivate=public", "-Dprotected=public", ] sources = [ "device_usage_statistics_mock_test.cpp", "mock/bundle_active_account_helper_mock.cpp", "mock/bundle_active_client_mock.cpp", "mock/bundle_active_core_mock.cpp", "mock/bundle_active_usage_database_mock.cpp", "mock/mock_service_registry.cpp", ] include_dirs = [ "mock/include" ] configs = [ ":module_private_config" ] deps = [ "../../:usagestatservice_static", "../../:usagestatsinner", "../../:usagestatsutils", "//third_party/jsoncpp:jsoncpp", ] external_deps = [ "ability_runtime:app_manager", "ability_runtime:wantagent_innerkits", "access_token:libaccesstoken_sdk", "bundle_framework:appexecfwk_core", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ffrt:libffrt", "hilog:libhilog", "ipc:ipc_single", "relational_store:native_rdb", "safwk:system_ability_fwk", "samgr:samgr_proxy", "time_service:time_client", ] defines = [] if (device_usage_statistics_with_powermgr_power_manager_enable) { defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] external_deps += [ "power_manager:powermgr_client" ] } branch_protector_ret = "pac_ret" sanitize = { cfi = true cfi_cross_dso = true debug = false } } ohos_unittest("DeviceUsagePackageUsageTest") { module_out_path = module_output_path cflags = [ "-Dprivate=public", "-Dprotected=public", ] sources = [ "package_usage_test.cpp" ] configs = [ ":module_private_config" ] deps = [ "../../:usagestatservice_static", "../../:usagestatsinner", "../../:usagestatsutils", "//third_party/jsoncpp:jsoncpp", ] external_deps = [ "ability_runtime:app_manager", "ability_runtime:wantagent_innerkits", "access_token:libaccesstoken_sdk", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "ffrt:libffrt", "hilog:libhilog", "ipc:ipc_single", "relational_store:native_rdb", "safwk:system_ability_fwk", "samgr:samgr_proxy", "time_service:time_client", ] defines = [] if (device_usage_statistics_with_powermgr_power_manager_enable) { defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] external_deps += [ "power_manager:powermgr_client" ] } branch_protector_ret = "pac_ret" sanitize = { cfi = true cfi_cross_dso = true debug = false } } group("unittest") { testonly = true deps = [ ":BundleActiveTotalTest", ":DeviceUsagePackageUsageTest", ":DeviceUsageStatsMockTest", ":DeviceUsageStatsMultiTest", ":DeviceUsageStatsServiceTest", ":DeviceUsageStatsTest", ] }