• 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/arkui/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      "//commonlibrary/c_utils/base/include",
29      "//third_party/node/src",
30      "//foundation/arkui/napi",
31      "//foundation/arkui/napi/interfaces/inner_api",
32      "//foundation/arkui/napi/interfaces/kits",
33      "//third_party/googletest/include",
34      "//foundation/arkui/napi/native_engine",
35      "//foundation/arkui/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/arkui/napi/:ace_napi_jerryscript",
51      "//test/testfwk/developer_test/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/arkui/ace_engine/ace_config.gni")
64  import("//foundation/arkui/napi/test/unittest/ut.gni")
65
66  if (is_standard_system) {
67    module_output_path = "ace_engine/napi"
68  } else {
69    module_output_path = "ace_engine_full/napi"
70  }
71
72  ark_support = false
73
74  foreach(item, ace_platforms) {
75    if (item.name == "ohos") {
76      engine_config = item.config
77      support_engines = engine_config.js_engines
78      foreach(engine, support_engines) {
79        if (engine.engine_name == "ark") {
80          ark_support = true
81        }
82      }
83    }
84  }
85
86  if (ark_support) {
87    ohos_unittest("test_ark_unittest") {
88      module_out_path = module_output_path
89
90      configs = [ "//arkcompiler/ets_runtime:ark_jsruntime_public_config" ]
91
92      include_dirs = ark_include
93
94      cflags = [ "-g3" ]
95
96      sources = [
97        "engine/test_ark.cpp",
98        "test_napi.cpp",
99      ]
100      sources += napi_sources
101
102      defines = [ "NAPI_TEST" ]
103
104      deps = ark_deps
105
106      external_deps = [ "c_utils:utils" ]
107
108      if (is_standard_system) {
109        external_deps += [ "hiviewdfx_hilog_native:libhilog" ]
110      } else {
111        external_deps += [ "hilog:libhilog" ]
112      }
113    }
114
115    ohos_unittest("test_ark_unittest_threadsafe") {
116      module_out_path = module_output_path
117
118      configs = [ "//arkcompiler/ets_runtime:ark_jsruntime_public_config" ]
119
120      include_dirs = ark_include
121
122      cflags = [ "-g3" ]
123
124      sources = [
125        "engine/test_ark.cpp",
126        "test_napi_threadsafe.cpp",
127      ]
128      sources += napi_sources
129
130      defines = [ "NAPI_TEST" ]
131
132      deps = ark_deps
133
134      if (is_standard_system) {
135        external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
136      } else {
137        external_deps = [ "hilog:libhilog" ]
138      }
139    }
140  }
141
142  group("unittest") {
143    testonly = true
144    deps = []
145    if (ark_support) {
146      deps += [
147        ":test_ark_unittest",
148        ":test_ark_unittest_threadsafe",
149      ]
150    }
151  }
152}
153