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} 78 79ohos_unittest("DeviceUsageStatsTest") { 80 module_out_path = module_output_path 81 cflags = [ 82 "-Dprivate=public", 83 "-Dprotected=public", 84 ] 85 86 sources = [ "device_usage_statistics_test.cpp" ] 87 88 configs = [ ":module_private_config" ] 89 90 deps = [ 91 "../../:usagestatservice_static", 92 "../../:usagestatsinner", 93 "../../:usagestatsutils", 94 "//third_party/jsoncpp:jsoncpp", 95 ] 96 97 external_deps = [ 98 "c_utils:utils", 99 "eventhandler:libeventhandler", 100 "ffrt:libffrt", 101 "hilog:libhilog", 102 "ipc:ipc_single", 103 "safwk:system_ability_fwk", 104 "samgr:samgr_proxy", 105 ] 106 defines = [] 107 if (device_usage_statistics_with_powermgr_power_manager_enable) { 108 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 109 external_deps += [ "power_manager:powermgr_client" ] 110 } 111} 112 113ohos_unittest("DeviceUsageStatsMultiTest") { 114 module_out_path = module_output_path 115 cflags = [ 116 "-Dprivate=public", 117 "-Dprotected=public", 118 ] 119 120 sources = [ "device_usage_statistics_multi_test.cpp" ] 121 122 configs = [ ":module_private_config" ] 123 124 deps = [ 125 "../../:usagestatservice_static", 126 "../../:usagestatsinner", 127 "../../:usagestatsutils", 128 "//third_party/jsoncpp:jsoncpp", 129 ] 130 131 external_deps = [ 132 "c_utils:utils", 133 "eventhandler:libeventhandler", 134 "ffrt:libffrt", 135 "hilog:libhilog", 136 "ipc:ipc_single", 137 "safwk:system_ability_fwk", 138 "samgr:samgr_proxy", 139 ] 140 defines = [] 141 if (device_usage_statistics_with_powermgr_power_manager_enable) { 142 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 143 external_deps += [ "power_manager:powermgr_client" ] 144 } 145} 146 147ohos_unittest("DeviceUsageStatsServiceTest") { 148 module_out_path = module_output_path 149 cflags = [ 150 "-Dprivate=public", 151 "-Dprotected=public", 152 ] 153 154 sources = [ "device_usage_statistics_service_test.cpp" ] 155 156 configs = [ ":module_private_config" ] 157 158 deps = [ 159 "../../:usagestatservice_static", 160 "../../:usagestatsinner", 161 "../../:usagestatsutils", 162 "//third_party/jsoncpp:jsoncpp", 163 ] 164 165 external_deps = [ 166 "ability_runtime:app_manager", 167 "ability_runtime:wantagent_innerkits", 168 "access_token:libaccesstoken_sdk", 169 "bundle_framework:appexecfwk_core", 170 "c_utils:utils", 171 "common_event_service:cesfwk_innerkits", 172 "eventhandler:libeventhandler", 173 "ffrt:libffrt", 174 "hilog:libhilog", 175 "ipc:ipc_single", 176 "relational_store:native_rdb", 177 "safwk:system_ability_fwk", 178 "samgr:samgr_proxy", 179 "time_service:time_client", 180 ] 181 defines = [] 182 if (device_usage_statistics_with_powermgr_power_manager_enable) { 183 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 184 external_deps += [ "power_manager:powermgr_client" ] 185 } 186 187 sanitize = { 188 cfi = true 189 cfi_cross_dso = true 190 debug = false 191 } 192 branch_protector_ret = "pac_ret" 193} 194 195ohos_unittest("DeviceUsageStatsMockTest") { 196 module_out_path = module_output_path 197 cflags = [ 198 "-Dprivate=public", 199 "-Dprotected=public", 200 ] 201 202 sources = [ 203 "device_usage_statistics_mock_test.cpp", 204 "mock/bundle_active_account_helper_mock.cpp", 205 "mock/bundle_active_client_mock.cpp", 206 "mock/bundle_active_core_mock.cpp", 207 "mock/bundle_active_usage_database_mock.cpp", 208 "mock/mock_service_registry.cpp", 209 ] 210 211 include_dirs = [ "mock/include" ] 212 213 configs = [ ":module_private_config" ] 214 215 deps = [ 216 "../../:usagestatservice_static", 217 "../../:usagestatsinner", 218 "../../:usagestatsutils", 219 "//third_party/jsoncpp:jsoncpp", 220 ] 221 222 external_deps = [ 223 "ability_runtime:app_manager", 224 "ability_runtime:wantagent_innerkits", 225 "access_token:libaccesstoken_sdk", 226 "bundle_framework:appexecfwk_core", 227 "c_utils:utils", 228 "common_event_service:cesfwk_innerkits", 229 "eventhandler:libeventhandler", 230 "ffrt:libffrt", 231 "hilog:libhilog", 232 "ipc:ipc_single", 233 "relational_store:native_rdb", 234 "safwk:system_ability_fwk", 235 "samgr:samgr_proxy", 236 "time_service:time_client", 237 ] 238 defines = [] 239 if (device_usage_statistics_with_powermgr_power_manager_enable) { 240 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 241 external_deps += [ "power_manager:powermgr_client" ] 242 } 243} 244 245ohos_unittest("DeviceUsagePackageUsageTest") { 246 module_out_path = module_output_path 247 cflags = [ 248 "-Dprivate=public", 249 "-Dprotected=public", 250 ] 251 252 sources = [ "package_usage_test.cpp" ] 253 254 configs = [ ":module_private_config" ] 255 256 deps = [ 257 "../../:usagestatservice_static", 258 "../../:usagestatsinner", 259 "../../:usagestatsutils", 260 "//third_party/jsoncpp:jsoncpp", 261 ] 262 263 external_deps = [ 264 "ability_runtime:app_manager", 265 "ability_runtime:wantagent_innerkits", 266 "access_token:libaccesstoken_sdk", 267 "bundle_framework:appexecfwk_base", 268 "bundle_framework:appexecfwk_core", 269 "c_utils:utils", 270 "common_event_service:cesfwk_innerkits", 271 "eventhandler:libeventhandler", 272 "ffrt:libffrt", 273 "hilog:libhilog", 274 "ipc:ipc_single", 275 "relational_store:native_rdb", 276 "safwk:system_ability_fwk", 277 "samgr:samgr_proxy", 278 "time_service:time_client", 279 ] 280 defines = [] 281 if (device_usage_statistics_with_powermgr_power_manager_enable) { 282 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 283 external_deps += [ "power_manager:powermgr_client" ] 284 } 285} 286 287group("unittest") { 288 testonly = true 289 deps = [ 290 ":BundleActiveTotalTest", 291 ":DeviceUsagePackageUsageTest", 292 ":DeviceUsageStatsMockTest", 293 ":DeviceUsageStatsMultiTest", 294 ":DeviceUsageStatsServiceTest", 295 ":DeviceUsageStatsTest", 296 ] 297} 298