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