From a5fa9dd5b11165ff5035994304e98656e16fed30 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Tue, 8 Jul 2025 15:27:17 +0800 Subject: [PATCH] symbleshadow tdd add Signed-off-by: wangweiyuan --- .../core/pattern/text/text_testfive_ng.cpp | 49 ++++++++++++++++--- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/test/unittest/core/pattern/text/text_testfive_ng.cpp b/test/unittest/core/pattern/text/text_testfive_ng.cpp index 7e06923a558..a97af88317a 100644 --- a/test/unittest/core/pattern/text/text_testfive_ng.cpp +++ b/test/unittest/core/pattern/text/text_testfive_ng.cpp @@ -2691,16 +2691,49 @@ HWTEST_F(TextTestFiveNg, GetThumbnailCallback001, TestSize.Level1) */ HWTEST_F(TextTestFiveNg, UpdateRectForSymbolShadow001, TestSize.Level1) { - auto frameNode = FrameNode::CreateFrameNode(V2::TEXT_ETS_TAG, 0, AceType::MakeRefPtr()); - ASSERT_NE(frameNode, nullptr); - auto pattern = frameNode->GetPattern(); - ASSERT_NE(pattern, nullptr); - auto textLayoutProperty = pattern->GetLayoutProperty(); + auto textFrameNode = FrameNode::CreateFrameNode(V2::TEXT_ETS_TAG, 0, AceType::MakeRefPtr()); + ASSERT_NE(textFrameNode, nullptr); + auto textPattern = textFrameNode->GetPattern(); + ASSERT_NE(textPattern, nullptr); + auto textLayoutProperty = textPattern->GetLayoutProperty(); + ASSERT_NE(textLayoutProperty, nullptr); + + TextModelNG text; + text.Create(u"text"); + text.SetHeightAdaptivePolicy(TextHeightAdaptivePolicy::MAX_LINES_FIRST); + Shadow textShadow; + text.SetTextShadow({ textShadow }); + RectF rectsForPlaceholders(0, 0, 10, 10); + textPattern->UpdateRectForSymbolShadow(rectsForPlaceholders, 1, 1, 1.0); + EXPECT_EQ(textLayoutProperty->GetHeightAdaptivePolicyValue(TextHeightAdaptivePolicy::MAX_LINES_FIRST), + TextHeightAdaptivePolicy::MAX_LINES_FIRST); + EXPECT_EQ(*textLayoutProperty->GetTextShadowValue({ textShadow }).begin(), textShadow); +} + +/** + * @tc.name: UpdateRectForSymbolShadow002 + * @tc.desc: test text_pattern.cpp UpdateRectForSymbolShadow function + * @tc.type: FUNC + */ +HWTEST_F(TextTestFiveNg, UpdateRectForSymbolShadow002, TestSize.Level1) +{ + auto textFrameNode = FrameNode::CreateFrameNode(V2::TEXT_ETS_TAG, 0, AceType::MakeRefPtr()); + ASSERT_NE(textFrameNode, nullptr); + auto textPattern = textFrameNode->GetPattern(); + ASSERT_NE(textPattern, nullptr); + auto textLayoutProperty = textPattern->GetLayoutProperty(); ASSERT_NE(textLayoutProperty, nullptr); + + TextModelNG text; + text.Create(u"text"); + text.SetHeightAdaptivePolicy(TextHeightAdaptivePolicy::MAX_LINES_FIRST); + Shadow textShadow; + text.SetTextShadow({ textShadow }); RectF rectsForPlaceholders(0, 0, 10, 10); - pattern->UpdateRectForSymbolShadow(rectsForPlaceholders, 0, 0, 0.0); - auto shadow = textLayoutProperty->GetTextShadow().value(); - EXPECT_TRUE(shadow.empty()); + textPattern->UpdateRectForSymbolShadow(rectsForPlaceholders, -1, -1, 1.0); + EXPECT_EQ(textLayoutProperty->GetHeightAdaptivePolicyValue(TextHeightAdaptivePolicy::MAX_LINES_FIRST), + TextHeightAdaptivePolicy::MAX_LINES_FIRST); + EXPECT_EQ(*textLayoutProperty->GetTextShadowValue({ textShadow }).begin(), textShadow); } /** -- Gitee