• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2022-2023 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    "${access_token_path}/frameworks/privacy/include",
31    "${access_token_path}/interfaces/innerkits/accesstoken/include",
32    "${access_token_path}/interfaces/innerkits/nativetoken/include",
33    "${access_token_path}/interfaces/innerkits/privacy/include",
34    "${access_token_path}/interfaces/innerkits/token_setproc/include",
35    "//third_party/googletest/include",
36  ]
37
38  sources = [
39    "unittest/src/permission_deny_test.cpp",
40    "unittest/src/privacy_kit_test.cpp",
41  ]
42
43  cflags_cc = [ "-DHILOG_ENABLE" ]
44
45  if (security_component_enhance_enable == true) {
46    cflags_cc += [ "-DSECURITY_COMPONENT_ENHANCE_ENABLE" ]
47  }
48
49  configs = [ "${access_token_path}/config:coverage_flags" ]
50
51  deps = [
52    "${access_token_path}/frameworks/privacy:privacy_communication_adapter_cxx",
53    "${access_token_path}/interfaces/innerkits/accesstoken:libaccesstoken_sdk",
54    "${access_token_path}/interfaces/innerkits/nativetoken:libnativetoken",
55    "${access_token_path}/interfaces/innerkits/privacy:libprivacy_sdk",
56    "${access_token_path}/interfaces/innerkits/token_setproc:libtoken_setproc",
57  ]
58  external_deps = [
59    "c_utils:utils",
60    "init:libbegetutil",
61    "ipc:ipc_core",
62  ]
63}
64
65ohos_unittest("libprivacy_mock_test") {
66  subsystem_name = "security"
67  part_name = "access_token"
68  module_out_path = part_name + "/" + part_name
69  sanitize = {
70    cfi = true
71    cfi_cross_dso = true
72    debug = false
73  }
74  branch_protector_ret = "pac_ret"
75
76  include_dirs = [
77    "../include",
78    "../src",
79    "${access_token_path}/frameworks/privacy/include",
80    "${access_token_path}/frameworks/common/include",
81    "${access_token_path}/frameworks/accesstoken/include",
82    "${access_token_path}/frameworks/tokensync/include",
83    "${access_token_path}/interfaces/innerkits/accesstoken/include",
84    "${access_token_path}/interfaces/innerkits/nativetoken/include",
85    "//third_party/googletest/include",
86  ]
87
88  sources = [
89    "../src/on_permission_used_record_callback_stub.cpp",
90    "../src/perm_active_status_change_callback.cpp",
91    "../src/perm_active_status_change_callback_stub.cpp",
92    "../src/perm_active_status_customized_cbk.cpp",
93    "../src/privacy_death_recipient.cpp",
94    "../src/privacy_kit.cpp",
95    "../src/privacy_manager_client.cpp",
96    "../src/privacy_manager_proxy.cpp",
97    "../src/state_change_callback.cpp",
98    "../src/state_change_callback_stub.cpp",
99    "../src/state_customized_cbk.cpp",
100    "mock/src/iservice_registry.cpp",
101    "unittest/privacy_mock_test/privacy_kit_test.cpp",
102  ]
103
104  configs = [ "${access_token_path}/config:coverage_flags" ]
105
106  deps = [
107    "${access_token_path}/frameworks/common:accesstoken_common_cxx",
108    "${access_token_path}/frameworks/privacy:privacy_communication_adapter_cxx",
109    "${access_token_path}/interfaces/innerkits/accesstoken:libaccesstoken_sdk",
110    "${access_token_path}/interfaces/innerkits/nativetoken:libnativetoken",
111    "${access_token_path}/interfaces/innerkits/token_setproc:libtoken_setproc",
112    "//third_party/googletest:gmock_main",
113    "//third_party/googletest:gtest_main",
114  ]
115
116  external_deps = [
117    "c_utils:utils",
118    "hilog:libhilog",
119    "hisysevent:libhisysevent",
120    "init:libbeget_proxy",
121    "init:libbegetutil",
122    "ipc:ipc_core",
123    "ipc:libdbinder",
124    "safwk:system_ability_fwk",
125    "samgr:samgr_proxy",
126  ]
127
128  cflags_cc = [
129    "-DHILOG_ENABLE",
130    "-DDEBUG_API_PERFORMANCE",
131  ]
132
133  if (eventhandler_enable == true) {
134    cflags_cc += [ "-DEVENTHANDLER_ENABLE" ]
135    external_deps += [ "eventhandler:libeventhandler" ]
136  }
137}
138
139group("unittest") {
140  testonly = true
141  deps = [
142    ":libprivacy_mock_test",
143    ":libprivacy_sdk_test",
144  ]
145}
146