mirror of
https://github.com/microsoft/microsoft-ui-xaml.git
synced 2026-10-29 00:46:30 +08:00
Add tests: item moved from Content to MenuItems, and between NavigationViews, follows the right closed compact state
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ec9a38b2-2629-4a10-bfb5-552decfe6848
This commit is contained in:
1 parent
0499ee2077
commit
bb2a413b34
1 file changed
+129
@@ -1134,6 +1134,135 @@ namespace Microsoft.UI.Xaml.Tests.MUXControls.ApiTests
|
||||
return (FrameworkElement)VisualTreeUtils.FindVisualChildByName(presenter, "InfoBadgePresenter");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestProperty("Description", "Verifies that an item first loaded in NavigationView.Content and then moved into MenuItems gets the closed compact state of a top-level menu item.")]
|
||||
public void VerifyItemMovedFromContentToMenuItemsGetsClosedCompactState()
|
||||
{
|
||||
NavigationView navView = null;
|
||||
NavigationViewItem item = null;
|
||||
RunOnUIThread.Execute(() =>
|
||||
{
|
||||
navView = new NavigationView();
|
||||
item = new NavigationViewItem() { Content = "Moved", Icon = new SymbolIcon(Symbol.Home) };
|
||||
navView.MenuItems.Add(new NavigationViewItem() { Content = "Menu", Icon = new SymbolIcon(Symbol.Home) });
|
||||
navView.Content = 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("NotClosedCompactAndTopLevelItem", GetPaneAndTopLevelItemState(item), "In Content");
|
||||
|
||||
navView.Content = null;
|
||||
Content.UpdateLayout();
|
||||
navView.MenuItems.Add(item);
|
||||
Content.UpdateLayout();
|
||||
});
|
||||
IdleSynchronizer.Wait();
|
||||
|
||||
RunOnUIThread.Execute(() =>
|
||||
{
|
||||
Verify.AreEqual("ClosedCompactAndTopLevelItem", GetPaneAndTopLevelItemState(item), "Moved to MenuItems");
|
||||
VerifyContentGridIsNotClipped(item, "Moved to MenuItems");
|
||||
|
||||
navView.IsPaneOpen = true;
|
||||
Content.UpdateLayout();
|
||||
});
|
||||
IdleSynchronizer.Wait();
|
||||
|
||||
RunOnUIThread.Execute(() =>
|
||||
{
|
||||
Verify.AreEqual("NotClosedCompactAndTopLevelItem", GetPaneAndTopLevelItemState(item), "MenuItems, pane open");
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestProperty("Description", "Verifies that an item moved from one NavigationView to another follows the closed compact state of the new NavigationView.")]
|
||||
public void VerifyItemMovedToAnotherNavigationViewFollowsItsPane()
|
||||
{
|
||||
NavigationView navViewA = null;
|
||||
NavigationView navViewB = null;
|
||||
NavigationViewItem item = null;
|
||||
RunOnUIThread.Execute(() =>
|
||||
{
|
||||
navViewA = new NavigationView() { IsSettingsVisible = false, PaneDisplayMode = NavigationViewPaneDisplayMode.LeftCompact, IsPaneOpen = false, Width = 400.0, Height = 600.0 };
|
||||
navViewB = new NavigationView() { IsSettingsVisible = false, PaneDisplayMode = NavigationViewPaneDisplayMode.LeftCompact, IsPaneOpen = true, Width = 400.0, Height = 600.0 };
|
||||
navViewA.MenuItems.Add(new NavigationViewItem() { Content = "A menu", Icon = new SymbolIcon(Symbol.Home) });
|
||||
navViewB.MenuItems.Add(new NavigationViewItem() { Content = "B menu", Icon = new SymbolIcon(Symbol.Home) });
|
||||
item = new NavigationViewItem() { Content = "Moved", Icon = new SymbolIcon(Symbol.Home) };
|
||||
navViewA.PaneFooter = item;
|
||||
var panel = new StackPanel() { Orientation = Orientation.Horizontal };
|
||||
panel.Children.Add(navViewA);
|
||||
panel.Children.Add(navViewB);
|
||||
Content = panel;
|
||||
Content.UpdateLayout();
|
||||
});
|
||||
IdleSynchronizer.Wait();
|
||||
|
||||
RunOnUIThread.Execute(() =>
|
||||
{
|
||||
Verify.AreEqual("ClosedCompactAndTopLevelItem", GetPaneAndTopLevelItemState(item), "A PaneFooter, A closed");
|
||||
|
||||
navViewA.PaneFooter = null;
|
||||
Content.UpdateLayout();
|
||||
navViewB.PaneFooter = item;
|
||||
Content.UpdateLayout();
|
||||
});
|
||||
IdleSynchronizer.Wait();
|
||||
|
||||
RunOnUIThread.Execute(() =>
|
||||
{
|
||||
Verify.AreEqual("NotClosedCompactAndTopLevelItem", GetPaneAndTopLevelItemState(item), "B PaneFooter, B open");
|
||||
|
||||
navViewB.IsPaneOpen = false;
|
||||
Content.UpdateLayout();
|
||||
});
|
||||
IdleSynchronizer.Wait();
|
||||
|
||||
RunOnUIThread.Execute(() =>
|
||||
{
|
||||
Verify.AreEqual("ClosedCompactAndTopLevelItem", GetPaneAndTopLevelItemState(item), "B PaneFooter, B closed");
|
||||
|
||||
// A's pane must no longer drive the item.
|
||||
navViewA.IsPaneOpen = true;
|
||||
Content.UpdateLayout();
|
||||
});
|
||||
IdleSynchronizer.Wait();
|
||||
|
||||
RunOnUIThread.Execute(() =>
|
||||
{
|
||||
Verify.AreEqual("ClosedCompactAndTopLevelItem", GetPaneAndTopLevelItemState(item), "B PaneFooter, B closed, A opened");
|
||||
|
||||
navViewB.PaneFooter = null;
|
||||
Content.UpdateLayout();
|
||||
navViewB.MenuItems.Add(item);
|
||||
navViewB.IsPaneOpen = true;
|
||||
Content.UpdateLayout();
|
||||
});
|
||||
IdleSynchronizer.Wait();
|
||||
|
||||
RunOnUIThread.Execute(() =>
|
||||
{
|
||||
Verify.AreEqual("NotClosedCompactAndTopLevelItem", GetPaneAndTopLevelItemState(item), "B MenuItems, B open");
|
||||
|
||||
navViewB.IsPaneOpen = false;
|
||||
Content.UpdateLayout();
|
||||
});
|
||||
IdleSynchronizer.Wait();
|
||||
|
||||
RunOnUIThread.Execute(() =>
|
||||
{
|
||||
Verify.AreEqual("ClosedCompactAndTopLevelItem", GetPaneAndTopLevelItemState(item), "B MenuItems, B closed");
|
||||
});
|
||||
}
|
||||
|
||||
[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