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/test.gni")
15import("//foundation/ability/ability_runtime/ability_runtime.gni")
16
17module_output_path = "ability_runtime/abilitymgr"
18
19config("coverage_flags") {
20  cflags = [ "--coverage" ]
21  ldflags = [ "--coverage" ]
22}
23
24ohos_unittest("quickfix_callback_test") {
25  module_out_path = module_output_path
26
27  include_dirs = [
28    "${ability_runtime_native_path}/runtime",
29    "${ability_runtime_native_path}/runtime/utils/include",
30  ]
31
32  sources = [ "js_quickfix_callback_test.cpp" ]
33
34  configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ]
35  deps = []
36
37  external_deps = [
38    "ability_runtime:runtime",
39    "c_utils:utils",
40  ]
41}
42
43ohos_unittest("runtime_test") {
44  module_out_path = module_output_path
45
46  include_dirs = [
47    "${ability_runtime_native_path}/runtime",
48    "${ability_runtime_native_path}/runtime/utils/include",
49    "${ability_base_kits_path}/extractortool/include",
50    "//third_party/zlib/contrib/minizip",
51    "//third_party/zlib",
52  ]
53
54  sources = [
55    # add mock file
56    "js_module_reader_test.cpp",
57  ]
58
59  configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ]
60  deps = []
61
62  external_deps = [
63    "ability_base:extractortool",
64    "ability_runtime:runtime",
65    "c_utils:utils",
66  ]
67}
68
69ohos_unittest("js_runtime_test") {
70  module_out_path = module_output_path
71  sanitize = {
72    cfi = true
73    cfi_cross_dso = true
74    debug = false
75    blocklist = "../../cfi_blocklist.txt"
76  }
77  branch_protector_ret = "pac_ret"
78
79  include_dirs = [
80    "${ability_runtime_native_path}/runtime",
81    "${ability_runtime_native_path}/runtime/utils/include",
82    "//third_party/zlib/contrib/minizip",
83    "//third_party/zlib",
84  ]
85
86  sources = [
87    # add mock file
88    "js_runtime_test.cpp",
89    "mock_jsnapi.cpp",
90  ]
91
92  configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ]
93  deps = [
94    "//third_party/googletest:gmock_main",
95    "//third_party/googletest:gtest_main",
96  ]
97
98  external_deps = [
99    "ability_runtime:js_environment",
100    "ability_runtime:runtime",
101    "bundle_framework:appexecfwk_core",
102    "c_utils:utils",
103    "ets_runtime:libark_jsruntime",
104    "eventhandler:libeventhandler",
105    "ffrt:libffrt",
106    "hilog:libhilog",
107    "ipc:ipc_core",
108    "napi:ace_napi",
109  ]
110}
111
112ohos_unittest("js_runtime_first_test") {
113  module_out_path = module_output_path
114  sanitize = {
115    cfi = true
116    cfi_cross_dso = true
117    debug = false
118    blocklist = "../../cfi_blocklist.txt"
119  }
120  branch_protector_ret = "pac_ret"
121
122  include_dirs = [
123    "${ability_runtime_native_path}/runtime",
124    "${ability_runtime_native_path}/runtime/utils/include",
125    "//third_party/zlib/contrib/minizip",
126    "//third_party/zlib",
127  ]
128
129  sources = [
130    # add mock file
131    "js_runtime_first_test.cpp",
132    "mock_jsnapi.cpp",
133  ]
134
135  configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ]
136  deps = [
137    "//third_party/googletest:gmock_main",
138    "//third_party/googletest:gtest_main",
139  ]
140
141  external_deps = [
142    "ability_runtime:js_environment",
143    "ability_runtime:runtime",
144    "bundle_framework:appexecfwk_core",
145    "c_utils:utils",
146    "ets_runtime:libark_jsruntime",
147    "eventhandler:libeventhandler",
148    "ffrt:libffrt",
149    "hilog:libhilog",
150    "ipc:ipc_core",
151    "napi:ace_napi",
152  ]
153}
154
155ohos_unittest("hdc_register_test") {
156  module_out_path = module_output_path
157
158  include_dirs = [
159    "${ability_runtime_native_path}/runtime",
160    "${ability_runtime_native_path}/runtime/utils/include",
161    "//third_party/zlib/contrib/minizip",
162    "//third_party/zlib",
163  ]
164
165  sources = [
166    # add mock file
167    "${ability_runtime_native_path}/runtime/hdc_register.cpp",
168    "hdc_register_test.cpp",
169  ]
170
171  configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ]
172  deps = [
173    "//third_party/googletest:gmock_main",
174    "//third_party/googletest:gtest_main",
175  ]
176
177  external_deps = [
178    "bundle_framework:appexecfwk_core",
179    "c_utils:utils",
180    "hilog:libhilog",
181    "ipc:ipc_core",
182  ]
183}
184
185ohos_unittest("ohos_js_environment_test") {
186  module_out_path = module_output_path
187
188  include_dirs = [ "${ability_runtime_native_path}/runtime" ]
189
190  sources = [ "ohos_js_environment_test.cpp" ]
191
192  configs = []
193
194  deps = [
195    "//third_party/googletest:gmock_main",
196    "//third_party/googletest:gtest_main",
197  ]
198
199  external_deps = [
200    "ability_runtime:js_environment",
201    "ability_runtime:runtime",
202    "c_utils:utils",
203    "ets_runtime:libark_jsruntime",
204    "eventhandler:libeventhandler",
205    "hilog:libhilog",
206    "napi:ace_napi",
207  ]
208}
209
210ohos_unittest("js_worker_test") {
211  module_out_path = module_output_path
212
213  include_dirs = [
214    "${ability_runtime_native_path}/runtime",
215    "${ability_runtime_native_path}/runtime/utils/include",
216    "${ability_base_kits_path}/extractortool/include",
217    "//third_party/zlib/contrib/minizip",
218    "//third_party/zlib",
219  ]
220
221  sources = [
222    # add mock file
223    "js_worker_test.cpp",
224  ]
225
226  configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ]
227  deps = []
228
229  external_deps = [
230    "ability_base:extractortool",
231    "ability_runtime:js_environment",
232    "ability_runtime:runtime",
233    "bundle_framework:appexecfwk_core",
234    "c_utils:utils",
235    "ets_runtime:libark_jsruntime",
236    "eventhandler:libeventhandler",
237    "hilog:libhilog",
238    "ipc:ipc_core",
239    "napi:ace_napi",
240  ]
241}
242
243group("unittest") {
244  testonly = true
245
246  deps = [
247    ":hdc_register_test",
248    ":js_runtime_first_test",
249    ":js_runtime_test",
250    ":js_worker_test",
251    ":ohos_js_environment_test",
252    ":runtime_test",
253  ]
254}
255