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("hdc_register_test") {
113  module_out_path = module_output_path
114
115  include_dirs = [
116    "${ability_runtime_native_path}/runtime",
117    "${ability_runtime_native_path}/runtime/utils/include",
118    "//third_party/zlib/contrib/minizip",
119    "//third_party/zlib",
120  ]
121
122  sources = [
123    # add mock file
124    "${ability_runtime_native_path}/runtime/hdc_register.cpp",
125    "hdc_register_test.cpp",
126  ]
127
128  configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ]
129  deps = [
130    "//third_party/googletest:gmock_main",
131    "//third_party/googletest:gtest_main",
132  ]
133
134  external_deps = [
135    "bundle_framework:appexecfwk_core",
136    "c_utils:utils",
137    "hilog:libhilog",
138    "ipc:ipc_core",
139  ]
140}
141
142ohos_unittest("ohos_js_environment_test") {
143  module_out_path = module_output_path
144
145  include_dirs = [ "${ability_runtime_native_path}/runtime" ]
146
147  sources = [ "ohos_js_environment_test.cpp" ]
148
149  configs = []
150
151  deps = [
152    "//third_party/googletest:gmock_main",
153    "//third_party/googletest:gtest_main",
154  ]
155
156  external_deps = [
157    "ability_runtime:js_environment",
158    "ability_runtime:runtime",
159    "c_utils:utils",
160    "ets_runtime:libark_jsruntime",
161    "eventhandler:libeventhandler",
162    "hilog:libhilog",
163    "napi:ace_napi",
164  ]
165}
166
167ohos_unittest("js_worker_test") {
168  module_out_path = module_output_path
169
170  include_dirs = [
171    "${ability_runtime_native_path}/runtime",
172    "${ability_runtime_native_path}/runtime/utils/include",
173    "${ability_base_kits_path}/extractortool/include",
174    "//third_party/zlib/contrib/minizip",
175    "//third_party/zlib",
176  ]
177
178  sources = [
179    # add mock file
180    "js_worker_test.cpp",
181  ]
182
183  configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ]
184  deps = []
185
186  external_deps = [
187    "ability_base:extractortool",
188    "ability_runtime:js_environment",
189    "ability_runtime:runtime",
190    "bundle_framework:appexecfwk_core",
191    "c_utils:utils",
192    "ets_runtime:libark_jsruntime",
193    "eventhandler:libeventhandler",
194    "hilog:libhilog",
195    "ipc:ipc_core",
196    "napi:ace_napi",
197  ]
198}
199
200group("unittest") {
201  testonly = true
202
203  deps = [
204    ":hdc_register_test",
205    ":js_runtime_test",
206    ":js_worker_test",
207    ":ohos_js_environment_test",
208    ":runtime_test",
209  ]
210}
211