Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 64 additions & 30 deletions dev/NavigationView/NavigationView_InteractionTests/CommonTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public void AddRemoveOriginalItemTest()
Log.Comment("Verify that original menu items can be removed");
removeButton.Invoke();
Wait.ForIdle();
VerifyElement.NotFound("Integer", FindBy.Name);
VerifyElement.NotFound("HasChildItem", FindBy.Name);

Log.Comment("Verify that menu items can be added after removing");
addButton.Invoke();
Expand Down Expand Up @@ -692,38 +692,36 @@ public void LeftNavigationWithAccessKeysTest()
[TestMethod]
public void MenuItemKeyboardInvokeTest()
{
var testScenarios = RegressionTestScenario.BuildLeftNavRegressionTestScenarios();
foreach (var testScenario in testScenarios)
// On RS2 scrollviewer handles arrow keys and this causes an issue with the current setup of the "NavigationView Test" test page
// used for the left NavigationView test. So instead we now execute this test on the "NavigationView Regression Test" test page for
// left navigation.
using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "NavigationView Regression Test" }))
{
using (IDisposable page1 = new TestSetupHelper("NavigationView Tests"),
page2 = new TestSetupHelper(testScenario.TestPageName))
{
Log.Comment("Verify the first menu item has focus and is selected");
UIObject firstItem = FindElement.ByName("Home");
firstItem.SetFocus();
Verify.IsTrue(firstItem.HasKeyboardFocus);
Verify.IsTrue(Convert.ToBoolean(firstItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));

Log.Comment("Move focus to the second menu item by pressing down arrow");
KeyboardHelper.PressKey(Key.Down);
Wait.ForIdle();
Log.Comment("Verify the first menu item has focus and is selected");
UIObject firstItem = FindElement.ByName("Home");
firstItem.SetFocus();
Verify.IsTrue(firstItem.HasKeyboardFocus);
Verify.IsTrue(Convert.ToBoolean(firstItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));

Log.Comment("Move focus to the second menu item by pressing down arrow");
KeyboardHelper.PressKey(Key.Down);
Wait.ForIdle();

Log.Comment("Verify second menu item has focus but is not selected");
UIObject secondItem = FindElement.ByName("Apps");
Verify.IsTrue(secondItem.HasKeyboardFocus);
Verify.IsFalse(Convert.ToBoolean(secondItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));
Log.Comment("Verify second menu item has focus but is not selected");
UIObject secondItem = FindElement.ByName("Apps");
Verify.IsTrue(secondItem.HasKeyboardFocus);
Verify.IsFalse(Convert.ToBoolean(secondItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));

if (PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone4))
{
Log.Comment("Select the second item by pressing enter");
KeyboardHelper.PressKey(Key.Enter);
Wait.ForIdle();
Verify.IsTrue(Convert.ToBoolean(secondItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));
}
else
{
Log.Warning("Full test is not executing due to lack of selection on keyboard selection behaviour in older versions of ListView");
}
if (PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone4))
{
Log.Comment("Select the second item by pressing enter");
KeyboardHelper.PressKey(Key.Enter);
Wait.ForIdle();
Verify.IsTrue(Convert.ToBoolean(secondItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));
}
else
{
Log.Warning("Full test is not executing due to lack of selection on keyboard selection behaviour in older versions of ListView");
}
}
}
Expand Down Expand Up @@ -1611,6 +1609,42 @@ public void VerifyNoCrashWhenSwitchingPaneDisplayModeWithAutoWrappedElements()
}
}

