# Copyright (c) 2022-2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("//build/test.gni") import("../../../../access_token.gni") ohos_unittest("libprivacy_sdk_test") { subsystem_name = "security" part_name = "access_token" module_out_path = part_name + "/" + part_name sanitize = { cfi = true cfi_cross_dso = true debug = false } branch_protector_ret = "pac_ret" include_dirs = [ "../src", "mock/src", "unittest/app_manager_client", "${access_token_path}/frameworks/common/include", "${access_token_path}/frameworks/privacy/include", "${access_token_path}/interfaces/innerkits/accesstoken/include", "${access_token_path}/interfaces/innerkits/nativetoken/include", "${access_token_path}/interfaces/innerkits/privacy/include", "${access_token_path}/interfaces/innerkits/token_setproc/include", ] sources = [ "mock/src/app_manager_access_client.cpp", "unittest/src/permission_deny_test.cpp", "unittest/src/privacy_kit_test.cpp", ] cflags_cc = [ "-DHILOG_ENABLE" ] if (security_component_enhance_enable == true) { cflags_cc += [ "-DSECURITY_COMPONENT_ENHANCE_ENABLE" ] } configs = [ "${access_token_path}/config:coverage_flags" ] deps = [ "${access_token_path}/frameworks/common:accesstoken_common_cxx", "${access_token_path}/frameworks/privacy:privacy_communication_adapter_cxx", "${access_token_path}/interfaces/innerkits/accesstoken:libaccesstoken_sdk", "${access_token_path}/interfaces/innerkits/nativetoken:libnativetoken_shared", "${access_token_path}/interfaces/innerkits/privacy:libprivacy_sdk", "${access_token_path}/interfaces/innerkits/token_setproc:libperm_setproc", "${access_token_path}/interfaces/innerkits/token_setproc:libtokensetproc_shared", ] external_deps = [ "c_utils:utils", "hilog:libhilog", "init:libbegetutil", "ipc:ipc_core", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] if (audio_framework_enable) { cflags_cc += [ "-DAUDIO_FRAMEWORK_ENABLE" ] external_deps += [ "audio_framework:audio_client" ] } } ohos_unittest("libprivacy_mock_test") { subsystem_name = "security" part_name = "access_token" module_out_path = part_name + "/" + part_name sanitize = { cfi = true cfi_cross_dso = true debug = false } branch_protector_ret = "pac_ret" include_dirs = [ "../include", "../src", "${access_token_path}/frameworks/privacy/include", "${access_token_path}/frameworks/common/include", "${access_token_path}/frameworks/accesstoken/include", "${access_token_path}/frameworks/tokensync/include", "${access_token_path}/interfaces/innerkits/accesstoken/include", "${access_token_path}/interfaces/innerkits/nativetoken/include", ] sources = [ "../src/on_permission_used_record_callback_stub.cpp", "../src/perm_active_status_change_callback.cpp", "../src/perm_active_status_change_callback_stub.cpp", "../src/perm_active_status_customized_cbk.cpp", "../src/privacy_death_recipient.cpp", "../src/privacy_kit.cpp", "../src/privacy_manager_client.cpp", "../src/privacy_manager_proxy.cpp", "../src/state_change_callback.cpp", "../src/state_change_callback_stub.cpp", "../src/state_customized_cbk.cpp", "mock/src/iservice_registry.cpp", "unittest/privacy_mock_test/privacy_kit_test.cpp", ] configs = [ "${access_token_path}/config:coverage_flags" ] deps = [ "${access_token_path}/frameworks/common:accesstoken_common_cxx", "${access_token_path}/frameworks/privacy:privacy_communication_adapter_cxx", "${access_token_path}/interfaces/innerkits/accesstoken:libaccesstoken_sdk", "${access_token_path}/interfaces/innerkits/nativetoken:libnativetoken_shared", "${access_token_path}/interfaces/innerkits/token_setproc:libtokensetproc_shared", ] external_deps = [ "c_utils:utils", "googletest:gmock", "googletest:gtest_main", "hilog:libhilog", "init:libbeget_proxy", "init:libbegetutil", "ipc:ipc_core", "ipc:libdbinder", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] cflags_cc = [ "-DHILOG_ENABLE", "-DDEBUG_API_PERFORMANCE", ] if (eventhandler_enable == true) { cflags_cc += [ "-DEVENTHANDLER_ENABLE" ] external_deps += [ "eventhandler:libeventhandler" ] } } group("unittest") { testonly = true deps = [ ":libprivacy_mock_test", ":libprivacy_sdk_test", ] }