1# Copyright (c) 2021-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("libaccesstoken_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 "${access_token_path}/frameworks/accesstoken/include", 30 "${access_token_path}/frameworks/common/include", 31 "${access_token_path}/frameworks/tokensync/include", 32 "../include", 33 "../src", 34 "${access_token_path}/interfaces/innerkits/nativetoken/include", 35 "${access_token_path}/interfaces/innerkits/token_setproc/include", 36 ] 37 38 sources = [ 39 "unittest/src/accesstoken_deny_test.cpp", 40 "unittest/src/accesstoken_kit_extension_test.cpp", 41 "unittest/src/accesstoken_kit_test.cpp", 42 "unittest/src/accesstoken_location_request_test.cpp", 43 "unittest/src/accesstoken_short_time_permission_test.cpp", 44 "unittest/src/app_installation_optimized_test.cpp", 45 "unittest/src/clone_app_permission_test.cpp", 46 "unittest/src/remote_token_kit_test.cpp", 47 "unittest/src/security_component_grant_test.cpp", 48 ] 49 50 cflags_cc = [ "-DHILOG_ENABLE" ] 51 52 configs = [ "${access_token_path}/config:coverage_flags" ] 53 54 deps = [ 55 "${access_token_path}/frameworks/accesstoken:accesstoken_communication_adapter_cxx", 56 "${access_token_path}/interfaces/innerkits/nativetoken:libnativetoken_shared", 57 "${access_token_path}/interfaces/innerkits/token_setproc:libtokensetproc_shared", 58 "../:libaccesstoken_sdk", 59 "../:libtokenid_sdk", 60 ] 61 62 external_deps = [ 63 "c_utils:utils", 64 "hilog:libhilog", 65 "ipc:ipc_single", 66 "samgr:samgr_proxy", 67 ] 68 if (token_sync_enable == true) { 69 cflags_cc += [ "-DTOKEN_SYNC_ENABLE" ] 70 external_deps += [ "device_manager:devicemanagersdk" ] 71 } 72 if (dlp_permission_enable == true) { 73 cflags_cc += [ "-DSUPPORT_SANDBOX_APP" ] 74 sources += [ "unittest/src/share_permission_with_sandbox_test.cpp" ] 75 } 76} 77 78ohos_unittest("accesstoken_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 "${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/nativetoken/include", 94 "../../token_setproc/include", 95 "../include", 96 "../src", 97 ] 98 99 sources = [ 100 "../src/accesstoken_callback_stubs.cpp", 101 "../src/accesstoken_callbacks.cpp", 102 "../src/accesstoken_death_recipient.cpp", 103 "../src/accesstoken_kit.cpp", 104 "../src/accesstoken_manager_client.cpp", 105 "../src/accesstoken_manager_proxy.cpp", 106 "../src/perm_state_change_callback_customize.cpp", 107 "mock/src/iservice_registry.cpp", 108 "unittest/accesstoken_mock_test/accesstoken_kit_test.cpp", 109 ] 110 111 cflags_cc = [ "-DHILOG_ENABLE" ] 112 configs = [ "${access_token_path}/config:coverage_flags" ] 113 114 deps = [ 115 "${access_token_path}/frameworks/accesstoken:accesstoken_communication_adapter_cxx", 116 "${access_token_path}/frameworks/common:accesstoken_common_cxx", 117 "${access_token_path}/interfaces/innerkits/token_setproc:libperm_setproc", 118 "${access_token_path}/interfaces/innerkits/token_setproc:libtokensetproc_shared", 119 "../:libtokenid_sdk", 120 ] 121 122 external_deps = [ 123 "c_utils:utils", 124 "googletest:gmock", 125 "googletest:gtest_main", 126 "hilog:libhilog", 127 "init:libbeget_proxy", 128 "init:libbegetutil", 129 "ipc:ipc_core", 130 "ipc:libdbinder", 131 "safwk:system_ability_fwk", 132 "samgr:samgr_proxy", 133 ] 134 if (eventhandler_enable == true) { 135 cflags_cc += [ "-DEVENTHANDLER_ENABLE" ] 136 external_deps += [ "eventhandler:libeventhandler" ] 137 } 138 if (token_sync_enable == true) { 139 cflags_cc += [ "-DTOKEN_SYNC_ENABLE" ] 140 } 141} 142 143group("unittest") { 144 testonly = true 145 deps = [ 146 ":accesstoken_mock_test", 147 ":libaccesstoken_sdk_test", 148 "tool:SetPermDialogCapTest", 149 ] 150} 151