mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-16 21:14:10 +01:00
A page swept point by point left a few places a reader heard nothing: the panel dividers, the vehicle preview in the depot and the texture base, the picture by a vehicle class and the empty part of the settings categories. Each now has a name; a picture with a caption beside it reads as the caption. The tests that build controls run one after another: a control belongs to the thread that made the first one, and side by side they now and then failed.
64 lines
2.2 KiB
C#
64 lines
2.2 KiB
C#
using Avalonia.Automation;
|
|
using Avalonia.Automation.Peers;
|
|
using Avalonia.Automation.Provider;
|
|
using StarterNG.Controls;
|
|
|
|
namespace StarterNG.Tests;
|
|
|
|
[Collection(AvaloniaControls.Name)]
|
|
public class ExpandableTreeViewItemTests
|
|
{
|
|
private static IExpandCollapseProvider Peer(ExpandableTreeViewItem item) =>
|
|
Assert.IsAssignableFrom<IExpandCollapseProvider>(ControlAutomationPeer.CreatePeerForElement(item));
|
|
|
|
[Fact]
|
|
public void A_scenery_with_nothing_under_it_is_a_leaf()
|
|
{
|
|
var peer = Peer(new ExpandableTreeViewItem { Header = "test32" });
|
|
|
|
Assert.Equal(ExpandCollapseState.LeafNode, peer.ExpandCollapseState);
|
|
Assert.False(peer.ShowsMenu);
|
|
}
|
|
|
|
[Fact]
|
|
public void A_group_says_whether_it_is_open()
|
|
{
|
|
Assert.Equal(ExpandCollapseState.Collapsed, ExpandableTreeViewItem.StateFor(hasChildren: true, expanded: false));
|
|
Assert.Equal(ExpandCollapseState.Expanded, ExpandableTreeViewItem.StateFor(hasChildren: true, expanded: true));
|
|
Assert.Equal(ExpandCollapseState.LeafNode, ExpandableTreeViewItem.StateFor(hasChildren: false, expanded: true));
|
|
}
|
|
|
|
[Fact]
|
|
public void A_screen_reader_can_open_and_close_an_entry()
|
|
{
|
|
var item = new ExpandableTreeViewItem { Header = "Całkowo" };
|
|
var peer = Peer(item);
|
|
|
|
peer.Expand();
|
|
Assert.True(item.IsExpanded);
|
|
|
|
peer.Collapse();
|
|
Assert.False(item.IsExpanded);
|
|
}
|
|
|
|
[Fact]
|
|
public void An_entry_on_its_own_has_nothing_over_it()
|
|
{
|
|
var item = new ExpandableTreeViewItem { Header = "Całkowo", IsExpanded = true };
|
|
var peer = ControlAutomationPeer.CreatePeerForElement(item);
|
|
|
|
Assert.Null(item.ReadableParent);
|
|
Assert.Null(peer.GetParent());
|
|
}
|
|
|
|
[Fact]
|
|
public void The_row_under_the_mouse_is_told_open_or_closed_and_a_leaf_nothing()
|
|
{
|
|
static string Loc(string key) => key == "TreeExpanded" ? "rozwinięte" : "zwinięte";
|
|
|
|
Assert.Equal("rozwinięte", ExpandableTreeViewItem.WordFor(ExpandCollapseState.Expanded, Loc));
|
|
Assert.Equal("zwinięte", ExpandableTreeViewItem.WordFor(ExpandCollapseState.Collapsed, Loc));
|
|
Assert.Null(ExpandableTreeViewItem.WordFor(ExpandCollapseState.LeafNode, Loc));
|
|
}
|
|
}
|