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 34 sources = [ "bundle_active_total_test.cpp" ] 35 36 configs = [ ":module_private_config" ] 37 38 deps = [ 39 "../../:usagestatservice_static", 40 "../../:usagestatsinner", 41 "../../:usagestatsutils", 42 "//third_party/jsoncpp:jsoncpp", 43 ] 44 45 external_deps = [ 46 "ability_base:want", 47 "ability_runtime:app_manager", 48 "ability_runtime:wantagent_innerkits", 49 "access_token:libaccesstoken_sdk", 50 "access_token:libtokenid_sdk", 51 "bundle_framework:appexecfwk_base", 52 "bundle_framework:appexecfwk_core", 53 "c_utils:utils", 54 "common_event_service:cesfwk_innerkits", 55 "eventhandler:libeventhandler", 56 "hilog:libhilog", 57 "init:libbegetutil", 58 "ipc:ipc_single", 59 "relational_store:native_rdb", 60 "safwk:system_ability_fwk", 61 "samgr:samgr_proxy", 62 "time_service:time_client", 63 ] 64 defines = [] 65 if (device_usage_statistics_with_powermgr_power_manager_enable) { 66 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 67 external_deps += [ "power_manager:powermgr_client" ] 68 } 69} 70 71ohos_unittest("DeviceUsageStatsTest") { 72 module_out_path = module_output_path 73 74 sources = [ "device_usage_statistics_test.cpp" ] 75 76 configs = [ ":module_private_config" ] 77 78 deps = [ 79 "../../:usagestatservice_static", 80 "../../:usagestatsinner", 81 "../../:usagestatsutils", 82 "//third_party/jsoncpp:jsoncpp", 83 ] 84 85 external_deps = [ 86 "c_utils:utils", 87 "eventhandler:libeventhandler", 88 "hilog:libhilog", 89 "ipc:ipc_single", 90 "safwk:system_ability_fwk", 91 "samgr:samgr_proxy", 92 ] 93 defines = [] 94 if (device_usage_statistics_with_powermgr_power_manager_enable) { 95 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 96 external_deps += [ "power_manager:powermgr_client" ] 97 } 98} 99 100ohos_unittest("DeviceUsageStatsMultiTest") { 101 module_out_path = module_output_path 102 103 sources = [ "device_usage_statistics_multi_test.cpp" ] 104 105 configs = [ ":module_private_config" ] 106 107 deps = [ 108 "../../:usagestatservice_static", 109 "../../:usagestatsinner", 110 "../../:usagestatsutils", 111 "//third_party/jsoncpp:jsoncpp", 112 ] 113 114 external_deps = [ 115 "c_utils:utils", 116 "eventhandler:libeventhandler", 117 "hilog:libhilog", 118 "ipc:ipc_single", 119 "safwk:system_ability_fwk", 120 "samgr:samgr_proxy", 121 ] 122 defines = [] 123 if (device_usage_statistics_with_powermgr_power_manager_enable) { 124 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 125 external_deps += [ "power_manager:powermgr_client" ] 126 } 127} 128 129ohos_unittest("DeviceUsageStatsServiceTest") { 130 module_out_path = module_output_path 131 132 sources = [ "device_usage_statistics_service_test.cpp" ] 133 134 configs = [ ":module_private_config" ] 135 136 deps = [ 137 "../../:usagestatservice_static", 138 "../../:usagestatsinner", 139 "../../:usagestatsutils", 140 "//third_party/jsoncpp:jsoncpp", 141 ] 142 143 external_deps = [ 144 "ability_runtime:app_manager", 145 "ability_runtime:wantagent_innerkits", 146 "access_token:libaccesstoken_sdk", 147 "bundle_framework:appexecfwk_core", 148 "c_utils:utils", 149 "common_event_service:cesfwk_innerkits", 150 "eventhandler:libeventhandler", 151 "hilog:libhilog", 152 "ipc:ipc_single", 153 "relational_store:native_rdb", 154 "safwk:system_ability_fwk", 155 "samgr:samgr_proxy", 156 "time_service:time_client", 157 ] 158 defines = [] 159 if (device_usage_statistics_with_powermgr_power_manager_enable) { 160 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 161 external_deps += [ "power_manager:powermgr_client" ] 162 } 163 164 sanitize = { 165 cfi = true 166 cfi_cross_dso = true 167 debug = false 168 } 169 branch_protector_ret = "pac_ret" 170} 171 172ohos_unittest("DeviceUsageStatsMockTest") { 173 module_out_path = module_output_path 174 175 sources = [ 176 "device_usage_statistics_mock_test.cpp", 177 "mock/bundle_active_account_helper_mock.cpp", 178 "mock/bundle_active_client_mock.cpp", 179 "mock/bundle_active_core_mock.cpp", 180 "mock/bundle_active_usage_database_mock.cpp", 181 "mock/mock_service_registry.cpp", 182 ] 183 184 include_dirs = [ "mock/include" ] 185 186 configs = [ ":module_private_config" ] 187 188 deps = [ 189 "../../:usagestatservice_static", 190 "../../:usagestatsinner", 191 "../../:usagestatsutils", 192 "//third_party/jsoncpp:jsoncpp", 193 ] 194 195 external_deps = [ 196 "ability_runtime:app_manager", 197 "ability_runtime:wantagent_innerkits", 198 "access_token:libaccesstoken_sdk", 199 "bundle_framework:appexecfwk_core", 200 "c_utils:utils", 201 "common_event_service:cesfwk_innerkits", 202 "eventhandler:libeventhandler", 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 217ohos_unittest("DeviceUsagePackageUsageTest") { 218 module_out_path = module_output_path 219 220 sources = [ "package_usage_test.cpp" ] 221 222 configs = [ ":module_private_config" ] 223 224 deps = [ 225 "../../:usagestatservice_static", 226 "../../:usagestatsinner", 227 "../../:usagestatsutils", 228 "//third_party/jsoncpp:jsoncpp", 229 ] 230 231 external_deps = [ 232 "ability_runtime:app_manager", 233 "ability_runtime:wantagent_innerkits", 234 "access_token:libaccesstoken_sdk", 235 "bundle_framework:appexecfwk_base", 236 "bundle_framework:appexecfwk_core", 237 "c_utils:utils", 238 "common_event_service:cesfwk_innerkits", 239 "eventhandler:libeventhandler", 240 "hilog:libhilog", 241 "ipc:ipc_single", 242 "relational_store:native_rdb", 243 "safwk:system_ability_fwk", 244 "samgr:samgr_proxy", 245 "time_service:time_client", 246 ] 247 defines = [] 248 if (device_usage_statistics_with_powermgr_power_manager_enable) { 249 defines += [ "DEVICE_USAGES_STATISTICS_POWERMANGER_ENABLE" ] 250 external_deps += [ "power_manager:powermgr_client" ] 251 } 252} 253 254group("unittest") { 255 testonly = true 256 deps = [ 257 ":BundleActiveTotalTest", 258 ":DeviceUsagePackageUsageTest", 259 ":DeviceUsageStatsMockTest", 260 ":DeviceUsageStatsMultiTest", 261 ":DeviceUsageStatsServiceTest", 262 ":DeviceUsageStatsTest", 263 ] 264} 265