mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-19 06:55:59 +01:00
NVDA passes over a group that is not content as well as control, so titled panels and the landmarks are now both. A setting's explanation and the note on why the simulator ignores it are read after its name. The key under each setting is no longer a silent stop for Tab, and a step of the fog slider moves the shown distance.
118 lines
3.6 KiB
C#
118 lines
3.6 KiB
C#
using Avalonia.Automation;
|
|
using Avalonia.Automation.Peers;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Controls.Primitives;
|
|
using StarterNG.Controls;
|
|
|
|
namespace StarterNG.Tests;
|
|
|
|
public class AnnouncerTests
|
|
{
|
|
private DateTime _now = new(2026, 11, 15, 12, 0, 0, DateTimeKind.Utc);
|
|
|
|
private Announcer NewAnnouncer() => new(() => _now);
|
|
|
|
[Fact]
|
|
public void A_message_is_read_while_fresh_and_then_forgotten()
|
|
{
|
|
var announcer = NewAnnouncer();
|
|
announcer.Say(" Jakość grafiki: Wysoka ");
|
|
Assert.Equal("Jakość grafiki: Wysoka", announcer.Message);
|
|
|
|
_now += Announcer.Shown;
|
|
Assert.Null(announcer.Message);
|
|
}
|
|
|
|
[Fact]
|
|
public void Nothing_to_say_says_nothing()
|
|
{
|
|
var announcer = NewAnnouncer();
|
|
announcer.Say("Zapisano ustawienia");
|
|
announcer.Say(" ");
|
|
|
|
Assert.Equal("Zapisano ustawienia", announcer.Message);
|
|
}
|
|
|
|
[Fact]
|
|
public void A_control_inside_says_it_through_the_window_announcer()
|
|
{
|
|
var button = new Button();
|
|
var announcer = NewAnnouncer();
|
|
announcer.Child = new Border { Child = button };
|
|
|
|
Announcer.Say(button, "Godzina: 07:05");
|
|
|
|
Assert.Equal("Godzina: 07:05", announcer.Message);
|
|
}
|
|
|
|
[Fact]
|
|
public void A_control_outside_any_announcer_is_not_heard()
|
|
{
|
|
Announcer.Say(new Button(), "Godzina: 07:05");
|
|
}
|
|
|
|
[Fact]
|
|
public void A_marked_text_is_read_when_it_changes()
|
|
{
|
|
var status = new TextBlock();
|
|
Announcer.SetChanges(status, true);
|
|
var plain = new TextBlock();
|
|
var announcer = NewAnnouncer();
|
|
announcer.Child = new StackPanel { Children = { status, plain } };
|
|
|
|
plain.Text = "Ścieżka";
|
|
Assert.Null(announcer.Message);
|
|
|
|
status.Text = "Niezapisane zmiany";
|
|
Assert.True(Announcer.GetChanges(status));
|
|
Assert.Equal("Niezapisane zmiany", announcer.Message);
|
|
}
|
|
|
|
[Fact]
|
|
public void A_screen_reader_hears_it_as_a_polite_live_region()
|
|
{
|
|
var announcer = NewAnnouncer();
|
|
var peer = ControlAutomationPeer.CreatePeerForElement(announcer);
|
|
announcer.Say("Przywrócono domyślne");
|
|
|
|
Assert.Equal("Przywrócono domyślne", peer.GetName());
|
|
Assert.Equal(AutomationLiveSetting.Polite, peer.GetLiveSetting());
|
|
Assert.Equal(AutomationControlType.Group, peer.GetAutomationControlType());
|
|
}
|
|
}
|
|
|
|
public class NamedGroupTests
|
|
{
|
|
static NamedGroupTests() => ScreenReaderNames.Install();
|
|
|
|
[Fact]
|
|
public void A_panel_with_a_title_is_a_group_named_by_it()
|
|
{
|
|
var panel = new HeaderedContentControl { Header = "Scenerie" };
|
|
|
|
Assert.Equal("Scenerie", AutomationProperties.GetName(panel));
|
|
Assert.Equal(AutomationControlType.Group, AutomationProperties.GetControlTypeOverride(panel));
|
|
Assert.Equal(AccessibilityView.Content, AutomationProperties.GetAccessibilityView(panel));
|
|
}
|
|
|
|
[Fact]
|
|
public void A_panel_whose_title_goes_is_no_longer_a_group()
|
|
{
|
|
var panel = new HeaderedContentControl { Header = "Skład" };
|
|
panel.Header = null;
|
|
|
|
Assert.Null(AutomationProperties.GetName(panel));
|
|
Assert.Null(AutomationProperties.GetControlTypeOverride(panel));
|
|
Assert.Equal(AccessibilityView.Default, AutomationProperties.GetAccessibilityView(panel));
|
|
}
|
|
|
|
[Fact]
|
|
public void A_tab_keeps_its_own_way_of_speaking()
|
|
{
|
|
var tab = new TabItem { Header = "Pogoda" };
|
|
|
|
Assert.Null(AutomationProperties.GetName(tab));
|
|
Assert.Equal(AutomationControlType.TabItem, AutomationProperties.GetControlTypeOverride(tab));
|
|
}
|
|
}
|