From dc71e06453ef5e86f874f911ba3e889a2564a669 Mon Sep 17 00:00:00 2001 From: freemanBao Date: Fri, 1 Aug 2025 14:35:37 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90RichEditor=E3=80=91=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=83=8C=E6=99=AF=E8=89=B2=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: freemanBao Change-Id: Id168dc62a74b185b3e92e70d1659f0d693c1a2e9 --- .../components/font/constants_converter.cpp | 1 + .../rich_editor_layout_test_ng.cpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/frameworks/core/components/font/constants_converter.cpp b/frameworks/core/components/font/constants_converter.cpp index 7ee4dfc0aa1..e8410e838b8 100644 --- a/frameworks/core/components/font/constants_converter.cpp +++ b/frameworks/core/components/font/constants_converter.cpp @@ -605,6 +605,7 @@ void ConvertTxtStyle(const TextStyle& textStyle, const WeakPtr& co } auto textBackgroundStyle = textStyle.GetTextBackgroundStyle(); + txtStyle.styleId = textStyle.GetTextStyleUid(); CHECK_NULL_VOID(textBackgroundStyle.has_value()); txtStyle.styleId = textBackgroundStyle->groupId; if (textBackgroundStyle->backgroundColor.has_value()) { diff --git a/test/unittest/core/pattern/rich_editor/rich_editor_layout_test_ng.cpp b/test/unittest/core/pattern/rich_editor/rich_editor_layout_test_ng.cpp index 243bddc5567..cac2c7efdce 100644 --- a/test/unittest/core/pattern/rich_editor/rich_editor_layout_test_ng.cpp +++ b/test/unittest/core/pattern/rich_editor/rich_editor_layout_test_ng.cpp @@ -295,12 +295,31 @@ HWTEST_F(RichEditorLayoutTestNg, RichEditorLayoutAlgorithm002, TestSize.Level1) auto layoutAlgorithm = AceType::DynamicCast(richEditorPattern->CreateLayoutAlgorithm()); ASSERT_NE(layoutAlgorithm, nullptr); + auto layoutWrapper = AceType::MakeRefPtr( + richEditorNode_, AceType::MakeRefPtr(), richEditorNode_->GetLayoutProperty()); + ASSERT_NE(layoutWrapper, nullptr); + /** + * @tc.steps: step1. test placeholder + */ std::list> spanGroup; spanGroup.clear(); spanGroup.emplace_back(AceType::MakeRefPtr()); auto span = layoutAlgorithm->GetParagraphStyleSpanItem(spanGroup); EXPECT_EQ(*spanGroup.begin(), span); + + /** + * @tc.steps: step2. test measure content + */ + TextSpanOptions textOptions; + textOptions.value = INIT_VALUE_2; + richEditorPattern->AddTextSpan(textOptions); + layoutAlgorithm = AceType::DynamicCast(richEditorPattern->CreateLayoutAlgorithm()); + layoutWrapper->SetLayoutAlgorithm(AceType::MakeRefPtr(layoutAlgorithm)); + LayoutConstraintF parentLayoutConstraint; + parentLayoutConstraint.maxSize = CONTAINER_SIZE; + layoutAlgorithm->MeasureContent(parentLayoutConstraint, AceType::RawPtr(layoutWrapper)); + EXPECT_EQ(layoutAlgorithm->GetSpans().size(), 1); } /** -- Gitee