diff --git a/examples/TextInputComponentTest/entry/src/main/ets/pages/01-style/08-barState.ets b/examples/TextInputComponentTest/entry/src/main/ets/pages/01-style/08-barState.ets index 973002442d98594b4b1c43470aae31a8ea19d0f9..677ea50896b2d53302936ced4f722a069e528c1a 100644 --- a/examples/TextInputComponentTest/entry/src/main/ets/pages/01-style/08-barState.ets +++ b/examples/TextInputComponentTest/entry/src/main/ets/pages/01-style/08-barState.ets @@ -24,7 +24,7 @@ struct struct_01_style_08_barState { TextInput({ text: '没有设置 barState ' }).style(TextInputStyle.Inline) TextInput({ text: ' .barState(BarState.Auto) ' }).style(TextInputStyle.Inline).barState(BarState.Auto) TextInput({ text: ' .barState(undefined) ' }).style(TextInputStyle.Inline).barState(undefined) - }.borderWidth(2) + } } } diff --git a/examples/TextInputComponentTest/entry/src/main/ets/pages/01-style/09-maxLines.ets b/examples/TextInputComponentTest/entry/src/main/ets/pages/01-style/09-maxLines.ets index 9842d82b8a1cfd330f073b95f47e12c6ee87a58d..a7cd2fcce7baa95004ee2c990e4c84b31e3220b7 100644 --- a/examples/TextInputComponentTest/entry/src/main/ets/pages/01-style/09-maxLines.ets +++ b/examples/TextInputComponentTest/entry/src/main/ets/pages/01-style/09-maxLines.ets @@ -30,7 +30,7 @@ struct struct_01_style_09_maxLines { TextInput({ text: ` .maxLines(0) ${this.message}` }).style(TextInputStyle.Inline).maxLines(0) TextInput({ text: ` .maxLines(0.5) ${this.message}` }).style(TextInputStyle.Inline).maxLines(0.5) TextInput({ text: ` .maxLines(-5) ${this.message}` }).style(TextInputStyle.Inline).maxLines(-5) - }.borderWidth(2) + } } } diff --git a/test/unittest/core/pattern/text/text_testnine_ng.cpp b/test/unittest/core/pattern/text/text_testnine_ng.cpp index 7cefeb911d45c15074810478d1c06b8748af4cb0..f5bdf2b4b680989ab2fb6c603fd7854445204bda 100644 --- a/test/unittest/core/pattern/text/text_testnine_ng.cpp +++ b/test/unittest/core/pattern/text/text_testnine_ng.cpp @@ -227,6 +227,58 @@ HWTEST_F(TextTestNineNg, OnMenuItemAction001, TestSize.Level1) EXPECT_FALSE(pattern->SelectOverlayIsOn()); } +/** + * @tc.name: OnMenuItemAction002 + * @tc.desc: test OnMenuItemAction, call memuCallback.onAIMenuOption + * @tc.type: FUNC + */ +HWTEST_F(TextTestNineNg, OnMenuItemAction002, TestSize.Level1) +{ + /** + * @tc.steps: step1. get text pattern + */ + auto* stack = ViewStackProcessor::GetInstance(); + stack->StartGetAccessRecordingFor(0); + TextModelNG textModelNG; + textModelNG.Create("TextValue"); + stack->StopGetAccessRecording(); + auto frameNode = AceType::DynamicCast(stack->Finish()); + auto pattern = frameNode->GetPattern(); + auto layoutProperty = frameNode->GetLayoutProperty(); + FlushUITasks(frameNode); + + /** + * @tc.steps: step2. request focus + */ + auto focusHub = frameNode->GetOrCreateFocusHub(); + focusHub->RequestFocusImmediately(); + FlushUITasks(frameNode); + + /** + * @tc.step: step3. create a scene where the text menu has popped up + */ + + pattern->textSelector_.Update(0, 2); + pattern->CalculateHandleOffsetAndShowOverlay(); + OverlayRequest request; + request.menuIsShow = true; + request.hideHandle = false; + request.animation = false; + request.hideHandleLine = false; + request.requestCode = 0; + pattern->ShowSelectOverlay(request); + + /** + * @tc.step: step4. test OnMenuItemAction + */ + pattern->isMousePressed_ = true; + auto info = pattern->selectOverlay_->GetSelectOverlayInfos(); + info->menuCallback.onAIMenuOption(""); + EXPECT_FALSE(pattern->SelectOverlayIsOn()); + info->menuCallback.onAIMenuOption("test"); + EXPECT_FALSE(pattern->SelectOverlayIsOn()); +} + HWTEST_F(TextTestNineNg, CheckHandleVisible001, TestSize.Level1) { /**