• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    "time_service:time_client",
68  ]
69
70  defines = []
71  if (enable_background_task_mgr) {
72    external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ]
73    defines += [ "ENABLE_BACKGROUND_TASK_MGR" ]
74  }
75
76  if (standby_power_manager_enable) {
77    external_deps += [ "power_manager:powermgr_client" ]
78    defines += [ "STANDBY_POWER_MANAGER_ENABLE" ]
79  }
80
81  if (standby_battery_manager_enable) {
82    external_deps += [ "battery_manager:batterysrv_client" ]
83    defines += [ "STANDBY_BATTERY_MANAGER_ENABLE" ]
84  }
85
86  if (standby_multimodalinput_input_enable) {
87    external_deps += [ "input:libmmi-client" ]
88    defines += [ "STANDBY_MULTIMODALINPUT_INPUT_ENABLE" ]
89  }
90
91  if (standby_sensors_sensor_enable) {
92    external_deps += [ "sensor:sensor_interface_native" ]
93    defines += [ "STANDBY_SENSORS_SENSOR_ENABLE" ]
94  }
95
96  subsystem_name = "resourceschedule"
97  part_name = "${standby_service_part_name}"
98}
99
100ohos_unittest("standby_plugin_strategy_test") {
101  module_out_path = module_output_path
102
103  include_dirs = [
104    "${standby_plugins_path}/ext/include",
105    "${standby_service_constraints_path}/include",
106    "${standby_service_message_listener_path}/include",
107    "${standby_service_standby_state_path}/include",
108    "${standby_service_strategy_path}/include",
109    "${standby_utils_common_path}/include",
110    "${standby_utils_policy_path}/include",
111    "${standby_service_path}/test/unittest/mock/include",
112  ]
113
114  sources = [
115    "${standby_plugins_path}/test/unittest/standby_plugin_strategy_test.cpp",
116    "${standby_service_path}/test/unittest/mock/mock_helper.cpp",
117    "${standby_service_path}/test/unittest/mock/mock_ipc.cpp",
118  ]
119
120  deps = [
121    "${standby_innerkits_path}:standby_innerkits",
122    "${standby_plugins_path}:standby_plugin_static",
123    "${standby_service_frameworks_path}:standby_fwk",
124    "${standby_service_path}:standby_service_static",
125    "${standby_utils_common_path}:standby_utils_common",
126    "${standby_utils_policy_path}:standby_utils_policy",
127  ]
128
129  external_deps = [
130    "ability_base:base",
131    "ability_base:want",
132    "ability_base:zuri",
133    "ability_runtime:app_manager",
134    "ability_runtime:wantagent_innerkits",
135    "access_token:libaccesstoken_sdk",
136    "access_token:libtokenid_sdk",
137    "c_utils:utils",
138    "common_event_service:cesfwk_innerkits",
139    "eventhandler:libeventhandler",
140    "hilog:libhilog",
141    "init:libbegetutil",
142    "input:libmmi-client",
143    "ipc:ipc_single",
144    "time_service:time_client",
145    "work_scheduler:workschedclient",
146  ]
147
148  defines = []
149  if (enable_background_task_mgr) {
150    external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ]
151    defines += [ "ENABLE_BACKGROUND_TASK_MGR" ]
152  }
153
154  if (standby_power_manager_enable) {
155    external_deps += [ "power_manager:powermgr_client" ]
156    defines += [ "STANDBY_POWER_MANAGER_ENABLE" ]
157  }
158
159  if (standby_battery_manager_enable) {
160    external_deps += [ "battery_manager:batterysrv_client" ]
161    defines += [ "STANDBY_BATTERY_MANAGER_ENABLE" ]
162  }
163
164  if (standby_sensors_sensor_enable) {
165    external_deps += [ "sensor:sensor_interface_native" ]
166    defines += [ "STANDBY_SENSORS_SENSOR_ENABLE" ]
167  }
168
169  if (standby_communication_netmanager_base_enable) {
170    external_deps += [ "netmanager_base:net_policy_manager_if" ]
171    defines += [ "STANDBY_COMMUNICATION_NETMANAGER_BASE_ENABLE" ]
172  }
173
174  subsystem_name = "resourceschedule"
175  part_name = "${standby_service_part_name}"
176}
177
178ohos_unittest("standby_plugin_constraints_test") {
179  module_out_path = module_output_path
180  cflags_cc = [
181    "-Dprivate=public",
182    "-Dprotected=public",
183  ]
184
185  include_dirs = [ "${standby_service_constraints_path}/include" ]
186
187  sources = [
188    "${standby_plugins_path}/test/unittest/charge_state_monitor_test.cpp",
189    "${standby_plugins_path}/test/unittest/constraint_manager_adapter_test.cpp",
190  ]
191
192  deps = [
193    "${standby_innerkits_path}:standby_innerkits",
194    "${standby_plugins_path}:standby_plugin_static",
195    "${standby_service_frameworks_path}:standby_fwk",
196    "${standby_service_path}:standby_service_static",
197    "${standby_utils_common_path}:standby_utils_common",
198    "${standby_utils_policy_path}:standby_utils_policy",
199  ]
200
201  external_deps = [
202    "ability_base:base",
203    "ability_base:want",
204    "ability_base:zuri",
205    "ability_runtime:app_manager",
206    "ability_runtime:wantagent_innerkits",
207    "access_token:libaccesstoken_sdk",
208    "access_token:libtokenid_sdk",
209    "c_utils:utils",
210    "hilog:libhilog",
211    "time_service:time_client",
212  ]
213
214  if (standby_sensors_sensor_enable) {
215    external_deps += [ "sensor:sensor_interface_native" ]
216    sources += [
217      "${standby_plugins_path}/test/unittest/motion_sensor_monitor_test.cpp",
218    ]
219  }
220
221  subsystem_name = "resourceschedule"
222  part_name = "${standby_service_part_name}"
223}
224
225group("unittest") {
226  testonly = true
227  deps = []
228  if (device_standby_plugin_enable) {
229    deps += [
230      ":standby_plugin_constraints_test",
231      ":standby_plugin_strategy_test",
232      ":standby_plugin_unit_test",
233    ]
234  }
235}
236