From 125ac0df9fd651e48c6e9d635cc852298664e173 Mon Sep 17 00:00:00 2001 From: AXYChen Date: Tue, 20 May 2025 12:08:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E5=85=A8=E6=8E=A7=E4=BB=B6tdd?= =?UTF-8?q?=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: AXYChen Change-Id: I47cc1520b50082afa148f66ff9689c8b6de35cd4 --- .../innerkits/accesstoken/test/unittest/BUILD.gn | 3 +++ .../security_component_grant_test.cpp | 13 +++++++++---- interfaces/innerkits/privacy/test/BUILD.gn | 4 ---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/interfaces/innerkits/accesstoken/test/unittest/BUILD.gn b/interfaces/innerkits/accesstoken/test/unittest/BUILD.gn index c8267ecdb..15eb18f68 100755 --- a/interfaces/innerkits/accesstoken/test/unittest/BUILD.gn +++ b/interfaces/innerkits/accesstoken/test/unittest/BUILD.gn @@ -114,6 +114,9 @@ ohos_unittest("libaccesstoken_sdk_test") { "DlpTest/share_permission_with_sandbox_test.cpp", ] } + if (security_component_enhance_enable == true) { + cflags_cc += [ "-DSECURITY_COMPONENT_ENHANCE_ENABLE" ] + } } ohos_unittest("accesstoken_mock_test") { diff --git a/interfaces/innerkits/accesstoken/test/unittest/SecurityComponentTest/security_component_grant_test.cpp b/interfaces/innerkits/accesstoken/test/unittest/SecurityComponentTest/security_component_grant_test.cpp index 2228b119b..eb1906281 100644 --- a/interfaces/innerkits/accesstoken/test/unittest/SecurityComponentTest/security_component_grant_test.cpp +++ b/interfaces/innerkits/accesstoken/test/unittest/SecurityComponentTest/security_component_grant_test.cpp @@ -16,6 +16,7 @@ #include "security_component_grant_test.h" #include +#include "accesstoken_callbacks.h" #include "accesstoken_kit.h" #include "access_token_error.h" #include "permission_grant_info.h" @@ -581,11 +582,15 @@ HWTEST_F(SecurityComponentGrantTest, RegisterSecCompEnhance001, TestSize.Level1) data.callback = nullptr; data.challenge = 0; data.seqNum = 0; - EXPECT_EQ(PrivacyError::ERR_WRITE_PARCEL_FAILED, AccessTokenKit::RegisterSecCompEnhance(data)); + EXPECT_EQ(ERR_WRITE_PARCEL_FAILED, AccessTokenKit::RegisterSecCompEnhance(data)); - // StateChangeCallback is not the real callback of SecCompEnhance, but it does not effect the final result. - auto callbackPtr = std::make_shared(); - data.callback = new (std::nothrow) StateChangeCallback(callbackPtr); + // PermissionStateChangeCallback is not the real callback of SecCompEnhance, + // but it does not effect the final result. + PermStateChangeScope scopeInfo9; + scopeInfo9.permList = {TEST_PERMISSION}; + scopeInfo9.tokenIDs = {}; + auto callbackPtr = std::make_shared(scopeInfo9); + data.callback = new (std::nothrow) PermissionStateChangeCallback(callbackPtr); EXPECT_EQ(RET_SUCCESS, AccessTokenKit::RegisterSecCompEnhance(data)); MockNativeToken mock("security_component_service"); diff --git a/interfaces/innerkits/privacy/test/BUILD.gn b/interfaces/innerkits/privacy/test/BUILD.gn index 9e90dbb65..14d742345 100644 --- a/interfaces/innerkits/privacy/test/BUILD.gn +++ b/interfaces/innerkits/privacy/test/BUILD.gn @@ -46,10 +46,6 @@ ohos_unittest("libprivacy_sdk_test") { cflags_cc = [ "-DHILOG_ENABLE" ] - if (security_component_enhance_enable == true) { - cflags_cc += [ "-DSECURITY_COMPONENT_ENHANCE_ENABLE" ] - } - configs = [ "${access_token_path}/config:coverage_flags" ] deps = [ -- Gitee