From bae76b17de6cc56751fb446a177d11052652777b Mon Sep 17 00:00:00 2001 From: baoyang Date: Thu, 31 Jul 2025 23:12:21 +0800 Subject: [PATCH] fix consistence Signed-off-by: baoyang Change-Id: I97fa6bb8b95550c3ba3aba7012eb402853f394b9 --- .../src/sec_comp_info_helper_test.cpp | 92 +++++++++---------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_info_helper_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_info_helper_test.cpp index 8798760..6350f35 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_info_helper_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_info_helper_test.cpp @@ -522,6 +522,51 @@ HWTEST_F(SecCompInfoHelperTest, ParseComponent015, TestSize.Level0) ASSERT_FALSE(comp->GetValid()); } +/** + * @tc.name: AdjustSecCompRect001 + * @tc.desc: Test AdjustSecCompRect + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(SecCompInfoHelperTest, AdjustSecCompRect001, TestSize.Level0) +{ + nlohmann::json jsonComponent; + ServiceTestCommon::BuildLocationComponentJson(jsonComponent); + std::string message; + SecCompBase* comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent, message); + float scale = 0.8f; + + comp->rect_.x_ = 10.0f; + comp->rect_.y_ = 5.0f; + comp->rect_.width_ = 20.0f; + comp->rect_.height_ = 10.0f; + comp->windowRect_.x_ = 0.0f; + comp->windowRect_.y_ = 0.0f; + comp->windowRect_.width_ = 200.0f; + comp->windowRect_.height_ = 100.0f; + + SecCompInfoHelper::AdjustSecCompRect(comp, scale, false); + EXPECT_TRUE(IsEqual(comp->rect_.width_, 16)); + EXPECT_TRUE(IsEqual(comp->rect_.height_, 8)); + EXPECT_TRUE(IsEqual(comp->rect_.x_, 8)); + EXPECT_TRUE(IsEqual(comp->rect_.y_, 4)); + + comp->rect_.x_ = 10.0f; + comp->rect_.y_ = 5.0f; + comp->rect_.width_ = 20.0f; + comp->rect_.height_ = 10.0f; + comp->windowRect_.x_ = 0.0f; + comp->windowRect_.y_ = 0.0f; + comp->windowRect_.width_ = 200.0f; + comp->windowRect_.height_ = 100.0f; + + SecCompInfoHelper::AdjustSecCompRect(comp, scale, true); + EXPECT_TRUE(IsEqual(comp->rect_.width_, 16)); + EXPECT_TRUE(IsEqual(comp->rect_.height_, 8)); + EXPECT_TRUE(IsEqual(comp->rect_.x_, 28)); + EXPECT_TRUE(IsEqual(comp->rect_.y_, 14)); +} + /** * @tc.name: CheckComponentValid001 * @tc.desc: Test CheckComponentValid with invalid color @@ -632,49 +677,4 @@ HWTEST_F(SecCompInfoHelperTest, CheckComponentValid005, TestSize.Level0) Rosen::WindowManager::GetInstance().result_ = static_cast(-1); ASSERT_TRUE(SecCompInfoHelper::CheckComponentValid(comp, message)); -} - -/** - * @tc.name: AdjustSecCompRect001 - * @tc.desc: Test AdjustSecCompRect - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(SecCompInfoHelperTest, AdjustSecCompRect001, TestSize.Level0) -{ - nlohmann::json jsonComponent; - ServiceTestCommon::BuildLocationComponentJson(jsonComponent); - std::string message; - SecCompBase* comp = SecCompInfoHelper::ParseComponent(LOCATION_COMPONENT, jsonComponent, message); - float scale = 0.8f; - - comp->rect_.x_ = 10.0f; - comp->rect_.y_ = 5.0f; - comp->rect_.width_ = 20.0f; - comp->rect_.height_ = 10.0f; - comp->windowRect_.x_ = 0.0f; - comp->windowRect_.y_ = 0.0f; - comp->windowRect_.width_ = 200.0f; - comp->windowRect_.height_ = 100.0f; - - SecCompInfoHelper::AdjustSecCompRect(comp, scale, false); - EXPECT_TRUE(IsEqual(comp->rect_.width_, 16)); - EXPECT_TRUE(IsEqual(comp->rect_.height_, 8)); - EXPECT_TRUE(IsEqual(comp->rect_.x_, 8)); - EXPECT_TRUE(IsEqual(comp->rect_.y_, 4)); - - comp->rect_.x_ = 10.0f; - comp->rect_.y_ = 5.0f; - comp->rect_.width_ = 20.0f; - comp->rect_.height_ = 10.0f; - comp->windowRect_.x_ = 0.0f; - comp->windowRect_.y_ = 0.0f; - comp->windowRect_.width_ = 200.0f; - comp->windowRect_.height_ = 100.0f; - - SecCompInfoHelper::AdjustSecCompRect(comp, scale, true); - EXPECT_TRUE(IsEqual(comp->rect_.width_, 16)); - EXPECT_TRUE(IsEqual(comp->rect_.height_, 8)); - EXPECT_TRUE(IsEqual(comp->rect_.x_, 28)); - EXPECT_TRUE(IsEqual(comp->rect_.y_, 14)); -} +} \ No newline at end of file -- Gitee