!42147 添加 overlayManager TDD用例

Merge pull request !42147 from 张全超/master
This commit is contained in:
openharmony_ci 2024-09-01 12:24:21 +00:00 committed by Gitee
commit 64d4394c12
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -1065,6 +1065,46 @@ HWTEST_F(OverlayManagerTestOneNG, HidePopupWithoutAnimation001, TestSize.Level1)
EXPECT_EQ(ret, nullptr);
}
/**
* @tc.name: HideAllPopups001
* @tc.desc: Test function of OverlayManager.
* @tc.type: FUNC
*/
HWTEST_F(OverlayManagerTestOneNG, HideAllPopups001, TestSize.Level1)
{
/**
* @tc.steps: step1. create root node and OverlayManager.
*/
auto rootNode = CreateRootNode();
ASSERT_NE(rootNode, nullptr);
auto overlayManager = AceType::MakeRefPtr<OverlayManager>(rootNode);
ASSERT_NE(overlayManager, nullptr);
/**
* @tc.steps: step2. call function.
*/
auto targetNode = CreateTargetNode();
ASSERT_NE(targetNode, nullptr);
auto popupId = ElementRegister::GetInstance()->MakeUniqueId();
auto popupNode = FrameNode::CreateFrameNode(
V2::POPUP_ETS_TAG, popupId, AceType::MakeRefPtr<BubblePattern>(targetNode->GetId(), targetNode->GetTag()));
ASSERT_NE(popupNode, nullptr);
auto popupPattern = popupNode->GetPattern<BubblePattern>();
EXPECT_NE(popupPattern, nullptr);
PopupInfo popupInfo;
popupInfo.popupId = popupId;
popupInfo.popupNode = popupNode;
popupInfo.target = targetNode;
popupInfo.markNeedUpdate = false;
popupInfo.isCurrentOnShow = true;
overlayManager->popupMap_[targetNode->GetId()] = popupInfo;
auto layoutProp = popupNode->GetLayoutProperty<BubbleLayoutProperty>();
ASSERT_NE(layoutProp, nullptr);
layoutProp->UpdateShowInSubWindow(true);
popupNode->MountToParent(rootNode);
overlayManager->HideAllPopups();
EXPECT_FALSE(overlayManager->popupMap_[targetNode->GetId()].markNeedUpdate);
}
/**
* @tc.name: HideCustomPopups001
* @tc.desc: Test function of OverlayManager.