Skip to content

Commit

Permalink
Fixed NavigationView on launch pane state (#1439)
Browse files Browse the repository at this point in the history
* fixed bug, added tests

* addressed comments, fixed test

* addressed comment
  • Loading branch information
ojhad authored Oct 16, 2019
1 parent 94002c4 commit ab66b66
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 22 deletions.
4 changes: 3 additions & 1 deletion dev/NavigationView/NavigationView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,10 @@ void NavigationView::UpdateAdaptiveLayout(double width, bool forceSetDisplayMode
{
MUX_FAIL_FAST();
}

if (!forceSetDisplayMode && m_InitialNonForcedModeUpdate) {
if (displayMode == winrt::NavigationViewDisplayMode::Minimal && PaneDisplayMode() == winrt::NavigationViewPaneDisplayMode::Auto) {
if (displayMode == winrt::NavigationViewDisplayMode::Minimal ||
displayMode == winrt::NavigationViewDisplayMode::Compact) {
ClosePane();
}
m_InitialNonForcedModeUpdate = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ public void VerifySettingsItemToolTip()

navView.IsSettingsVisible = true;
navView.IsPaneOpen = true;
navView.PaneDisplayMode = NavigationViewPaneDisplayMode.Left;
MUXControlsTestApp.App.TestContentRoot = navView;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,18 +445,25 @@ public void PaneOpenForceCloseTest()

[TestMethod]
[TestProperty("TestSuite", "A")]
public void PaneClosedWhenAutoAndNarrow()
public void PaneClosedUponLaunch()
{
var testScenarios = RegressionTestScenario.BuildLeftNavRegressionTestScenarios();
foreach (var testScenario in testScenarios)
{
using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "Navigation Minimal Test" }))
{

CheckBox isPaneOpenCheckBox = new CheckBox(FindElement.ById("IsAutoPaneOpenCheckBox"));
Log.Comment("Checking that a NavigationView with displaymode set to 'Auto' and a narrow width does not display pane");
Log.Comment("Verify that NavigationView with DisplayMode set to 'Auto' and a narrow width does not display pane on load.");
CheckBox isAutoPaneOpenCheckBox = new CheckBox(FindElement.ById("IsAutoPaneOpenCheckBox"));
Wait.ForIdle();
Verify.IsTrue(isPaneOpenCheckBox.ToggleState == ToggleState.Off);
Verify.IsTrue(isAutoPaneOpenCheckBox.ToggleState == ToggleState.Off);

Log.Comment("Verify that NavigationView with DisplayMode set to 'LeftMinimal' does not display pane on load.");
CheckBox isLeftMinimalPaneOpenCheckBox = new CheckBox(FindElement.ById("IsLeftMinimalPaneOpenCheckBox"));
Verify.IsTrue(isLeftMinimalPaneOpenCheckBox.ToggleState == ToggleState.Off);

Log.Comment("Verify that NavigationView with DisplayMode set to 'LeftCompact' does not display pane on load.");
CheckBox isLeftCompactPaneOpenCheckBox = new CheckBox(FindElement.ById("IsLeftCompactPaneOpenCheckBox"));
Verify.IsTrue(isLeftCompactPaneOpenCheckBox.ToggleState == ToggleState.Off);
}

}
Expand Down
49 changes: 33 additions & 16 deletions dev/NavigationView/TestUI/NavigationViewMinimalPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,38 @@
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<!-- This page contains a NavigationView control that is in LeftMinimal mode on initial load -->
<StackPanel>
<muxcontrols:NavigationView x:Name="NavView" AutomationProperties.Name="NavView" AutomationProperties.AutomationId="NavView"
IsBackEnabled="True" Header="Minimal Test Page" PaneDisplayMode="LeftMinimal">
<StackPanel>
<TextBlock x:Name="NavViewActiveVisualStatesResult" AutomationProperties.Name="NavViewActiveVisualStatesResult"/>
<Button x:Name="GetNavViewActiveVisualStates" AutomationProperties.Name="GetNavViewActiveVisualStates" Content="GetNavViewActiveVisualStates" Click="GetNavViewActiveVisualStates_Click"/>
</StackPanel>
</muxcontrols:NavigationView>
<muxcontrols:NavigationView x:Name="NavViewAuto" AutomationProperties.Name="NavView" AutomationProperties.AutomationId="NavView"
IsBackEnabled="True" Header="Minimal Test Page" Width="250" Height="300" >
<StackPanel>
</StackPanel>
</muxcontrols:NavigationView>
<CheckBox
IsChecked="{Binding IsPaneOpen, ElementName=NavViewAuto, Mode=TwoWay}"
x:Name="IsAutoPaneOpenCheckBox"
AutomationProperties.Name="IsPaneOpenCheckBox" >Toggle auto pane open</CheckBox>
<StackPanel Orientation="Horizontal">
<muxcontrols:NavigationView x:Name="NavView" AutomationProperties.Name="NavView" AutomationProperties.AutomationId="NavView"
IsBackEnabled="True" Header="LeftMinimal" PaneDisplayMode="LeftMinimal">
<StackPanel>
<TextBlock x:Name="NavViewActiveVisualStatesResult" AutomationProperties.Name="NavViewActiveVisualStatesResult"/>
<Button x:Name="GetNavViewActiveVisualStates" AutomationProperties.Name="GetNavViewActiveVisualStates" Content="GetNavViewActiveVisualStates" Click="GetNavViewActiveVisualStates_Click"/>
</StackPanel>
</muxcontrols:NavigationView>
<muxcontrols:NavigationView x:Name="NavViewLeftCompact" AutomationProperties.Name="NavView" AutomationProperties.AutomationId="NavViewLeftCompact"
IsBackEnabled="True" Header="LeftCompact" PaneDisplayMode="LeftCompact">
<StackPanel>
</StackPanel>
</muxcontrols:NavigationView>
<muxcontrols:NavigationView x:Name="NavViewAuto" AutomationProperties.Name="NavView" AutomationProperties.AutomationId="NavView"
IsBackEnabled="True" Header="Auto" Width="250" Height="300" >
<StackPanel>
</StackPanel>
</muxcontrols:NavigationView>
</StackPanel>
<StackPanel>
<CheckBox
IsChecked="{Binding IsPaneOpen, ElementName=NavView, Mode=TwoWay}"
x:Name="IsLeftMinimalPaneOpenCheckBox"
AutomationProperties.Name="IsLeftMinimalPaneOpenCheckBox" >Toggle LeftMinimal pane open</CheckBox>
<CheckBox
IsChecked="{Binding IsPaneOpen, ElementName=NavViewLeftCompact, Mode=TwoWay}"
x:Name="IsLeftCompactPaneOpenCheckBox"
AutomationProperties.Name="IsLeftCompactPaneOpenCheckBox" >Toggle LeftCompact pane open</CheckBox>
<CheckBox
IsChecked="{Binding IsPaneOpen, ElementName=NavViewAuto, Mode=TwoWay}"
x:Name="IsAutoPaneOpenCheckBox"
AutomationProperties.Name="IsPaneOpenCheckBox" >Toggle auto pane open</CheckBox>
</StackPanel>
</StackPanel>
</local:TestPage>

0 comments on commit ab66b66

Please sign in to comment.