1# Copyright (c) 2022-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("../../../../common/config/common.gni")
16
17module_output_path = "enterprise_device_management/enterprise_device_management"
18
19config("module_private_config") {
20  visibility = [ ":*" ]
21  include_dirs = [ "../" ]
22}
23
24config("edm_config") {
25  visibility = [ ":*" ]
26  include_dirs = [
27    "../../../../services/edm/include",
28    "../../../../services/edm/include/connection",
29    "../../../../services/edm/include/database",
30    "../../../../services/edm/include/strategy",
31    "../../../../services/edm_plugin/include/utils",
32    "../../../../framework/extension/include",
33  ]
34}
35
36ohos_static_library("edmservice_static") {
37  testonly = true
38  sources = [
39    "../../../../services/edm/src/admin.cpp",
40    "../../../../services/edm/src/admin_manager.cpp",
41    "../../../../services/edm/src/admin_policies_storage_rdb.cpp",
42    "../../../../services/edm/src/application_state_observer.cpp",
43    "../../../../services/edm/src/connection/enterprise_admin_connection.cpp",
44    "../../../../services/edm/src/connection/enterprise_admin_proxy.cpp",
45    "../../../../services/edm/src/connection/enterprise_bundle_connection.cpp",
46    "../../../../services/edm/src/connection/enterprise_conn_manager.cpp",
47    "../../../../services/edm/src/connection/enterprise_update_connection.cpp",
48    "../../../../services/edm/src/database/edm_rdb_data_manager.cpp",
49    "../../../../services/edm/src/database/edm_rdb_open_callback.cpp",
50    "../../../../services/edm/src/device_policies_storage_rdb.cpp",
51    "../../../../services/edm/src/enterprise_device_mgr_ability.cpp",
52    "../../../../services/edm/src/enterprise_device_mgr_stub.cpp",
53    "../../../../services/edm/src/permission_manager.cpp",
54    "../../../../services/edm/src/plugin_manager.cpp",
55    "../../../../services/edm/src/policy_manager.cpp",
56    "../../../../services/edm/src/strategy/enhance_execute_strategy.cpp",
57    "../../../../services/edm/src/strategy/replace_execute_strategy.cpp",
58    "../../../../services/edm/src/strategy/single_execute_strategy.cpp",
59    "../../../../services/edm/src/user_policy_manager.cpp",
60    "../../../../services/edm_plugin/src/utils/clipboard_policy_serializer.cpp",
61    "../../../../services/edm_plugin/src/utils/clipboard_utils.cpp",
62    "../../../../services/edm_plugin/src/utils/password_policy_serializer.cpp",
63    "../../../../services/edm_plugin/src/utils/usb_policy_utils.cpp",
64  ]
65
66  public_configs = [
67    ":edm_config",
68    "../../../../common/config:coverage_flags",
69  ]
70
71  defines = []
72
73  if (target_cpu == "arm64") {
74    defines += [ "_ARM64_" ]
75    print("defines _ARM64_")
76  }
77
78  if (target_cpu == "x86_64") {
79    defines += [ "_X86_64_" ]
80    print("defines _X86_64_")
81  }
82
83  if (common_event_service_edm_enable) {
84    defines += [ "COMMON_EVENT_SERVICE_EDM_ENABLE" ]
85  }
86
87  external_deps = [
88    "ability_base:want",
89    "ability_runtime:app_manager",
90    "ability_runtime:extension_manager",
91    "access_token:libaccesstoken_sdk",
92    "access_token:libtokenid_sdk",
93    "bundle_framework:appexecfwk_base",
94    "cJSON:cjson",
95    "c_utils:utils",
96    "common_event_service:cesfwk_innerkits",
97    "hilog:libhilog",
98    "init:libbegetutil",
99    "ipc:ipc_core",
100    "jsoncpp:jsoncpp",
101    "pasteboard:pasteboard_client",
102    "relational_store:native_rdb",
103    "safwk:system_ability_fwk",
104    "user_auth_framework:userauth_client",
105  ]
106
107  external_deps += [
108    "drivers_interface_usb:libusb_proxy_1.0",
109    "usb_manager:usbsrv_client",
110  ]
111
112  deps = [
113    "../../../../common/external:edm_external_adapters",
114    "../../../../common/native:edm_commom",
115    "../../../../interfaces/inner_api:edmservice_kits",
116    "../../../../interfaces/inner_api/plugin_kits:plugin_kits",
117  ]
118
119  sanitize = {
120    boundary_sanitize = true
121    cfi = true
122    cfi_cross_dso = true
123    debug = false
124    integer_overflow = true
125    ubsan = true
126  }
127  branch_protector_ret = "pac_ret"
128  subsystem_name = "customization"
129  part_name = "enterprise_device_management"
130}
131
132ohos_unittest("EdmServicesUnitTest") {
133  module_out_path = module_output_path
134
135  include_dirs = [
136    "./include",
137    "./include/mock",
138    "../../common/mock/include",
139    "../../external_mock/include",
140    "../../../../interfaces/inner_api/plugin_kits/include/utils",
141  ]
142
143  sources = [
144    "./src/admin_manager_test.cpp",
145    "./src/admin_test.cpp",
146    "./src/device_policies_storage_rdb_test.cpp",
147    "./src/enterprise_admin_connection_test.cpp",
148    "./src/enterprise_bundle_connection_test.cpp",
149    "./src/enterprise_conn_manager_test.cpp",
150    "./src/enterprise_device_mgr_ability_test.cpp",
151    "./src/enterprise_update_connection_test.cpp",
152    "./src/iplugin_template_test.cpp",
153    "./src/permission_manager_test.cpp",
154    "./src/plugin_manager_test.cpp",
155    "./src/policy_manager_test.cpp",
156    "./src/user_policy_manager_test.cpp",
157  ]
158
159  defines = []
160  if (common_event_service_edm_enable) {
161    defines += [ "COMMON_EVENT_SERVICE_EDM_ENABLE" ]
162  }
163
164  configs = [
165    ":module_private_config",
166    "../../../../common/config:coverage_flags",
167  ]
168
169  deps = [
170    ":edmservice_static",
171    "../../../../common/external:edm_external_adapters",
172    "../../../../common/native:edm_commom",
173    "../../../../interfaces/inner_api:edmservice_kits",
174    "../../../../interfaces/inner_api/plugin_kits:plugin_kits",
175    "../../utils:edm_unittest_utils",
176    "//third_party/googletest:gmock_main",
177  ]
178
179  external_deps = [
180    "ability_base:want",
181    "ability_runtime:ability_manager",
182    "access_token:libaccesstoken_sdk",
183    "access_token:libnativetoken",
184    "access_token:libtoken_setproc",
185    "bundle_framework:appexecfwk_core",
186    "cJSON:cjson",
187    "c_utils:utils",
188    "common_event_service:cesfwk_innerkits",
189    "hilog:libhilog",
190    "ipc:ipc_core",
191    "jsoncpp:jsoncpp",
192    "safwk:system_ability_fwk",
193    "samgr:samgr_proxy",
194    "user_auth_framework:userauth_client",
195  ]
196
197  if (os_account_edm_enable) {
198    external_deps += [
199      "os_account:libaccountkits",
200      "os_account:os_account_innerkits",
201    ]
202    defines += [ "OS_ACCOUNT_EDM_ENABLE" ]
203  }
204
205  sanitize = {
206    boundary_sanitize = true
207    cfi = true
208    cfi_cross_dso = true
209    debug = false
210    integer_overflow = true
211    ubsan = true
212    blocklist = "../../cfi_blocklist.txt"
213  }
214  branch_protector_ret = "pac_ret"
215  subsystem_name = "customization"
216  part_name = "enterprise_device_management"
217}
218
219group("unittest") {
220  testonly = true
221
222  deps = [
223    # deps file
224    ":EdmServicesUnitTest",
225  ]
226}
227