Browse Source

Merge pull request #11458 from AvaloniaUI/fixes/11370-automation-effectively-disabled

Use `IsEffectivelyEnabled` in automation peers.
pull/11465/head
Max Katz 3 years ago
committed by GitHub
parent
commit
7422dc3068
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      samples/IntegrationTestApp/MainWindow.axaml
  2. 2
      src/Avalonia.Controls/Automation/Peers/ControlAutomationPeer.cs
  3. 9
      tests/Avalonia.IntegrationTests.Appium/ButtonTests.cs

3
samples/IntegrationTestApp/MainWindow.axaml

@ -47,6 +47,9 @@
<Button Name="DisabledButton" IsEnabled="False">
Disabled Button
</Button>
<Button Name="EffectivelyDisabledButton" Command="{ReflectionBinding DoesntExist}">
Effectively Disabled Button
</Button>
<Button Name="BasicButton">
Basic Button
</Button>

2
src/Avalonia.Controls/Automation/Peers/ControlAutomationPeer.cs

@ -151,7 +151,7 @@ namespace Avalonia.Automation.Peers
protected override bool HasKeyboardFocusCore() => Owner.IsFocused;
protected override bool IsContentElementCore() => true;
protected override bool IsControlElementCore() => true;
protected override bool IsEnabledCore() => Owner.IsEnabled;
protected override bool IsEnabledCore() => Owner.IsEffectivelyEnabled;
protected override bool IsKeyboardFocusableCore() => Owner.Focusable;
protected override void SetFocusCore() => Owner.Focus();

9
tests/Avalonia.IntegrationTests.Appium/ButtonTests.cs

@ -27,6 +27,15 @@ namespace Avalonia.IntegrationTests.Appium
Assert.False(button.Enabled);
}
[Fact]
public void EffectivelyDisabledButton()
{
var button = _session.FindElementByAccessibilityId("EffectivelyDisabledButton");
Assert.Equal("Effectively Disabled Button", button.Text);
Assert.False(button.Enabled);
}
[Fact]
public void BasicButton()
{

Loading…
Cancel
Save