mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-12-11 18:05:04 +00:00
!34944 Text组件 TextTestNg的TDD补充
Merge pull request !34944 from xieqiqi/master
This commit is contained in:
commit
6e22c1722f
@ -1054,6 +1054,234 @@ HWTEST_F(RichEditorEditTestNg, DeleteValueSetImageSpan, TestSize.Level1)
|
||||
ClearSpan();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CheckEditorTypeChange001
|
||||
* @tc.desc: test CheckEditorTypeChange
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RichEditorEditTestNg, CheckEditorTypeChange001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(richEditorNode_, nullptr);
|
||||
auto richEditorPattern = richEditorNode_->GetPattern<RichEditorPattern>();
|
||||
auto pipeline = PipelineContext::GetCurrentContextSafely();
|
||||
SelectOverlayInfo selectOverlayInfo;
|
||||
int32_t singleLineHeight = 143;
|
||||
selectOverlayInfo.singleLineHeight = singleLineHeight;
|
||||
CHECK_NULL_VOID(pipeline);
|
||||
auto host = richEditorPattern->GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
pipeline->AddOnAreaChangeNode(host->GetId());
|
||||
|
||||
richEditorPattern->selectOverlayProxy_ =
|
||||
pipeline->GetSelectOverlayManager()->CreateAndShowSelectOverlay(selectOverlayInfo, nullptr);
|
||||
|
||||
richEditorPattern->CheckEditorTypeChange();
|
||||
EXPECT_EQ(richEditorPattern->GetEditorType(), TextSpanType::NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: InsertValueByPaste001
|
||||
* @tc.desc: test InsertValueByPaste
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RichEditorEditTestNg, InsertValueByPaste001, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. create textFrameNode.
|
||||
*/
|
||||
ASSERT_NE(richEditorNode_, nullptr);
|
||||
auto richEditorPattern = richEditorNode_->GetPattern<RichEditorPattern>();
|
||||
auto textFrameNode = FrameNode::CreateFrameNode(V2::TEXT_ETS_TAG, 0, AceType::MakeRefPtr<TextPattern>());
|
||||
ASSERT_NE(textFrameNode, nullptr);
|
||||
RefPtr<GeometryNode> geometryNode = AceType::MakeRefPtr<GeometryNode>();
|
||||
ASSERT_NE(geometryNode, nullptr);
|
||||
RefPtr<LayoutWrapperNode> layoutWrapper =
|
||||
AceType::MakeRefPtr<LayoutWrapperNode>(textFrameNode, geometryNode, textFrameNode->GetLayoutProperty());
|
||||
auto textPattern = textFrameNode->GetPattern<TextPattern>();
|
||||
ASSERT_NE(textPattern, nullptr);
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. construct spanItem_.
|
||||
*/
|
||||
textPattern->isSpanStringMode_ = true;
|
||||
|
||||
auto pasteStr = richEditorPattern->GetPasteStr();
|
||||
richEditorPattern->InsertValueByPaste(pasteStr);
|
||||
|
||||
richEditorPattern->OnAreaChangedInner();
|
||||
OffsetF Offset = {1, 2};
|
||||
EXPECT_NE(richEditorPattern->GetPaintRectGlobalOffset(), Offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetThumbnailCallback001
|
||||
* @tc.desc: test GetThumbnailCallback
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RichEditorEditTestNg, GetThumbnailCallback001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(richEditorNode_, nullptr);
|
||||
auto richEditorPattern = richEditorNode_->GetPattern<RichEditorPattern>();
|
||||
auto host = richEditorPattern->GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
auto gestureHub = host->GetOrCreateGestureEventHub();
|
||||
CHECK_NULL_VOID(gestureHub);
|
||||
|
||||
gestureHub->InitDragDropEvent();
|
||||
gestureHub->SetThumbnailCallback(richEditorPattern->GetThumbnailCallback());
|
||||
EXPECT_EQ(richEditorPattern->dragNode_, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetSelection001
|
||||
* @tc.desc: test SetSelection
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RichEditorEditTestNg, SetSelection001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(richEditorNode_, nullptr);
|
||||
auto richEditorPattern = richEditorNode_->GetPattern<RichEditorPattern>();
|
||||
ASSERT_NE(richEditorPattern, nullptr);
|
||||
richEditorPattern->DumpInfo();
|
||||
|
||||
auto pipeline = PipelineContext::GetCurrentContext();
|
||||
auto theme = AceType::MakeRefPtr<MockThemeManager>();
|
||||
pipeline->SetThemeManager(theme);
|
||||
|
||||
richEditorPattern->isTextChange_ = false;
|
||||
EXPECT_EQ(richEditorPattern->IsShowHandle(), false);
|
||||
|
||||
auto manager = AceType::MakeRefPtr<TextFieldManagerNG>();
|
||||
richEditorPattern->ScrollToSafeArea();
|
||||
EXPECT_EQ(LessNotEqual(manager->GetHeight(), 800.0f), true);
|
||||
|
||||
richEditorPattern->InitScrollablePattern();
|
||||
EXPECT_EQ(richEditorPattern->GetScrollBar(), true);
|
||||
|
||||
richEditorPattern->overlayMod_ = AceType::MakeRefPtr<TextOverlayModifier>();
|
||||
richEditorPattern->InitScrollablePattern();
|
||||
EXPECT_EQ(richEditorPattern->GetScrollBar(), true);
|
||||
|
||||
Offset Offset = {1, 4};
|
||||
richEditorPattern->isTextChange_ = true;
|
||||
richEditorPattern->UpdateTextFieldManager(Offset, 1.0f);
|
||||
EXPECT_EQ(richEditorPattern->HasFocus(), false);
|
||||
|
||||
richEditorPattern->isTextChange_ = false;
|
||||
richEditorPattern->UpdateTextFieldManager(Offset, 1.0f);
|
||||
EXPECT_EQ(richEditorPattern->HasFocus(), false);
|
||||
|
||||
richEditorPattern->caretUpdateType_ = CaretUpdateType::DOUBLE_CLICK;
|
||||
richEditorPattern->sourceType_ = SourceType::MOUSE;
|
||||
int32_t index = 1;
|
||||
richEditorPattern->MouseDoubleClickParagraphEnd(index);
|
||||
EXPECT_NE(richEditorPattern->GetParagraphEndPosition(index), index);
|
||||
|
||||
SelectionOptions options;
|
||||
options.menuPolicy = MenuPolicy::SHOW;
|
||||
richEditorPattern->HandleSelectOverlayWithOptions(options);
|
||||
EXPECT_EQ(richEditorPattern->selectionMenuOffsetByMouse_.GetX(),
|
||||
richEditorPattern->selectionMenuOffsetByMouse_.GetX());
|
||||
|
||||
int32_t start = 1;
|
||||
int32_t end = 3;
|
||||
richEditorPattern->SetSelection(start, end, options);
|
||||
EXPECT_NE(richEditorPattern->textSelector_.GetStart(), start);
|
||||
|
||||
options.menuPolicy = MenuPolicy::HIDE;
|
||||
richEditorPattern->HandleSelectOverlayWithOptions(options);
|
||||
EXPECT_EQ(richEditorPattern->selectionMenuOffsetByMouse_.GetX(),
|
||||
richEditorPattern->selectionMenuOffsetByMouse_.GetX());
|
||||
|
||||
richEditorPattern->SetSelection(start, end, options);
|
||||
EXPECT_NE(richEditorPattern->textSelector_.GetEnd(), end);
|
||||
|
||||
options.menuPolicy = MenuPolicy::DEFAULT;
|
||||
richEditorPattern->SetSelection(start, end, options);
|
||||
EXPECT_NE(richEditorPattern->textSelector_.GetEnd(), end);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CreateHandles001
|
||||
* @tc.desc: test CreateHandles
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RichEditorEditTestNg, CreateHandles001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(richEditorNode_, nullptr);
|
||||
auto richEditorPattern = richEditorNode_->GetPattern<RichEditorPattern>();
|
||||
richEditorPattern->textForDisplay_ = "testShowHandles";
|
||||
ASSERT_NE(richEditorPattern, nullptr);
|
||||
richEditorPattern->caretPosition_ = 1;
|
||||
richEditorPattern->textSelector_.baseOffset = 1;
|
||||
richEditorPattern->textSelector_.destinationOffset = 3;
|
||||
|
||||
richEditorPattern->CreateHandles();
|
||||
auto offsetF = OffsetF(0.0f, 0.0f);
|
||||
EXPECT_EQ(richEditorPattern->textSelector_.selectionBaseOffset, offsetF);
|
||||
|
||||
richEditorPattern->ShowHandles(false);
|
||||
EXPECT_NE(richEditorPattern->showSelect_, false);
|
||||
|
||||
richEditorPattern->ShowHandles(true);
|
||||
EXPECT_EQ(richEditorPattern->showSelect_, true);
|
||||
|
||||
Offset textOffset = {1, 3};
|
||||
EXPECT_NE(richEditorPattern->BetweenSelection(textOffset), true);
|
||||
|
||||
richEditorPattern->CloseHandleAndSelect();
|
||||
EXPECT_EQ(richEditorPattern->showSelect_, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetTextBoxes001
|
||||
* @tc.desc: test GetTextBoxes
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RichEditorEditTestNg, GetTextBoxes001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(richEditorNode_, nullptr);
|
||||
auto richEditorPattern = richEditorNode_->GetPattern<RichEditorPattern>();
|
||||
richEditorPattern->textForDisplay_ = "testShowHandles";
|
||||
ASSERT_NE(richEditorPattern, nullptr);
|
||||
richEditorPattern->caretPosition_ = 1;
|
||||
richEditorPattern->textSelector_.baseOffset = 1;
|
||||
richEditorPattern->textSelector_.destinationOffset = 3;
|
||||
|
||||
std::vector<RectF> res;
|
||||
auto ret = richEditorPattern->GetTextBoxes();
|
||||
EXPECT_EQ(ret, res);
|
||||
|
||||
|
||||
TextLineMetrics lineMetrics;
|
||||
richEditorPattern->GetLineCount();
|
||||
EXPECT_EQ(richEditorPattern->GetLineHeight(), 0.0f);
|
||||
EXPECT_EQ(richEditorPattern->GetLetterSpacing(), 0.0f);
|
||||
auto retLineMetrics = richEditorPattern->GetLineMetrics(-1);
|
||||
EXPECT_EQ(retLineMetrics.x, 0);
|
||||
|
||||
auto retLineMetricsS = richEditorPattern->GetLineMetrics(2);
|
||||
EXPECT_EQ(retLineMetricsS.x, 0);
|
||||
|
||||
int32_t scroll_from_update = 1;
|
||||
richEditorPattern->richTextRect_ = RectF(0, 4, 100, 140);
|
||||
richEditorPattern->contentRect_ = RectF(0, 1, 100, 160);
|
||||
richEditorPattern->UpdateScrollStateAfterLayout(true);
|
||||
EXPECT_FALSE(richEditorPattern->OnScrollCallback(10, scroll_from_update)) << "Reach Top Boundary";
|
||||
|
||||
EXPECT_EQ(richEditorPattern->MoveTextRect(0.0f), 0.0f);
|
||||
|
||||
auto offsetF = OffsetF(0.0f, 0.5f);
|
||||
richEditorPattern->MoveCaretToContentRect(offsetF, 8.0f);
|
||||
EXPECT_EQ(richEditorPattern->GetTextRect(), richEditorPattern->richTextRect_);
|
||||
|
||||
richEditorPattern->MoveCaretToContentRect(1.0f, 10);
|
||||
EXPECT_EQ(richEditorPattern->GetTextRect(), richEditorPattern->richTextRect_);
|
||||
|
||||
richEditorPattern->contentChange_ = true;
|
||||
EXPECT_EQ(richEditorPattern->GetCrossOverHeight(), 0.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UpdateTextStyle
|
||||
* @tc.desc: test update span style
|
||||
|
@ -190,6 +190,203 @@ HWTEST_F(TextTestNg, TextFrameNodeCreator003, TestSize.Level1)
|
||||
textModelNG.SetOnDrop(OnDragDropFunction);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetTextDetectEnable002
|
||||
* @tc.desc: Test SetTextDetectEnable.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(TextTestNg, SetTextDetectEnable002, TestSize.Level1)
|
||||
{
|
||||
TextModelNG textModelNG;
|
||||
textModelNG.Create(CREATE_VALUE);
|
||||
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||
ASSERT_NE(frameNode, nullptr);
|
||||
RefPtr<LayoutProperty> layoutProperty = frameNode->GetLayoutProperty();
|
||||
ASSERT_NE(layoutProperty, nullptr);
|
||||
RefPtr<TextLayoutProperty> textLayoutProperty = AceType::DynamicCast<TextLayoutProperty>(layoutProperty);
|
||||
ASSERT_NE(textLayoutProperty, nullptr);
|
||||
EXPECT_EQ(textLayoutProperty->GetContentValue(), CREATE_VALUE);
|
||||
|
||||
ASSERT_EQ(textModelNG.GetTextOverflow(frameNode), TextOverflow::CLIP);
|
||||
ASSERT_EQ(textModelNG.GetTextIndent(frameNode), ADAPT_ZERO_FONT_SIZE_VALUE);
|
||||
ASSERT_EQ(textModelNG.GetCopyOption(frameNode), CopyOptions::None);
|
||||
textModelNG.GetMarqueeOptions(frameNode);
|
||||
ASSERT_EQ(textModelNG.GetHeightAdaptivePolicy(frameNode), TextHeightAdaptivePolicy::MAX_LINES_FIRST);
|
||||
ASSERT_EQ(textModelNG.GetAdaptMinFontSize(frameNode), ADAPT_ZERO_FONT_SIZE_VALUE);
|
||||
ASSERT_EQ(textModelNG.GetAdaptMaxFontSize(frameNode), ADAPT_ZERO_FONT_SIZE_VALUE);
|
||||
ASSERT_EQ(textModelNG.GetDefaultColor(), Color::BLACK);
|
||||
ASSERT_EQ(textModelNG.GetFontColor(frameNode), Color::BLACK);
|
||||
ASSERT_EQ(textModelNG.GetTextBaselineOffset(frameNode), ADAPT_ZERO_FONT_SIZE_VALUE);
|
||||
std::vector<Shadow> defaultShadow;
|
||||
ASSERT_EQ(textModelNG.GetTextShadow(frameNode), defaultShadow);
|
||||
ASSERT_EQ(textModelNG.GetWordBreak(frameNode), WordBreak::BREAK_WORD);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetTextDetectEnable003
|
||||
* @tc.desc: Test SetTextDetectEnable.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(TextTestNg, SetTextDetectEnable003, TestSize.Level1)
|
||||
{
|
||||
TextModelNG textModelNG;
|
||||
textModelNG.Create(CREATE_VALUE);
|
||||
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||
ASSERT_NE(frameNode, nullptr);
|
||||
RefPtr<LayoutProperty> layoutProperty = frameNode->GetLayoutProperty();
|
||||
ASSERT_NE(layoutProperty, nullptr);
|
||||
RefPtr<TextLayoutProperty> textLayoutProperty = AceType::DynamicCast<TextLayoutProperty>(layoutProperty);
|
||||
ASSERT_NE(textLayoutProperty, nullptr);
|
||||
EXPECT_EQ(textLayoutProperty->GetContentValue(), CREATE_VALUE);
|
||||
|
||||
textModelNG.SetFontSize(frameNode, ADAPT_ZERO_FONT_SIZE_VALUE);
|
||||
EXPECT_EQ(textModelNG.GetFontSize(frameNode), ADAPT_ZERO_FONT_SIZE_VALUE);
|
||||
|
||||
textModelNG.SetTextDetectConfig(frameNode, "apple, orange, banana");
|
||||
ASSERT_NE(textModelNG.GetTextDetectConfig(frameNode), "apple, orange, banana");
|
||||
|
||||
auto onResult = [](const std::string&) {};
|
||||
textModelNG.SetTextDetectConfig(frameNode, "apple, orange, banana", std::move(onResult));
|
||||
ASSERT_NE(textModelNG.GetTextDetectConfig(frameNode), "apple, orange, banana");
|
||||
|
||||
auto textPattern = frameNode->GetPattern<TextPattern>();
|
||||
ASSERT_NE(textPattern, nullptr);
|
||||
textModelNG.SetOnDetectResultUpdate(frameNode, std::move(onResult));
|
||||
EXPECT_NE(textPattern->dataDetectorAdapter_->onResult_, nullptr);
|
||||
|
||||
FONT_FEATURES_LIST value;
|
||||
ASSERT_EQ(textModelNG.GetFontFeature(frameNode), value);
|
||||
ASSERT_EQ(textModelNG.GetLineBreakStrategy(frameNode), TEXT_LINE_BREAK_STRATEGY);
|
||||
|
||||
textModelNG.SetSelectedBackgroundColor(frameNode, Color::BLACK);
|
||||
ASSERT_EQ(textModelNG.GetSelectedBackgroundColor(frameNode), Color::BLACK);
|
||||
|
||||
textModelNG.ResetSelectedBackgroundColor(frameNode);
|
||||
ASSERT_EQ(textModelNG.GetSelectedBackgroundColor(frameNode), Color::BLACK);
|
||||
|
||||
textModelNG.SetTextContentWithStyledString(frameNode, nullptr);
|
||||
ASSERT_EQ(textPattern->GetExternalParagraph(), nullptr);
|
||||
|
||||
int32_t startIndex = 1;
|
||||
int32_t endIndex = 10;
|
||||
textModelNG.SetTextSelection(frameNode, startIndex, endIndex);
|
||||
EXPECT_NE(textPattern->textSelector_.GetStart(), startIndex);
|
||||
|
||||
std::string EventValue;
|
||||
auto onCopyResult = [&EventValue](const std::string& param) { EventValue = param; };
|
||||
|
||||
auto eventHub = frameNode->GetEventHub<TextEventHub>();
|
||||
textModelNG.SetOnCopy(frameNode, onCopyResult);
|
||||
EXPECT_NE(eventHub->onCopy_, nullptr);
|
||||
|
||||
bool isSelectChanged = false;
|
||||
auto onSelectionChanged = [&isSelectChanged](int32_t, int32_t) { isSelectChanged = true; };
|
||||
textModelNG.SetOnTextSelectionChange(frameNode, onSelectionChanged);
|
||||
EXPECT_NE(eventHub->onSelectionChange_, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetSelectedBackgroundColor001
|
||||
* @tc.desc: Test GetSelectedBackgroundColor when GetHost is nullptr.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(TextTestNg, GetSelectedBackgroundColor001, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. create.
|
||||
*/
|
||||
TextModelNG textModelNG;
|
||||
textModelNG.Create(CREATE_VALUE);
|
||||
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||
ASSERT_NE(frameNode, nullptr);
|
||||
RefPtr<LayoutProperty> layoutProperty = frameNode->GetLayoutProperty();
|
||||
ASSERT_NE(layoutProperty, nullptr);
|
||||
RefPtr<TextLayoutProperty> textLayoutProperty = AceType::DynamicCast<TextLayoutProperty>(layoutProperty);
|
||||
ASSERT_NE(textLayoutProperty, nullptr);
|
||||
EXPECT_EQ(textLayoutProperty->GetContentValue(), CREATE_VALUE);
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. set theme.
|
||||
*/
|
||||
auto pipeline = PipelineContext::GetCurrentContext();
|
||||
auto theme = AceType::MakeRefPtr<MockThemeManager>();
|
||||
pipeline->SetThemeManager(theme);
|
||||
EXPECT_CALL(*theme, GetTheme(_)).WillRepeatedly(Return(AceType::MakeRefPtr<TextTheme>()));
|
||||
ASSERT_EQ(textModelNG.GetSelectedBackgroundColor(frameNode), Color::BLACK);
|
||||
|
||||
Font font;
|
||||
textModelNG.SetFont(font);
|
||||
EXPECT_EQ(textModelNG.GetFontSize(frameNode), ADAPT_ZERO_FONT_SIZE_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetMarqueeOptions001
|
||||
* @tc.desc: Test GetMarqueeOptions when GetHost is nullptr.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(TextTestNg, GetMarqueeOptions001, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. create.
|
||||
*/
|
||||
TextModelNG textModelNG;
|
||||
textModelNG.Create(CREATE_VALUE);
|
||||
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||
ASSERT_NE(frameNode, nullptr);
|
||||
RefPtr<LayoutProperty> layoutProperty = frameNode->GetLayoutProperty();
|
||||
ASSERT_NE(layoutProperty, nullptr);
|
||||
RefPtr<TextLayoutProperty> textLayoutProperty = AceType::DynamicCast<TextLayoutProperty>(layoutProperty);
|
||||
ASSERT_NE(textLayoutProperty, nullptr);
|
||||
EXPECT_EQ(textLayoutProperty->GetContentValue(), CREATE_VALUE);
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. set theme.
|
||||
*/
|
||||
TextMarqueeOptions options;
|
||||
options.UpdateTextMarqueeStart(true);
|
||||
options.UpdateTextMarqueeStep(3);
|
||||
options.UpdateTextMarqueeLoop(3);
|
||||
options.UpdateTextMarqueeDirection(MarqueeDirection::RIGHT);
|
||||
options.UpdateTextMarqueeDelay(3);
|
||||
options.UpdateTextMarqueeFadeout(false);
|
||||
options.UpdateTextMarqueeStartPolicy(MarqueeStartPolicy::ON_FOCUS);
|
||||
textModelNG.SetMarqueeOptions(options);
|
||||
textModelNG.GetMarqueeOptions(frameNode);
|
||||
|
||||
EXPECT_EQ(textLayoutProperty->HasTextMarqueeStart(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetOnMarqueeStateChange001
|
||||
* @tc.desc: Test SetOnMarqueeStateChange.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(TextTestNg, SetOnMarqueeStateChange001, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. create.
|
||||
*/
|
||||
TextModelNG textModelNG;
|
||||
textModelNG.Create(CREATE_VALUE);
|
||||
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||
ASSERT_NE(frameNode, nullptr);
|
||||
RefPtr<LayoutProperty> layoutProperty = frameNode->GetLayoutProperty();
|
||||
ASSERT_NE(layoutProperty, nullptr);
|
||||
RefPtr<TextLayoutProperty> textLayoutProperty = AceType::DynamicCast<TextLayoutProperty>(layoutProperty);
|
||||
ASSERT_NE(textLayoutProperty, nullptr);
|
||||
EXPECT_EQ(textLayoutProperty->GetContentValue(), CREATE_VALUE);
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. set theme.
|
||||
*/
|
||||
bool isSelectChanged = false;
|
||||
auto onSelectionChanged = [&isSelectChanged](int32_t) { isSelectChanged = true; };
|
||||
textModelNG.SetOnMarqueeStateChange(onSelectionChanged);
|
||||
|
||||
auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<TextEventHub>();
|
||||
EXPECT_NE(eventHub->onMarqueeStateChange_, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: OnAttachToFrameNode001
|
||||
* @tc.desc: Test TextPattern OnAttachToFrameNode when GetHost is nullptr.
|
||||
@ -2454,7 +2651,7 @@ HWTEST_F(TextTestNg, CreateImageSourceInfo001, TestSize.Level1)
|
||||
* @tc.desc: Test create with spanstring.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(TextTestNg, TextTestNg_create001, TestSize.Level1)
|
||||
HWTEST_F(TextTestNg, create001, TestSize.Level1)
|
||||
{
|
||||
TextModelNG textModelNG;
|
||||
textModelNG.Create(CREATE_VALUE);
|
||||
@ -2466,7 +2663,7 @@ HWTEST_F(TextTestNg, TextTestNg_create001, TestSize.Level1)
|
||||
* @tc.steps: step2. call spanBases
|
||||
*/
|
||||
textModelNG.Create(spanStringWithSpans);
|
||||
EXPECT_TRUE(true);
|
||||
EXPECT_EQ(textModelNG->GetSpanStringMode(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2474,7 +2671,7 @@ HWTEST_F(TextTestNg, TextTestNg_create001, TestSize.Level1)
|
||||
* @tc.desc: Test SetTextSelectableMode by frameNode..
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(TextTestNg, TextTestNg_SetTextSelectableMode001, TestSize.Level1)
|
||||
HWTEST_F(TextTestNg, SetTextSelectableMode001, TestSize.Level1)
|
||||
{
|
||||
TextModelNG textModelNG;
|
||||
textModelNG.Create(CREATE_VALUE);
|
||||
@ -2497,7 +2694,6 @@ HWTEST_F(TextTestNg, TextTestNg_SetTextSelectableMode001, TestSize.Level1)
|
||||
textModelNG.SetEllipsisMode(frameNode, EllipsisMode::HEAD);
|
||||
textModelNG.SetEllipsisMode(EllipsisMode::HEAD);
|
||||
ASSERT_EQ(textModelNG.GetEllipsisMode(frameNode), EllipsisMode::HEAD);
|
||||
EXPECT_TRUE(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2505,7 +2701,7 @@ HWTEST_F(TextTestNg, TextTestNg_SetTextSelectableMode001, TestSize.Level1)
|
||||
* @tc.desc: Test InitSpanStringController.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(TextTestNg, TextTestNg_InitSpanStringController001, TestSize.Level1)
|
||||
HWTEST_F(TextTestNg, InitSpanStringController001, TestSize.Level1)
|
||||
{
|
||||
TextModelNG textModelNG;
|
||||
textModelNG.Create(CREATE_VALUE);
|
||||
@ -2520,7 +2716,7 @@ HWTEST_F(TextTestNg, TextTestNg_InitSpanStringController001, TestSize.Level1)
|
||||
auto spanStringWithSpans = AceType::MakeRefPtr<SpanString>("01234567893421");
|
||||
|
||||
textModelNG.InitSpanStringController(frameNode, spanStringWithSpans);
|
||||
EXPECT_TRUE(true);
|
||||
EXPECT_EQ(textModelNG->GetSpanStringMode(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2528,7 +2724,7 @@ HWTEST_F(TextTestNg, TextTestNg_InitSpanStringController001, TestSize.Level1)
|
||||
* @tc.desc: Test InitTextController.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(TextTestNg, TextTestNg_InitTextController001, TestSize.Level1)
|
||||
HWTEST_F(TextTestNg, InitTextController001, TestSize.Level1)
|
||||
{
|
||||
TextModelNG textModelNG;
|
||||
textModelNG.Create(CREATE_VALUE);
|
||||
@ -2549,7 +2745,7 @@ HWTEST_F(TextTestNg, TextTestNg_InitTextController001, TestSize.Level1)
|
||||
* @tc.desc: Test SetTextDetectEnable.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(TextTestNg, TextTestNg_SetTextDetectEnable001, TestSize.Level1)
|
||||
HWTEST_F(TextTestNg, SetTextDetectEnable001, TestSize.Level1)
|
||||
{
|
||||
TextModelNG textModelNG;
|
||||
textModelNG.Create(CREATE_VALUE);
|
||||
@ -2568,7 +2764,7 @@ HWTEST_F(TextTestNg, TextTestNg_SetTextDetectEnable001, TestSize.Level1)
|
||||
EXPECT_NE(ret, nullptr);
|
||||
|
||||
textModelNG.SetClipEdge(true);
|
||||
EXPECT_TRUE(true);
|
||||
EXPECT_NE(frameNode->renderContext_, nullptr);
|
||||
|
||||
auto strContent = textModelNG.GetContent(frameNode);
|
||||
EXPECT_EQ(strContent, CREATE_VALUE);
|
||||
|
Loading…
Reference in New Issue
Block a user