[TestMethod]
public void VerifyNavigationViewItemContentPresenterMargin()
{
using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "NavigationView Test" }))
{
var getTopLevelContentPresenterMarginButton = FindElement.ById<Button>("GetTopLevelNavViewItemContentPresenterMarginButton");
var getChildContentPresenterMarginButton = FindElement.ById<Button>("GetChildNavViewItemContentPresenterMarginButton");
var contentPresenterMarginTextBlock = new TextBlock(FindElement.ByName("NavViewItemContentPresenterMarginTextBlock"));

// Switch the NavigationView to closed compact mode
Log.Comment("Switch NavigationView to closed compact mode");
SetNavViewWidth(ControlWidth.Medium);
Wait.ForIdle();

// Verify that top-level items use the correct content margin
getTopLevelContentPresenterMarginButton.InvokeAndWait();
Verify.AreEqual("0,0,0,0", contentPresenterMarginTextBlock.DocumentText);

// Child items in closed compact mode are shown in a flyout. Verify that they are using the correct margin
Log.Comment("Expand item with children");
UIObject hasChildItem = FindElement.ByName("HasChildItem");
InputHelper.LeftClick(hasChildItem);
Wait.ForIdle();

getChildContentPresenterMarginButton.InvokeAndWait();
Verify.AreEqual("0,0,20,0", contentPresenterMarginTextBlock.DocumentText);

// Switch the NavigationView to expanded mode
Log.Comment("Switch NavigationView to expanded mode");
SetNavViewWidth(ControlWidth.Wide);
Wait.ForIdle();

// Verify that top-level items use the correct content margin
getTopLevelContentPresenterMarginButton.InvokeAndWait();
Verify.AreEqual("0,0,20,0", contentPresenterMarginTextBlock.DocumentText);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void HomeEndNavigationTest()

UIObject firstItem = FindElement.ByName("Home");
UIObject appsItem = FindElement.ByName("Apps");
UIObject lastItem = FindElement.ByName("Integer");
UIObject lastItem = FindElement.ByName("HasChildItem");

Log.Comment("Make sure something inside the ListView other than the first item has input focus");
appsItem.SetFocus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ public void SuppressSelectionItemInvokeTest()
[TestMethod]
public void SelectionFollowFocusTest()
{
if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2))
if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone3))
{
Log.Warning("Test is disabled on RS1 and earlier because SingleSelectionFollowFocus on RS2.");
Log.Warning("Test is disabled on RS2 and earlier because SingleSelectionFollowFocus isn't on RS1 and scrollviewer handles arrow keys on RS2.");
return;
}
var testScenarios = RegressionTestScenario.BuildTopNavRegressionTestScenarios();
Expand Down Expand Up @@ -151,10 +151,15 @@ public void SelectionFollowFocusTest()
[TestMethod]
public void MenuItemAutomationSelectionTest()
{
var testScenarios = RegressionTestScenario.BuildAllRegressionTestScenarios();
// On RS2 scrollviewer handles arrow keys and this causes an issue with the current setup of the "NavigationView Test" test page
// used for the left NavigationView test. So instead we now execute this test on the "NavigationView Regression Test" test page for
// left navigation.
(string testPageName, bool isLeftNavTest)[] testScenarios = new (string, bool)[]
{ ("NavigationView Regression Test", true), ("NavigationView TopNav Test", false) };

foreach (var testScenario in testScenarios)
{
using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.TestPageName }))
using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.testPageName }))
{
UIObject firstItem = FindElement.ByName("Home");
UIObject secondItem = FindElement.ByName("Apps");
Expand All @@ -169,7 +174,7 @@ public void MenuItemAutomationSelectionTest()

Log.Comment("Move focus to the second item by pressing down(left nav)/right(right nav) arrow once");
var key = Key.Right;
if (testScenario.IsLeftNavTest)
if (testScenario.isLeftNavTest)
{
key = Key.Down;
}
Expand Down
2 changes: 1 addition & 1 deletion dev/NavigationView/NavigationView_rs1_themeresources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
<Thickness x:Key="TopNavigationViewItemSeparatorMargin">10,0</Thickness>
<Thickness x:Key="TopNavigationViewOverflowButtonMargin">0</Thickness>
<Thickness x:Key="NavigationViewItemContentPresenterMargin">0,0,20,0</Thickness>
<Thickness x:Key="NavigationViewCompactItemContentPresenterMargin">0,0,16,0</Thickness>
<Thickness x:Key="NavigationViewCompactItemContentPresenterMargin">0,0,0,0</Thickness>
<Thickness x:Key="TopNavigationViewItemContentPresenterMargin">8,0,16,0</Thickness>
<Thickness x:Key="NavigationViewItemExpandChevronMargin">-20,0,6,0</Thickness>
<Thickness x:Key="TopNavigationViewItemExpandChevronMargin">-16,0,0,0</Thickness>
Expand Down
15 changes: 15 additions & 0 deletions dev/NavigationView/TestUI/NavigationViewPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
</muxcontrols:NavigationViewItem.Content>
</muxcontrols:NavigationViewItem>
<muxcontrols:NavigationViewItem x:Name="IntegerItem" AutomationProperties.Name="Integer" Icon="Accept"/>
<muxcontrols:NavigationViewItemSeparator />
<muxcontrols:NavigationViewItem x:Name="HasChildItem" AutomationProperties.Name="HasChildItem" Content="Item with child">
<muxcontrols:NavigationViewItem.MenuItems>
<muxcontrols:NavigationViewItem x:Name="ChildItem" AutomationProperties.Name="ChildItem" Content="Child Item Content" Icon="Document" />
</muxcontrols:NavigationViewItem.MenuItems>
</muxcontrols:NavigationViewItem>
</muxcontrols:NavigationView.MenuItems>

<ScrollViewer Margin="8,0,0,0">
Expand Down Expand Up @@ -267,6 +273,15 @@
</StackPanel>
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="0 5">
<Button x:Name="GetTopLevelNavViewItemContentPresenterMarginButton" AutomationProperties.Name="GetTopLevelNavViewItemContentPresenterMarginButton"
Content="GetTopLevelNavViewItemContentPresenterMargin" Margin="0,0,5,0" Click="GetTopLevelNavViewItemContentPresenterMarginButton_Click"/>
<Button x:Name="GetChildNavViewItemContentPresenterMarginButton" AutomationProperties.Name="GetChildNavViewItemContentPresenterMarginButton"
Content="GetChildNavViewItemContentPresenterMargin" Margin="0,0,2,0" Click="GetChildNavViewItemContentPresenterMarginButton_Click" />
<TextBlock Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center">NavViewItemContentPresenter.Margin:</TextBlock>
<TextBlock x:Name="NavViewItemContentPresenterMarginTextBlock" AutomationProperties.Name="NavViewItemContentPresenterMarginTextBlock" VerticalAlignment="Center"/>
</StackPanel>

<TextBlock TextWrapping="Wrap" Grid.Row="1" Margin="5">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris faucibus quam id sem porta posuere. Interdum et malesuada fames ac ante ipsum primis in faucibus. Morbi sodales suscipit justo quis consequat. Vestibulum lectus magna, mattis id eleifend sed, congue eget lectus. Nam et sem pellentesque, dignissim erat eu, tincidunt lacus. Ut porttitor tincidunt ullamcorper. Vestibulum sodales neque purus, vitae eleifend metus convallis in. Etiam non metus nec ligula pharetra molestie. Donec dignissim dapibus blandit. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.

Expand Down
16 changes: 16 additions & 0 deletions dev/NavigationView/TestUI/NavigationViewPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -726,5 +726,21 @@ private void ReadSettingsSelected_Click(object sender, RoutedEventArgs e)

SettingsSelectedState.Text = (settings as NavigationViewItem).IsSelected.ToString();
}

