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("../../../../access_token.gni")
16
17ohos_unittest("libprivacy_sdk_test") {
18  subsystem_name = "security"
19  part_name = "access_token"
20  module_out_path = part_name + "/" + part_name
21  sanitize = {
22    cfi = true
23    cfi_cross_dso = true
24    debug = false
25  }
26  branch_protector_ret = "pac_ret"
27
28  include_dirs = [
29    "../src",
30    "mock/src",
31    "unittest/app_manager_client",
32    "${access_token_path}/frameworks/common/include",
33    "${access_token_path}/frameworks/privacy/include",
34    "${access_token_path}/interfaces/innerkits/accesstoken/include",
35    "${access_token_path}/interfaces/innerkits/nativetoken/include",
36    "${access_token_path}/interfaces/innerkits/privacy/include",
37    "${access_token_path}/interfaces/innerkits/token_setproc/include",
38  ]
39
40  sources = [
41    "mock/src/app_manager_access_client.cpp",
42    "unittest/src/permission_deny_test.cpp",
43    "unittest/src/privacy_kit_test.cpp",
44  ]
45
46  cflags_cc = [ "-DHILOG_ENABLE" ]
47
48  if (security_component_enhance_enable == true) {
49    cflags_cc += [ "-DSECURITY_COMPONENT_ENHANCE_ENABLE" ]
50  }
51
52  configs = [ "${access_token_path}/config:coverage_flags" ]
53
54  deps = [
55    "${access_token_path}/frameworks/common:accesstoken_common_cxx",
56    "${access_token_path}/frameworks/privacy:privacy_communication_adapter_cxx",
57    "${access_token_path}/interfaces/innerkits/accesstoken:libaccesstoken_sdk",
58    "${access_token_path}/interfaces/innerkits/nativetoken:libnativetoken_shared",
59    "${access_token_path}/interfaces/innerkits/privacy:libprivacy_sdk",
60    "${access_token_path}/interfaces/innerkits/token_setproc:libperm_setproc",
61    "${access_token_path}/interfaces/innerkits/token_setproc:libtokensetproc_shared",
62  ]
63  external_deps = [
64    "c_utils:utils",
65    "hilog:libhilog",
66    "init:libbegetutil",
67    "ipc:ipc_core",
68    "safwk:system_ability_fwk",
69    "samgr:samgr_proxy",
70  ]
71
72  if (audio_framework_enable) {
73    cflags_cc += [ "-DAUDIO_FRAMEWORK_ENABLE" ]
74    external_deps += [ "audio_framework:audio_client" ]
75  }
76}
77
78ohos_unittest("libprivacy_mock_test") {
79  subsystem_name = "security"
80  part_name = "access_token"
81  module_out_path = part_name + "/" + part_name
82  sanitize = {
83    cfi = true
84    cfi_cross_dso = true
85    debug = false
86  }
87  branch_protector_ret = "pac_ret"
88
89  include_dirs = [
90    "../include",
91    "../src",
92    "${access_token_path}/frameworks/privacy/include",
93    "${access_token_path}/frameworks/common/include",
94    "${access_token_path}/frameworks/accesstoken/include",
95    "${access_token_path}/frameworks/tokensync/include",
96    "${access_token_path}/interfaces/innerkits/accesstoken/include",
97    "${access_token_path}/interfaces/innerkits/nativetoken/include",
98  ]
99
100  sources = [
101    "../src/on_permission_used_record_callback_stub.cpp",
102    "../src/perm_active_status_change_callback.cpp",
103    "../src/perm_active_status_change_callback_stub.cpp",
104    "../src/perm_active_status_customized_cbk.cpp",
105    "../src/privacy_death_recipient.cpp",
106    "../src/privacy_kit.cpp",
107    "../src/privacy_manager_client.cpp",
108    "../src/privacy_manager_proxy.cpp",
109    "../src/state_change_callback.cpp",
110    "../src/state_change_callback_stub.cpp",
111    "../src/state_customized_cbk.cpp",
112    "mock/src/iservice_registry.cpp",
113    "unittest/privacy_mock_test/privacy_kit_test.cpp",
114  ]
115
116  configs = [ "${access_token_path}/config:coverage_flags" ]
117
118  deps = [
119    "${access_token_path}/frameworks/common:accesstoken_common_cxx",
120    "${access_token_path}/frameworks/privacy:privacy_communication_adapter_cxx",
121    "${access_token_path}/interfaces/innerkits/accesstoken:libaccesstoken_sdk",
122    "${access_token_path}/interfaces/innerkits/nativetoken:libnativetoken_shared",
123    "${access_token_path}/interfaces/innerkits/token_setproc:libtokensetproc_shared",
124  ]
125
126  external_deps = [
127    "c_utils:utils",
128    "googletest:gmock",
129    "googletest:gtest_main",
130    "hilog:libhilog",
131    "init:libbeget_proxy",
132    "init:libbegetutil",
133    "ipc:ipc_core",
134    "ipc:libdbinder",
135    "safwk:system_ability_fwk",
136    "samgr:samgr_proxy",
137  ]
138
139  cflags_cc = [
140    "-DHILOG_ENABLE",
141    "-DDEBUG_API_PERFORMANCE",
142  ]
143
144  if (eventhandler_enable == true) {
145    cflags_cc += [ "-DEVENTHANDLER_ENABLE" ]
146    external_deps += [ "eventhandler:libeventhandler" ]
147  }
148}
149
150group("unittest") {
151  testonly = true
152  deps = [
153    ":libprivacy_mock_test",
154    ":libprivacy_sdk_test",
155  ]
156}
157