Skip to content

Commit fb6f7b4

Browse files
committed
Add unit test for microsoft#148
1 parent 1261d4d commit fb6f7b4

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

dev/NavigationView/NavigationView_InteractionTests/NavigationViewTests.cs

+32
Original file line numberDiff line numberDiff line change
@@ -2895,6 +2895,38 @@ public void KeyboardFocusToolTipTest() // Verify tooltips appear when Keyboard f
28952895
}
28962896
}
28972897

2898+
[TestMethod]
2899+
[TestProperty("TestSuite", "C")]
2900+
public void DisplayModeChangeSelectionEventTest()
2901+
{
2902+
var testScenarios = RegressionTestScenario.BuildLeftNavRegressionTestScenarios();
2903+
foreach (var testScenario in testScenarios)
2904+
{
2905+
using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "NavigationView Test" }))
2906+
{
2907+
if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone3))
2908+
{
2909+
Log.Warning("Test is disabled on RS2 and earlier because SplitView lacks the requisite events.");
2910+
return;
2911+
}
2912+
2913+
ComboBox selectedItem = new ComboBox(FindElement.ById("SelectedItemCombobox"));
2914+
selectedItem.SelectItemByName("Settings");
2915+
2916+
ComboBox displayMode = new ComboBox(FindElement.ById("PaneDisplayModeCombobox"));
2917+
displayMode.SelectItemByName("Top");
2918+
Wait.ForIdle();
2919+
2920+
TextBlock selectedItemWasNull = new TextBlock(FindElement.ById("SelectionChangedItemWasNull"));
2921+
Verify.AreEqual("False", selectedItemWasNull.GetText());
2922+
2923+
displayMode.SelectItemByName("Left");
2924+
Wait.ForIdle();
2925+
Verify.AreEqual("False", selectedItemWasNull.GetText());
2926+
}
2927+
}
2928+
}
2929+
28982930
[TestMethod]
28992931
[TestProperty("TestSuite", "C")]
29002932
public void PaneOpenCloseEventsTest()

dev/NavigationView/TestUI/NavigationViewPage.xaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
1+
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
22
<local:TestPage
33
x:Class="MUXControlsTestApp.NavigationViewPage"
44
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
@@ -177,6 +177,8 @@
177177
<ComboBoxItem Content="LeftCompact" Tag="LeftCompact"/>
178178
<ComboBoxItem Content="LeftMinimal" Tag="LeftMinimal"/>
179179
</ComboBox>
180+
<TextBlock VerticalAlignment="Center">SelectedItem in SelectionChanged event was null: </TextBlock>
181+
<TextBlock VerticalAlignment="Center" x:Name="SelectionChangedItemWasNull" AutomationProperties.Name="SelectionChangedItemWasNull"/>
180182
</StackPanel>
181183

182184
<StackPanel Orientation="Horizontal">

dev/NavigationView/TestUI/NavigationViewPage.xaml.cs

+5
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ private void NavView_SelectionChanged(NavigationView sender, NavigationViewSelec
296296
{
297297
if (args.SelectedItem != null)
298298
{
299+
SelectionChangedItemWasNull.Text = "False";
299300
var itemdata = args.SelectedItem as NavigationViewItem;
300301
if (itemdata != null)
301302
{
@@ -309,6 +310,10 @@ private void NavView_SelectionChanged(NavigationView sender, NavigationViewSelec
309310
}
310311
}
311312
}
313+
else
314+
{
315+
SelectionChangedItemWasNull.Text = "True";
316+
}
312317
}
313318

314319
private void MoviesEnabledCheckbox_Checked(object sender, RoutedEventArgs e)

0 commit comments

Comments
 (0)