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