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