• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    "$WEBSOCKET_NAPI/async_context/include",
37    "$WEBSOCKET_NAPI/async_work/include",
38    "$WEBSOCKET_NAPI/constant/include",
39    "$WEBSOCKET_NAPI/websocket_exec/include",
40    "$WEBSOCKET_NAPI/websocket_module/include",
41  ]
42  include_dirs += utils_include
43
44  sources = [
45    "$WEBSOCKET_NAPI/async_context/src/close_context.cpp",
46    "$WEBSOCKET_NAPI/async_context/src/connect_context.cpp",
47    "$WEBSOCKET_NAPI/async_context/src/send_context.cpp",
48    "$WEBSOCKET_NAPI/async_work/src/websocket_async_work.cpp",
49    "$WEBSOCKET_NAPI/constant/src/constant.cpp",
50    "$WEBSOCKET_NAPI/websocket_exec/src/websocket_exec.cpp",
51    "$WEBSOCKET_NAPI/websocket_module/src/websocket_module.cpp",
52    "WebSocketTest.cpp",
53  ]
54
55  defines = [ "OHOS_LIBWEBSOCKETS=1" ]
56
57  deps = [ "$NETSTACK_DIR/utils/napi_utils:napi_utils" ]
58
59  external_deps = common_external_deps
60  external_deps += [
61    "libwebsockets:websockets",
62    "openssl:libssl_shared",
63  ]
64
65  if (defined(global_parts_info) &&
66      defined(global_parts_info.communication_netmanager_base) &&
67      global_parts_info.communication_netmanager_base) {
68    external_deps += [ "netmanager_base:net_conn_manager_if" ]
69    defines += [ "HAS_NETMANAGER_BASE=1" ]
70  } else {
71    defines += [ "HAS_NETMANAGER_BASE=0" ]
72  }
73
74  part_name = "netstack"
75  subsystem_name = "communication"
76}
77
78group("unittest") {
79  testonly = true
80  deps = [ ":websocket_unittest" ]
81}
82