diff --git a/interfaces/innerkits/accesstoken/test/unittest/BUILD.gn b/interfaces/innerkits/accesstoken/test/unittest/BUILD.gn index c8267ecdb7a51539444b1efd34d9a156e0f7ba39..15eb18f6843db11639a7d2a51759e9b75eea24c4 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 2228b119b964a220ba198d557d2503c71efd90c2..eb1906281be10d268a450bdc06ab100a76a6302d 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 9e90dbb65fd16629688b9f36e9f1d4d9f8a008a1..14d742345f0f42edd580e5b90737aa1e327a9c35 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 = [