1# Copyright (c) 2021-2024 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/test.gni")
15import("//foundation/communication/netmanager_base/netmanager_base_config.gni")
16
17ohos_unittest("net_policy_manager_test") {
18  module_out_path = "netmanager_base/net_policy_manager_test"
19  sanitize = {
20    cfi = true
21    cfi_cross_dso = true
22    debug = false
23  }
24
25  branch_protector_ret = "pac_ret"
26
27  sources = [
28    "$NETMANAGER_BASE_ROOT/test/security/netmanager_base_test_security.cpp",
29    "net_policy_callback_proxy_test.cpp",
30    "net_policy_callback_test.cpp",
31    "net_policy_exception_service_test.cpp",
32    "net_policy_manager_test.cpp",
33    "net_policy_service_stub_test.cpp",
34    "net_policy_setting_test.cpp",
35    "ut_firewall_rule.cpp",
36    "ut_net_policy_callback.cpp",
37    "ut_net_policy_callback_ipc.cpp",
38    "ut_net_policy_callback_stub.cpp",
39    "ut_net_policy_client.cpp",
40    "ut_net_policy_core.cpp",
41    "ut_net_policy_event_handler.cpp",
42    "ut_net_policy_file.cpp",
43    "ut_net_policy_firewall.cpp",
44    "ut_net_policy_rule.cpp",
45    "ut_net_policy_service.cpp",
46    "ut_net_policy_service_common.cpp",
47    "ut_net_policy_traffic.cpp",
48    "ut_net_quota_policy.cpp",
49    "ut_netsys_policy_wrapper.cpp",
50  ]
51
52  include_dirs = [
53    "$INNERKITS_ROOT/netpolicyclient/include",
54    "$NETPOLICYMANAGER_SOURCE_DIR/include",
55    "$NETPOLICYMANAGER_SOURCE_DIR/include/stub",
56    "$INNERKITS_ROOT/netconnclient/include",
57    "$NETCONNMANAGER_COMMON_DIR/include",
58    "$NETSYSCONTROLLER_ROOT_DIR/include",
59    "$NETMANAGER_BASE_ROOT/test/commonduplicatedcode",
60    "$NETMANAGER_BASE_ROOT/test/security",
61  ]
62
63  deps = [
64    "$INNERKITS_ROOT/netpolicyclient:net_policy_manager_if",
65    "$NETCONNMANAGER_COMMON_DIR:net_service_common",
66    "$NETMANAGER_BASE_ROOT/services/netpolicymanager:net_policy_manager_static",
67    "$NETMANAGER_BASE_ROOT/utils:net_manager_common",
68  ]
69
70  external_deps = [
71    "ability_base:want",
72    "ability_runtime:app_manager",
73    "access_token:libaccesstoken_sdk",
74    "access_token:libnativetoken",
75    "access_token:libtoken_setproc",
76    "bundle_framework:appexecfwk_base",
77    "bundle_framework:appexecfwk_core",
78    "cJSON:cjson",
79    "common_event_service:cesfwk_core",
80    "common_event_service:cesfwk_innerkits",
81    "eventhandler:libeventhandler",
82    "ffrt:libffrt",
83    "hitrace:hitrace_meter",
84    "ipc:ipc_core",
85    "netmanager_base:net_conn_manager_if",
86    "netmanager_base:net_stats_manager_if",
87    "relational_store:native_rdb",
88    "safwk:system_ability_fwk",
89    "samgr:samgr_proxy",
90  ]
91
92  defines = [
93    "NETMGR_LOG_TAG = \"NetPolicyUT\"",
94    "LOG_DOMAIN = 0xD0015B0",
95  ]
96
97  if (enable_netmgr_debug) {
98    defines += [ "NETMGR_DEBUG" ]
99  }
100
101  external_deps += [ "hilog:libhilog" ]
102
103  part_name = "netmanager_base"
104  subsystem_name = "communication"
105}
106