Skip to content

Commit

Permalink
fix: Ensure that AppBarToggleButton's base.OnPropertyChanged is called
Browse files Browse the repository at this point in the history
  • Loading branch information
kazo0 committed Jan 3, 2022
1 parent 50844d7 commit 70c44e9
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4591,6 +4591,59 @@ public async Task VerifySubMenuHasLightDismissOnPrimaryAppBarButton()
await TestServices.WindowHelper.WaitForIdle();
}

[TestMethod]
[Description("Validates that setting IsChecked on an AppBarToggleButton programatically will still result in the same visual effect")]
public async Task ValidateAppBarToggleButtonIsCheckedProgramatically()
{
TestCleanupWrapper cleanup;

CommandBar root = null;
AppBarToggleButton button = null;

await RunOnUIThread(() =>
{
root = (CommandBar)XamlReader.Load(@"
<CommandBar xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<AppBarToggleButton x:Name=""button""/>
</CommandBar>
");
button = (AppBarToggleButton)root.FindName("button");
SetWindowContent(root);
});
await WindowHelper.WaitForIdle();

await OpenCommandBar(root, OpenMethod.Programmatic);

await WindowHelper.WaitForIdle();

await RunOnUIThread(() =>
{
button = (AppBarToggleButton)root.FindName("button");
});

await RunOnUIThread(async () =>
{
VERIFY_IS_TRUE(await ControlHelper.IsInVisualState(button, "CommonStates", "Normal"));
});
await WindowHelper.WaitForIdle();

await RunOnUIThread(() =>
{
button.IsChecked = true;
});
await WindowHelper.WaitForIdle();

await RunOnUIThread(async () =>
{
VERIFY_IS_TRUE(await ControlHelper.IsInVisualState(button, "CommonStates", "Checked"));
});
await WindowHelper.WaitForIdle();
}


private async Task ValidateDynamicOverflowOrderWorker(CommandBar cmdBar, DynamicOverflowOrderTest orderTestCase)
{
await OpenCommandBar(cmdBar, OpenMethod.Programmatic);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ bool ICommandBarLabeledElement.GetHasBottomLabel()

internal override void OnPropertyChanged2(DependencyPropertyChangedEventArgs args)
{
base.OnPropertyChanged2(args);
OnPropertyChanged(args);
}

Expand Down

0 comments on commit 70c44e9

Please sign in to comment.