зеркало из https://github.com/dotnet/winforms.git
Adding Splitter UIA accessibility (#3246)
This commit is contained in:
Родитель
697e81d2c4
Коммит
cc0c82707b
|
@ -1,6 +1,7 @@
|
|||
~override System.Windows.Forms.Splitter.CreateAccessibilityInstance() -> System.Windows.Forms.AccessibleObject
|
||||
System.Windows.Forms.ListViewGroup.TitleImageIndex.get -> int
|
||||
System.Windows.Forms.ListViewGroup.TitleImageIndex.set -> void
|
||||
System.Windows.Forms.ListViewGroup.TitleImageKey.get -> string!
|
||||
System.Windows.Forms.ListViewGroup.TitleImageKey.set -> void
|
||||
~System.Windows.Forms.ListView.GroupImageList.get -> System.Windows.Forms.ImageList
|
||||
~System.Windows.Forms.ListView.GroupImageList.set -> void
|
||||
~System.Windows.Forms.ListView.GroupImageList.set -> void
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using static Interop;
|
||||
|
||||
namespace System.Windows.Forms
|
||||
{
|
||||
public partial class Splitter
|
||||
{
|
||||
internal class SplitterAccessibleObject : ControlAccessibleObject
|
||||
{
|
||||
internal SplitterAccessibleObject(Splitter owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
internal override object? GetPropertyValue(UiaCore.UIA propertyID)
|
||||
=> propertyID switch
|
||||
{
|
||||
UiaCore.UIA.NamePropertyId
|
||||
=> Name,
|
||||
UiaCore.UIA.AutomationIdPropertyId
|
||||
=> Owner.Name,
|
||||
UiaCore.UIA.ControlTypePropertyId
|
||||
=> UiaCore.UIA.PaneControlTypeId,
|
||||
UiaCore.UIA.IsKeyboardFocusablePropertyId
|
||||
// This is necessary for compatibility with MSAA proxy:
|
||||
// IsKeyboardFocusable = true regardless the control is enabled/disabled.
|
||||
=> true,
|
||||
_ => base.GetPropertyValue(propertyID)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@ namespace System.Windows.Forms
|
|||
[DefaultProperty(nameof(Dock))]
|
||||
[SRDescription(nameof(SR.DescriptionSplitter))]
|
||||
[Designer("System.Windows.Forms.Design.SplitterDesigner, " + AssemblyRef.SystemDesign)]
|
||||
public class Splitter : Control
|
||||
public partial class Splitter : Control
|
||||
{
|
||||
private const int DRAW_START = 1;
|
||||
private const int DRAW_MOVE = 2;
|
||||
|
@ -207,6 +207,9 @@ namespace System.Windows.Forms
|
|||
}
|
||||
}
|
||||
|
||||
protected override AccessibleObject CreateAccessibilityInstance()
|
||||
=> new SplitterAccessibleObject(this);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the parameters needed to create the handle. Inheriting classes
|
||||
/// can override this to provide extra functionality. They should not,
|
||||
|
@ -428,6 +431,8 @@ namespace System.Windows.Forms
|
|||
}
|
||||
}
|
||||
|
||||
internal override bool SupportsUiaProviders => true;
|
||||
|
||||
[Browsable(false)]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
new public bool TabStop
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Xunit;
|
||||
using static Interop.UiaCore;
|
||||
|
||||
namespace System.Windows.Forms.Tests
|
||||
{
|
||||
public class Splitter_SplitterAccessibleObjectTests
|
||||
{
|
||||
[WinFormsFact]
|
||||
public void SplitterAccessibleObject_Ctor_NullControl_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("ownerControl", () => new Splitter.SplitterAccessibleObject(null));
|
||||
}
|
||||
|
||||
[WinFormsFact]
|
||||
public void SplitterAccessibleObject_Ctor_Default()
|
||||
{
|
||||
using var splitter = new Splitter();
|
||||
Assert.False(splitter.IsHandleCreated);
|
||||
var splitterAccessibleObject = new Splitter.SplitterAccessibleObject(splitter);
|
||||
|
||||
Assert.NotNull(splitterAccessibleObject.Owner);
|
||||
// TODO: ControlAccessibleObject shouldn't force handle creation, tracked in https://github.com/dotnet/winforms/issues/3062
|
||||
Assert.True(splitter.IsHandleCreated);
|
||||
}
|
||||
|
||||
[WinFormsFact]
|
||||
public void SplitterAccessibleObject_Descrpition_ReturnsExpected()
|
||||
{
|
||||
using var splitter = new Splitter
|
||||
{
|
||||
AccessibleDescription = "TestDescription"
|
||||
};
|
||||
|
||||
Assert.False(splitter.IsHandleCreated);
|
||||
var splitterAccessibleObject = new Splitter.SplitterAccessibleObject(splitter);
|
||||
|
||||
Assert.Equal("TestDescription", splitterAccessibleObject.Description);
|
||||
// TODO: ControlAccessibleObject shouldn't force handle creation, tracked in https://github.com/dotnet/winforms/issues/3062
|
||||
Assert.True(splitter.IsHandleCreated);
|
||||
}
|
||||
|
||||
[WinFormsFact]
|
||||
public void SplitterAccessibleObject_Name_ReturnsExpected()
|
||||
{
|
||||
using var splitter = new Splitter
|
||||
{
|
||||
AccessibleName = "TestName"
|
||||
};
|
||||
|
||||
Assert.False(splitter.IsHandleCreated);
|
||||
var splitterAccessibleObject = new Splitter.SplitterAccessibleObject(splitter);
|
||||
|
||||
Assert.Equal("TestName", splitterAccessibleObject.Name);
|
||||
// TODO: ControlAccessibleObject shouldn't force handle creation, tracked in https://github.com/dotnet/winforms/issues/3062
|
||||
Assert.True(splitter.IsHandleCreated);
|
||||
}
|
||||
|
||||
[WinFormsFact]
|
||||
public void SplitterAccessibleObject_CustomRole_ReturnsExpected()
|
||||
{
|
||||
using var splitter = new Splitter
|
||||
{
|
||||
AccessibleRole = AccessibleRole.PushButton
|
||||
};
|
||||
|
||||
Assert.False(splitter.IsHandleCreated);
|
||||
var splitterAccessibleObject = new Splitter.SplitterAccessibleObject(splitter);
|
||||
|
||||
Assert.Equal(AccessibleRole.PushButton, splitterAccessibleObject.Role);
|
||||
// TODO: ControlAccessibleObject shouldn't force handle creation, tracked in https://github.com/dotnet/winforms/issues/3062
|
||||
Assert.True(splitter.IsHandleCreated);
|
||||
}
|
||||
|
||||
[WinFormsFact]
|
||||
public void SplitterAccessibleObject_DefaultRole_ReturnsExpected()
|
||||
{
|
||||
using var splitter = new Splitter();
|
||||
Assert.False(splitter.IsHandleCreated);
|
||||
var splitterAccessibleObject = new Splitter.SplitterAccessibleObject(splitter);
|
||||
|
||||
Assert.Equal(AccessibleRole.Client, splitterAccessibleObject.Role);
|
||||
// TODO: ControlAccessibleObject shouldn't force handle creation, tracked in https://github.com/dotnet/winforms/issues/3062
|
||||
Assert.True(splitter.IsHandleCreated);
|
||||
}
|
||||
|
||||
[WinFormsTheory]
|
||||
[InlineData((int)UIA.NamePropertyId, "TestName")]
|
||||
[InlineData((int)UIA.ControlTypePropertyId, UIA.PaneControlTypeId)]
|
||||
[InlineData((int)UIA.IsKeyboardFocusablePropertyId, true)]
|
||||
[InlineData((int)UIA.AutomationIdPropertyId, "Splitter1")]
|
||||
public void SplitterAccessibleObject_GetPropertyValue_Invoke_ReturnsExpected(int propertyID, object expected)
|
||||
{
|
||||
using var splitter = new Splitter
|
||||
{
|
||||
Name = "Splitter1",
|
||||
AccessibleName = "TestName"
|
||||
};
|
||||
|
||||
Assert.False(splitter.IsHandleCreated);
|
||||
var splitterAccessibleObject = new Splitter.SplitterAccessibleObject(splitter);
|
||||
object value = splitterAccessibleObject.GetPropertyValue((UIA)propertyID);
|
||||
|
||||
Assert.Equal(expected, value);
|
||||
// TODO: ControlAccessibleObject shouldn't force handle creation, tracked in https://github.com/dotnet/winforms/issues/3062
|
||||
Assert.True(splitter.IsHandleCreated);
|
||||
}
|
||||
|
||||
[WinFormsFact]
|
||||
public void SplitterAccessibleObject_IsPatternSupported_Invoke_ReturnsTrue_ForLegacyIAccessiblePattern()
|
||||
{
|
||||
using var splitter = new Splitter
|
||||
{
|
||||
Name = "Splitter1"
|
||||
};
|
||||
Assert.False(splitter.IsHandleCreated);
|
||||
var splitterAccessibleObject = new Splitter.SplitterAccessibleObject(splitter);
|
||||
|
||||
Assert.True(splitterAccessibleObject.IsPatternSupported(UIA.LegacyIAccessiblePatternId));
|
||||
// TODO: ControlAccessibleObject shouldn't force handle creation, tracked in https://github.com/dotnet/winforms/issues/3062
|
||||
Assert.True(splitter.IsHandleCreated);
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче