1# Copyright (c) 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("//build/ohos.gni")
15import("//build/test.gni")
16import("//foundation/resourceschedule/background_task_mgr/bgtaskmgr.gni")
17
18module_output_path = "background_task_mgr/unittest"
19
20ohos_unittest("bgtask_unit_test") {
21  module_out_path = module_output_path
22
23  cflags = [
24    "-Dprivate=public",
25    "-Dprotected=public",
26  ]
27
28  cflags_cc = []
29  include_dirs = [
30    "${bgtaskmgr_services_path}/transient_task/include",
31    "${bgtaskmgr_services_path}/core/inlcude",
32    "${bgtaskmgr_services_path}/test/unittest/mock/include",
33    "${bgtaskmgr_interfaces_path}/innerkits/transient_task/include",
34    "//third_party/icu/icu4c/source/i18n",
35  ]
36
37  sources = [
38    "background_task_mgr_service_test.cpp",
39    "bg_continuous_task_mgr_test.cpp",
40    "bg_transient_task_mgr_test.cpp",
41    "mock/mock_bundle_manager_helper.cpp",
42    "mock/mock_event_handler.cpp",
43    "mock/mock_ipc.cpp",
44    "mock/mock_notification_tools.cpp",
45  ]
46
47  deps = [
48    "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits",
49    "${bgtaskmgr_services_path}:bgtaskmgr_service_static",
50    "//third_party/googletest:gtest_main",
51  ]
52
53  external_deps = [
54    "ability_base:want",
55    "ability_base:zuri",
56    "ability_runtime:app_manager",
57    "ability_runtime:wantagent_innerkits",
58    "bundle_framework:appexecfwk_base",
59    "bundle_framework:appexecfwk_core",
60    "c_utils:utils",
61    "common_event_service:cesfwk_innerkits",
62    "eventhandler:libeventhandler",
63    "hilog:libhilog",
64    "hisysevent:libhisysevent",
65    "image_framework:image_native",
66    "ipc:ipc_single",
67    "relational_store:native_rdb",
68    "resource_management:global_resmgr",
69    "safwk:system_ability_fwk",
70    "samgr:samgr_proxy",
71  ]
72
73  if (has_os_account_part) {
74    cflags_cc += [ "-DHAS_OS_ACCOUNT_PART" ]
75    external_deps += [ "os_account:os_account_innerkits" ]
76  }
77
78  if (distributed_notification_enable) {
79    cflags_cc += [ "-DDISTRIBUTED_NOTIFICATION_ENABLE" ]
80    external_deps += [ "distributed_notification_service:ans_innerkits" ]
81  }
82
83  subsystem_name = "resourceschedule"
84  part_name = "background_task_mgr"
85}
86
87ohos_unittest("efficiency_mgr_unit_test") {
88  module_out_path = module_output_path
89
90  cflags = [
91    "-Dprivate=public",
92    "-Dprotected=public",
93  ]
94
95  cflags_cc = []
96  include_dirs = [
97    "${bgtaskmgr_services_path}/transient_task/include",
98    "${bgtaskmgr_services_path}/core/inlcude",
99    "${bgtaskmgr_interfaces_path}/innerkits/transient_task/include",
100    "//third_party/icu/icu4c/source/i18n",
101  ]
102
103  sources = [
104    "bg_efficiency_resources_mgr_test.cpp",
105    "mock/mock_bundle_manager_helper.cpp",
106    "mock/mock_ipc.cpp",
107  ]
108
109  deps = [
110    "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits",
111    "${bgtaskmgr_services_path}:bgtaskmgr_service_static",
112    "//third_party/googletest:gtest_main",
113  ]
114
115  external_deps = [
116    "ability_base:want",
117    "ability_base:zuri",
118    "ability_runtime:app_manager",
119    "ability_runtime:wantagent_innerkits",
120    "bundle_framework:appexecfwk_base",
121    "bundle_framework:appexecfwk_core",
122    "c_utils:utils",
123    "common_event_service:cesfwk_innerkits",
124    "eventhandler:libeventhandler",
125    "hilog:libhilog",
126    "hisysevent:libhisysevent",
127    "image_framework:image_native",
128    "ipc:ipc_single",
129    "relational_store:native_rdb",
130    "resource_management:global_resmgr",
131    "safwk:system_ability_fwk",
132    "samgr:samgr_proxy",
133  ]
134
135  if (has_os_account_part) {
136    cflags_cc += [ "-DHAS_OS_ACCOUNT_PART" ]
137    external_deps += [ "os_account:os_account_innerkits" ]
138  }
139
140  subsystem_name = "resourceschedule"
141  part_name = "background_task_mgr"
142}
143
144ohos_unittest("mock_efficiency_mgr_unit_test") {
145  module_out_path = module_output_path
146  cflags_cc = [
147    "-Dprivate=public",
148    "-Dprotected=public",
149  ]
150  include_dirs = [
151    "${bgtaskmgr_services_path}/common/include",
152    "${bgtaskmgr_services_path}/efficiency_resources/inlcude",
153    "${bgtaskmgr_services_path}/core/include",
154    "${bgtaskmgr_services_path}/test/unittest/mock/include",
155  ]
156
157  sources = [
158    "mock/mock_bundle_manager_helper.cpp",
159    "mock_efficiency_resources_mgr_test.cpp",
160  ]
161
162  deps = [
163    "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits",
164    "${bgtaskmgr_services_path}:bgtaskmgr_service_static",
165    "//third_party/googletest:gmock_main",
166    "//third_party/googletest:gtest_main",
167  ]
168
169  external_deps = [
170    "ability_base:want",
171    "ability_base:zuri",
172    "ability_runtime:app_manager",
173    "ability_runtime:wantagent_innerkits",
174    "bundle_framework:appexecfwk_base",
175    "bundle_framework:appexecfwk_core",
176    "c_utils:utils",
177    "common_event_service:cesfwk_innerkits",
178    "eventhandler:libeventhandler",
179    "hilog:libhilog",
180    "hisysevent:libhisysevent",
181    "image_framework:image_native",
182    "ipc:ipc_single",
183    "relational_store:native_rdb",
184    "resource_management:global_resmgr",
185    "safwk:system_ability_fwk",
186    "samgr:samgr_proxy",
187  ]
188
189  if (has_os_account_part) {
190    cflags_cc += [ "-DHAS_OS_ACCOUNT_PART" ]
191    external_deps += [ "os_account:os_account_innerkits" ]
192  }
193
194  subsystem_name = "resourceschedule"
195  part_name = "background_task_mgr"
196}
197
198ohos_unittest("bgtask_manager_unit_test") {
199  module_out_path = module_output_path
200  cflags_cc = [
201    "-Dprivate=public",
202    "-Dprotected=public",
203  ]
204  include_dirs = [
205    "${bgtaskmgr_services_path}/transient_task/include",
206    "${bgtaskmgr_services_path}/core/inlcude",
207    "${bgtaskmgr_services_path}/test/unittest/mock/include",
208    "${bgtaskmgr_interfaces_path}/innerkits/transient_task/include",
209    "//third_party/icu/icu4c/source/i18n",
210  ]
211
212  sources = [
213    "bgtask_manager_unit_test.cpp",
214    "mock/mock_bundle_manager_helper.cpp",
215    "mock/mock_ipc_skeleton.cpp",
216    "mock/mock_transient_task_mgr.cpp",
217  ]
218
219  deps = [
220    "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits",
221    "${bgtaskmgr_services_path}:bgtaskmgr_service_static",
222    "//third_party/googletest:gtest_main",
223  ]
224
225  external_deps = [
226    "ability_base:configuration",
227    "ability_base:want",
228    "ability_base:zuri",
229    "ability_runtime:app_manager",
230    "ability_runtime:wantagent_innerkits",
231    "bundle_framework:appexecfwk_base",
232    "bundle_framework:appexecfwk_core",
233    "c_utils:utils",
234    "common_event_service:cesfwk_innerkits",
235    "eventhandler:libeventhandler",
236    "hilog:libhilog",
237    "hisysevent:libhisysevent",
238    "image_framework:image_native",
239    "ipc:ipc_single",
240    "relational_store:native_rdb",
241    "resource_management:global_resmgr",
242    "safwk:system_ability_fwk",
243    "samgr:samgr_proxy",
244  ]
245
246  if (has_os_account_part) {
247    cflags_cc += [ "-DHAS_OS_ACCOUNT_PART" ]
248    external_deps += [ "os_account:os_account_innerkits" ]
249  }
250
251  if (distributed_notification_enable) {
252    cflags_cc += [ "-DDISTRIBUTED_NOTIFICATION_ENABLE" ]
253    external_deps += [ "distributed_notification_service:ans_innerkits" ]
254    sources += [ "mock/mock_notification_helper.cpp" ]
255  }
256
257  subsystem_name = "resourceschedule"
258  part_name = "background_task_mgr"
259}
260
261ohos_unittest("bgtask_misc_unit_test") {
262  module_out_path = module_output_path
263  cflags_cc = [
264    "-Dprivate=public",
265    "-Dprotected=public",
266  ]
267  include_dirs = [
268    "${bgtaskmgr_services_path}/transient_task/include",
269    "${bgtaskmgr_services_path}/core/inlcude",
270    "${bgtaskmgr_interfaces_path}/innerkits/transient_task/include",
271    "//third_party/icu/icu4c/source/i18n",
272  ]
273
274  sources = [ "bgtask_misc_unit_test.cpp" ]
275
276  deps = [
277    "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits",
278    "${bgtaskmgr_services_path}:bgtaskmgr_service_static",
279    "//third_party/googletest:gtest_main",
280  ]
281
282  external_deps = [
283    "ability_base:base",
284    "ability_base:configuration",
285    "ability_base:want",
286    "ability_base:zuri",
287    "ability_runtime:app_manager",
288    "ability_runtime:wantagent_innerkits",
289    "bundle_framework:appexecfwk_base",
290    "bundle_framework:appexecfwk_core",
291    "c_utils:utils",
292    "common_event_service:cesfwk_innerkits",
293    "eventhandler:libeventhandler",
294    "hilog:libhilog",
295    "hisysevent:libhisysevent",
296    "image_framework:image_native",
297    "ipc:ipc_single",
298    "relational_store:native_rdb",
299    "resource_management:global_resmgr",
300    "safwk:system_ability_fwk",
301    "samgr:samgr_proxy",
302  ]
303
304  if (has_os_account_part) {
305    cflags_cc += [ "-DHAS_OS_ACCOUNT_PART" ]
306    external_deps += [ "os_account:os_account_innerkits" ]
307  }
308
309  if (distributed_notification_enable) {
310    cflags_cc += [ "-DDISTRIBUTED_NOTIFICATION_ENABLE" ]
311    external_deps += [ "distributed_notification_service:ans_innerkits" ]
312    sources += [ "mock/mock_notification_helper.cpp" ]
313  }
314
315  subsystem_name = "resourceschedule"
316  part_name = "background_task_mgr"
317}
318
319group("unittest") {
320  testonly = true
321
322  deps = [
323    ":bgtask_manager_unit_test",
324    ":bgtask_misc_unit_test",
325    ":bgtask_unit_test",
326    ":efficiency_mgr_unit_test",
327    ":mock_efficiency_mgr_unit_test",
328    "bgtask_manager_abnormal_unit_test:bgtask_manager_abnormal_unit_test",
329  ]
330}
331