Skip to content

Commit

Permalink
Add unit test for microsoft#148
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelwgn committed Oct 15, 2019
1 parent 8eacce0 commit e5cae29
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2923,6 +2923,38 @@ public void KeyboardFocusToolTipTest() // Verify tooltips appear when Keyboard f
}
}

[TestMethod]
[TestProperty("TestSuite", "C")]
public void DisplayModeChangeSelectionEventTest()
{
var testScenarios = RegressionTestScenario.BuildLeftNavRegressionTestScenarios();
foreach (var testScenario in testScenarios)
{
using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "NavigationView Test" }))
{
if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone3))
{
Log.Warning("Test is disabled on RS2 and earlier because SplitView lacks the requisite events.");
return;
}

ComboBox selectedItem = new ComboBox(FindElement.ById("SelectedItemCombobox"));
selectedItem.SelectItemByName("Settings");

ComboBox displayMode = new ComboBox(FindElement.ById("PaneDisplayModeCombobox"));
displayMode.SelectItemByName("Top");
Wait.ForIdle();

TextBlock selectedItemWasNull = new TextBlock(FindElement.ById("SelectionChangedItemWasNull"));
Verify.AreEqual("False", selectedItemWasNull.GetText());

displayMode.SelectItemByName("Left");
Wait.ForIdle();
Verify.AreEqual("False", selectedItemWasNull.GetText());
}
}
}

[TestMethod]
[TestProperty("TestSuite", "C")]
public void PaneOpenCloseEventsTest()
Expand Down
4 changes: 3 additions & 1 deletion dev/NavigationView/TestUI/NavigationViewPage.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<local:TestPage
x:Class="MUXControlsTestApp.NavigationViewPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Expand Down Expand Up @@ -177,6 +177,8 @@
<ComboBoxItem Content="LeftCompact" Tag="LeftCompact"/>
<ComboBoxItem Content="LeftMinimal" Tag="LeftMinimal"/>
</ComboBox>
<TextBlock VerticalAlignment="Center">SelectedItem in SelectionChanged event was null: </TextBlock>
<TextBlock VerticalAlignment="Center" x:Name="SelectionChangedItemWasNull" AutomationProperties.Name="SelectionChangedItemWasNull"/>
</StackPanel>

<StackPanel Orientation="Horizontal">
Expand Down
5 changes: 5 additions & 0 deletions dev/NavigationView/TestUI/NavigationViewPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ private void NavView_SelectionChanged(NavigationView sender, NavigationViewSelec
{
if (args.SelectedItem != null)
{
SelectionChangedItemWasNull.Text = "False";
var itemdata = args.SelectedItem as NavigationViewItem;
if (itemdata != null)
{
Expand All @@ -309,6 +310,10 @@ private void NavView_SelectionChanged(NavigationView sender, NavigationViewSelec
}
}
}
else
{
SelectionChangedItemWasNull.Text = "True";
}
}

private void MoviesEnabledCheckbox_Checked(object sender, RoutedEventArgs e)
Expand Down

0 comments on commit e5cae29

Please sign in to comment.