Browse Source
* [Automation] Add EmbeddableControlRootAutomationPeer tests * [Automation] Implement IRootProvider on EmbeddableControlRootAutomationPeer Without IRootProvider, AutomationNode.Create falls back to the plain AutomationNode which doesn't implement IRawElementProviderFragmentRoot and returns null from GetHostRawElementProvider. As a result, UiaReturnRawElementProvider responds with E_FAIL for the WM_GETOBJECT sent to the embedded HWND, and the Avalonia automation tree is invisible to UIA clients (Inspect.exe, Narrator, FlaUI etc.) when the control is hosted via WinFormsAvaloniaControlHost.pull/21440/head
committed by
GitHub
2 changed files with 51 additions and 1 deletions
@ -0,0 +1,47 @@ |
|||
using Avalonia.Automation.Peers; |
|||
using Avalonia.Automation.Provider; |
|||
using Avalonia.UnitTests; |
|||
using Xunit; |
|||
|
|||
#nullable enable |
|||
|
|||
namespace Avalonia.Controls.UnitTests.Automation |
|||
{ |
|||
public class EmbeddableControlRootAutomationPeerTests : ScopedTestBase |
|||
{ |
|||
[Fact] |
|||
public void Peer_Provides_IRootProvider() |
|||
{ |
|||
using var services = new CompositorTestServices(); |
|||
var peer = ControlAutomationPeer.CreatePeerForElement(services.TopLevel); |
|||
|
|||
var rootProvider = peer.GetProvider<IRootProvider>(); |
|||
|
|||
Assert.NotNull(rootProvider); |
|||
Assert.Same(peer, rootProvider); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Peer_Still_Provides_IEmbeddedRootProvider() |
|||
{ |
|||
using var services = new CompositorTestServices(); |
|||
var peer = ControlAutomationPeer.CreatePeerForElement(services.TopLevel); |
|||
|
|||
var embeddedRootProvider = peer.GetProvider<IEmbeddedRootProvider>(); |
|||
|
|||
Assert.NotNull(embeddedRootProvider); |
|||
} |
|||
|
|||
[Fact] |
|||
public void IRootProvider_PlatformImpl_Returns_Owner_PlatformImpl() |
|||
{ |
|||
using var services = new CompositorTestServices(); |
|||
var peer = ControlAutomationPeer.CreatePeerForElement(services.TopLevel); |
|||
|
|||
var rootProvider = peer.GetProvider<IRootProvider>(); |
|||
|
|||
Assert.NotNull(rootProvider); |
|||
Assert.Same(services.TopLevel.PlatformImpl, rootProvider!.PlatformImpl); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue