diff --git a/test/unittest/core/pattern/hyperlink/hyperlink_test_ng.cpp b/test/unittest/core/pattern/hyperlink/hyperlink_test_ng.cpp index 2740cda604b..2110619a4ab 100644 --- a/test/unittest/core/pattern/hyperlink/hyperlink_test_ng.cpp +++ b/test/unittest/core/pattern/hyperlink/hyperlink_test_ng.cpp @@ -44,6 +44,7 @@ constexpr double RADIUS_DEFAULT = 300.0; const std::string HYPERLINK_ADDRESS = "https://www.baidu.com"; const std::string HYPERLINK_CONTENT = "baidu"; const std::string HYPERLINK_EXTRAINFO = "{\"url\":\"https://www.baidu.com\",\"title\":\"baidu\"}"; +const std::string HYPERLINK_NULL = ""; } // namespace class HyperlinkTestNg : public testing::Test { @@ -436,4 +437,61 @@ HWTEST_F(HyperlinkTestNg, HyperlinkPatternTest008, TestSize.Level1) hyperlinkPattern->OnHoverEvent(false); EXPECT_EQ(hyperlinkLayoutProperty->GetTextDecoration().value(), TextDecoration::NONE); } + +/** + * @tc.name: SetColor001 + * @tc.desc: Test SetColor. + * @tc.type: FUNC + */ +HWTEST_F(HyperlinkTestNg, SetColor001, TestSize.Level1) +{ + auto frameNode = FrameNode::GetOrCreateFrameNode(V2::HYPERLINK_ETS_TAG, + ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr(); }); + ASSERT_NE(frameNode, nullptr); + auto LayoutProperty = frameNode->GetLayoutProperty(); + ASSERT_NE(LayoutProperty, nullptr); + HyperlinkModelNG hyperlinkModelNG; + hyperlinkModelNG.SetResponseRegion(true); + hyperlinkModelNG.SetColor(Color::BLACK); + EXPECT_EQ(LayoutProperty->GetTextColor().value(), Color::BLACK); +} + +/** + * @tc.name: SetColor002 + * @tc.desc: Test SetColor. + * @tc.type: FUNC + */ +HWTEST_F(HyperlinkTestNg, SetColor002, TestSize.Level1) +{ + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + HyperlinkModelNG hyperlinkModelNG; + auto LayoutProperty = frameNode->GetLayoutProperty(); + ASSERT_NE(LayoutProperty, nullptr); + auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub(); + hyperlinkModelNG.SetColor(frameNode, Color::RED); + EXPECT_EQ(LayoutProperty->GetTextColor().value(), Color::RED); +} + +/** + * @tc.name: EnableDrag001 + * @tc.desc: Test EnableDrag(). + * @tc.type: FUNC + */ +HWTEST_F(HyperlinkTestNg, EnableDrag001, TestSize.Level1) +{ + auto frameNode = FrameNode::GetOrCreateFrameNode(V2::HYPERLINK_ETS_TAG, + ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr(); }); + ASSERT_NE(frameNode, nullptr); + EXPECT_EQ(frameNode->GetTag(), V2::HYPERLINK_ETS_TAG); + auto textLayoutProperty = frameNode->GetLayoutProperty(); + ASSERT_NE(textLayoutProperty, nullptr); + textLayoutProperty->UpdateContent(HYPERLINK_NULL); + textLayoutProperty->UpdateAddress(HYPERLINK_ADDRESS); + frameNode->SetDraggable(true); + frameNode->MarkModifyDone(); + auto hyperlinkPattern = frameNode->GetPattern(); + ASSERT_NE(hyperlinkPattern, nullptr); + hyperlinkPattern->EnableDrag(); +} + } // namespace OHOS::Ace::NG diff --git a/test/unittest/core/pattern/search/search_test_ng.cpp b/test/unittest/core/pattern/search/search_test_ng.cpp index 04f16416233..33ad72d615c 100755 --- a/test/unittest/core/pattern/search/search_test_ng.cpp +++ b/test/unittest/core/pattern/search/search_test_ng.cpp @@ -760,6 +760,8 @@ HWTEST_F(SearchTestNg, SetCaretWidth001, TestSize.Level1) auto textFrameNode = AceType::DynamicCast(frameNode->GetChildAtIndex(TEXTFIELD_INDEX)); auto textPaintProperty = textFrameNode->GetPaintProperty(); ASSERT_NE(textPaintProperty, nullptr); + NG::DragPreviewOption option { false }; + searchModelInstance.SetDragPreviewOptions(option); searchModelInstance.SetCaretWidth(14.0_vp); searchModelInstance.SetCaretColor(Color::RED); EXPECT_EQ(textPaintProperty->GetCursorWidth()->Value(), 14); @@ -1210,6 +1212,7 @@ HWTEST_F(SearchTestNg, SetTextAlign001, TestSize.Level1) ASSERT_NE(textFieldChild, nullptr); auto textFieldLayoutProperty = textFieldChild->GetLayoutProperty(); ASSERT_NE(textFieldLayoutProperty, nullptr); + searchModelInstance.SetTextAlign(OHOS::Ace::TextAlign::START); searchModelInstance.SetTextAlign(OHOS::Ace::TextAlign::CENTER); EXPECT_EQ(textFieldLayoutProperty->GetTextAlign(), OHOS::Ace::TextAlign::CENTER); searchModelInstance.SetTextAlign(OHOS::Ace::TextAlign::CENTER); @@ -1970,4 +1973,88 @@ HWTEST_F(SearchTestNg, SetTextAlign002, TestSize.Level1) } } } +/** + * @tc.name: SetSearchEnterKeyType001 + * @tc.desc: SetSearchEnterKeyType + * @tc.type: FUNC + */ +HWTEST_F(SearchTestNg, SetSearchEnterKeyType001, TestSize.Level1) +{ + SearchModelNG searchModelInstance; + searchModelInstance.Create(EMPTY_VALUE, PLACEHOLDER, SEARCH_SVG); + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + frameNode->MarkModifyDone(); + auto pattern = frameNode->GetPattern(); + auto textFieldFrameNode = AceType::DynamicCast(frameNode->GetChildAtIndex(TEXTFIELD_INDEX)); + auto textFieldPattern = textFieldFrameNode->GetPattern(); + searchModelInstance.SetSearchEnterKeyType(TextInputAction::UNSPECIFIED); +} +/** + * @tc.name: SetSearchEnterKeyType002 + * @tc.desc: SetSearchEnterKeyType + * @tc.type: FUNC + */ +HWTEST_F(SearchTestNg, SetSearchEnterKeyType002, TestSize.Level1) +{ + SearchModelNG searchModelInstance; + searchModelInstance.Create(EMPTY_VALUE, PLACEHOLDER, SEARCH_SVG); + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + frameNode->MarkModifyDone(); + auto pattern = frameNode->GetPattern(); + auto textFieldFrameNode = AceType::DynamicCast(frameNode->GetChildAtIndex(TEXTFIELD_INDEX)); + auto textFieldPattern = textFieldFrameNode->GetPattern(); + searchModelInstance.SetTextIndent(DEFAULT_INDENT_SIZE); + searchModelInstance.SetSearchEnterKeyType(TextInputAction::GO); +} +/** + * @tc.name: SetEnablePreviewText + * @tc.desc: Test SetEnablePreviewText + * @tc.type: FUNC + */ +HWTEST_F(SearchTestNg, SetEnablePreviewText, TestSize.Level1) +{ + SearchModelNG searchModelInstance; + searchModelInstance.Create(EMPTY_VALUE, PLACEHOLDER, SEARCH_SVG); + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + frameNode->MarkModifyDone(); + auto pattern = frameNode->GetPattern(); + auto textFieldFrameNode = AceType::DynamicCast(frameNode->GetChildAtIndex(TEXTFIELD_INDEX)); + auto textFieldPattern = textFieldFrameNode->GetPattern(); + searchModelInstance.SetEnablePreviewText(true); + EXPECT_TRUE(textFieldPattern->GetSupportPreviewText()); +} +/** + * @tc.name: ConvertTextFontScaleValue001 + * @tc.desc: Test ConvertTextFontScaleValue + * @tc.type: FUNC + */ +HWTEST_F(SearchTestNg, ConvertTextFontScaleValue001, TestSize.Level1) +{ + SearchModelNG searchModelInstance; + searchModelInstance.Create(EMPTY_VALUE, PLACEHOLDER, SEARCH_SVG); + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + frameNode->MarkModifyDone(); + auto pipeline = PipelineContext::GetCurrentContext(); + CHECK_NULL_VOID(pipeline); + pipeline->SetFontScale(0.0f); + const Dimension fontsizevalue = Dimension(20.1, DimensionUnit::PX); + EXPECT_EQ(searchModelInstance.ConvertTextFontScaleValue(fontsizevalue), fontsizevalue); +} +/** + * @tc.name: ConvertTextFontScaleValue002 + * @tc.desc: Test ConvertTextFontScaleValue + * @tc.type: FUNC + */ +HWTEST_F(SearchTestNg, ConvertTextFontScaleValue002, TestSize.Level1) +{ + SearchModelNG searchModelInstance; + searchModelInstance.Create(EMPTY_VALUE, PLACEHOLDER, SEARCH_SVG); + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + frameNode->MarkModifyDone(); + auto pipeline = PipelineContext::GetCurrentContext(); + CHECK_NULL_VOID(pipeline); + pipeline->SetFontScale(3.0f); + const Dimension fontsizevalue = Dimension(6.0, DimensionUnit::PX); + EXPECT_EQ(searchModelInstance.ConvertTextFontScaleValue(fontsizevalue), Dimension(4.0, DimensionUnit::PX)); +} } // namespace OHOS::Ace::NG diff --git a/test/unittest/core/pattern/search/search_testtwo_ng.cpp b/test/unittest/core/pattern/search/search_testtwo_ng.cpp index 3d4d2c6cf87..26a8139daeb 100644 --- a/test/unittest/core/pattern/search/search_testtwo_ng.cpp +++ b/test/unittest/core/pattern/search/search_testtwo_ng.cpp @@ -939,6 +939,8 @@ HWTEST_F(SearchTestTwoNg, SetProperty001, TestSize.Level1) EXPECT_EQ(textFieldLayoutProperty->GetTextInputType().value(), TextInputType::BEGIN); searchModelInstance.SetType(TextInputType::TEXT); EXPECT_EQ(textFieldLayoutProperty->GetTextInputType().value(), TextInputType::TEXT); + searchModelInstance.SetType(TextInputType::TEXT); + EXPECT_EQ(textFieldLayoutProperty->GetTextInputType().value(), TextInputType::TEXT); } /** @@ -964,6 +966,9 @@ HWTEST_F(SearchTestTwoNg, SetProperty002, TestSize.Level1) EXPECT_EQ(pattern->needToRequestKeyboardOnFocus_, true); //test SetPlaceholderFont + Font otherfont; + searchModelInstance.SetPlaceholderFont(otherfont); + EXPECT_EQ(textFieldLayoutProperty->GetPreferredPlaceholderLineHeightNeedToUpdate(), true); Font font; font.fontSize = Dimension(2); font.fontStyle = Ace::FontStyle::NORMAL; @@ -972,7 +977,60 @@ HWTEST_F(SearchTestTwoNg, SetProperty002, TestSize.Level1) font.fontFamilies = families; searchModelInstance.SetPlaceholderFont(frameNode, font); EXPECT_EQ(textFieldLayoutProperty->GetPlaceholderFontWeight(), FontWeight::W200); +} +/** + * @tc.name: SetHeight003 + * @tc.desc: test search + * @tc.type: FUNC + */ +HWTEST_F(SearchTestTwoNg, SetProperty003, TestSize.Level1) +{ + SearchModelNG searchModelInstance; + searchModelInstance.Create(EMPTY_VALUE, PLACEHOLDER, SEARCH_SVG); + auto fNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + FrameNode* frameNode = &(*fNode); + auto textFieldChild = AceType::DynamicCast(fNode->GetChildren().front()); + auto textFieldLayoutProperty = textFieldChild->GetLayoutProperty(); + + //test SetSearchButtonFontColor + auto buttonFNode = AceType::DynamicCast(fNode->GetChildAtIndex(BUTTON_INDEX)); + auto bnLayoutProperty = buttonFNode->GetLayoutProperty(); + searchModelInstance.SetSearchButtonFontColor(frameNode, Color::RED); + EXPECT_EQ(bnLayoutProperty->GetFontColor(), Color::RED); + + //test SetCopyOption + searchModelInstance.SetCopyOption(frameNode, CopyOptions::Distributed); + EXPECT_EQ(textFieldLayoutProperty->GetCopyOptions(), OHOS::Ace::CopyOptions::Distributed); + + //test SetTextFont + Font font; + font.fontSize = Dimension(2); + font.fontStyle = Ace::FontStyle::NORMAL; + font.fontWeight = FontWeight::W200; + std::vector families = { "cursive" }; + font.fontFamilies = families; + searchModelInstance.SetTextFont(frameNode, font); + EXPECT_EQ(textFieldLayoutProperty->GetFontWeight(), FontWeight::W200); +} + +/** + * @tc.name: SetHeight004 + * @tc.desc: test search + * @tc.type: FUNC + */ +HWTEST_F(SearchTestTwoNg, SetProperty004, TestSize.Level1) +{ + SearchModelNG searchModelInstance; + searchModelInstance.Create(EMPTY_VALUE, PLACEHOLDER, SEARCH_SVG); + auto fNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + FrameNode* frameNode = &(*fNode); + auto textFieldChild = AceType::DynamicCast(fNode->GetChildren().front()); + ASSERT_NE(textFieldChild, nullptr); + auto textFieldLayoutProperty = textFieldChild->GetLayoutProperty(); + CHECK_NULL_VOID(textFieldLayoutProperty); + auto pattern = textFieldChild->GetPattern(); + ASSERT_NE(pattern, nullptr); //test SetSearchIconSize auto searchLayoutProperty = fNode->GetLayoutProperty(); searchModelInstance.SetSearchIconSize(frameNode, Dimension(2.5, DimensionUnit::VP)); @@ -1013,11 +1071,11 @@ HWTEST_F(SearchTestTwoNg, SetProperty002, TestSize.Level1) } /** - * @tc.name: SetHeight003 + * @tc.name: SetHeight005 * @tc.desc: test search * @tc.type: FUNC */ -HWTEST_F(SearchTestTwoNg, SetProperty003, TestSize.Level1) +HWTEST_F(SearchTestTwoNg, SetProperty005, TestSize.Level1) { SearchModelNG searchModelInstance; searchModelInstance.Create(EMPTY_VALUE, PLACEHOLDER, SEARCH_SVG); @@ -1025,27 +1083,6 @@ HWTEST_F(SearchTestTwoNg, SetProperty003, TestSize.Level1) FrameNode* frameNode = &(*fNode); auto textFieldChild = AceType::DynamicCast(fNode->GetChildren().front()); auto textFieldLayoutProperty = textFieldChild->GetLayoutProperty(); - - //test SetSearchButtonFontColor - auto buttonFNode = AceType::DynamicCast(fNode->GetChildAtIndex(BUTTON_INDEX)); - auto bnLayoutProperty = buttonFNode->GetLayoutProperty(); - searchModelInstance.SetSearchButtonFontColor(frameNode, Color::RED); - EXPECT_EQ(bnLayoutProperty->GetFontColor(), Color::RED); - - //test SetCopyOption - searchModelInstance.SetCopyOption(frameNode, CopyOptions::Distributed); - EXPECT_EQ(textFieldLayoutProperty->GetCopyOptions(), OHOS::Ace::CopyOptions::Distributed); - - //test SetTextFont - Font font; - font.fontSize = Dimension(2); - font.fontStyle = Ace::FontStyle::NORMAL; - font.fontWeight = FontWeight::W200; - std::vector families = { "cursive" }; - font.fontFamilies = families; - searchModelInstance.SetTextFont(frameNode, font); - EXPECT_EQ(textFieldLayoutProperty->GetFontWeight(), FontWeight::W200); - //test SetPlaceholderColor searchModelInstance.SetPlaceholderColor(frameNode, Color::RED); EXPECT_EQ(textFieldLayoutProperty->GetPlaceholderTextColor(), Color::RED); @@ -1054,6 +1091,19 @@ HWTEST_F(SearchTestTwoNg, SetProperty003, TestSize.Level1) searchModelInstance.SetSelectionMenuHidden(frameNode, true); EXPECT_EQ(textFieldLayoutProperty->GetSelectionMenuHidden(), true); + //test SetHeight + searchModelInstance.SetHeight(frameNode, Dimension(2.5, DimensionUnit::VP)); + + //test SET + searchModelInstance.SetAdaptMinFontSize(frameNode, Dimension(2.5, DimensionUnit::VP)); + searchModelInstance.SetAdaptMaxFontSize(frameNode, Dimension(3.5, DimensionUnit::VP)); + searchModelInstance.SetLetterSpacing(frameNode, Dimension(2.5, DimensionUnit::VP)); + searchModelInstance.SetLineHeight(frameNode, Dimension(2.5, DimensionUnit::VP)); + + //test SetSearchImageIcon + NG::IconOptions iconOptions = NG::IconOptions(Color::RED, 14.0_vp, "/common/icon.png", "", ""); + searchModelInstance.SetSearchImageIcon(frameNode, iconOptions); + //test SetCaretWidth auto paintProperty = textFieldChild->GetPaintProperty(); searchModelInstance.SetCaretWidth(frameNode, Dimension(2.5, DimensionUnit::VP)); @@ -1092,7 +1142,6 @@ HWTEST_F(SearchTestTwoNg, SetProperty003, TestSize.Level1) auto textFieldPattern = textFieldChild->GetPattern(); EXPECT_EQ(TextInputAction::NEXT, textFieldPattern->GetTextInputActionValue(TextInputAction::UNSPECIFIED)); } - /** * @tc.name: SetEnterKeyType001 * @tc.desc: test search set enterKeyType default value @@ -1208,11 +1257,11 @@ HWTEST_F(SearchTestTwoNg, TextDecoration001, TestSize.Level1) } /** - * @tc.name: UpdateFontFeature + * @tc.name: UpdateFontFeature001 * @tc.desc: test fontFeature * @tc.type: FUNC */ -HWTEST_F(SearchTestTwoNg, SetProperty004, TestSize.Level1) +HWTEST_F(SearchTestTwoNg, UpdateFontFeature001, TestSize.Level1) { auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); ASSERT_NE(frameNode, nullptr); @@ -1223,6 +1272,7 @@ HWTEST_F(SearchTestTwoNg, SetProperty004, TestSize.Level1) layoutProperty->UpdateFontFeature(ParseFontFeatureSettings("\"ss01\" 0")); SearchModelNG::SetFontFeature(frameNode, FONT_FEATURE_VALUE_1); + frameNode->MarkModifyDone(); EXPECT_EQ(layoutProperty->GetFontFeature(), FONT_FEATURE_VALUE_1); } @@ -1231,7 +1281,7 @@ HWTEST_F(SearchTestTwoNg, SetProperty004, TestSize.Level1) * @tc.desc: test fontFeature * @tc.type: FUNC */ -HWTEST_F(SearchTestTwoNg, SetProperty005, TestSize.Level1) +HWTEST_F(SearchTestTwoNg, UpdateFontFeature002, TestSize.Level1) { auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); ASSERT_NE(frameNode, nullptr); @@ -1475,4 +1525,66 @@ HWTEST_F(SearchTestTwoNg, PatternHandleFocusEvent001, TestSize.Level1) EXPECT_EQ(pattern->focusChoice_, SearchPattern::FocusChoice::SEARCH); } +/** + * @tc.name: SetTextFont(FrameNode* frameNode, const Font& font) + * @tc.desc: test search + * @tc.type: FUNC + */ +HWTEST_F(SearchTestTwoNg, SetTextFont, TestSize.Level1) +{ + SearchModelNG searchModelInstance; + searchModelInstance.Create(EMPTY_VALUE, PLACEHOLDER, SEARCH_SVG); + auto fNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + FrameNode* frameNode = &(*fNode); + auto textFieldChild = AceType::DynamicCast(fNode->GetChildren().front()); + auto textFieldLayoutProperty = textFieldChild->GetLayoutProperty(); + Font otherfont; + searchModelInstance.SetTextFont(otherfont); + EXPECT_EQ(textFieldLayoutProperty->GetPreferredPlaceholderLineHeightNeedToUpdate(), true); + Font font; + font.fontSize = Dimension(2); + font.fontStyle = Ace::FontStyle::NORMAL; + font.fontWeight = FontWeight::W200; + std::vector families = { "cursive" }; + font.fontFamilies = families; + searchModelInstance.SetTextFont(frameNode, font); + EXPECT_EQ(textFieldLayoutProperty->GetFontWeight(), FontWeight::W200); + const std::string str = "DEFAULT"; + searchModelInstance.SetTextValue(frameNode, str); + searchModelInstance.SetIcon(frameNode, ""); + searchModelInstance.SetMaxLength(frameNode, 19); + searchModelInstance.SetOnSubmit(frameNode, [](const std::string& title) {}); + searchModelInstance.SetOnChange(frameNode, [](const std::string str, PreviewText previewText) {}); + searchModelInstance.SetType(frameNode, TextInputType::BEGIN); + EXPECT_EQ(textFieldLayoutProperty->GetTextInputType().value(), TextInputType::BEGIN); + searchModelInstance.SetType(frameNode, TextInputType::TEXT); + EXPECT_EQ(textFieldLayoutProperty->GetTextInputType().value(), TextInputType::TEXT); + searchModelInstance.SetType(frameNode, TextInputType::TEXT); + EXPECT_EQ(textFieldLayoutProperty->GetTextInputType().value(), TextInputType::TEXT); + searchModelInstance.SetOnTextSelectionChange(frameNode, [](int32_t a, int32_t b) {}); + searchModelInstance.SetOnCopy(frameNode, [](const std::string& title) {}); + searchModelInstance.SetOnCut(frameNode, [](const std::string str) {}); + searchModelInstance.SetOnPasteWithEvent(frameNode, [](const std::string& title, NG::TextCommonEvent& event) {}); + searchModelInstance.SetPlaceholder(frameNode, PLACEHOLDER); + searchModelInstance.SetTextDecoration(frameNode, Ace::TextDecoration::UNDERLINE); + EXPECT_EQ(textFieldLayoutProperty->GetTextDecoration(), Ace::TextDecoration::UNDERLINE); + searchModelInstance.SetTextDecorationColor(frameNode, Color::BLUE); + EXPECT_EQ(textFieldLayoutProperty->GetTextDecorationColor(), Color::BLUE); + searchModelInstance.SetTextDecorationStyle(frameNode, Ace::TextDecorationStyle::DASHED); + EXPECT_EQ(textFieldLayoutProperty->GetTextDecorationStyle(), Ace::TextDecorationStyle::DASHED); + searchModelInstance.SetEnablePreviewText(frameNode, true); +} +/** + * @tc.name: CreateSearchNode + * @tc.desc: CreateSearchNode + * @tc.type: FUNC + */ +HWTEST_F(SearchTestTwoNg, CreateSearchNode, TestSize.Level1) +{ + SearchModelNG searchModelInstance; + searchModelInstance.Create(EMPTY_VALUE, PLACEHOLDER, SEARCH_SVG); + auto nodeId = ElementRegister::GetInstance()->MakeUniqueId(); + searchModelInstance.SetSearchDefaultIcon(); + searchModelInstance.CreateSearchNode(nodeId, "", "", ""); +} } // namespace OHOS::Ace::NG diff --git a/test/unittest/core/pattern/select_overlay/select_overlay_test_ng.cpp b/test/unittest/core/pattern/select_overlay/select_overlay_test_ng.cpp index ba0f6d4b2bf..1ab51c35c6c 100644 --- a/test/unittest/core/pattern/select_overlay/select_overlay_test_ng.cpp +++ b/test/unittest/core/pattern/select_overlay/select_overlay_test_ng.cpp @@ -4510,4 +4510,28 @@ HWTEST_F(SelectOverlayTestNg, CreatExtensionMenu001, TestSize.Level1) selectOverlayNode->CreatExtensionMenu(std::move(params)); EXPECT_NE(selectOverlayNode->selectMenu_, nullptr); } + +/** + * @tc.name: IsFirstHandleMoveStart + * @tc.desc: Test IsFirstHandleMoveStart. + * @tc.type: FUNC + */ +HWTEST_F(SelectOverlayTestNg, IsFirstHandleMoveStart, TestSize.Level1) +{ + SelectOverlayInfo selectInfo; + auto infoPtr = std::make_shared(selectInfo); + auto frameNode = SelectOverlayNode::CreateSelectOverlayNode(infoPtr); + auto selectOverlayNode = AceType::DynamicCast(frameNode); + ASSERT_NE(selectOverlayNode, nullptr); + auto pattern = selectOverlayNode->GetPattern(); + ASSERT_NE(pattern, nullptr); + GestureEvent info; + info.localLocation_ = Offset(1, 1); + pattern->isFirstHandleTouchDown_ = true; + pattern->isSecondHandleTouchDown_ = true; + EXPECT_FALSE(pattern->IsSingleHandleMenuShow()); + EXPECT_FALSE(pattern->IsSingleHandle()); + EXPECT_FALSE(pattern->IsFirstHandleMoveStart(info.GetLocalLocation())); +} + } // namespace OHOS::Ace::NG