• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021 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("//foundation/ace/napi/napi.gni")
15
16if (defined(ohos_lite)) {
17  import("//build/lite/config/component/lite_component.gni")
18  import("//build/lite/config/subsystem/aafwk/config.gni")
19  import("//build/lite/config/test.gni")
20
21  test_output_root = "$root_out_dir/test/unittest/jsfwk"
22
23  executable("test_jerryscript_unittest") {
24    output_extension = "bin"
25    output_dir = test_output_root
26
27    include_dirs = [
28      "//utils/native/base/include",
29      "//third_party/node/src",
30      "//foundation/ace/napi",
31      "//foundation/ace/napi/interfaces/innerkits",
32      "//foundation/ace/napi/interfaces/kits",
33      "//third_party/googletest/include",
34      "//foundation/ace/napi/native_engine",
35      "//foundation/ace/napi/native_engine/impl/jerryscript",
36    ]
37
38    cflags = [ "-g3" ]
39
40    sources = [
41      "test_jerryscript.cpp",
42      "test_napi.cpp",
43    ]
44    sources += napi_sources
45
46    defines = [ "NAPI_TEST" ]
47
48    deps = [
49      "//base//hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
50      "//foundation/ace/napi/:ace_napi_jerryscript",
51      "//test/developertest/third_party/lib/cpp:gtest_main",
52      "//third_party/jerryscript/jerry-core:jerry-core_shared",
53      "//third_party/jerryscript/jerry-ext:jerry-ext_shared",
54      "//third_party/jerryscript/jerry-port/default:jerry-port-default_shared",
55    ]
56  }
57
58  group("unittest") {
59    deps = [ ":test_jerryscript_unittest" ]
60  }
61} else {
62  import("//build/test.gni")
63  import("//foundation/ace/ace_engine/ace_config.gni")
64  import("//foundation/ace/napi/test/unittest/ut.gni")
65
66  if (is_standard_system) {
67    module_output_path = "ace_engine_standard/napi"
68  } else {
69    module_output_path = "ace_engine_full/napi"
70  }
71
72  ark_support = false
73  qjs_support = false
74
75  foreach(item, ace_platforms) {
76    if (item.name == "ohos") {
77      engine_config = item.config
78      support_engines = engine_config.js_engines
79      foreach(engine, support_engines) {
80        if (engine.engine_name == "ark") {
81          ark_support = true
82        } else if (engine.engine_name == "qjs") {
83          qjs_support = true
84        }
85      }
86    }
87  }
88
89  if (qjs_support) {
90    ohos_unittest("test_quickjs_unittest") {
91      module_out_path = module_output_path
92
93      include_dirs = quickjs_include
94
95      cflags = [ "-g3" ]
96
97      sources = [
98        "engine/test_quickjs.cpp",
99        "test_napi.cpp",
100      ]
101      sources += napi_sources
102
103      defines = [ "NAPI_TEST" ]
104
105      deps = quickjs_deps
106
107      if (is_standard_system) {
108        external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
109      }
110    }
111
112    ohos_unittest("test_quickjs_unittest_ext") {
113      module_out_path = module_output_path
114
115      include_dirs = quickjs_include
116
117      cflags = [ "-g3" ]
118
119      sources = [
120        "./engine/test_quickjs.cpp",
121        "test_napi_ext.cpp",
122      ]
123      sources += napi_sources
124
125      defines = [ "NAPI_TEST" ]
126
127      deps = quickjs_deps
128
129      if (is_standard_system) {
130        external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
131      }
132    }
133
134    ohos_unittest("test_quickjs_unittest_threadsafe") {
135      module_out_path = module_output_path
136
137      include_dirs = quickjs_include
138
139      cflags = [ "-g3" ]
140
141      sources = [
142        "engine/test_quickjs.cpp",
143        "test_napi_threadsafe.cpp",
144      ]
145      sources += napi_sources
146
147      defines = [ "NAPI_TEST" ]
148
149      deps = quickjs_deps
150
151      if (is_standard_system) {
152        external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
153      }
154    }
155
156    ohos_unittest("test_quickjs_unittest_instance_data") {
157      module_out_path = module_output_path
158
159      include_dirs = quickjs_include
160
161      cflags = [ "-g3" ]
162
163      sources = [
164        "engine/test_quickjs.cpp",
165        "test_instance_data.cpp",
166      ]
167      sources += napi_sources
168
169      defines = [ "NAPI_TEST" ]
170
171      deps = quickjs_deps
172
173      if (is_standard_system) {
174        external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
175      }
176    }
177  }
178
179  if (ark_support) {
180    ohos_unittest("test_ark_unittest") {
181      module_out_path = module_output_path
182
183      configs = [ "//ark/js_runtime:ark_jsruntime_public_config" ]
184
185      include_dirs = ark_include
186
187      cflags = [ "-g3" ]
188
189      sources = [
190        "engine/test_ark.cpp",
191        "test_napi.cpp",
192      ]
193      sources += napi_sources
194
195      defines = [ "NAPI_TEST" ]
196
197      deps = ark_deps
198
199      if (is_standard_system) {
200        external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
201      } else {
202        external_deps = [ "hilog:libhilog" ]
203      }
204    }
205  }
206
207  group("unittest") {
208    testonly = true
209    deps = []
210    if (qjs_support) {
211      deps += [
212        ":test_quickjs_unittest",
213        ":test_quickjs_unittest_ext",
214        ":test_quickjs_unittest_threadsafe",
215      ]
216    }
217  }
218}
219