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 = "device_usage_statistics/deviceusagestatisticstest" 17 18config("module_private_config") { 19 visibility = [ ":*" ] 20 21 include_dirs = [ 22 "../../interfaces/innerkits/include", 23 "../../services/common/include", 24 "../../services/packageusage/include", 25 "../../services/packagegroup/include", 26 "../../utils/include", 27 "//third_party/jsoncpp/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 "//third_party/jsoncpp:jsoncpp", 50 ] 51 52 external_deps = [ 53 "ability_base:want", 54 "ability_runtime:app_manager", 55 "ability_runtime:wantagent_innerkits", 56 "access_token:libaccesstoken_sdk", 57 "access_token:libtokenid_sdk", 58 "bundle_framework:appexecfwk_base", 59 "bundle_framework:appexecfwk_core", 60 "c_utils:utils", 61 "common_event_service:cesfwk_innerkits", 62 "eventhandler:libeventhandler", 63 "ffrt:libffrt", 64 "hilog:libhilog", 65 "init:libbegetutil", 66 "ipc:ipc_single", 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 "//third_party/jsoncpp:jsoncpp", 102 ] 103 104 external_deps = [ 105 "access_token:libaccesstoken_sdk", 106 "access_token:libnativetoken", 107 "access_token:libtoken_setproc", 108 "c_utils:utils", 109 "eventhandler:libeventhandler", 110 "ffrt:libffrt", 111 "hilog:libhilog", 112 "ipc:ipc_single", 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 "//third_party/jsoncpp:jsoncpp", 146 ] 147 148 external_deps = [ 149 "access_token:libaccesstoken_sdk", 150 "access_token:libnativetoken", 151 "access_token:libtoken_setproc", 152 "c_utils:utils", 153 "eventhandler:libeventhandler", 154 "ffrt:libffrt", 155 "hilog:libhilog", 156 "ipc:ipc_single", 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 "//third_party/jsoncpp:jsoncpp", 190 ] 191 192 external_deps = [ 193 "ability_runtime:app_manager", 194 "ability_runtime:wantagent_innerkits", 195 "access_token:libaccesstoken_sdk", 196 "access_token:libnativetoken", 197 "access_token:libtoken_setproc", 198 "bundle_framework:appexecfwk_core", 199 "c_utils:utils", 200 "common_event_service:cesfwk_innerkits", 201 "eventhandler:libeventhandler", 202 "ffrt:libffrt", 203 "hilog:libhilog", 204 "ipc:ipc_single", 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 "//third_party/jsoncpp:jsoncpp", 249 ] 250 251 external_deps = [ 252 "ability_runtime:app_manager", 253 "ability_runtime:wantagent_innerkits", 254 "access_token:libaccesstoken_sdk", 255 "bundle_framework:appexecfwk_core", 256 "c_utils:utils", 257 "common_event_service:cesfwk_innerkits", 258 "eventhandler:libeventhandler", 259 "ffrt:libffrt", 260 "hilog:libhilog", 261 "ipc:ipc_single", 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 "//third_party/jsoncpp:jsoncpp", 297 ] 298 299 external_deps = [ 300 "ability_runtime:app_manager", 301 "ability_runtime:wantagent_innerkits", 302 "access_token:libaccesstoken_sdk", 303 "bundle_framework:appexecfwk_base", 304 "bundle_framework:appexecfwk_core", 305 "c_utils:utils", 306 "common_event_service:cesfwk_innerkits", 307 "eventhandler:libeventhandler", 308 "ffrt:libffrt", 309 "hilog:libhilog", 310 "ipc:ipc_single", 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