• 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_interfaces_path}/innerkits/transient_task/include",
27    "//base/global/resource_management/frameworks/resmgr/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    "mock/mock_resource_manager.cpp",
40  ]
41
42  configs = [ "//commonlibrary/c_utils/base:utils_config" ]
43
44  deps = [
45    "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits",
46    "${bgtaskmgr_services_path}:bgtaskmgr_service",
47    "//third_party/googletest:gtest_main",
48  ]
49
50  external_deps = [
51    "ability_base:want",
52    "ability_base:zuri",
53    "ability_runtime:app_manager",
54    "ability_runtime:wantagent_innerkits",
55    "bundle_framework:appexecfwk_base",
56    "bundle_framework:appexecfwk_core",
57    "c_utils:utils",
58    "common_event_service:cesfwk_innerkits",
59    "eventhandler:libeventhandler",
60    "hiviewdfx_hilog_native:libhilog",
61    "ipc:ipc_core",
62    "multimedia_image_framework:image_native",
63    "relational_store:native_rdb",
64    "safwk:system_ability_fwk",
65    "samgr:samgr_proxy",
66  ]
67
68  if (has_os_account_part) {
69    cflags_cc += [ "-DHAS_OS_ACCOUNT_PART" ]
70    external_deps += [ "os_account:os_account_innerkits" ]
71  }
72
73  if (distributed_notification_enable) {
74    cflags_cc += [ "-DDISTRIBUTED_NOTIFICATION_ENABLE" ]
75    deps += [ "//base/notification/distributed_notification_service/frameworks/ans:ans_innerkits" ]
76  }
77
78  subsystem_name = "resourceschedule"
79  part_name = "background_task_mgr"
80}
81
82ohos_unittest("efficiency_mgr_unit_test") {
83  module_out_path = module_output_path
84  cflags_cc = []
85  include_dirs = [
86    "${bgtaskmgr_services_path}/transient_task/include",
87    "${bgtaskmgr_services_path}/core/inlcude",
88    "${bgtaskmgr_interfaces_path}/innerkits/transient_task/include",
89    "//base/global/resource_management/frameworks/resmgr/include",
90    "//third_party/icu/icu4c/source/i18n",
91  ]
92
93  sources = [
94    "bg_efficiency_resources_mgr_test.cpp",
95    "mock/mock_app_state_observer.cpp",
96    "mock/mock_bundle_manager_helper.cpp",
97    "mock/mock_ipc.cpp",
98  ]
99
100  configs = [ "//commonlibrary/c_utils/base:utils_config" ]
101
102  deps = [
103    "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits",
104    "${bgtaskmgr_services_path}:bgtaskmgr_service",
105    "//third_party/googletest:gtest_main",
106  ]
107
108  external_deps = [
109    "ability_base:want",
110    "ability_base:zuri",
111    "ability_runtime:app_manager",
112    "ability_runtime:wantagent_innerkits",
113    "bundle_framework:appexecfwk_base",
114    "bundle_framework:appexecfwk_core",
115    "c_utils:utils",
116    "common_event_service:cesfwk_innerkits",
117    "eventhandler:libeventhandler",
118    "hiviewdfx_hilog_native:libhilog",
119    "ipc:ipc_core",
120    "multimedia_image_framework:image_native",
121    "relational_store:native_rdb",
122    "safwk:system_ability_fwk",
123    "samgr:samgr_proxy",
124  ]
125
126  if (has_os_account_part) {
127    cflags_cc += [ "-DHAS_OS_ACCOUNT_PART" ]
128    external_deps += [ "os_account:os_account_innerkits" ]
129  }
130
131  subsystem_name = "resourceschedule"
132  part_name = "background_task_mgr"
133}
134
135ohos_unittest("bgtask_manager_unit_test") {
136  module_out_path = module_output_path
137  cflags_cc = [
138    "-Dprivate=public",
139    "-Dprotected=public",
140  ]
141  include_dirs = [
142    "${bgtaskmgr_services_path}/transient_task/include",
143    "${bgtaskmgr_services_path}/core/inlcude",
144    "${bgtaskmgr_interfaces_path}/innerkits/transient_task/include",
145    "//base/global/resource_management/frameworks/resmgr/include",
146    "//third_party/icu/icu4c/source/i18n",
147  ]
148
149  sources = [
150    "bgtask_manager_unit_test.cpp",
151    "mock/mock_bundle_manager_helper.cpp",
152    "mock/mock_ipc_skeleton.cpp",
153    "mock/mock_resource_manager.cpp",
154  ]
155
156  configs = [ "//commonlibrary/c_utils/base:utils_config" ]
157
158  deps = [
159    "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits",
160    "${bgtaskmgr_services_path}:bgtaskmgr_service",
161    "//third_party/googletest:gtest_main",
162  ]
163
164  external_deps = [
165    "ability_base:configuration",
166    "ability_base:want",
167    "ability_base:zuri",
168    "ability_runtime:app_manager",
169    "ability_runtime:wantagent_innerkits",
170    "bundle_framework:appexecfwk_base",
171    "bundle_framework:appexecfwk_core",
172    "c_utils:utils",
173    "common_event_service:cesfwk_innerkits",
174    "eventhandler:libeventhandler",
175    "hiviewdfx_hilog_native:libhilog",
176    "ipc:ipc_core",
177    "multimedia_image_framework:image_native",
178    "relational_store:native_rdb",
179    "resource_management:global_resmgr",
180    "safwk:system_ability_fwk",
181    "samgr:samgr_proxy",
182  ]
183
184  if (has_os_account_part) {
185    cflags_cc += [ "-DHAS_OS_ACCOUNT_PART" ]
186    external_deps += [ "os_account:os_account_innerkits" ]
187  }
188
189  if (distributed_notification_enable) {
190    cflags_cc += [ "-DDISTRIBUTED_NOTIFICATION_ENABLE" ]
191    deps += [ "//base/notification/distributed_notification_service/frameworks/ans:ans_innerkits" ]
192    sources += [ "mock/mock_notification_helper.cpp" ]
193  }
194
195  subsystem_name = "resourceschedule"
196  part_name = "background_task_mgr"
197}
198
199ohos_unittest("bgtask_misc_unit_test") {
200  module_out_path = module_output_path
201  cflags_cc = [
202    "-Dprivate=public",
203    "-Dprotected=public",
204  ]
205  include_dirs = [
206    "${bgtaskmgr_services_path}/transient_task/include",
207    "${bgtaskmgr_services_path}/core/inlcude",
208    "${bgtaskmgr_interfaces_path}/innerkits/transient_task/include",
209    "//base/global/resource_management/frameworks/resmgr/include",
210    "//third_party/icu/icu4c/source/i18n",
211  ]
212
213  sources = [ "bgtask_misc_unit_test.cpp" ]
214
215  configs = [ "//commonlibrary/c_utils/base:utils_config" ]
216
217  deps = [
218    "${bgtaskmgr_interfaces_path}/innerkits:bgtaskmgr_innerkits",
219    "${bgtaskmgr_services_path}:bgtaskmgr_service",
220    "//third_party/googletest:gtest_main",
221  ]
222
223  external_deps = [
224    "ability_base:base",
225    "ability_base:configuration",
226    "ability_base:want",
227    "ability_base:zuri",
228    "ability_runtime:app_manager",
229    "ability_runtime:wantagent_innerkits",
230    "bundle_framework:appexecfwk_base",
231    "bundle_framework:appexecfwk_core",
232    "c_utils:utils",
233    "common_event_service:cesfwk_innerkits",
234    "eventhandler:libeventhandler",
235    "hiviewdfx_hilog_native:libhilog",
236    "ipc:ipc_core",
237    "multimedia_image_framework:image_native",
238    "relational_store:native_rdb",
239    "safwk:system_ability_fwk",
240    "samgr:samgr_proxy",
241  ]
242
243  if (has_os_account_part) {
244    cflags_cc += [ "-DHAS_OS_ACCOUNT_PART" ]
245    external_deps += [ "os_account:os_account_innerkits" ]
246  }
247
248  if (distributed_notification_enable) {
249    cflags_cc += [ "-DDISTRIBUTED_NOTIFICATION_ENABLE" ]
250    deps += [ "//base/notification/distributed_notification_service/frameworks/ans:ans_innerkits" ]
251    sources += [ "mock/mock_notification_helper.cpp" ]
252  }
253
254  subsystem_name = "resourceschedule"
255  part_name = "background_task_mgr"
256}
257
258group("unittest") {
259  testonly = true
260
261  deps = [
262    ":bgtask_manager_unit_test",
263    ":bgtask_misc_unit_test",
264    ":bgtask_unit_test",
265    ":efficiency_mgr_unit_test",
266    "bgtask_manager_abnormal_unit_test:bgtask_manager_abnormal_unit_test",
267  ]
268}
269