!43877 【挑单】【Menu】修复自由多窗模式下,bindContextMenu二级菜单布局异常

Merge pull request !43877 from 王一卉/cherry-pick-1726714195
This commit is contained in:
openharmony_ci 2024-09-19 13:23:10 +00:00 committed by Gitee
commit 94078c3fa8
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 4 additions and 18 deletions

View File

@ -232,27 +232,13 @@ float SubMenuLayoutAlgorithm::HorizontalLayoutSubMenu(
void SubMenuLayoutAlgorithm::ModifySubMenuWrapper(LayoutWrapper* layoutWrapper)
{
CHECK_NULL_VOID(layoutWrapper);
auto props = AceType::DynamicCast<MenuLayoutProperty>(layoutWrapper->GetLayoutProperty());
CHECK_NULL_VOID(props);
auto pipelineContext = PipelineContext::GetMainPipelineContext();
CHECK_NULL_VOID(pipelineContext);
auto safeAreaManager = pipelineContext->GetSafeAreaManager();
CHECK_NULL_VOID(safeAreaManager);
auto theme = pipelineContext->GetTheme<SelectTheme>();
CHECK_NULL_VOID(theme);
auto expandDisplay = theme->GetExpandDisplay();
auto windowGlobalRect = pipelineContext->GetDisplayWindowRectInfo();
auto bottom = safeAreaManager->GetSystemSafeArea().bottom_.Length();
auto menuNode = layoutWrapper->GetHostNode();
CHECK_NULL_VOID(menuNode);
auto menuPattern = menuNode->GetPattern<MenuPattern>();
CHECK_NULL_VOID(menuPattern);
auto mainMenuPattern = menuPattern->GetMainMenuPattern();
auto isContextMenu = false;
if (mainMenuPattern) {
isContextMenu = mainMenuPattern->IsContextMenu();
}
if (isContextMenu && !expandDisplay) {
if (!hierarchicalParameters_) {
wrapperSize_ = SizeF(windowGlobalRect.Width(), windowGlobalRect.Height() - bottom);
} else {
wrapperSize_ = SizeF(wrapperSize_.Width(), wrapperSize_.Height());

View File

@ -1479,7 +1479,7 @@ HWTEST_F(MenuLayout2TestNg, SubMenuLayoutAlgorithmTestNg001, TestSize.Level1)
* @tc.expected: wrapperSize_ is not Data anomalies
*/
algorithm->ModifySubMenuWrapper(wrapper);
ASSERT_NE(algorithm->wrapperSize_, SizeF(0, 0));
ASSERT_EQ(algorithm->wrapperSize_, SizeF(0, 0));
}
/**
@ -1544,7 +1544,7 @@ HWTEST_F(MenuLayout2TestNg, SubMenuLayoutAlgorithmTestNg002, TestSize.Level1)
* @tc.expected: wrapperSize_ is not Data anomalies
*/
algorithm->ModifySubMenuWrapper(wrapper);
ASSERT_NE(algorithm->wrapperSize_, SizeF(0, 0));
ASSERT_EQ(algorithm->wrapperSize_, SizeF(0, 0));
/**
* @tc.steps: step3. call the InitializePaddingAPI12 method.
@ -1621,7 +1621,7 @@ HWTEST_F(MenuLayout2TestNg, SubMenuLayoutAlgorithmTestNg003, TestSize.Level1)
* @tc.expected: wrapperSize_ is not Data anomalies
*/
algorithm->ModifySubMenuWrapper(wrapper);
ASSERT_NE(algorithm->wrapperSize_, SizeF(0, 0));
ASSERT_EQ(algorithm->wrapperSize_, SizeF(0, 0));
/**
* @tc.cases: case2. layering parameter is false.