diff --git a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp index 48d587d..4d19961 100644 --- a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp +++ b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp @@ -130,6 +130,7 @@ void SecCompRegisterCallbackTest::TearDown() */ HWTEST_F(SecCompRegisterCallbackTest, RegisterSecurityComponent001, TestSize.Level1) { + sleep(1); nlohmann::json jsonRes; TestCommon::BuildLocationComponentInfo(jsonRes); std::string locationInfo = jsonRes.dump(); diff --git a/services/security_component_service/sa/test/BUILD.gn b/services/security_component_service/sa/test/BUILD.gn index 528b6fd..3030383 100644 --- a/services/security_component_service/sa/test/BUILD.gn +++ b/services/security_component_service/sa/test/BUILD.gn @@ -57,7 +57,6 @@ ohos_unittest("sec_comp_service_test") { "unittest/src/sec_comp_stub_test.cpp", "unittest/src/service_test_common.cpp", "unittest/src/window_info_helper_test.cpp", - "unittest/src/zzenv_exit_operate.cpp", ] configs = [ "${sec_comp_root_dir}/config:coverage_flags" ] diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp index 8845ecb..ed7144a 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp @@ -94,13 +94,24 @@ static LocationButton BuildValidLocationComponent() button.bg_ = SecCompBackground::CIRCLE; return button; } +static const int32_t SLEEP_TIME = 5; } void SecCompManagerTest::SetUpTestCase() {} void SecCompManagerTest::TearDownTestCase() -{} +{ + if (SecCompManager::GetInstance().secRunner_ != nullptr) { + SecCompManager::GetInstance().secRunner_->queue_.reset(); + SecCompManager::GetInstance().secRunner_ = nullptr; + } + if (SecCompManager::GetInstance().secHandler_ != nullptr) { + SecCompManager::GetInstance().secHandler_->eventRunner_.reset(); + SecCompManager::GetInstance().secHandler_ = nullptr; + } + sleep(SLEEP_TIME); +} void SecCompManagerTest::SetUp() { diff --git a/services/security_component_service/sa/test/unittest/src/zzenv_exit_operate.cpp b/services/security_component_service/sa/test/unittest/src/zzenv_exit_operate.cpp deleted file mode 100644 index 55fc51e..0000000 --- a/services/security_component_service/sa/test/unittest/src/zzenv_exit_operate.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 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. - */ - -#include -#define private public -#include "event_handler.h" -#include "event_runner.h" -#include "sec_comp_manager.h" -#undef private - -using namespace testing::ext; - -namespace OHOS { -namespace Security { -namespace SecurityComponent { -/** - * @brief This test class is used to release resources before process end to avoid crash - */ -class ZZEnvExitOperate : public testing::Test { -public: - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp(); - void TearDown(); -}; - -void ZZEnvExitOperate::SetUpTestCase() -{} - -void ZZEnvExitOperate::TearDownTestCase() -{} - -void ZZEnvExitOperate::SetUp() -{} - -void ZZEnvExitOperate::TearDown() -{} - -/** - * @tc.name: ZExitOperateTest001 - * @tc.desc: remove ffrt handler to avoid uaf crash - * @tc.type: FUNC - * @tc.require: None - */ -HWTEST_F(ZZEnvExitOperate, ZExitOperateTest001, TestSize.Level1) -{ - if (SecCompManager::GetInstance().secRunner_ != nullptr) { - SecCompManager::GetInstance().secRunner_->queue_.reset(); - SecCompManager::GetInstance().secRunner_ = nullptr; - } - if (SecCompManager::GetInstance().secHandler_ != nullptr) { - SecCompManager::GetInstance().secHandler_->eventRunner_.reset(); - SecCompManager::GetInstance().secHandler_ = nullptr; - } - sleep(5); -} -} -} -} \ No newline at end of file diff --git a/test/fuzztest/security_component/common/fuzz_common.cpp b/test/fuzztest/security_component/common/fuzz_common.cpp index 30a8086..c67cf94 100644 --- a/test/fuzztest/security_component/common/fuzz_common.cpp +++ b/test/fuzztest/security_component/common/fuzz_common.cpp @@ -80,6 +80,12 @@ std::string CompoRandomGenerator::ConstructLocationJson() // set default val jsonComponent[JsonTagConstants::JSON_PARENT_TAG] = nlohmann::json { { JsonTagConstants::JSON_PARENT_EFFECT_TAG, GetData() }, + { JsonTagConstants::JSON_IS_CLIPPED_TAG, GetData() }, + { JsonTagConstants::JSON_TOP_CLIP_TAG, GetData() }, + { JsonTagConstants::JSON_BOTTOM_CLIP_TAG, GetData() }, + { JsonTagConstants::JSON_LEFT_CLIP_TAG, GetData() }, + { JsonTagConstants::JSON_RIGHT_CLIP_TAG, GetData() }, + { JsonTagConstants::JSON_PARENT_TAG_TAG, "" }, }; jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json { { JsonTagConstants::JSON_TEXT_TAG, @@ -116,6 +122,12 @@ std::string CompoRandomGenerator::ConstructSaveJson() // set default val jsonComponent[JsonTagConstants::JSON_PARENT_TAG] = nlohmann::json { { JsonTagConstants::JSON_PARENT_EFFECT_TAG, GetData() }, + { JsonTagConstants::JSON_IS_CLIPPED_TAG, GetData() }, + { JsonTagConstants::JSON_TOP_CLIP_TAG, GetData() }, + { JsonTagConstants::JSON_BOTTOM_CLIP_TAG, GetData() }, + { JsonTagConstants::JSON_LEFT_CLIP_TAG, GetData() }, + { JsonTagConstants::JSON_RIGHT_CLIP_TAG, GetData() }, + { JsonTagConstants::JSON_PARENT_TAG_TAG, "" }, }; jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json { { JsonTagConstants::JSON_TEXT_TAG, @@ -152,6 +164,12 @@ std::string CompoRandomGenerator::ConstructPasteJson() // set default val jsonComponent[JsonTagConstants::JSON_PARENT_TAG] = nlohmann::json { { JsonTagConstants::JSON_PARENT_EFFECT_TAG, GetData() }, + { JsonTagConstants::JSON_IS_CLIPPED_TAG, GetData() }, + { JsonTagConstants::JSON_TOP_CLIP_TAG, GetData() }, + { JsonTagConstants::JSON_BOTTOM_CLIP_TAG, GetData() }, + { JsonTagConstants::JSON_LEFT_CLIP_TAG, GetData() }, + { JsonTagConstants::JSON_RIGHT_CLIP_TAG, GetData() }, + { JsonTagConstants::JSON_PARENT_TAG_TAG, "" }, }; jsonComponent[JsonTagConstants::JSON_STYLE_TAG] = nlohmann::json { { JsonTagConstants::JSON_TEXT_TAG,