private void GetTopLevelNavViewItemContentPresenterMarginButton_Click(object sender, RoutedEventArgs e)
{
if (FindVisualChildByName(HomeItem, "ContentPresenter") is ContentPresenter presenter)
{
NavViewItemContentPresenterMarginTextBlock.Text = presenter.Margin.ToString();
}
}

private void GetChildNavViewItemContentPresenterMarginButton_Click(object sender, RoutedEventArgs e)
{
if (FindVisualChildByName(ChildItem, "ContentPresenter") is ContentPresenter presenter)
{
NavViewItemContentPresenterMarginTextBlock.Text = presenter.Margin.ToString();
}
}
}
}
8 changes: 8 additions & 0 deletions dev/NavigationView/TestUI/NavigationViewRS4Page.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@
PaneOpened="NavView_PaneOpened"
BackRequested="NavView_BackRequested"
AccessKey="H">
<!-- Note: Adding more NavViewItems here will cause the following tests to fail on RS2 and below:
- CommonTests.MenuItemKeyboardInvokeTest()
- SelectionTests.MenuItemAutomationSelectionTest()

The reason is that on RS2, the ScollViewer handles arrow keys and thus scrolls the NavigationView pane instead of moving focus.
This is not an issue with the current page setup as all NavView items fit the page without the need to scroll it. Adding more items,
however, will push these items off-screen leading the ScrollViewer to scroll the pane instead of moving focus. As a result, the above
mentioned tests will fail. -->
<muxcontrols:NavigationView.MenuItems>
<muxcontrols:NavigationViewItem x:Name="HomeItem" Content="Home" Icon="Home"/>
<muxcontrols:NavigationViewItem x:Name="AppsItem" Content="Apps" Icon="Shop" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@
BorderBrush=[NULL]
Background=[NULL]
Name=ContentPresenter
Margin=0,0,16,0
Margin=0,0,0,0
FocusVisualSecondaryThickness=1,1,1,1
FocusVisualSecondaryBrush=#99FFFFFF
FocusVisualPrimaryThickness=2,2,2,2
Expand Down Expand Up @@ -1250,7 +1250,7 @@
BorderBrush=[NULL]
Background=[NULL]
Name=ContentPresenter
Margin=0,0,16,0
Margin=0,0,0,0
FocusVisualSecondaryThickness=1,1,1,1
FocusVisualSecondaryBrush=#99FFFFFF
FocusVisualPrimaryThickness=2,2,2,2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@
BorderBrush=[NULL]
Background=[NULL]
Name=ContentPresenter
Margin=0,0,16,0
Margin=0,0,0,0
FocusVisualSecondaryThickness=1,1,1,1
FocusVisualSecondaryBrush=#99FFFFFF
FocusVisualPrimaryThickness=2,2,2,2
Expand Down Expand Up @@ -1250,7 +1250,7 @@
BorderBrush=[NULL]
Background=[NULL]
Name=ContentPresenter
Margin=0,0,16,0
Margin=0,0,0,0
FocusVisualSecondaryThickness=1,1,1,1
FocusVisualSecondaryBrush=#99FFFFFF
FocusVisualPrimaryThickness=2,2,2,2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@
BorderBrush=[NULL]
Background=[NULL]
Name=ContentPresenter
Margin=0,0,16,0
Margin=0,0,0,0
FocusVisualSecondaryThickness=1,1,1,1
FocusVisualSecondaryBrush=#99FFFFFF
FocusVisualPrimaryThickness=2,2,2,2
Expand Down Expand Up @@ -1273,7 +1273,7 @@
BorderBrush=[NULL]
Background=[NULL]
Name=ContentPresenter
Margin=0,0,16,0
Margin=0,0,0,0
FocusVisualSecondaryThickness=1,1,1,1
FocusVisualSecondaryBrush=#99FFFFFF
FocusVisualPrimaryThickness=2,2,2,2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@
BorderBrush=[NULL]
Background=[NULL]
Name=ContentPresenter
Margin=0,0,16,0
Margin=0,0,0,0
FocusVisualSecondaryThickness=1,1,1,1
FocusVisualSecondaryBrush=#99FFFFFF
FocusVisualPrimaryThickness=2,2,2,2
Expand Down Expand Up @@ -1273,7 +1273,7 @@
BorderBrush=[NULL]
Background=[NULL]
Name=ContentPresenter
Margin=0,0,16,0
Margin=0,0,0,0
FocusVisualSecondaryThickness=1,1,1,1
FocusVisualSecondaryBrush=#99FFFFFF
FocusVisualPrimaryThickness=2,2,2,2
Expand Down
Loading