diff --git a/frameworks/core/components/font/constants_converter.cpp b/frameworks/core/components/font/constants_converter.cpp index 7ee4dfc0aa17718a432fd1c64f275db6301ca381..e8410e838b8ef33a95dde891b89e0cfd18e5765c 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 243bddc5567ea028c46b5b4baee8785a0fe50e69..cac2c7efdce739475986df59fab624c2abfe6812 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); } /**