1# Copyright (c) 2022 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("../../device_usage_statistics.gni") 16module_output_path = 17 "device_usage_statistics/device_usage_statistics/deviceusagestatisticstest" 18 19config("module_private_config") { 20 visibility = [ ":*" ] 21 22 include_dirs = [ 23 "../../interfaces/innerkits/include", 24 "../../services/common/include", 25 "../../services/packageusage/include", 26 "../../services/packagegroup/include", 27 "../../utils/include", 28 ] 29} 30 31ohos_unittest("BundleActiveTotalTest") { 32 module_out_path = module_output_path 33 cflags = [ 34 "-Dprivate=public", 35 "-Dprotected=public", 36 ] 37 38 sources = [ 39 "bundle_active_total_test.cpp", 40 "bundle_active_usage_database_test.cpp", 41 ] 42 43 configs = [ ":module_private_config" ] 44 45 deps = [ 46 "../../:usagestatservice_static", 47 "../../:usagestatsinner", 48 "../../:usagestatsutils", 49 ] 50 51 external_deps = [ 52 "ability_base:want", 53 "ability_runtime:app_manager", 54 "ability_runtime:wantagent_innerkits", 55 "access_token:libaccesstoken_sdk", 56 "access_token:libtokenid_sdk", 57 "bundle_framework:appexecfwk_base", 58 "bundle_framework:appexecfwk_core", 59 "c_utils:utils", 60 "common_event_service:cesfwk_innerkits", 61 "eventhandler:libeventhandler", 62 "ffrt:libffrt", 63 "hilog:libhilog", 64 "init:libbegetutil", 65 "ipc:ipc_single", 66 "jsoncpp:jsoncpp", 67 "relational_store:native_rdb", 68 "safwk:system_ability_fwk", 69 "samgr:samgr_proxy", 70 "time_service:time_client", 71 ] 72 defines = [] 73 if (device_usage_statistics_with_powermgr_power_manager_enable) { 74 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 75 external_deps += [ "power_manager:powermgr_client" ] 76 } 77 branch_protector_ret = "pac_ret" 78 79 sanitize = { 80 cfi = true 81 cfi_cross_dso = true 82 debug = false 83 } 84} 85 86ohos_unittest("DeviceUsageStatsTest") { 87 module_out_path = module_output_path 88 cflags = [ 89 "-Dprivate=public", 90 "-Dprotected=public", 91 ] 92 93 sources = [ "device_usage_statistics_test.cpp" ] 94 95 configs = [ ":module_private_config" ] 96 97 deps = [ 98 "../../:usagestatservice_static", 99 "../../:usagestatsinner", 100 "../../:usagestatsutils", 101 ] 102 103 external_deps = [ 104 "access_token:libaccesstoken_sdk", 105 "access_token:libnativetoken", 106 "access_token:libtoken_setproc", 107 "c_utils:utils", 108 "eventhandler:libeventhandler", 109 "ffrt:libffrt", 110 "hilog:libhilog", 111 "ipc:ipc_single", 112 "jsoncpp:jsoncpp", 113 "safwk:system_ability_fwk", 114 "samgr:samgr_proxy", 115 ] 116 defines = [] 117 if (device_usage_statistics_with_powermgr_power_manager_enable) { 118 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 119 external_deps += [ "power_manager:powermgr_client" ] 120 } 121 branch_protector_ret = "pac_ret" 122 123 sanitize = { 124 cfi = true 125 cfi_cross_dso = true 126 debug = false 127 } 128} 129 130ohos_unittest("DeviceUsageStatsMultiTest") { 131 module_out_path = module_output_path 132 cflags = [ 133 "-Dprivate=public", 134 "-Dprotected=public", 135 ] 136 137 sources = [ "device_usage_statistics_multi_test.cpp" ] 138 139 configs = [ ":module_private_config" ] 140 141 deps = [ 142 "../../:usagestatservice_static", 143 "../../:usagestatsinner", 144 "../../:usagestatsutils", 145 ] 146 147 external_deps = [ 148 "access_token:libaccesstoken_sdk", 149 "access_token:libnativetoken", 150 "access_token:libtoken_setproc", 151 "c_utils:utils", 152 "eventhandler:libeventhandler", 153 "ffrt:libffrt", 154 "hilog:libhilog", 155 "ipc:ipc_single", 156 "jsoncpp:jsoncpp", 157 "safwk:system_ability_fwk", 158 "samgr:samgr_proxy", 159 ] 160 defines = [] 161 if (device_usage_statistics_with_powermgr_power_manager_enable) { 162 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 163 external_deps += [ "power_manager:powermgr_client" ] 164 } 165 branch_protector_ret = "pac_ret" 166 167 sanitize = { 168 cfi = true 169 cfi_cross_dso = true 170 debug = false 171 } 172} 173 174ohos_unittest("DeviceUsageStatsServiceTest") { 175 module_out_path = module_output_path 176 cflags = [ 177 "-Dprivate=public", 178 "-Dprotected=public", 179 ] 180 181 sources = [ "device_usage_statistics_service_test.cpp" ] 182 183 configs = [ ":module_private_config" ] 184 185 deps = [ 186 "../../:usagestatservice_static", 187 "../../:usagestatsinner", 188 "../../:usagestatsutils", 189 ] 190 191 external_deps = [ 192 "ability_runtime:app_manager", 193 "ability_runtime:wantagent_innerkits", 194 "access_token:libaccesstoken_sdk", 195 "access_token:libnativetoken", 196 "access_token:libtoken_setproc", 197 "bundle_framework:appexecfwk_core", 198 "c_utils:utils", 199 "common_event_service:cesfwk_innerkits", 200 "eventhandler:libeventhandler", 201 "ffrt:libffrt", 202 "hilog:libhilog", 203 "ipc:ipc_single", 204 "jsoncpp:jsoncpp", 205 "relational_store:native_rdb", 206 "safwk:system_ability_fwk", 207 "samgr:samgr_proxy", 208 "time_service:time_client", 209 ] 210 defines = [] 211 if (device_usage_statistics_with_powermgr_power_manager_enable) { 212 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 213 external_deps += [ "power_manager:powermgr_client" ] 214 } 215 216 sanitize = { 217 cfi = true 218 cfi_cross_dso = true 219 debug = false 220 } 221 branch_protector_ret = "pac_ret" 222} 223 224ohos_unittest("DeviceUsageStatsMockTest") { 225 module_out_path = module_output_path 226 cflags = [ 227 "-Dprivate=public", 228 "-Dprotected=public", 229 ] 230 231 sources = [ 232 "device_usage_statistics_mock_test.cpp", 233 "mock/bundle_active_account_helper_mock.cpp", 234 "mock/bundle_active_client_mock.cpp", 235 "mock/bundle_active_core_mock.cpp", 236 "mock/bundle_active_usage_database_mock.cpp", 237 "mock/mock_service_registry.cpp", 238 ] 239 240 include_dirs = [ "mock/include" ] 241 242 configs = [ ":module_private_config" ] 243 244 deps = [ 245 "../../:usagestatservice_static", 246 "../../:usagestatsinner", 247 "../../:usagestatsutils", 248 ] 249 250 external_deps = [ 251 "ability_runtime:app_manager", 252 "ability_runtime:wantagent_innerkits", 253 "access_token:libaccesstoken_sdk", 254 "bundle_framework:appexecfwk_core", 255 "c_utils:utils", 256 "common_event_service:cesfwk_innerkits", 257 "eventhandler:libeventhandler", 258 "ffrt:libffrt", 259 "hilog:libhilog", 260 "ipc:ipc_single", 261 "jsoncpp:jsoncpp", 262 "relational_store:native_rdb", 263 "safwk:system_ability_fwk", 264 "samgr:samgr_proxy", 265 "time_service:time_client", 266 ] 267 defines = [] 268 if (device_usage_statistics_with_powermgr_power_manager_enable) { 269 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 270 external_deps += [ "power_manager:powermgr_client" ] 271 } 272 branch_protector_ret = "pac_ret" 273 274 sanitize = { 275 cfi = true 276 cfi_cross_dso = true 277 debug = false 278 } 279} 280 281ohos_unittest("DeviceUsagePackageUsageTest") { 282 module_out_path = module_output_path 283 cflags = [ 284 "-Dprivate=public", 285 "-Dprotected=public", 286 ] 287 288 sources = [ "package_usage_test.cpp" ] 289 290 configs = [ ":module_private_config" ] 291 292 deps = [ 293 "../../:usagestatservice_static", 294 "../../:usagestatsinner", 295 "../../:usagestatsutils", 296 ] 297 298 external_deps = [ 299 "ability_runtime:app_manager", 300 "ability_runtime:wantagent_innerkits", 301 "access_token:libaccesstoken_sdk", 302 "bundle_framework:appexecfwk_base", 303 "bundle_framework:appexecfwk_core", 304 "c_utils:utils", 305 "common_event_service:cesfwk_innerkits", 306 "eventhandler:libeventhandler", 307 "ffrt:libffrt", 308 "hilog:libhilog", 309 "ipc:ipc_single", 310 "jsoncpp:jsoncpp", 311 "relational_store:native_rdb", 312 "safwk:system_ability_fwk", 313 "samgr:samgr_proxy", 314 "time_service:time_client", 315 ] 316 defines = [] 317 if (device_usage_statistics_with_powermgr_power_manager_enable) { 318 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 319 external_deps += [ "power_manager:powermgr_client" ] 320 } 321 branch_protector_ret = "pac_ret" 322 323 sanitize = { 324 cfi = true 325 cfi_cross_dso = true 326 debug = false 327 } 328} 329 330group("unittest") { 331 testonly = true 332 deps = [ 333 ":BundleActiveTotalTest", 334 ":DeviceUsagePackageUsageTest", 335 ":DeviceUsageStatsMockTest", 336 ":DeviceUsageStatsMultiTest", 337 ":DeviceUsageStatsServiceTest", 338 ":DeviceUsageStatsTest", 339 ] 340} 341