1# Copyright (c) 2021-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("//base/powermgr/battery_statistics/batterystats.gni") 15import("//build/test.gni") 16 17module_output_path = "${batterystats_part_name}/batterystats" 18 19config("module_private_config") { 20 visibility = [ ":*" ] 21 22 include_dirs = [ 23 "include", 24 "${batterystats_service_native}/include", 25 "//base/telephony/call_manager/interfaces/innerkits", 26 "//foundation/communication/bluetooth/services/bluetooth/common", 27 "//foundation/communication/wifi/wifi/utils/inc", 28 ] 29} 30 31config("module_mock_private_config") { 32 include_dirs = [ 33 "include/mock", 34 "mock/include", 35 "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include/", 36 "//commonlibrary/c_utils/base/include/", 37 ] 38} 39 40deps_ex = [ 41 "ability_base:base", 42 "ability_base:want", 43 "common_event_service:cesfwk_innerkits", 44 "c_utils:utils", 45 "eventhandler:libeventhandler", 46 "hisysevent_native:libhisysevent", 47 "hiviewdfx_hilog_native:libhilog", 48 "ipc:ipc_core", 49 "safwk:system_ability_fwk", 50 "samgr:samgr_proxy", 51 "power_manager:powermgr_client", 52 "display_manager:displaymgr", 53] 54 55############################service_test############################# 56ohos_unittest("stats_service_test") { 57 module_out_path = module_output_path 58 59 sources = [ "src/stats_service_test.cpp" ] 60 61 configs = [ ":module_private_config" ] 62 63 deps = [ "//third_party/googletest:gtest_main" ] 64 65 external_deps = deps_ex 66} 67 68############################service_death_test############################# 69ohos_unittest("stats_service_death_test") { 70 module_out_path = module_output_path 71 72 sources = [ "src/stats_service_death_test.cpp" ] 73 74 configs = [ ":module_private_config" ] 75 76 defines = [ "STATS_SERVICE_DEATH_UT" ] 77 78 deps = [ 79 "${batterystats_innerkits}:batterystats_client", 80 "${batterystats_service_path}:batterystats_service", 81 "${batterystats_utils_path}:batterystats_utils", 82 "//third_party/googletest:gtest_main", 83 "//third_party/jsoncpp:jsoncpp", 84 ] 85 86 external_deps = deps_ex 87} 88 89############################wifi_test############################# 90ohos_unittest("stats_wifi_test") { 91 module_out_path = module_output_path 92 93 sources = [ 94 "${batterystats_service_path}/native/src/battery_stats_parser.cpp", 95 "src/stats_wifi_test.cpp", 96 ] 97 98 configs = [ 99 "${batterystats_utils_path}:batterystats_utils_config", 100 ":module_private_config", 101 ] 102 103 deps = [ 104 "${batterystats_innerkits}:batterystats_client", 105 "${batterystats_service_path}:batterystats_service", 106 "${batterystats_utils_path}:batterystats_utils", 107 "//third_party/googletest:gtest_main", 108 "//third_party/jsoncpp:jsoncpp", 109 ] 110 111 external_deps = deps_ex 112} 113 114############################camera_test############################# 115ohos_unittest("stats_camera_test") { 116 module_out_path = module_output_path 117 118 sources = [ 119 "${batterystats_service_path}/native/src/battery_stats_parser.cpp", 120 "src/stats_camera_test.cpp", 121 ] 122 123 configs = [ 124 "${batterystats_utils_path}:batterystats_utils_config", 125 ":module_private_config", 126 ] 127 128 deps = [ 129 "${batterystats_innerkits}:batterystats_client", 130 "${batterystats_service_path}:batterystats_service", 131 "${batterystats_utils_path}:batterystats_utils", 132 "//third_party/googletest:gtest_main", 133 "//third_party/jsoncpp:jsoncpp", 134 ] 135 136 external_deps = deps_ex 137} 138 139############################audio_test############################# 140ohos_unittest("stats_audio_test") { 141 module_out_path = module_output_path 142 143 sources = [ 144 "${batterystats_service_path}/native/src/battery_stats_parser.cpp", 145 "src/stats_audio_test.cpp", 146 ] 147 148 configs = [ ":module_private_config" ] 149 150 deps = [ 151 "${batterystats_innerkits}:batterystats_client", 152 "${batterystats_service_path}:batterystats_service", 153 "${batterystats_utils_path}:batterystats_utils", 154 "//third_party/googletest:gtest_main", 155 "//third_party/jsoncpp:jsoncpp", 156 ] 157 158 external_deps = deps_ex 159} 160 161############################powermgr_test############################# 162ohos_unittest("stats_powermgr_test") { 163 module_out_path = module_output_path 164 165 sources = [ 166 "${batterystats_service_path}/native/src/battery_stats_parser.cpp", 167 "src/stats_powermgr_test.cpp", 168 ] 169 170 configs = [ 171 "${batterystats_utils_path}:batterystats_utils_config", 172 ":module_private_config", 173 ] 174 175 deps = [ 176 "${batterystats_innerkits}:batterystats_client", 177 "${batterystats_service_path}:batterystats_service", 178 "${batterystats_utils_path}:batterystats_utils", 179 "//third_party/googletest:gtest_main", 180 "//third_party/jsoncpp:jsoncpp", 181 ] 182 183 external_deps = deps_ex 184} 185 186############################location_test############################# 187ohos_unittest("stats_location_test") { 188 module_out_path = module_output_path 189 190 sources = [ 191 "${batterystats_service_path}/native/src/battery_stats_parser.cpp", 192 "src/stats_location_test.cpp", 193 ] 194 195 configs = [ 196 "${batterystats_utils_path}:batterystats_utils_config", 197 ":module_private_config", 198 ] 199 200 deps = [ 201 "${batterystats_innerkits}:batterystats_client", 202 "${batterystats_service_path}:batterystats_service", 203 "${batterystats_utils_path}:batterystats_utils", 204 "//third_party/googletest:gtest_main", 205 "//third_party/jsoncpp:jsoncpp", 206 ] 207 208 external_deps = deps_ex 209} 210 211############################dump_test############################# 212ohos_unittest("stats_dump_test") { 213 module_out_path = module_output_path 214 215 sources = [ "src/stats_dump_test.cpp" ] 216 217 configs = [ 218 "${batterystats_utils_path}:batterystats_utils_config", 219 ":module_private_config", 220 ] 221 222 deps = [ 223 "${batterystats_innerkits}:batterystats_client", 224 "${batterystats_service_path}:batterystats_service", 225 "${batterystats_utils_path}:batterystats_utils", 226 "//third_party/googletest:gtest_main", 227 ] 228 229 external_deps = deps_ex 230} 231 232############################display_test############################# 233ohos_unittest("stats_display_test") { 234 module_out_path = module_output_path 235 236 sources = [ 237 "${batterystats_service_path}/native/src/battery_stats_parser.cpp", 238 "src/stats_display_test.cpp", 239 ] 240 241 configs = [ ":module_private_config" ] 242 243 deps = [ 244 "${batterystats_innerkits}:batterystats_client", 245 "${batterystats_service_path}:batterystats_service", 246 "${batterystats_utils_path}:batterystats_utils", 247 "//third_party/googletest:gtest_main", 248 "//third_party/jsoncpp:jsoncpp", 249 ] 250 251 external_deps = deps_ex 252} 253 254############################phone_test############################# 255ohos_unittest("stats_phone_test") { 256 module_out_path = module_output_path 257 258 sources = [ 259 "${batterystats_service_path}/native/src/battery_stats_parser.cpp", 260 "src/stats_phone_test.cpp", 261 ] 262 263 configs = [ ":module_private_config" ] 264 265 deps = [ 266 "${batterystats_innerkits}:batterystats_client", 267 "${batterystats_service_path}:batterystats_service", 268 "${batterystats_utils_path}:batterystats_utils", 269 "//third_party/googletest:gtest_main", 270 "//third_party/jsoncpp:jsoncpp", 271 ] 272 273 external_deps = deps_ex 274} 275 276############################bluetooth_test############################# 277ohos_unittest("stats_bluetooth_test") { 278 module_out_path = module_output_path 279 280 sources = [ 281 "${batterystats_service_path}/native/src/battery_stats_parser.cpp", 282 "src/stats_bluetooth_test.cpp", 283 ] 284 285 configs = [ ":module_private_config" ] 286 287 deps = [ 288 "${batterystats_innerkits}:batterystats_client", 289 "${batterystats_service_path}:batterystats_service", 290 "${batterystats_utils_path}:batterystats_utils", 291 "//third_party/googletest:gtest_main", 292 "//third_party/jsoncpp:jsoncpp", 293 ] 294 295 external_deps = deps_ex 296} 297 298############################alarm_test############################# 299ohos_unittest("stats_alarm_test") { 300 module_out_path = module_output_path 301 302 sources = [ 303 "${batterystats_service_path}/native/src/battery_stats_parser.cpp", 304 "src/stats_alarm_test.cpp", 305 ] 306 307 configs = [ ":module_private_config" ] 308 309 deps = [ 310 "${batterystats_innerkits}:batterystats_client", 311 "${batterystats_service_path}:batterystats_service", 312 "${batterystats_utils_path}:batterystats_utils", 313 "//third_party/googletest:gtest_main", 314 "//third_party/jsoncpp:jsoncpp", 315 ] 316 317 external_deps = deps_ex 318} 319 320############################util_test############################# 321ohos_unittest("stats_util_test") { 322 module_out_path = module_output_path 323 324 sources = [ "src/stats_util_test.cpp" ] 325 326 configs = [ ":module_private_config" ] 327 328 deps = [ 329 "${batterystats_utils_path}:batterystats_utils", 330 "//third_party/googletest:gtest_main", 331 ] 332 333 external_deps = deps_ex 334} 335 336############################mock_parcel_test############################# 337ohos_unittest("stats_mock_parcel_test") { 338 module_out_path = module_output_path 339 340 sources = [ 341 "${batterystats_service_path}/zidl/src/battery_stats_proxy.cpp", 342 "mock/source/mock_message_parcel.cpp", 343 "mock/source/mock_parcel.cpp", 344 "src/mock/stats_mock_parcel_test.cpp", 345 ] 346 347 configs = [ 348 ":module_mock_private_config", 349 ":module_private_config", 350 ] 351 352 deps = [ 353 "${batterystats_innerkits}:batterystats_client", 354 "${batterystats_service_path}:batterystats_service", 355 "${batterystats_utils_path}:batterystats_utils", 356 "//third_party/googletest:gtest_main", 357 "//third_party/jsoncpp:jsoncpp", 358 ] 359 360 external_deps = deps_ex 361} 362 363############################mock_object_test############################# 364ohos_unittest("stats_mock_object_test") { 365 module_out_path = module_output_path 366 367 sources = [ 368 "${batterystats_service_path}/zidl/src/battery_stats_proxy.cpp", 369 "mock/source/mock_stats_remote_object.cpp", 370 "src/mock/stats_mock_object_test.cpp", 371 ] 372 373 configs = [ 374 ":module_mock_private_config", 375 ":module_private_config", 376 ] 377 378 deps = [ 379 "${batterystats_innerkits}:batterystats_client", 380 "${batterystats_service_path}:batterystats_service", 381 "${batterystats_utils_path}:batterystats_utils", 382 "//third_party/googletest:gtest_main", 383 "//third_party/jsoncpp:jsoncpp", 384 ] 385 386 external_deps = deps_ex 387} 388 389############################mock_peer_test############################# 390ohos_unittest("stats_mock_peer_test") { 391 module_out_path = module_output_path 392 393 sources = [ 394 "${batterystats_service_path}/zidl/src/battery_stats_proxy.cpp", 395 "mock/source/mock_peer_holder.cpp", 396 "src/mock/stats_mock_peer_test.cpp", 397 ] 398 399 configs = [ 400 ":module_mock_private_config", 401 ":module_private_config", 402 ] 403 404 deps = [ 405 "${batterystats_innerkits}:batterystats_client", 406 "${batterystats_service_path}:batterystats_service", 407 "${batterystats_utils_path}:batterystats_utils", 408 "//third_party/googletest:gtest_main", 409 "//third_party/jsoncpp:jsoncpp", 410 ] 411 412 external_deps = deps_ex 413} 414group("unittest") { 415 testonly = true 416 deps = [ 417 ":stats_alarm_test", 418 ":stats_audio_test", 419 ":stats_bluetooth_test", 420 ":stats_camera_test", 421 ":stats_display_test", 422 ":stats_dump_test", 423 ":stats_location_test", 424 ":stats_mock_object_test", 425 ":stats_mock_parcel_test", 426 ":stats_mock_peer_test", 427 ":stats_phone_test", 428 ":stats_powermgr_test", 429 ":stats_service_death_test", 430 ":stats_service_test", 431 ":stats_util_test", 432 ":stats_wifi_test", 433 ] 434} 435