1# Copyright (c) 2023 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/communication/netstack/netstack_config.gni")
17
18WEBSOCKET_NAPI = "$NETSTACK_DIR/frameworks/js/napi/websocket"
19
20utils_include = [
21  "$SUBSYSTEM_DIR/netstack/utils/common_utils/include",
22  "$SUBSYSTEM_DIR/netstack/utils/log/include",
23  "$SUBSYSTEM_DIR/netstack/utils/napi_utils/include",
24]
25
26common_external_deps = [
27  "hilog:libhilog",
28  "napi:ace_napi",
29]
30
31ohos_unittest("websocket_unittest") {
32  module_out_path = "netstack/websocket_unittest"
33
34  include_dirs = [
35    "$NETSTACK_DIR/utils/napi_utils/include",
36    "$THIRD_PARTY_ROOT/libwebsockets/include",
37    "$WEBSOCKET_NAPI/async_context/include",
38    "$WEBSOCKET_NAPI/async_work/include",
39    "$WEBSOCKET_NAPI/constant/include",
40    "$WEBSOCKET_NAPI/websocket_exec/include",
41    "$WEBSOCKET_NAPI/websocket_module/include",
42  ]
43  include_dirs += utils_include
44
45  sources = [
46    "$WEBSOCKET_NAPI/async_context/src/close_context.cpp",
47    "$WEBSOCKET_NAPI/async_context/src/connect_context.cpp",
48    "$WEBSOCKET_NAPI/async_context/src/send_context.cpp",
49    "$WEBSOCKET_NAPI/async_work/src/websocket_async_work.cpp",
50    "$WEBSOCKET_NAPI/constant/src/constant.cpp",
51    "$WEBSOCKET_NAPI/websocket_exec/src/websocket_exec.cpp",
52    "$WEBSOCKET_NAPI/websocket_module/src/websocket_module.cpp",
53    "WebSocketTest.cpp",
54  ]
55
56  defines = [ "OHOS_LIBWEBSOCKETS=1" ]
57
58  deps = [
59    "$NETSTACK_DIR/utils/napi_utils:napi_utils",
60    "$THIRD_PARTY_ROOT/libwebsockets:websockets",
61  ]
62
63  external_deps = common_external_deps
64  external_deps += [ "openssl:libssl_shared" ]
65
66  part_name = "netstack"
67  subsystem_name = "communication"
68}
69
70group("unittest") {
71  testonly = true
72  deps = [ ":websocket_unittest" ]
73}
74