mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-27 09:12:41 +00:00
!40357 提高text_field TDD覆盖率
Merge pull request !40357 from jiangzhijun8/master
This commit is contained in:
commit
a6b79a17d9
@ -1238,4 +1238,73 @@ HWTEST_F(TextFieldPatternTestTwo, GetDragUpperLeftCoordinates001, TestSize.Level
|
||||
|
||||
EXPECT_EQ(pattern->GetDragUpperLeftCoordinates(), OffsetF(100, 100));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: HandleFocusEvent001
|
||||
* @tc.desc: test testInput text HandleFocusEvent
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(TextFieldPatternTestTwo, HandleFocusEvent001, TestSize.Level0)
|
||||
{
|
||||
auto textFieldNode = FrameNode::GetOrCreateFrameNode(V2::TEXTINPUT_ETS_TAG,
|
||||
ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr<TextFieldPattern>(); });
|
||||
ASSERT_NE(textFieldNode, nullptr);
|
||||
auto pattern = textFieldNode->GetPattern<TextFieldPattern>();
|
||||
ASSERT_NE(pattern, nullptr);
|
||||
|
||||
auto layoutProperty = pattern->GetLayoutProperty<TextFieldLayoutProperty>();
|
||||
ASSERT_NE(layoutProperty, nullptr);
|
||||
layoutProperty->UpdateSelectAllValue(true);
|
||||
|
||||
pattern->dragStatus_ = DragStatus::DRAGGING;
|
||||
pattern->HandleFocusEvent();
|
||||
|
||||
pattern->dragRecipientStatus_ = DragStatus::DRAGGING;
|
||||
pattern->HandleFocusEvent();
|
||||
|
||||
pattern->isLongPress_ = true;
|
||||
pattern->HandleFocusEvent();
|
||||
|
||||
pattern->contentController_->content_ = "Test";
|
||||
pattern->needSelectAll_ = false;
|
||||
pattern->HandleFocusEvent();
|
||||
EXPECT_EQ(pattern->needSelectAll_, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ProcessFocusStyle001
|
||||
* @tc.desc: test testInput text ProcessFocusStyle
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(TextFieldPatternTestTwo, ProcessFocusStyle001, TestSize.Level0)
|
||||
{
|
||||
auto textFieldNode = FrameNode::GetOrCreateFrameNode(V2::TEXTINPUT_ETS_TAG,
|
||||
ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr<TextFieldPattern>(); });
|
||||
ASSERT_NE(textFieldNode, nullptr);
|
||||
auto pattern = textFieldNode->GetPattern<TextFieldPattern>();
|
||||
ASSERT_NE(pattern, nullptr);
|
||||
|
||||
auto paintProperty = pattern->GetPaintProperty<TextFieldPaintProperty>();
|
||||
ASSERT_NE(paintProperty, nullptr);
|
||||
auto layoutProperty = pattern->GetLayoutProperty<TextFieldLayoutProperty>();
|
||||
ASSERT_NE(layoutProperty, nullptr);
|
||||
|
||||
paintProperty->UpdateInputStyle(InputStyle::INLINE);
|
||||
pattern->ProcessFocusStyle();
|
||||
|
||||
pattern->contentController_->content_ = "Test";
|
||||
pattern->blurReason_ = BlurReason::FOCUS_SWITCH;
|
||||
pattern->ProcessFocusStyle();
|
||||
EXPECT_EQ(pattern->inlineSelectAllFlag_, true);
|
||||
pattern->blurReason_ = BlurReason::WINDOW_BLUR;
|
||||
pattern->ProcessFocusStyle();
|
||||
EXPECT_EQ(pattern->inlineSelectAllFlag_, false);
|
||||
|
||||
layoutProperty->UpdateShowErrorText(true);
|
||||
layoutProperty->UpdateErrorText("ERROR");
|
||||
layoutProperty->UpdateTextInputType(TextInputType::NUMBER);
|
||||
pattern->inlineSelectAllFlag_ = true;
|
||||
pattern->ProcessFocusStyle();
|
||||
EXPECT_EQ(pattern->inlineSelectAllFlag_, true);
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
Loading…
Reference in New Issue
Block a user