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/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 = [ 56 "OHOS_LIBWEBSOCKETS=1", 57 "private = public", 58 ] 59 60 deps = [ "$NETSTACK_DIR/utils/napi_utils:napi_utils" ] 61 62 external_deps = common_external_deps 63 external_deps += [ 64 "libwebsockets:websockets", 65 "openssl:libcrypto_shared", 66 "openssl:libssl_shared", 67 "samgr:samgr_proxy", 68 ] 69 70 if (defined(global_parts_info) && 71 defined(global_parts_info.communication_netmanager_base) && 72 global_parts_info.communication_netmanager_base) { 73 external_deps += [ 74 "netmanager_base:net_conn_manager_if", 75 "netmanager_base:net_security_config_if", 76 ] 77 defines += [ "HAS_NETMANAGER_BASE=1" ] 78 } else { 79 defines += [ "HAS_NETMANAGER_BASE=0" ] 80 } 81 82 if (netstack_websocket_server_enable) { 83 defines += [ "NETSTACK_WEBSOCKETSERVER", 84 "private = public",] 85 sources += [ 86 "$WEBSOCKET_NAPI/async_context/src/list_all_connections_context.cpp", 87 "$WEBSOCKET_NAPI/async_context/src/server_close_context.cpp", 88 "$WEBSOCKET_NAPI/async_context/src/server_send_context.cpp", 89 "$WEBSOCKET_NAPI/async_context/src/server_start_context.cpp", 90 "$WEBSOCKET_NAPI/async_context/src/server_stop_context.cpp", 91 "$WEBSOCKET_NAPI/websocket_exec/src/websocket_server_exec.cpp", 92 ] 93 } 94 95 part_name = "netstack" 96 subsystem_name = "communication" 97} 98 99group("unittest") { 100 testonly = true 101 deps = [ ":websocket_unittest" ] 102} 103