• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2022-2025 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 = "accesscontrol"
19  module_out_path = module_output_path_unittest_privacy
20  sanitize = {
21    cfi = true
22    cfi_cross_dso = true
23    debug = false
24  }
25  branch_protector_ret = "pac_ret"
26
27  include_dirs = [
28    "../src",
29    "mock/src",
30    "unittest/app_manager_client",
31    "${access_token_path}/frameworks/common/include",
32    "${access_token_path}/frameworks/privacy/include",
33    "${access_token_path}/interfaces/innerkits/accesstoken/include",
34    "${access_token_path}/interfaces/innerkits/nativetoken/include",
35    "${access_token_path}/interfaces/innerkits/privacy/include",
36    "${access_token_path}/interfaces/innerkits/proxy_death/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    "unittest/src/privacy_test_common.cpp",
45  ]
46
47  cflags_cc = [ "-DHILOG_ENABLE" ]
48
49  configs = [ "${access_token_path}/config:coverage_flags" ]
50
51  deps = [
52    "${access_token_path}/frameworks/common:accesstoken_common_cxx",
53    "${access_token_path}/frameworks/privacy:privacy_communication_adapter_cxx",
54    "${access_token_path}/interfaces/innerkits/accesstoken:libaccesstoken_sdk",
55    "${access_token_path}/interfaces/innerkits/nativetoken:libnativetoken_shared",
56    "${access_token_path}/interfaces/innerkits/privacy:libprivacy_sdk",
57    "${access_token_path}/interfaces/innerkits/token_setproc:libperm_setproc",
58    "${access_token_path}/interfaces/innerkits/token_setproc:libtokensetproc_shared",
59    "${access_token_path}/services/common/proxy_death:proxy_death_stub",
60  ]
61  external_deps = [
62    "c_utils:utils",
63    "hilog:libhilog",
64    "init:libbegetutil",
65    "ipc:ipc_single",
66    "safwk:system_ability_fwk",
67    "samgr:samgr_proxy",
68  ]
69
70  if (audio_framework_enable) {
71    cflags_cc += [ "-DAUDIO_FRAMEWORK_ENABLE" ]
72    external_deps += [ "audio_framework:audio_client" ]
73  }
74}
75
76ohos_unittest("libprivacy_mock_test") {
77  subsystem_name = "accesscontrol"
78  module_out_path = module_output_path_unittest_privacy
79  sanitize = {
80    cfi = true
81    cfi_cross_dso = true
82    debug = false
83  }
84  branch_protector_ret = "pac_ret"
85
86  include_dirs = [
87    "../include",
88    "../src",
89    "${access_token_path}/frameworks/privacy/include",
90    "${access_token_path}/frameworks/common/include",
91    "${access_token_path}/frameworks/accesstoken/include",
92    "${access_token_path}/frameworks/tokensync/include",
93    "${access_token_path}/interfaces/innerkits/accesstoken/include",
94    "${access_token_path}/interfaces/innerkits/nativetoken/include",
95    "${access_token_path}/interfaces/innerkits/privacy/include",
96    "${access_token_path}/interfaces/innerkits/proxy_death/include",
97  ]
98
99  sources = [
100    "../src/on_permission_used_record_callback_stub.cpp",
101    "../src/perm_active_status_change_callback.cpp",
102    "../src/perm_active_status_change_callback_stub.cpp",
103    "../src/perm_active_status_customized_cbk.cpp",
104    "../src/privacy_death_recipient.cpp",
105    "../src/privacy_kit.cpp",
106    "../src/privacy_manager_client.cpp",
107    "../src/state_change_callback.cpp",
108    "../src/state_change_callback_stub.cpp",
109    "../src/state_customized_cbk.cpp",
110    "mock/src/iservice_registry.cpp",
111    "unittest/privacy_mock_test/privacy_kit_test.cpp",
112  ]
113
114  configs = [
115    "${access_token_path}/config:coverage_flags",
116    "${access_token_path}/services/privacymanager:privacy_manager_gen_config",
117  ]
118
119  deps = [
120    "${access_token_path}/frameworks/common:accesstoken_common_cxx",
121    "${access_token_path}/frameworks/privacy:privacy_communication_adapter_cxx",
122    "${access_token_path}/interfaces/innerkits/accesstoken:libaccesstoken_sdk",
123    "${access_token_path}/interfaces/innerkits/nativetoken:libnativetoken_shared",
124    "${access_token_path}/interfaces/innerkits/token_setproc:libtokensetproc_shared",
125    "${access_token_path}/services/common/proxy_death:proxy_death_stub",
126    "${access_token_path}/services/privacymanager:privacy_manager_proxy",
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