From abe19f49ce87d8df9d4346a730a2d6f4bdf5880e Mon Sep 17 00:00:00 2001 From: Lisa_lian <15575970019@163.com> Date: Tue, 23 Jul 2024 21:27:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=85=83=E6=9C=8D=E5=8A=A1re?= =?UTF-8?q?moveoverlay=20tdd=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=20Signd-o?= =?UTF-8?q?ff-by:=20Lisa=5Flian=20=20Signed-off-by:=20?= =?UTF-8?q?Lisa=5Flian=20<15575970019@163.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/pattern/overlay/overlay_test_ng.cpp | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/test/unittest/core/pattern/overlay/overlay_test_ng.cpp b/test/unittest/core/pattern/overlay/overlay_test_ng.cpp index 2f594d7c0c4..23541ee61fd 100644 --- a/test/unittest/core/pattern/overlay/overlay_test_ng.cpp +++ b/test/unittest/core/pattern/overlay/overlay_test_ng.cpp @@ -1268,6 +1268,56 @@ HWTEST_F(OverlayTestNg, RemoveOverlayTest002, TestSize.Level1) EXPECT_TRUE(overlayManager->RemoveModalInOverlay()); } +/** + * @tc.name: RemoveOverlayTest003 + * @tc.desc:  Test OverlayManager::RemoveOverlay from atomicService. + * @tc.type: FUNC + */ +HWTEST_F(OverlayTestNg, RemoveOverlayTest003, TestSize.Level1) +{ + /** + * @tc.steps: step1. create atomicservice node. + */ + auto atom = FrameNode::CreateFrameNode(V2::ATOMIC_SERVICE_ETS_TAG, + ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr(false)); + auto menuBarRow = FrameNode::CreateFrameNode(V2::APP_BAR_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), + AceType::MakeRefPtr(false)); + auto stageNode = FrameNode::CreateFrameNode( + V2::STAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr()); + ASSERT_NE(stageNode, nullptr); + atom->AddChild(stageNode); + atom->AddChild(menuBarRow); + auto pipeline = PipelineContext::GetCurrentContext(); + pipeline->SetInstallationFree(1); + /** + * @tc.steps: step2. create target node and popupInfo. + */ + auto targetNode = CreateTargetNode(); + auto targetId = targetNode->GetId(); + auto targetTag = targetNode->GetTag(); + auto popupId = ElementRegister::GetInstance()->MakeUniqueId(); + auto popupNode = + FrameNode::CreateFrameNode(V2::POPUP_ETS_TAG, popupId, AceType::MakeRefPtr(targetId, targetTag)); + PopupInfo popupInfo; + popupInfo.popupId = popupId; + popupInfo.popupNode = popupNode; + popupInfo.target = targetNode; + popupInfo.markNeedUpdate = true; + auto rootNode = FrameNode::CreateFrameNode(V2::ROOT_ETS_TAG, 1, AceType::MakeRefPtr()); + auto overlayManager = AceType::MakeRefPtr(rootNode); + atom->MountToParent(rootNode); + /** + * @tc.steps: step3. showpopup node. + */ + overlayManager->ShowPopup(targetId, popupInfo); + /** + * @tc.steps: step4. remove popupNode from atomicService. + */ + auto res = overlayManager->RemoveOverlay(false); + EXPECT_FALSE(res); + EXPECT_TRUE(overlayManager->RemoveOverlayInSubwindow()); +} + /** * @tc.name: ToastShowModeTest001 * @tc.desc: Test OverlayManager::ShowToast with showMode.