1# Copyright (c) 2023-2024 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/ohos.gni") 15import("//build/test.gni") 16import("//foundation/resourceschedule/device_standby/standby_service.gni") 17 18module_output_path = "${standby_service_part_name}/unittest" 19 20ohos_unittest("standby_plugin_unit_test") { 21 module_out_path = module_output_path 22 cflags_cc = [ 23 "-Dprivate=public", 24 "-Dprotected=public", 25 ] 26 27 include_dirs = [ 28 "${standby_plugins_path}/ext/include", 29 "${standby_service_constraints_path}/include", 30 "${standby_service_message_listener_path}/include", 31 "${standby_service_standby_state_path}/include", 32 "${standby_service_strategy_path}/include", 33 "${standby_utils_common_path}/include", 34 "${standby_utils_policy_path}/include", 35 "${standby_service_path}/test/unittest/mock/include", 36 ] 37 38 sources = [ 39 "${standby_plugins_path}/test/unittest/standby_plugin_unit_test.cpp", 40 "${standby_service_path}/test/unittest/mock/mock_helper.cpp", 41 "${standby_service_path}/test/unittest/mock/mock_ipc.cpp", 42 ] 43 44 deps = [ 45 "${standby_innerkits_path}:standby_innerkits", 46 "${standby_plugins_path}:standby_plugin_static", 47 "${standby_service_frameworks_path}:standby_fwk", 48 "${standby_service_path}:standby_service_static", 49 "${standby_utils_common_path}:standby_utils_common", 50 "${standby_utils_policy_path}:standby_utils_policy", 51 ] 52 53 external_deps = [ 54 "ability_base:base", 55 "ability_base:want", 56 "ability_base:zuri", 57 "ability_runtime:app_manager", 58 "ability_runtime:wantagent_innerkits", 59 "access_token:libaccesstoken_sdk", 60 "access_token:libtokenid_sdk", 61 "c_utils:utils", 62 "common_event_service:cesfwk_innerkits", 63 "eventhandler:libeventhandler", 64 "hilog:libhilog", 65 "init:libbegetutil", 66 "ipc:ipc_single", 67 "resource_schedule_service:ressched_client", 68 "time_service:time_client", 69 ] 70 71 defines = [] 72 if (enable_background_task_mgr) { 73 external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] 74 defines += [ "ENABLE_BACKGROUND_TASK_MGR" ] 75 } 76 77 if (standby_power_manager_enable) { 78 external_deps += [ "power_manager:powermgr_client" ] 79 defines += [ "STANDBY_POWER_MANAGER_ENABLE" ] 80 } 81 82 if (standby_battery_manager_enable) { 83 external_deps += [ "battery_manager:batterysrv_client" ] 84 defines += [ "STANDBY_BATTERY_MANAGER_ENABLE" ] 85 } 86 87 if (standby_multimodalinput_input_enable) { 88 external_deps += [ "input:libmmi-client" ] 89 defines += [ "STANDBY_MULTIMODALINPUT_INPUT_ENABLE" ] 90 } 91 92 if (standby_sensors_sensor_enable) { 93 external_deps += [ "sensor:sensor_interface_native" ] 94 defines += [ "STANDBY_SENSORS_SENSOR_ENABLE" ] 95 } 96 97 subsystem_name = "resourceschedule" 98 part_name = "${standby_service_part_name}" 99} 100 101ohos_unittest("standby_plugin_strategy_test") { 102 module_out_path = module_output_path 103 104 include_dirs = [ 105 "${standby_plugins_path}/ext/include", 106 "${standby_service_constraints_path}/include", 107 "${standby_service_message_listener_path}/include", 108 "${standby_service_standby_state_path}/include", 109 "${standby_service_strategy_path}/include", 110 "${standby_utils_common_path}/include", 111 "${standby_utils_policy_path}/include", 112 "${standby_service_path}/test/unittest/mock/include", 113 ] 114 115 sources = [ 116 "${standby_plugins_path}/test/unittest/standby_plugin_strategy_test.cpp", 117 "${standby_service_path}/test/unittest/mock/mock_helper.cpp", 118 "${standby_service_path}/test/unittest/mock/mock_ipc.cpp", 119 ] 120 121 deps = [ 122 "${standby_innerkits_path}:standby_innerkits", 123 "${standby_plugins_path}:standby_plugin_static", 124 "${standby_service_frameworks_path}:standby_fwk", 125 "${standby_service_path}:standby_service_static", 126 "${standby_utils_common_path}:standby_utils_common", 127 "${standby_utils_policy_path}:standby_utils_policy", 128 ] 129 130 external_deps = [ 131 "ability_base:base", 132 "ability_base:want", 133 "ability_base:zuri", 134 "ability_runtime:app_manager", 135 "ability_runtime:wantagent_innerkits", 136 "access_token:libaccesstoken_sdk", 137 "access_token:libtokenid_sdk", 138 "c_utils:utils", 139 "common_event_service:cesfwk_innerkits", 140 "eventhandler:libeventhandler", 141 "hilog:libhilog", 142 "init:libbegetutil", 143 "input:libmmi-client", 144 "ipc:ipc_single", 145 "time_service:time_client", 146 "work_scheduler:workschedclient", 147 ] 148 149 defines = [] 150 if (enable_background_task_mgr) { 151 external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] 152 defines += [ "ENABLE_BACKGROUND_TASK_MGR" ] 153 } 154 155 if (standby_power_manager_enable) { 156 external_deps += [ "power_manager:powermgr_client" ] 157 defines += [ "STANDBY_POWER_MANAGER_ENABLE" ] 158 } 159 160 if (standby_battery_manager_enable) { 161 external_deps += [ "battery_manager:batterysrv_client" ] 162 defines += [ "STANDBY_BATTERY_MANAGER_ENABLE" ] 163 } 164 165 if (standby_sensors_sensor_enable) { 166 external_deps += [ "sensor:sensor_interface_native" ] 167 defines += [ "STANDBY_SENSORS_SENSOR_ENABLE" ] 168 } 169 170 if (standby_communication_netmanager_base_enable) { 171 external_deps += [ "netmanager_base:net_policy_manager_if" ] 172 defines += [ "STANDBY_COMMUNICATION_NETMANAGER_BASE_ENABLE" ] 173 } 174 175 subsystem_name = "resourceschedule" 176 part_name = "${standby_service_part_name}" 177} 178 179ohos_unittest("standby_plugin_constraints_test") { 180 module_out_path = module_output_path 181 cflags_cc = [ 182 "-Dprivate=public", 183 "-Dprotected=public", 184 ] 185 186 include_dirs = [ "${standby_service_constraints_path}/include" ] 187 188 sources = [ 189 "${standby_plugins_path}/test/unittest/charge_state_monitor_test.cpp", 190 "${standby_plugins_path}/test/unittest/constraint_manager_adapter_test.cpp", 191 ] 192 193 deps = [ 194 "${standby_innerkits_path}:standby_innerkits", 195 "${standby_plugins_path}:standby_plugin_static", 196 "${standby_service_frameworks_path}:standby_fwk", 197 "${standby_service_path}:standby_service_static", 198 "${standby_utils_common_path}:standby_utils_common", 199 "${standby_utils_policy_path}:standby_utils_policy", 200 ] 201 202 external_deps = [ 203 "ability_base:base", 204 "ability_base:want", 205 "ability_base:zuri", 206 "ability_runtime:app_manager", 207 "ability_runtime:wantagent_innerkits", 208 "access_token:libaccesstoken_sdk", 209 "access_token:libtokenid_sdk", 210 "c_utils:utils", 211 "hilog:libhilog", 212 "resource_schedule_service:ressched_client", 213 "time_service:time_client", 214 ] 215 216 if (standby_sensors_sensor_enable) { 217 external_deps += [ "sensor:sensor_interface_native" ] 218 sources += [ 219 "${standby_plugins_path}/test/unittest/motion_sensor_monitor_test.cpp", 220 ] 221 } 222 223 subsystem_name = "resourceschedule" 224 part_name = "${standby_service_part_name}" 225} 226 227group("unittest") { 228 testonly = true 229 deps = [] 230 if (device_standby_plugin_enable) { 231 deps += [ 232 ":standby_plugin_constraints_test", 233 ":standby_plugin_strategy_test", 234 ":standby_plugin_unit_test", 235 ] 236 } 237} 238