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_service_unit_test") {
21  module_out_path = module_output_path
22  cflags_cc = [
23    "-Dprivate=public",
24    "-Dprotected=public",
25  ]
26
27  include_dirs = [ "${standby_service_path}/test/unittest/mock/include" ]
28
29  sources = [
30    "mock/mock_common_event.cpp",
31    "mock/mock_helper.cpp",
32    "mock/mock_ipc.cpp",
33    "standby_service_unit_test.cpp",
34  ]
35
36  deps = [
37    "${standby_innerkits_path}:standby_innerkits",
38    "${standby_plugins_path}:standby_plugin_static",
39    "${standby_service_frameworks_path}:standby_fwk",
40    "${standby_service_path}:standby_service_static",
41    "${standby_utils_common_path}:standby_utils_common",
42    "${standby_utils_policy_path}:standby_utils_policy_static",
43  ]
44
45  external_deps = [
46    "ability_base:base",
47    "ability_base:want",
48    "ability_base:zuri",
49    "ability_runtime:app_manager",
50    "ability_runtime:wantagent_innerkits",
51    "access_token:libaccesstoken_sdk",
52    "access_token:libtokenid_sdk",
53    "bundle_framework:appexecfwk_base",
54    "c_utils:utils",
55    "common_event_service:cesfwk_innerkits",
56    "eventhandler:libeventhandler",
57    "hilog:libhilog",
58    "init:libbegetutil",
59    "ipc:ipc_single",
60    "safwk:system_ability_fwk",
61    "samgr:samgr_proxy",
62    "time_service:time_client",
63  ]
64
65  defines = []
66  if (enable_background_task_mgr) {
67    external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ]
68    defines += [ "ENABLE_BACKGROUND_TASK_MGR" ]
69  }
70
71  if (standby_power_manager_enable) {
72    external_deps += [ "power_manager:powermgr_client" ]
73    defines += [ "STANDBY_POWER_MANAGER_ENABLE" ]
74  }
75
76  subsystem_name = "resourceschedule"
77  part_name = "${standby_service_part_name}"
78}
79
80ohos_unittest("standby_utils_unit_test") {
81  module_out_path = module_output_path
82  cflags_cc = [
83    "-Dprivate=public",
84    "-Dprotected=public",
85  ]
86
87  sources = [ "standby_utils_unit_test.cpp" ]
88
89  deps = [
90    "${standby_service_path}:standby_service_static",
91    "${standby_utils_common_path}:standby_utils_common",
92    "${standby_utils_policy_path}:standby_utils_policy_static",
93  ]
94
95  external_deps = [
96    "ability_base:base",
97    "ability_base:want",
98    "ability_base:zuri",
99    "ability_runtime:app_manager",
100    "ability_runtime:wantagent_innerkits",
101    "access_token:libaccesstoken_sdk",
102    "access_token:libtokenid_sdk",
103    "bundle_framework:appexecfwk_base",
104    "c_utils:utils",
105    "common_event_service:cesfwk_innerkits",
106    "eventhandler:libeventhandler",
107    "hilog:libhilog",
108    "init:libbegetutil",
109    "ipc:ipc_single",
110    "safwk:system_ability_fwk",
111    "samgr:samgr_proxy",
112    "time_service:time_client",
113  ]
114
115  defines = []
116  if (enable_background_task_mgr) {
117    external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ]
118    defines += [ "ENABLE_BACKGROUND_TASK_MGR" ]
119  }
120
121  if (standby_power_manager_enable) {
122    external_deps += [ "power_manager:powermgr_client" ]
123    defines += [ "STANDBY_POWER_MANAGER_ENABLE" ]
124  }
125
126  subsystem_name = "resourceschedule"
127  part_name = "${standby_service_part_name}"
128}
129
130ohos_unittest("standby_helper_unit_test") {
131  module_out_path = module_output_path
132  cflags_cc = [
133    "-Dprivate=public",
134    "-Dprotected=public",
135  ]
136
137  include_dirs = [ "${standby_service_path}/test/unittest/mock/include" ]
138
139  sources = [
140    "allow_record_unit_test.cpp",
141    "mock/mock_helper.cpp",
142    "standby_helper_unit_test.cpp",
143  ]
144
145  deps = [
146    "${standby_service_path}:standby_service_static",
147    "${standby_utils_common_path}:standby_utils_common",
148    "${standby_utils_policy_path}:standby_utils_policy_static",
149  ]
150
151  external_deps = [
152    "ability_base:base",
153    "ability_base:want",
154    "ability_base:zuri",
155    "ability_runtime:app_manager",
156    "ability_runtime:wantagent_innerkits",
157    "access_token:libaccesstoken_sdk",
158    "access_token:libtokenid_sdk",
159    "bundle_framework:appexecfwk_base",
160    "c_utils:utils",
161    "common_event_service:cesfwk_innerkits",
162    "eventhandler:libeventhandler",
163    "hilog:libhilog",
164    "init:libbegetutil",
165    "ipc:ipc_single",
166    "safwk:system_ability_fwk",
167    "samgr:samgr_proxy",
168    "time_service:time_client",
169  ]
170
171  defines = []
172  if (enable_background_task_mgr) {
173    external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ]
174    defines += [ "ENABLE_BACKGROUND_TASK_MGR" ]
175  }
176
177  if (standby_power_manager_enable) {
178    external_deps += [ "power_manager:powermgr_client" ]
179    defines += [ "STANDBY_POWER_MANAGER_ENABLE" ]
180  }
181
182  subsystem_name = "resourceschedule"
183  part_name = "${standby_service_part_name}"
184}
185
186ohos_unittest("mock_standby_helper_unit_test") {
187  module_out_path = module_output_path
188  cflags_cc = [
189    "-Dprivate=public",
190    "-Dprotected=public",
191  ]
192
193  sources = [
194    "mock/mock_connect.cpp",
195    "mock/mock_standby_helper_unit_test.cpp",
196  ]
197
198  deps = [
199    "${standby_service_path}:standby_service_static",
200    "${standby_utils_common_path}:standby_utils_common",
201    "${standby_utils_policy_path}:standby_utils_policy_static",
202  ]
203
204  external_deps = [
205    "ability_base:base",
206    "ability_base:want",
207    "ability_base:zuri",
208    "ability_runtime:app_manager",
209    "ability_runtime:wantagent_innerkits",
210    "access_token:libaccesstoken_sdk",
211    "access_token:libtokenid_sdk",
212    "bundle_framework:appexecfwk_base",
213    "c_utils:utils",
214    "common_event_service:cesfwk_innerkits",
215    "eventhandler:libeventhandler",
216    "hilog:libhilog",
217    "init:libbegetutil",
218    "ipc:ipc_single",
219    "safwk:system_ability_fwk",
220    "samgr:samgr_proxy",
221    "time_service:time_client",
222  ]
223
224  defines = []
225  if (enable_background_task_mgr) {
226    external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ]
227    defines += [ "ENABLE_BACKGROUND_TASK_MGR" ]
228  }
229
230  if (standby_power_manager_enable) {
231    external_deps += [ "power_manager:powermgr_client" ]
232    defines += [ "STANDBY_POWER_MANAGER_ENABLE" ]
233  }
234
235  subsystem_name = "resourceschedule"
236  part_name = "${standby_service_part_name}"
237}
238
239ohos_unittest("mock_standby_service_unit_test") {
240  module_out_path = module_output_path
241  cflags_cc = [
242    "-Dprivate=public",
243    "-Dprotected=public",
244  ]
245
246  include_dirs = [ "${standby_service_path}/test/unittest/mock/include" ]
247
248  sources = [
249    "mock/mock_helper.cpp",
250    "mock_standby_service_unit_test.cpp",
251  ]
252
253  deps = [
254    "${standby_innerkits_path}:standby_innerkits",
255    "${standby_service_frameworks_path}:standby_fwk",
256    "${standby_service_path}:standby_service_static",
257    "${standby_utils_common_path}:standby_utils_common",
258    "${standby_utils_policy_path}:standby_utils_policy_static",
259    "//third_party/googletest:gmock_main",
260  ]
261
262  external_deps = [
263    "ability_base:base",
264    "ability_base:want",
265    "ability_base:zuri",
266    "ability_runtime:app_manager",
267    "ability_runtime:wantagent_innerkits",
268    "access_token:libaccesstoken_sdk",
269    "access_token:libtokenid_sdk",
270    "bundle_framework:appexecfwk_base",
271    "c_utils:utils",
272    "common_event_service:cesfwk_innerkits",
273    "eventhandler:libeventhandler",
274    "hilog:libhilog",
275    "init:libbegetutil",
276    "ipc:ipc_single",
277    "safwk:system_ability_fwk",
278    "samgr:samgr_proxy",
279    "time_service:time_client",
280  ]
281
282  defines = []
283  if (enable_background_task_mgr) {
284    external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ]
285    defines += [ "ENABLE_BACKGROUND_TASK_MGR" ]
286  }
287
288  if (standby_power_manager_enable) {
289    external_deps += [ "power_manager:powermgr_client" ]
290    defines += [ "STANDBY_POWER_MANAGER_ENABLE" ]
291  }
292
293  subsystem_name = "resourceschedule"
294  part_name = "${standby_service_part_name}"
295}
296
297group("unittest") {
298  testonly = true
299
300  deps = [
301    ":mock_standby_helper_unit_test",
302    ":mock_standby_service_unit_test",
303    ":standby_helper_unit_test",
304    ":standby_utils_unit_test",
305  ]
306  if (device_standby_plugin_enable) {
307    deps += [ ":standby_service_unit_test" ]
308  }
309}
310