• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    "${access_token_path}/services/common/proxy_death:proxy_death_stub",
63  ]
64  external_deps = [
65    "c_utils:utils",
66    "hilog:libhilog",
67    "init:libbegetutil",
68    "ipc:ipc_single",
69    "safwk:system_ability_fwk",
70    "samgr:samgr_proxy",
71  ]
72
73  if (audio_framework_enable) {
74    cflags_cc += [ "-DAUDIO_FRAMEWORK_ENABLE" ]
75    external_deps += [ "audio_framework:audio_client" ]
76  }
77}
78
79ohos_unittest("libprivacy_mock_test") {
80  subsystem_name = "security"
81  part_name = "access_token"
82  module_out_path = part_name + "/" + part_name
83  sanitize = {
84    cfi = true
85    cfi_cross_dso = true
86    debug = false
87  }
88  branch_protector_ret = "pac_ret"
89
90  include_dirs = [
91    "../include",
92    "../src",
93    "${access_token_path}/frameworks/privacy/include",
94    "${access_token_path}/frameworks/common/include",
95    "${access_token_path}/frameworks/accesstoken/include",
96    "${access_token_path}/frameworks/tokensync/include",
97    "${access_token_path}/interfaces/innerkits/accesstoken/include",
98    "${access_token_path}/interfaces/innerkits/nativetoken/include",
99    "${access_token_path}/interfaces/innerkits/privacy/include",
100  ]
101
102  sources = [
103    "../src/on_permission_used_record_callback_stub.cpp",
104    "../src/perm_active_status_change_callback.cpp",
105    "../src/perm_active_status_change_callback_stub.cpp",
106    "../src/perm_active_status_customized_cbk.cpp",
107    "../src/privacy_death_recipient.cpp",
108    "../src/privacy_kit.cpp",
109    "../src/privacy_manager_client.cpp",
110    "../src/privacy_manager_proxy.cpp",
111    "../src/state_change_callback.cpp",
112    "../src/state_change_callback_stub.cpp",
113    "../src/state_customized_cbk.cpp",
114    "mock/src/iservice_registry.cpp",
115    "unittest/privacy_mock_test/privacy_kit_test.cpp",
116  ]
117
118  configs = [ "${access_token_path}/config:coverage_flags" ]
119
120  deps = [
121    "${access_token_path}/frameworks/common:accesstoken_common_cxx",
122    "${access_token_path}/frameworks/privacy:privacy_communication_adapter_cxx",
123    "${access_token_path}/interfaces/innerkits/accesstoken:libaccesstoken_sdk",
124    "${access_token_path}/interfaces/innerkits/nativetoken:libnativetoken_shared",
125    "${access_token_path}/interfaces/innerkits/token_setproc:libtokensetproc_shared",
126    "${access_token_path}/services/common/proxy_death:proxy_death_stub",
127  ]
128
129  external_deps = [
130    "c_utils:utils",
131    "googletest:gmock",
132    "googletest:gtest_main",
133    "hilog:libhilog",
134    "init:libbeget_proxy",
135    "init:libbegetutil",
136    "ipc:ipc_single",
137    "ipc:libdbinder",
138    "safwk:system_ability_fwk",
139    "samgr:samgr_proxy",
140  ]
141
142  cflags_cc = [
143    "-DHILOG_ENABLE",
144    "-DDEBUG_API_PERFORMANCE",
145  ]
146
147  if (eventhandler_enable == true) {
148    cflags_cc += [ "-DEVENTHANDLER_ENABLE" ]
149    external_deps += [ "eventhandler:libeventhandler" ]
150  }
151}
152
153group("unittest") {
154  testonly = true
155  deps = [
156    ":libprivacy_mock_test",
157    ":libprivacy_sdk_test",
158  ]
159}
160