mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-27 17:21:11 +00:00
!37040 【RichEditor】手柄层级需求TDD用例
Merge pull request !37040 from FreemanBao/20230704
This commit is contained in:
commit
e0e59dbfb9
@ -1351,4 +1351,88 @@ HWTEST_F(RichEditorOverlayTestNg, SelectionMenuOptionsTest002, TestSize.Level1)
|
||||
OnMenuItemClickCallback onMenuItemClick;
|
||||
richEditorPattern->OnSelectionMenuOptionsUpdate(std::move(onCreateMenuCallback), std::move(onMenuItemClick));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: HandleLevel001
|
||||
* @tc.desc: Test RichEditorPattern Handle Level OnFrameNodeChanged
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RichEditorOverlayTestNg, HandleLevel001, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. get rich editor pattern instance, then add text span
|
||||
*/
|
||||
ASSERT_NE(richEditorNode_, nullptr);
|
||||
auto richEditorPattern = richEditorNode_->GetPattern<RichEditorPattern>();
|
||||
ASSERT_NE(richEditorPattern, nullptr);
|
||||
AddSpan(INIT_VALUE_1);
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. request focus
|
||||
*/
|
||||
auto focusHub = richEditorNode_->GetOrCreateFocusHub();
|
||||
ASSERT_NE(focusHub, nullptr);
|
||||
focusHub->RequestFocusImmediately();
|
||||
|
||||
/**
|
||||
* @tc.step: step3. show overlay
|
||||
*/
|
||||
richEditorPattern->OnModifyDone();
|
||||
richEditorPattern->caretPosition_ = richEditorPattern->GetTextContentLength();
|
||||
richEditorPattern->textSelector_.Update(0, 2);
|
||||
|
||||
richEditorPattern->CalculateHandleOffsetAndShowOverlay();
|
||||
richEditorPattern->ShowSelectOverlay(
|
||||
richEditorPattern->textSelector_.firstHandle, richEditorPattern->textSelector_.secondHandle, false);
|
||||
EXPECT_TRUE(richEditorPattern->SelectOverlayIsOn());
|
||||
|
||||
/**
|
||||
* @tc.steps: step3. mark framnode changed.
|
||||
*/
|
||||
richEditorNode_->AddFrameNodeChangeInfoFlag(FRAME_NODE_CHANGE_START_SCROLL);
|
||||
richEditorNode_->ProcessFrameNodeChangeFlag();
|
||||
EXPECT_EQ(richEditorPattern->selectOverlay_->handleLevelMode_, HandleLevelMode::EMBED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: HandleLevel002
|
||||
* @tc.desc: Test RichEditorPattern Handle Level on FrameNode changed finish.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RichEditorOverlayTestNg, HandleLevel002, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. get rich editor pattern instance, then add text span
|
||||
*/
|
||||
ASSERT_NE(richEditorNode_, nullptr);
|
||||
auto richEditorPattern = richEditorNode_->GetPattern<RichEditorPattern>();
|
||||
ASSERT_NE(richEditorPattern, nullptr);
|
||||
AddSpan(INIT_VALUE_1);
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. request focus
|
||||
*/
|
||||
auto focusHub = richEditorNode_->GetOrCreateFocusHub();
|
||||
ASSERT_NE(focusHub, nullptr);
|
||||
focusHub->RequestFocusImmediately();
|
||||
|
||||
/**
|
||||
* @tc.step: step3. show overlay
|
||||
*/
|
||||
richEditorPattern->OnModifyDone();
|
||||
richEditorPattern->caretPosition_ = richEditorPattern->GetTextContentLength();
|
||||
richEditorPattern->textSelector_.Update(0, 2);
|
||||
|
||||
richEditorPattern->CalculateHandleOffsetAndShowOverlay();
|
||||
richEditorPattern->ShowSelectOverlay(
|
||||
richEditorPattern->textSelector_.firstHandle, richEditorPattern->textSelector_.secondHandle, false);
|
||||
EXPECT_TRUE(richEditorPattern->SelectOverlayIsOn());
|
||||
|
||||
/**
|
||||
* @tc.steps: step3. mark framnode change finish.
|
||||
*/
|
||||
richEditorNode_->AddFrameNodeChangeInfoFlag(FRAME_NODE_CHANGE_END_SCROLL);
|
||||
richEditorNode_->ProcessFrameNodeChangeFlag();
|
||||
EXPECT_EQ(richEditorPattern->selectOverlay_->handleLevelMode_, HandleLevelMode::OVERLAY);
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
Loading…
Reference in New Issue
Block a user