mirror of
https://github.com/microsoft/microsoft-ui-xaml.git
synced 2026-10-29 00:46:30 +08:00
Add test: item reused from MenuItems refreshes closed compact state in PaneFooter and Content
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ec9a38b2-2629-4a10-bfb5-552decfe6848
This commit is contained in:
1 parent
20648440ba
commit
540eb5dcd2
1 file changed
+78
@@ -1056,6 +1056,84 @@ namespace Microsoft.UI.Xaml.Tests.MUXControls.ApiTests
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestProperty("Description", "Verifies that an item first realized in MenuItems and then reused as PaneFooter and in Content gets its closed compact state recomputed on every move.")]
|
||||
public void VerifyItemReusedFromMenuItemsRefreshesClosedCompactStateOnEveryHost()
|
||||
{
|
||||
NavigationView navView = null;
|
||||
NavigationViewItem item = null;
|
||||
RunOnUIThread.Execute(() =>
|
||||
{
|
||||
navView = new NavigationView();
|
||||
item = new NavigationViewItem() { Content = "Reused", Icon = new SymbolIcon(Symbol.Home), InfoBadge = new InfoBadge() { Value = 5 } };
|
||||
navView.MenuItems.Add(item);
|
||||
navView.IsSettingsVisible = false;
|
||||
navView.PaneDisplayMode = NavigationViewPaneDisplayMode.LeftCompact;
|
||||
navView.IsPaneOpen = false;
|
||||
navView.Width = 800.0;
|
||||
navView.Height = 600.0;
|
||||
Content = navView;
|
||||
Content.UpdateLayout();
|
||||
});
|
||||
IdleSynchronizer.Wait();
|
||||
|
||||
RunOnUIThread.Execute(() =>
|
||||
{
|
||||
Verify.AreEqual("ClosedCompactAndTopLevelItem", GetPaneAndTopLevelItemState(item), "In MenuItems");
|
||||
|
||||
navView.MenuItems.Remove(item);
|
||||
Content.UpdateLayout();
|
||||
navView.PaneFooter = item;
|
||||
Content.UpdateLayout();
|
||||
});
|
||||
IdleSynchronizer.Wait();
|
||||
|
||||
RunOnUIThread.Execute(() =>
|
||||
{
|
||||
Verify.AreEqual("ClosedCompactAndTopLevelItem", GetPaneAndTopLevelItemState(item), "Moved to PaneFooter");
|
||||
VerifyContentGridIsNotClipped(item, "Moved to PaneFooter");
|
||||
|
||||
navView.IsPaneOpen = true;
|
||||
Content.UpdateLayout();
|
||||
});
|
||||
IdleSynchronizer.Wait();
|
||||
|
||||
RunOnUIThread.Execute(() =>
|
||||
{
|
||||
Verify.AreEqual("NotClosedCompactAndTopLevelItem", GetPaneAndTopLevelItemState(item), "PaneFooter, pane open");
|
||||
|
||||
navView.IsPaneOpen = false;
|
||||
Content.UpdateLayout();
|
||||
});
|
||||
IdleSynchronizer.Wait();
|
||||
|
||||
RunOnUIThread.Execute(() =>
|
||||
{
|
||||
Verify.AreEqual("ClosedCompactAndTopLevelItem", GetPaneAndTopLevelItemState(item), "PaneFooter, pane closed again");
|
||||
Verify.AreEqual(0, Grid.GetColumn(GetInfoBadgePresenter(item)), "PaneFooter, pane closed: InfoBadge uses the compact overlay");
|
||||
|
||||
navView.PaneFooter = null;
|
||||
Content.UpdateLayout();
|
||||
navView.Content = item;
|
||||
Content.UpdateLayout();
|
||||
});
|
||||
IdleSynchronizer.Wait();
|
||||
|
||||
RunOnUIThread.Execute(() =>
|
||||
{
|
||||
Verify.AreEqual("NotClosedCompactAndTopLevelItem", GetPaneAndTopLevelItemState(item), "Moved to the content area");
|
||||
var infoBadgePresenter = GetInfoBadgePresenter(item);
|
||||
Verify.AreEqual(2, Grid.GetColumn(infoBadgePresenter), "Content area: InfoBadge is in its normal column");
|
||||
Verify.AreEqual(VerticalAlignment.Center, infoBadgePresenter.VerticalAlignment, "Content area: InfoBadge is not in the compact overlay position");
|
||||
});
|
||||
}
|
||||
|
||||
private static FrameworkElement GetInfoBadgePresenter(NavigationViewItem item)
|
||||
{
|
||||
var presenter = VisualTreeUtils.FindVisualChildByName(item, "NavigationViewItemPresenter");
|
||||
return (FrameworkElement)VisualTreeUtils.FindVisualChildByName(presenter, "InfoBadgePresenter");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestProperty("Description", "Verifies that a NavigationViewItem with children in PaneFooter gets the closed compact layout and its icon is not clipped.")]
|
||||
public void VerifyHierarchicalPaneFooterItemIsNotClippedInClosedCompactPane()
|
||||
|
||||
Reference in new issue
Block a user