122c0b7e4Sopenharmony_ci# Copyright (c) 2022  Huawei Device Co., Ltd.
222c0b7e4Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
322c0b7e4Sopenharmony_ci# you may not use this file except in compliance with the License.
422c0b7e4Sopenharmony_ci# You may obtain a copy of the License at
522c0b7e4Sopenharmony_ci#
622c0b7e4Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
722c0b7e4Sopenharmony_ci#
822c0b7e4Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
922c0b7e4Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
1022c0b7e4Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1122c0b7e4Sopenharmony_ci# See the License for the specific language governing permissions and
1222c0b7e4Sopenharmony_ci# limitations under the License.
1322c0b7e4Sopenharmony_ci
1422c0b7e4Sopenharmony_ciimport("//build/test.gni")
1522c0b7e4Sopenharmony_ciimport("../../device_usage_statistics.gni")
1622c0b7e4Sopenharmony_cimodule_output_path = "device_usage_statistics/deviceusagestatisticstest"
1722c0b7e4Sopenharmony_ci
1822c0b7e4Sopenharmony_ciconfig("module_private_config") {
1922c0b7e4Sopenharmony_ci  visibility = [ ":*" ]
2022c0b7e4Sopenharmony_ci
2122c0b7e4Sopenharmony_ci  include_dirs = [
2222c0b7e4Sopenharmony_ci    "../../interfaces/innerkits/include",
2322c0b7e4Sopenharmony_ci    "../../services/common/include",
2422c0b7e4Sopenharmony_ci    "../../services/packageusage/include",
2522c0b7e4Sopenharmony_ci    "../../services/packagegroup/include",
2622c0b7e4Sopenharmony_ci    "../../utils/include",
2722c0b7e4Sopenharmony_ci    "//third_party/jsoncpp/include",
2822c0b7e4Sopenharmony_ci  ]
2922c0b7e4Sopenharmony_ci}
3022c0b7e4Sopenharmony_ci
3122c0b7e4Sopenharmony_ciohos_unittest("BundleActiveTotalTest") {
3222c0b7e4Sopenharmony_ci  module_out_path = module_output_path
3322c0b7e4Sopenharmony_ci  cflags = [
3422c0b7e4Sopenharmony_ci    "-Dprivate=public",
3522c0b7e4Sopenharmony_ci    "-Dprotected=public",
3622c0b7e4Sopenharmony_ci  ]
3722c0b7e4Sopenharmony_ci
3822c0b7e4Sopenharmony_ci  sources = [
3922c0b7e4Sopenharmony_ci    "bundle_active_total_test.cpp",
4022c0b7e4Sopenharmony_ci    "bundle_active_usage_database_test.cpp",
4122c0b7e4Sopenharmony_ci  ]
4222c0b7e4Sopenharmony_ci
4322c0b7e4Sopenharmony_ci  configs = [ ":module_private_config" ]
4422c0b7e4Sopenharmony_ci
4522c0b7e4Sopenharmony_ci  deps = [
4622c0b7e4Sopenharmony_ci    "../../:usagestatservice_static",
4722c0b7e4Sopenharmony_ci    "../../:usagestatsinner",
4822c0b7e4Sopenharmony_ci    "../../:usagestatsutils",
4922c0b7e4Sopenharmony_ci    "//third_party/jsoncpp:jsoncpp",
5022c0b7e4Sopenharmony_ci  ]
5122c0b7e4Sopenharmony_ci
5222c0b7e4Sopenharmony_ci  external_deps = [
5322c0b7e4Sopenharmony_ci    "ability_base:want",
5422c0b7e4Sopenharmony_ci    "ability_runtime:app_manager",
5522c0b7e4Sopenharmony_ci    "ability_runtime:wantagent_innerkits",
5622c0b7e4Sopenharmony_ci    "access_token:libaccesstoken_sdk",
5722c0b7e4Sopenharmony_ci    "access_token:libtokenid_sdk",
5822c0b7e4Sopenharmony_ci    "bundle_framework:appexecfwk_base",
5922c0b7e4Sopenharmony_ci    "bundle_framework:appexecfwk_core",
6022c0b7e4Sopenharmony_ci    "c_utils:utils",
6122c0b7e4Sopenharmony_ci    "common_event_service:cesfwk_innerkits",
6222c0b7e4Sopenharmony_ci    "eventhandler:libeventhandler",
6322c0b7e4Sopenharmony_ci    "ffrt:libffrt",
6422c0b7e4Sopenharmony_ci    "hilog:libhilog",
6522c0b7e4Sopenharmony_ci    "init:libbegetutil",
6622c0b7e4Sopenharmony_ci    "ipc:ipc_single",
6722c0b7e4Sopenharmony_ci    "relational_store:native_rdb",
6822c0b7e4Sopenharmony_ci    "safwk:system_ability_fwk",
6922c0b7e4Sopenharmony_ci    "samgr:samgr_proxy",
7022c0b7e4Sopenharmony_ci    "time_service:time_client",
7122c0b7e4Sopenharmony_ci  ]
7222c0b7e4Sopenharmony_ci  defines = []
7322c0b7e4Sopenharmony_ci  if (device_usage_statistics_with_powermgr_power_manager_enable) {
7422c0b7e4Sopenharmony_ci    defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ]
7522c0b7e4Sopenharmony_ci    external_deps += [ "power_manager:powermgr_client" ]
7622c0b7e4Sopenharmony_ci  }
7722c0b7e4Sopenharmony_ci}
7822c0b7e4Sopenharmony_ci
7922c0b7e4Sopenharmony_ciohos_unittest("DeviceUsageStatsTest") {
8022c0b7e4Sopenharmony_ci  module_out_path = module_output_path
8122c0b7e4Sopenharmony_ci  cflags = [
8222c0b7e4Sopenharmony_ci    "-Dprivate=public",
8322c0b7e4Sopenharmony_ci    "-Dprotected=public",
8422c0b7e4Sopenharmony_ci  ]
8522c0b7e4Sopenharmony_ci
8622c0b7e4Sopenharmony_ci  sources = [ "device_usage_statistics_test.cpp" ]
8722c0b7e4Sopenharmony_ci
8822c0b7e4Sopenharmony_ci  configs = [ ":module_private_config" ]
8922c0b7e4Sopenharmony_ci
9022c0b7e4Sopenharmony_ci  deps = [
9122c0b7e4Sopenharmony_ci    "../../:usagestatservice_static",
9222c0b7e4Sopenharmony_ci    "../../:usagestatsinner",
9322c0b7e4Sopenharmony_ci    "../../:usagestatsutils",
9422c0b7e4Sopenharmony_ci    "//third_party/jsoncpp:jsoncpp",
9522c0b7e4Sopenharmony_ci  ]
9622c0b7e4Sopenharmony_ci
9722c0b7e4Sopenharmony_ci  external_deps = [
9822c0b7e4Sopenharmony_ci    "c_utils:utils",
9922c0b7e4Sopenharmony_ci    "eventhandler:libeventhandler",
10022c0b7e4Sopenharmony_ci    "ffrt:libffrt",
10122c0b7e4Sopenharmony_ci    "hilog:libhilog",
10222c0b7e4Sopenharmony_ci    "ipc:ipc_single",
10322c0b7e4Sopenharmony_ci    "safwk:system_ability_fwk",
10422c0b7e4Sopenharmony_ci    "samgr:samgr_proxy",
10522c0b7e4Sopenharmony_ci  ]
10622c0b7e4Sopenharmony_ci  defines = []
10722c0b7e4Sopenharmony_ci  if (device_usage_statistics_with_powermgr_power_manager_enable) {
10822c0b7e4Sopenharmony_ci    defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ]
10922c0b7e4Sopenharmony_ci    external_deps += [ "power_manager:powermgr_client" ]
11022c0b7e4Sopenharmony_ci  }
11122c0b7e4Sopenharmony_ci}
11222c0b7e4Sopenharmony_ci
11322c0b7e4Sopenharmony_ciohos_unittest("DeviceUsageStatsMultiTest") {
11422c0b7e4Sopenharmony_ci  module_out_path = module_output_path
11522c0b7e4Sopenharmony_ci  cflags = [
11622c0b7e4Sopenharmony_ci    "-Dprivate=public",
11722c0b7e4Sopenharmony_ci    "-Dprotected=public",
11822c0b7e4Sopenharmony_ci  ]
11922c0b7e4Sopenharmony_ci
12022c0b7e4Sopenharmony_ci  sources = [ "device_usage_statistics_multi_test.cpp" ]
12122c0b7e4Sopenharmony_ci
12222c0b7e4Sopenharmony_ci  configs = [ ":module_private_config" ]
12322c0b7e4Sopenharmony_ci
12422c0b7e4Sopenharmony_ci  deps = [
12522c0b7e4Sopenharmony_ci    "../../:usagestatservice_static",
12622c0b7e4Sopenharmony_ci    "../../:usagestatsinner",
12722c0b7e4Sopenharmony_ci    "../../:usagestatsutils",
12822c0b7e4Sopenharmony_ci    "//third_party/jsoncpp:jsoncpp",
12922c0b7e4Sopenharmony_ci  ]
13022c0b7e4Sopenharmony_ci
13122c0b7e4Sopenharmony_ci  external_deps = [
13222c0b7e4Sopenharmony_ci    "c_utils:utils",
13322c0b7e4Sopenharmony_ci    "eventhandler:libeventhandler",
13422c0b7e4Sopenharmony_ci    "ffrt:libffrt",
13522c0b7e4Sopenharmony_ci    "hilog:libhilog",
13622c0b7e4Sopenharmony_ci    "ipc:ipc_single",
13722c0b7e4Sopenharmony_ci    "safwk:system_ability_fwk",
13822c0b7e4Sopenharmony_ci    "samgr:samgr_proxy",
13922c0b7e4Sopenharmony_ci  ]
14022c0b7e4Sopenharmony_ci  defines = []
14122c0b7e4Sopenharmony_ci  if (device_usage_statistics_with_powermgr_power_manager_enable) {
14222c0b7e4Sopenharmony_ci    defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ]
14322c0b7e4Sopenharmony_ci    external_deps += [ "power_manager:powermgr_client" ]
14422c0b7e4Sopenharmony_ci  }
14522c0b7e4Sopenharmony_ci}
14622c0b7e4Sopenharmony_ci
14722c0b7e4Sopenharmony_ciohos_unittest("DeviceUsageStatsServiceTest") {
14822c0b7e4Sopenharmony_ci  module_out_path = module_output_path
14922c0b7e4Sopenharmony_ci  cflags = [
15022c0b7e4Sopenharmony_ci    "-Dprivate=public",
15122c0b7e4Sopenharmony_ci    "-Dprotected=public",
15222c0b7e4Sopenharmony_ci  ]
15322c0b7e4Sopenharmony_ci
15422c0b7e4Sopenharmony_ci  sources = [ "device_usage_statistics_service_test.cpp" ]
15522c0b7e4Sopenharmony_ci
15622c0b7e4Sopenharmony_ci  configs = [ ":module_private_config" ]
15722c0b7e4Sopenharmony_ci
15822c0b7e4Sopenharmony_ci  deps = [
15922c0b7e4Sopenharmony_ci    "../../:usagestatservice_static",
16022c0b7e4Sopenharmony_ci    "../../:usagestatsinner",
16122c0b7e4Sopenharmony_ci    "../../:usagestatsutils",
16222c0b7e4Sopenharmony_ci    "//third_party/jsoncpp:jsoncpp",
16322c0b7e4Sopenharmony_ci  ]
16422c0b7e4Sopenharmony_ci
16522c0b7e4Sopenharmony_ci  external_deps = [
16622c0b7e4Sopenharmony_ci    "ability_runtime:app_manager",
16722c0b7e4Sopenharmony_ci    "ability_runtime:wantagent_innerkits",
16822c0b7e4Sopenharmony_ci    "access_token:libaccesstoken_sdk",
16922c0b7e4Sopenharmony_ci    "bundle_framework:appexecfwk_core",
17022c0b7e4Sopenharmony_ci    "c_utils:utils",
17122c0b7e4Sopenharmony_ci    "common_event_service:cesfwk_innerkits",
17222c0b7e4Sopenharmony_ci    "eventhandler:libeventhandler",
17322c0b7e4Sopenharmony_ci    "ffrt:libffrt",
17422c0b7e4Sopenharmony_ci    "hilog:libhilog",
17522c0b7e4Sopenharmony_ci    "ipc:ipc_single",
17622c0b7e4Sopenharmony_ci    "relational_store:native_rdb",
17722c0b7e4Sopenharmony_ci    "safwk:system_ability_fwk",
17822c0b7e4Sopenharmony_ci    "samgr:samgr_proxy",
17922c0b7e4Sopenharmony_ci    "time_service:time_client",
18022c0b7e4Sopenharmony_ci  ]
18122c0b7e4Sopenharmony_ci  defines = []
18222c0b7e4Sopenharmony_ci  if (device_usage_statistics_with_powermgr_power_manager_enable) {
18322c0b7e4Sopenharmony_ci    defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ]
18422c0b7e4Sopenharmony_ci    external_deps += [ "power_manager:powermgr_client" ]
18522c0b7e4Sopenharmony_ci  }
18622c0b7e4Sopenharmony_ci
18722c0b7e4Sopenharmony_ci  sanitize = {
18822c0b7e4Sopenharmony_ci    cfi = true
18922c0b7e4Sopenharmony_ci    cfi_cross_dso = true
19022c0b7e4Sopenharmony_ci    debug = false
19122c0b7e4Sopenharmony_ci  }
19222c0b7e4Sopenharmony_ci  branch_protector_ret = "pac_ret"
19322c0b7e4Sopenharmony_ci}
19422c0b7e4Sopenharmony_ci
19522c0b7e4Sopenharmony_ciohos_unittest("DeviceUsageStatsMockTest") {
19622c0b7e4Sopenharmony_ci  module_out_path = module_output_path
19722c0b7e4Sopenharmony_ci  cflags = [
19822c0b7e4Sopenharmony_ci    "-Dprivate=public",
19922c0b7e4Sopenharmony_ci    "-Dprotected=public",
20022c0b7e4Sopenharmony_ci  ]
20122c0b7e4Sopenharmony_ci
20222c0b7e4Sopenharmony_ci  sources = [
20322c0b7e4Sopenharmony_ci    "device_usage_statistics_mock_test.cpp",
20422c0b7e4Sopenharmony_ci    "mock/bundle_active_account_helper_mock.cpp",
20522c0b7e4Sopenharmony_ci    "mock/bundle_active_client_mock.cpp",
20622c0b7e4Sopenharmony_ci    "mock/bundle_active_core_mock.cpp",
20722c0b7e4Sopenharmony_ci    "mock/bundle_active_usage_database_mock.cpp",
20822c0b7e4Sopenharmony_ci    "mock/mock_service_registry.cpp",
20922c0b7e4Sopenharmony_ci  ]
21022c0b7e4Sopenharmony_ci
21122c0b7e4Sopenharmony_ci  include_dirs = [ "mock/include" ]
21222c0b7e4Sopenharmony_ci
21322c0b7e4Sopenharmony_ci  configs = [ ":module_private_config" ]
21422c0b7e4Sopenharmony_ci
21522c0b7e4Sopenharmony_ci  deps = [
21622c0b7e4Sopenharmony_ci    "../../:usagestatservice_static",
21722c0b7e4Sopenharmony_ci    "../../:usagestatsinner",
21822c0b7e4Sopenharmony_ci    "../../:usagestatsutils",
21922c0b7e4Sopenharmony_ci    "//third_party/jsoncpp:jsoncpp",
22022c0b7e4Sopenharmony_ci  ]
22122c0b7e4Sopenharmony_ci
22222c0b7e4Sopenharmony_ci  external_deps = [
22322c0b7e4Sopenharmony_ci    "ability_runtime:app_manager",
22422c0b7e4Sopenharmony_ci    "ability_runtime:wantagent_innerkits",
22522c0b7e4Sopenharmony_ci    "access_token:libaccesstoken_sdk",
22622c0b7e4Sopenharmony_ci    "bundle_framework:appexecfwk_core",
22722c0b7e4Sopenharmony_ci    "c_utils:utils",
22822c0b7e4Sopenharmony_ci    "common_event_service:cesfwk_innerkits",
22922c0b7e4Sopenharmony_ci    "eventhandler:libeventhandler",
23022c0b7e4Sopenharmony_ci    "ffrt:libffrt",
23122c0b7e4Sopenharmony_ci    "hilog:libhilog",
23222c0b7e4Sopenharmony_ci    "ipc:ipc_single",
23322c0b7e4Sopenharmony_ci    "relational_store:native_rdb",
23422c0b7e4Sopenharmony_ci    "safwk:system_ability_fwk",
23522c0b7e4Sopenharmony_ci    "samgr:samgr_proxy",
23622c0b7e4Sopenharmony_ci    "time_service:time_client",
23722c0b7e4Sopenharmony_ci  ]
23822c0b7e4Sopenharmony_ci  defines = []
23922c0b7e4Sopenharmony_ci  if (device_usage_statistics_with_powermgr_power_manager_enable) {
24022c0b7e4Sopenharmony_ci    defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ]
24122c0b7e4Sopenharmony_ci    external_deps += [ "power_manager:powermgr_client" ]
24222c0b7e4Sopenharmony_ci  }
24322c0b7e4Sopenharmony_ci}
24422c0b7e4Sopenharmony_ci
24522c0b7e4Sopenharmony_ciohos_unittest("DeviceUsagePackageUsageTest") {
24622c0b7e4Sopenharmony_ci  module_out_path = module_output_path
24722c0b7e4Sopenharmony_ci  cflags = [
24822c0b7e4Sopenharmony_ci    "-Dprivate=public",
24922c0b7e4Sopenharmony_ci    "-Dprotected=public",
25022c0b7e4Sopenharmony_ci  ]
25122c0b7e4Sopenharmony_ci
25222c0b7e4Sopenharmony_ci  sources = [ "package_usage_test.cpp" ]
25322c0b7e4Sopenharmony_ci
25422c0b7e4Sopenharmony_ci  configs = [ ":module_private_config" ]
25522c0b7e4Sopenharmony_ci
25622c0b7e4Sopenharmony_ci  deps = [
25722c0b7e4Sopenharmony_ci    "../../:usagestatservice_static",
25822c0b7e4Sopenharmony_ci    "../../:usagestatsinner",
25922c0b7e4Sopenharmony_ci    "../../:usagestatsutils",
26022c0b7e4Sopenharmony_ci    "//third_party/jsoncpp:jsoncpp",
26122c0b7e4Sopenharmony_ci  ]
26222c0b7e4Sopenharmony_ci
26322c0b7e4Sopenharmony_ci  external_deps = [
26422c0b7e4Sopenharmony_ci    "ability_runtime:app_manager",
26522c0b7e4Sopenharmony_ci    "ability_runtime:wantagent_innerkits",
26622c0b7e4Sopenharmony_ci    "access_token:libaccesstoken_sdk",
26722c0b7e4Sopenharmony_ci    "bundle_framework:appexecfwk_base",
26822c0b7e4Sopenharmony_ci    "bundle_framework:appexecfwk_core",
26922c0b7e4Sopenharmony_ci    "c_utils:utils",
27022c0b7e4Sopenharmony_ci    "common_event_service:cesfwk_innerkits",
27122c0b7e4Sopenharmony_ci    "eventhandler:libeventhandler",
27222c0b7e4Sopenharmony_ci    "ffrt:libffrt",
27322c0b7e4Sopenharmony_ci    "hilog:libhilog",
27422c0b7e4Sopenharmony_ci    "ipc:ipc_single",
27522c0b7e4Sopenharmony_ci    "relational_store:native_rdb",
27622c0b7e4Sopenharmony_ci    "safwk:system_ability_fwk",
27722c0b7e4Sopenharmony_ci    "samgr:samgr_proxy",
27822c0b7e4Sopenharmony_ci    "time_service:time_client",
27922c0b7e4Sopenharmony_ci  ]
28022c0b7e4Sopenharmony_ci  defines = []
28122c0b7e4Sopenharmony_ci  if (device_usage_statistics_with_powermgr_power_manager_enable) {
28222c0b7e4Sopenharmony_ci    defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ]
28322c0b7e4Sopenharmony_ci    external_deps += [ "power_manager:powermgr_client" ]
28422c0b7e4Sopenharmony_ci  }
28522c0b7e4Sopenharmony_ci}
28622c0b7e4Sopenharmony_ci
28722c0b7e4Sopenharmony_cigroup("unittest") {
28822c0b7e4Sopenharmony_ci  testonly = true
28922c0b7e4Sopenharmony_ci  deps = [
29022c0b7e4Sopenharmony_ci    ":BundleActiveTotalTest",
29122c0b7e4Sopenharmony_ci    ":DeviceUsagePackageUsageTest",
29222c0b7e4Sopenharmony_ci    ":DeviceUsageStatsMockTest",
29322c0b7e4Sopenharmony_ci    ":DeviceUsageStatsMultiTest",
29422c0b7e4Sopenharmony_ci    ":DeviceUsageStatsServiceTest",
29522c0b7e4Sopenharmony_ci    ":DeviceUsageStatsTest",
29622c0b7e4Sopenharmony_ci  ]
29722c0b7e4Sopenharmony_ci}
298