fix(app): announce job and transfer states, not progress ticks; smoke tests for the screens
- Jobs and sync rows announce a new state with their job or sequence; the update check announces each state, not each download percent. Live regions stay quiet when a recycled row shows another item or a language switch relabels them. - The first-run dialog keeps its chosen card as the window's focused element, so focus starts inside it even before the window is active. - Known-server addresses read left to right in the menu. - Smoke tests: row names and states, row buttons, radio chips, header and cell columns, Workers readout, badge and strip counts, Settings values set elsewhere, German labels never cut, the cache row at 1200 px, no Reset on Advanced, Forget asks first, first-run focus and the RTL window direction. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
18 files changed
+398
-8
No files matched your search
@@ -27,6 +27,7 @@
|
||||
<data name="About.Update.DownloadFailed" xml:space="preserve"><value>Download failed</value></data>
|
||||
<data name="About.Update.Downloading" xml:space="preserve"><value>Downloading {0:P0}</value></data>
|
||||
<data name="About.Update.Failed" xml:space="preserve"><value>Check failed</value></data>
|
||||
<data name="About.Update.InProgress" xml:space="preserve"><value>Downloading…</value></data>
|
||||
<data name="About.Update.NotVerified" xml:space="preserve"><value>Download not verified</value></data>
|
||||
<data name="About.Update.Ready" xml:space="preserve"><value>Titano {0} downloaded</value></data>
|
||||
<data name="About.Update.ShowFile" xml:space="preserve"><value>Show file</value></data>
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
<data name="Jobs.PauseAll" xml:space="preserve"><value>Pause all</value></data>
|
||||
<data name="Jobs.RenderingSettings" xml:space="preserve"><value>Rendering settings</value></data>
|
||||
<data name="Jobs.Row.Name" xml:space="preserve"><value>{0} · {1}</value></data>
|
||||
<data name="Jobs.Row.State" xml:space="preserve"><value>{0}: {1}</value><comment>invariant</comment></data>
|
||||
<data name="Jobs.Search" xml:space="preserve"><value>Search target or kind</value></data>
|
||||
<data name="Jobs.Speed.Fps" xml:space="preserve"><value>{0} fps</value></data>
|
||||
<data name="Jobs.Speed.PerSecond" xml:space="preserve"><value>{0}/s</value></data>
|
||||
|
||||
@@ -182,6 +182,7 @@
|
||||
<data name="Server.Sync.Queued.other" xml:space="preserve"><value>{0} uploads queued</value><comment>{0} count</comment></data>
|
||||
<data name="Server.Sync.Received" xml:space="preserve"><value>{0} received</value><comment>{0} percent</comment></data>
|
||||
<data name="Server.Sync.Retrying" xml:space="preserve"><value>Not compared · retrying</value></data>
|
||||
<data name="Server.Sync.Row.State" xml:space="preserve"><value>{0}: {1}</value><comment>invariant</comment></data>
|
||||
<data name="Server.Sync.SavedBoth" xml:space="preserve"><value>This PC's settings saved</value><comment>long</comment></data>
|
||||
<data name="Server.Sync.Search" xml:space="preserve"><value>Search</value></data>
|
||||
<data name="Server.Sync.ShowCopy" xml:space="preserve"><value>Show file</value></data>
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
<data name="About.Update.DownloadFailed" xml:space="preserve"><value>Download non riuscito</value></data>
|
||||
<data name="About.Update.Downloading" xml:space="preserve"><value>Download in corso {0:P0}</value></data>
|
||||
<data name="About.Update.Failed" xml:space="preserve"><value>Verifica non riuscita</value></data>
|
||||
<data name="About.Update.InProgress" xml:space="preserve"><value>Download in corso…</value></data>
|
||||
<data name="About.Update.NotVerified" xml:space="preserve"><value>Download non verificato</value></data>
|
||||
<data name="About.Update.Ready" xml:space="preserve"><value>Titano {0} scaricato</value></data>
|
||||
<data name="About.Update.ShowFile" xml:space="preserve"><value>Mostra file</value></data>
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
<data name="Jobs.PauseAll" xml:space="preserve"><value>Sospendi tutte</value></data>
|
||||
<data name="Jobs.RenderingSettings" xml:space="preserve"><value>Impostazioni di rendering</value></data>
|
||||
<data name="Jobs.Row.Name" xml:space="preserve"><value>{0} · {1}</value></data>
|
||||
<data name="Jobs.Row.State" xml:space="preserve"><value>{0}: {1}</value></data>
|
||||
<data name="Jobs.Search" xml:space="preserve"><value>Cerca oggetto o tipo</value></data>
|
||||
<data name="Jobs.Speed.Fps" xml:space="preserve"><value>{0} fps</value></data>
|
||||
<data name="Jobs.Speed.PerSecond" xml:space="preserve"><value>{0}/s</value></data>
|
||||
|
||||
@@ -179,6 +179,7 @@
|
||||
<data name="Server.Sync.Queued.other" xml:space="preserve"><value>{0} caricamenti in coda</value></data>
|
||||
<data name="Server.Sync.Received" xml:space="preserve"><value>{0} ricevuto</value></data>
|
||||
<data name="Server.Sync.Retrying" xml:space="preserve"><value>Confronto fallito · riprovo</value></data>
|
||||
<data name="Server.Sync.Row.State" xml:space="preserve"><value>{0}: {1}</value></data>
|
||||
<data name="Server.Sync.SavedBoth" xml:space="preserve"><value>Impostazioni di questo PC salvate</value></data>
|
||||
<data name="Server.Sync.Search" xml:space="preserve"><value>Cerca</value></data>
|
||||
<data name="Server.Sync.ShowCopy" xml:space="preserve"><value>Mostra file</value></data>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Automation;
|
||||
using System.Windows.Automation.Peers;
|
||||
using System.Windows.Threading;
|
||||
using Titano.Core.Localization;
|
||||
|
||||
namespace Titano.App.Infrastructure;
|
||||
|
||||
@@ -15,6 +17,13 @@ public static class LiveRegion
|
||||
public static readonly DependencyProperty TextProperty = DependencyProperty.RegisterAttached(
|
||||
"Text", typeof(string), typeof(LiveRegion), new PropertyMetadata(null, OnTextChanged));
|
||||
|
||||
/// <summary>
|
||||
/// The data and language the last text came from: a recycled list row showing another item, or every status
|
||||
/// relabelled by a language switch, is not news.
|
||||
/// </summary>
|
||||
private static readonly DependencyProperty SourceProperty = DependencyProperty.RegisterAttached(
|
||||
"Source", typeof(Origin), typeof(LiveRegion), new PropertyMetadata(null));
|
||||
|
||||
public static string? GetText(DependencyObject element) => (string?)element.GetValue(TextProperty);
|
||||
|
||||
public static void SetText(DependencyObject element, string? value) => element.SetValue(TextProperty, value);
|
||||
@@ -23,10 +32,15 @@ public static class LiveRegion
|
||||
{
|
||||
if (d is not FrameworkElement element) return;
|
||||
AutomationProperties.SetName(element, (string?)e.NewValue ?? string.Empty);
|
||||
var origin = new Origin(element.DataContext, Loc.Culture);
|
||||
var sameSource = element.GetValue(SourceProperty) is Origin last && ReferenceEquals(last.Data, origin.Data) && last.Culture.Equals(origin.Culture);
|
||||
element.SetValue(SourceProperty, origin);
|
||||
// The first value arrives with the screen: only what changes while it is shown is announced, once layout has shown
|
||||
// it (a status that appears with its text is still collapsed when the text arrives).
|
||||
if (!element.IsLoaded || e.NewValue is null || !AutomationPeer.ListenerExists(AutomationEvents.LiveRegionChanged)) return;
|
||||
if (!sameSource || !element.IsLoaded || e.NewValue is null || !AutomationPeer.ListenerExists(AutomationEvents.LiveRegionChanged)) return;
|
||||
element.Dispatcher.InvokeAsync(() => UIElementAutomationPeer.CreatePeerForElement(element)?.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged),
|
||||
DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
private sealed record Origin(object? Data, CultureInfo Culture);
|
||||
}
|
||||
@@ -53,6 +53,9 @@ public sealed class JobRowViewModel : ObservableObject
|
||||
|
||||
public string StateText => JobText.State(_entry);
|
||||
|
||||
/// <summary>"Render · Harbour sunset: done · 3:00": what a screen reader announces when the state changes (not progress).</summary>
|
||||
public string StateAnnouncement => Loc.L("Jobs.Row.State", AccessibleName, StateText);
|
||||
|
||||
/// <summary>Glyph and colour of the state (paired with the word, never colour alone).</summary>
|
||||
public StatusKind StateKind => _entry.State switch
|
||||
{
|
||||
@@ -131,6 +134,7 @@ public sealed class JobRowViewModel : ObservableObject
|
||||
OnPropertyChanged(nameof(LeftText));
|
||||
OnPropertyChanged(nameof(WhereText));
|
||||
OnPropertyChanged(nameof(StateText));
|
||||
OnPropertyChanged(nameof(StateAnnouncement));
|
||||
if (_isExpanded) OnPropertyChanged(nameof(LogText));
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
<StackPanel Grid.Row="7" Grid.Column="1" Orientation="Horizontal">
|
||||
<ui:StatusGlyph Kind="{Binding UpdateKind}" Text="{Binding UpdateText}" FontSize="13" VerticalAlignment="Center"
|
||||
Visibility="{Binding HasUpdateText, Converter={StaticResource BoolToVisibility}}"
|
||||
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding UpdateText}" />
|
||||
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding UpdateAnnouncement}" />
|
||||
<Button Style="{StaticResource Button.Link}" FontSize="13" Margin="12,0,0,0" VerticalAlignment="Center" Content="{l:Loc About.Update.Download}"
|
||||
Command="{Binding DownloadCommand}" ToolTip="{Binding DownloadToolTip}"
|
||||
Visibility="{Binding IsUpdateAvailable, Converter={StaticResource BoolToVisibility}}" />
|
||||
|
||||
@@ -81,6 +81,9 @@ public sealed class AboutViewModel : SectionViewModel
|
||||
_ => null,
|
||||
};
|
||||
|
||||
/// <summary>What screen readers announce: each new state, not each percent of a download.</summary>
|
||||
public string? UpdateAnnouncement => _update.State == UpdateState.Downloading ? Loc.L("About.Update.InProgress") : UpdateText;
|
||||
|
||||
public StatusKind UpdateKind => _update.State switch
|
||||
{
|
||||
UpdateState.Checking or UpdateState.Downloading => StatusKind.Running,
|
||||
@@ -137,6 +140,7 @@ public sealed class AboutViewModel : SectionViewModel
|
||||
private void RaiseUpdate()
|
||||
{
|
||||
OnPropertyChanged(nameof(UpdateText));
|
||||
OnPropertyChanged(nameof(UpdateAnnouncement));
|
||||
OnPropertyChanged(nameof(UpdateKind));
|
||||
OnPropertyChanged(nameof(HasUpdateText));
|
||||
OnPropertyChanged(nameof(IsUpdateAvailable));
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
xmlns:ui="clr-namespace:Titano.Ui.Controls;assembly=Titano.Ui"
|
||||
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
|
||||
xmlns:s="clr-namespace:Titano.App.Sections"
|
||||
xmlns:infra="clr-namespace:Titano.App.Infrastructure"
|
||||
xmlns:j="clr-namespace:Titano.App.Jobs">
|
||||
<UserControl.Resources>
|
||||
<Style x:Key="Text.Muted" TargetType="TextBlock" BasedOn="{StaticResource Text.Cell}">
|
||||
@@ -167,8 +168,10 @@
|
||||
<TextBlock Grid.Column="4" Style="{StaticResource Text.MutedNumber}" Text="{Binding SpeedText}" Margin="10,0,0,0" />
|
||||
<TextBlock Grid.Column="5" Style="{StaticResource Text.MutedNumber}" Text="{Binding LeftText}" Margin="10,0,0,0" />
|
||||
<TextBlock Grid.Column="6" Style="{StaticResource Text.Muted}" Text="{Binding WhereText}" Margin="16,0,0,0" />
|
||||
<!-- A new state is announced with its job; progress ticks are not. -->
|
||||
<ui:StatusGlyph Grid.Column="7" Kind="{Binding StateKind}" Text="{Binding StateText}" ToolTip="{Binding StateToolTip}"
|
||||
FontSize="13" VerticalAlignment="Center" Margin="10,0,0,0" />
|
||||
FontSize="13" VerticalAlignment="Center" Margin="10,0,0,0"
|
||||
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding StateAnnouncement}" />
|
||||
<ItemsControl Grid.Column="8" ItemsSource="{Binding Actions}" ItemsPanel="{StaticResource Panel.Row}" Focusable="False"
|
||||
VerticalAlignment="Center" Margin="10,0,0,0">
|
||||
<ItemsControl.ItemTemplate>
|
||||
|
||||
@@ -84,6 +84,14 @@
|
||||
<ContextMenu.ItemContainerStyle>
|
||||
<Style TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}">
|
||||
<Setter Property="Header" Value="{Binding Address}" />
|
||||
<!-- An address reads left to right in every language. -->
|
||||
<Setter Property="HeaderTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding}" FlowDirection="LeftToRight" />
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="InputGestureText" Value="{Binding Name}" />
|
||||
<Setter Property="Command" Value="{Binding DataContext.UseServerCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}" />
|
||||
<Setter Property="CommandParameter" Value="{Binding}" />
|
||||
@@ -244,8 +252,10 @@
|
||||
<TextBlock Style="{StaticResource Text.Cell}" Text="{Binding Title}" ToolTip="{Binding Title}" />
|
||||
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding LocalText}" ToolTip="{Binding LocalText}" Margin="10,0,0,0" />
|
||||
<TextBlock Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding ServerText}" ToolTip="{Binding ServerText}" Margin="10,0,0,0" />
|
||||
<!-- A new state (uploading, in sync, failed) is announced with its sequence; progress ticks are not. -->
|
||||
<ui:StatusGlyph Grid.Column="3" Kind="{Binding StateKind}" Text="{Binding StateText}" ToolTip="{Binding StateToolTip}"
|
||||
FontSize="13" VerticalAlignment="Center" Margin="10,0,0,0" />
|
||||
FontSize="13" VerticalAlignment="Center" Margin="10,0,0,0"
|
||||
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding StateAnnouncement}" />
|
||||
<ItemsControl Grid.Column="4" ItemsSource="{Binding Actions}" ItemsPanel="{StaticResource Panel.Wrap}" Focusable="False" VerticalAlignment="Center" Margin="10,4,0,4">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type srv:SyncRowAction}">
|
||||
|
||||
@@ -383,7 +383,7 @@
|
||||
<Button Content="{l:Loc About.Update.Check}" Command="{Binding Shell.About.CheckCommand}" ToolTip="{l:Loc Tooltips.About.Check}" />
|
||||
<ui:StatusGlyph Kind="{Binding Shell.About.UpdateKind}" Text="{Binding Shell.About.UpdateText}" FontSize="13" VerticalAlignment="Center" Margin="12,0,0,0"
|
||||
Visibility="{Binding Shell.About.HasUpdateText, Converter={StaticResource BoolToVisibility}}"
|
||||
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding Shell.About.UpdateText}" />
|
||||
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding Shell.About.UpdateAnnouncement}" />
|
||||
<Button Style="{StaticResource Button.Link}" Content="{l:Loc About.Update.Download}" Command="{Binding Shell.About.DownloadCommand}" ToolTip="{Binding Shell.About.DownloadToolTip}"
|
||||
VerticalAlignment="Center" Margin="12,0,0,0" FontSize="13"
|
||||
Visibility="{Binding Shell.About.IsUpdateAvailable, Converter={StaticResource BoolToVisibility}}" />
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
@@ -16,10 +15,14 @@ public partial class WelcomeView : UserControl
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>The dialog opens with keyboard focus on the chosen card, so the keyboard starts inside it.</summary>
|
||||
/// <summary>
|
||||
/// The dialog opens with focus on the chosen card, so the keyboard starts inside it; the window keeps it as its focused
|
||||
/// element, so a window not active yet gives the card keyboard focus when activated.
|
||||
/// </summary>
|
||||
private void FocusChoice()
|
||||
{
|
||||
var chosen = new[] { LocalChoice, AdoptChoice, ServerChoice }.FirstOrDefault(c => c.IsChecked == true) ?? LocalChoice;
|
||||
FocusManager.SetFocusedElement(FocusManager.GetFocusScope(chosen), chosen);
|
||||
Keyboard.Focus(chosen);
|
||||
}
|
||||
}
|
||||
@@ -65,9 +65,13 @@ public sealed class SyncRow : ObservableObject
|
||||
public string ServerText => SyncText.Server(_entry);
|
||||
public StatusKind StateKind => SyncText.State(_entry).Kind;
|
||||
public string StateText => SyncText.State(_entry).Text;
|
||||
|
||||
/// <summary>"Clouds over the Langhe: In sync": what a screen reader announces when the state changes (not progress).</summary>
|
||||
public string StateAnnouncement => Loc.L("Server.Sync.Row.State", Title, StateText);
|
||||
|
||||
public string StateToolTip => SyncText.State(_entry).ToolTip;
|
||||
|
||||
/// <summary>Settings differ on both sides: the row is drawn on the card colour, as in Server.html.</summary>
|
||||
/// <summary>Settings differ on both sides: the row is drawn on the warning tint (the word in the State column says it too).</summary>
|
||||
public bool IsConflict => _entry.Status == SyncStatus.Conflict && _entry.Transfer is null;
|
||||
|
||||
public IReadOnlyList<SyncRowAction> Actions
|
||||
@@ -125,6 +129,7 @@ public sealed class SyncRow : ObservableObject
|
||||
OnPropertyChanged(nameof(ServerText));
|
||||
OnPropertyChanged(nameof(StateKind));
|
||||
OnPropertyChanged(nameof(StateText));
|
||||
OnPropertyChanged(nameof(StateAnnouncement));
|
||||
OnPropertyChanged(nameof(StateToolTip));
|
||||
OnPropertyChanged(nameof(IsConflict));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Automation;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using Titano.App.Jobs;
|
||||
using Titano.App.Sections;
|
||||
using Titano.App.Shell;
|
||||
using Titano.App.Tests.Windows;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Testing;
|
||||
using Titano.Ui.Controls;
|
||||
|
||||
namespace Titano.App.Tests.Jobs;
|
||||
|
||||
/// <summary>The Jobs screen on the capture sample: keyboard reach, names for screen readers, counts and the table's columns.</summary>
|
||||
[WindowsOnly]
|
||||
[Serial]
|
||||
[Timeout(300_000)]
|
||||
public sealed class JobsScreenSmokeTests
|
||||
{
|
||||
[Test]
|
||||
public Task RowsAreReachableNamedAndLinedUpWithTheHeader() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
var shell = app.Shell;
|
||||
await app.Sample.FillAsync();
|
||||
await shell.Jobs.ReloadAsync();
|
||||
shell.Navigate(SectionKey.Jobs);
|
||||
await app.ExpectAsync<JobsView>("jobs");
|
||||
var jobs = shell.Jobs;
|
||||
|
||||
// The rail badge, the status strip and the Running chip count the same jobs.
|
||||
var running = jobs.Chips.Single(c => c.Filter == JobFilter.Running).Count;
|
||||
Assert.Greater(running, 0);
|
||||
Assert.Equal(running, jobs.Badge);
|
||||
Assert.Equal(Loc.Plural("Shell.Status.Jobs", running), shell.JobsText);
|
||||
// The capture engine starts no workers: there is no "Workers n / 0" to show.
|
||||
Assert.False(jobs.HasWorkers);
|
||||
|
||||
// Tab reaches every row button: the rows take no focus, the list passes Tab on to their content.
|
||||
var list = app.FindAll<ListBox>().Single(l => l.Name == "JobList");
|
||||
Assert.Equal(KeyboardNavigationMode.Continue, KeyboardNavigation.GetTabNavigation(list));
|
||||
var items = app.FindAll<ListBoxItem>().Where(i => i.DataContext is JobRowViewModel && i.IsVisible).ToList();
|
||||
Assert.True(items.Count > 3, "several rows are on screen");
|
||||
foreach (var item in items)
|
||||
{
|
||||
var row = (JobRowViewModel)item.DataContext;
|
||||
// A row reads as its job and state; its buttons and its log toggle name the job.
|
||||
Assert.Equal(row.AccessibleName, AutomationProperties.GetName(item));
|
||||
Assert.Equal(row.StateText, AutomationProperties.GetItemStatus(item));
|
||||
var buttons = Descendants<Button>(item).Where(b => b.IsVisible).ToList();
|
||||
Assert.True(buttons.All(b => b.Focusable && b.IsTabStop), "every row button is a tab stop");
|
||||
Assert.True(buttons.All(b => AutomationProperties.GetName(b).Contains(row.AccessibleName, StringComparison.Ordinal)), $"buttons of {row.AccessibleName} name it");
|
||||
var state = Descendants<StatusGlyph>(item).Single();
|
||||
Assert.Equal(AutomationLiveSetting.Polite, AutomationProperties.GetLiveSetting(state));
|
||||
// Right to left: numbers stay right-aligned in both reading directions.
|
||||
var percent = Descendants<TextBlock>(item).First(t => t.Text == row.PercentText);
|
||||
Assert.True(percent.FlowDirection == FlowDirection.LeftToRight && percent.TextAlignment == TextAlignment.Right, "the percentage stays right-aligned");
|
||||
}
|
||||
|
||||
// Header and rows share their columns: same padding, one actions column for all, the scroll-bar gutter kept.
|
||||
var rows = items.Select(i => (Row: (JobRowViewModel)i.DataContext, Item: i)).ToList();
|
||||
var kindHeader = Text(app, Loc.L("Jobs.Column.Kind"));
|
||||
var stateHeader = Text(app, Loc.L("Jobs.Column.State"));
|
||||
foreach (var (row, item) in rows)
|
||||
{
|
||||
Assert.Approximately(Left(kindHeader), Left(Descendants<TextBlock>(item).First(t => t.Text == row.Kind)), 1.5, $"Kind of {row.AccessibleName}");
|
||||
Assert.Approximately(Left(stateHeader), Left(Descendants<StatusGlyph>(item).Single()), 1.5, $"State of {row.AccessibleName}");
|
||||
}
|
||||
var actionColumns = rows.Select(r => Left(Descendants<ItemsControl>(r.Item).Last())).ToList();
|
||||
Assert.True(actionColumns.Max() - actionColumns.Min() < 1, "the actions column starts at the same x in every row");
|
||||
});
|
||||
|
||||
private static TextBlock Text(ScreenSmokeTests.SampleApp app, string text) => app.FindAll<TextBlock>().First(t => t.Text == text && t.IsVisible);
|
||||
|
||||
/// <summary>The left edge of an element in window coordinates.</summary>
|
||||
private static double Left(FrameworkElement element) => element.TranslatePoint(new Point(0, 0), Window.GetWindow(element)).X;
|
||||
|
||||
private static IEnumerable<T> Descendants<T>(DependencyObject node)
|
||||
where T : DependencyObject
|
||||
{
|
||||
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(node); i++)
|
||||
{
|
||||
var child = VisualTreeHelper.GetChild(node, i);
|
||||
if (child is T match) yield return match;
|
||||
foreach (var nested in Descendants<T>(child)) yield return nested;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Automation;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using Titano.App.Infrastructure;
|
||||
@@ -82,6 +84,36 @@ public sealed class ServerScreenSmokeTests
|
||||
Assert.True(rowButtons.Select(b => b.DataContext).OfType<SyncRowAction>().Count() > 3, "buttons of several rows are on screen");
|
||||
Assert.True(rowButtons.All(b => b.Focusable && b.IsTabStop), "every row button is a tab stop");
|
||||
|
||||
// Screen readers: a row reads as its sequence and state, each of the many "Upload" buttons names its sequence.
|
||||
foreach (var item in app.FindAll<ListBoxItem>().Where(i => i.DataContext is SyncRow && i.IsVisible))
|
||||
{
|
||||
var row = (SyncRow)item.DataContext;
|
||||
Assert.Equal(row.Title, AutomationProperties.GetName(item));
|
||||
Assert.Equal(row.StateText, AutomationProperties.GetItemStatus(item));
|
||||
}
|
||||
Assert.True(rowButtons.All(b => AutomationProperties.GetName(b) == ((SyncRowAction)b.DataContext).AccessibleName), "row buttons carry their row's name");
|
||||
Assert.Equal(Loc.L("Server.Sync.ActionFor", Loc.L("Server.Sync.Action.Upload"), "Clouds over the Langhe"),
|
||||
Row(table, "Clouds over the Langhe").Actions.Single().AccessibleName);
|
||||
|
||||
// The filters are a radio group: the chosen one is checked, so its state reaches screen readers.
|
||||
var chips = app.FindAll<RadioButton>().Where(r => r.DataContext is SyncFilterChip).ToList();
|
||||
Assert.Count(Enum.GetValues<SyncFilter>().Length, chips);
|
||||
Assert.True(chips.All(c => c.IsChecked == ((SyncFilterChip)c.DataContext).IsSelected), "the checked chip is the chosen filter");
|
||||
|
||||
// While connected the address is read-only text (selectable, not dimmed), kept left to right; status changes are announced.
|
||||
var address = app.FindAll<TextBox>().Single(t => t.Name == "AddressBox");
|
||||
Assert.True(address.IsEnabled && address.IsReadOnly, "the connected address is read-only, not disabled");
|
||||
Assert.Equal(FlowDirection.LeftToRight, address.FlowDirection);
|
||||
var known = app.FindAll<Button>().Single(b => b.Name == "KnownButton");
|
||||
Assert.False(string.IsNullOrEmpty(AutomationProperties.GetName(known)), "the icon-only button has a name");
|
||||
Assert.True(ToolTipService.GetShowOnDisabled(known), "a disabled ▾ still says why");
|
||||
Assert.Equal(AutomationLiveSetting.Polite, AutomationProperties.GetLiveSetting(
|
||||
app.FindAll<StatusGlyph>().First(g => g.IsVisible && g.Text == shell.Server.StatusText)));
|
||||
|
||||
// The web admin admits administrators only: the sample user is an editor.
|
||||
Assert.False(table.CanOpenAdmin);
|
||||
Assert.False(app.FindAll<Button>().Any(b => b.Content as string == Loc.L("Server.Sync.OpenAdmin") && b.IsVisible), "no admin link for an editor");
|
||||
|
||||
// Transfers in every state: the rows show what moves and offer Pause or Resume.
|
||||
await app.Sample.FillSyncAsync();
|
||||
await table.ReloadAsync();
|
||||
@@ -104,9 +136,22 @@ public sealed class ServerScreenSmokeTests
|
||||
Assert.Equal("Holy grail · Monviso", Assert.Contains(table.Rows, _ => true).Title);
|
||||
Assert.Count(1, table.Rows);
|
||||
await app.ExpectAsync<ServerView>("server-conflict");
|
||||
|
||||
// One row, no scrolling: the header still lines up with the cells (same padding, constant scroll-bar gutter).
|
||||
var only = table.Rows[0];
|
||||
Assert.Approximately(Left(Text(app, Loc.L("Server.Sync.Column.Local"))), Left(Text(app, only.LocalText)), 1.5, "This PC column");
|
||||
Assert.Approximately(Left(Text(app, Loc.L("Server.Sync.Column.State"))),
|
||||
Left(app.FindAll<StatusGlyph>().First(g => g.DataContext == only && g.IsVisible)), 1.5, "State column");
|
||||
|
||||
// No match: one sentence and its one action, which shows every sequence again.
|
||||
table.SearchText = "nothing like this";
|
||||
Assert.False(table.HasRows);
|
||||
Assert.NotNull(table.EmptyText);
|
||||
Assert.Equal(SyncEmpty.NoMatch, table.Empty);
|
||||
table.ClearFiltersCommand.Execute(null);
|
||||
Assert.Equal(string.Empty, table.SearchText);
|
||||
Assert.True(Chip(table, SyncFilter.All).IsSelected);
|
||||
Assert.Equal(Chip(table, SyncFilter.All).Count, table.Rows.Count);
|
||||
|
||||
// Another language relabels chips and rows at once.
|
||||
UiLanguage.Apply("it");
|
||||
@@ -137,12 +182,23 @@ public sealed class ServerScreenSmokeTests
|
||||
|
||||
Assert.False(shell.Server.Sync.IsActive);
|
||||
Assert.False(shell.Server.Sync.HasRows);
|
||||
Assert.Equal(SyncEmpty.SignedOut, shell.Server.Sync.Empty);
|
||||
Assert.False(shell.Server.Sync.UploadAllCommand.CanExecute(null));
|
||||
Assert.Equal(Loc.L("Tooltips.Server.Sync.UploadAll.NotConnected"), shell.Server.Sync.UploadAllToolTip);
|
||||
shell.Navigate(SectionKey.Server);
|
||||
await app.ExpectAsync<ServerView>("server-signedout-table");
|
||||
|
||||
// Nothing to filter while signed out: chips and search give way to the one action, Connect.
|
||||
Assert.False(app.FindAll<RadioButton>().Any(r => r.DataContext is SyncFilterChip && r.IsVisible), "no filter chips while signed out");
|
||||
Assert.False(app.FindAll<TextBox>().Any(t => AutomationProperties.GetName(t) == Loc.L("Server.Sync.Search") && t.IsVisible), "no search while signed out");
|
||||
Assert.True(app.FindAll<Button>().Any(b => b.Content as string == Loc.L("Server.Connect") && b.IsVisible), "the empty table offers Connect");
|
||||
});
|
||||
|
||||
private static TextBlock Text(ScreenSmokeTests.SampleApp app, string text) => app.FindAll<TextBlock>().First(t => t.Text == text && t.IsVisible);
|
||||
|
||||
/// <summary>The left edge of an element in window coordinates.</summary>
|
||||
private static double Left(FrameworkElement element) => element.TranslatePoint(new Point(0, 0), Window.GetWindow(element)).X;
|
||||
|
||||
private static SyncFilterChip Chip(SyncTableViewModel table, SyncFilter filter) => table.Chips.Single(c => c.Filter == filter);
|
||||
|
||||
private static SyncRow Row(SyncTableViewModel table, string title) => table.Rows.Single(r => r.Title == title);
|
||||
|
||||
@@ -0,0 +1,195 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Automation;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using Titano.App.Infrastructure;
|
||||
using Titano.App.Sections;
|
||||
using Titano.App.Server;
|
||||
using Titano.App.Settings;
|
||||
using Titano.App.Shell;
|
||||
using Titano.App.Tests.Windows;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Testing;
|
||||
|
||||
namespace Titano.App.Tests.Settings;
|
||||
|
||||
/// <summary>
|
||||
/// Settings, the first-run dialog and the reading direction on the capture sample: values other screens set, labels and
|
||||
/// paths that survive long translations and right-to-left text, keyboard focus and the questions before forgetting.
|
||||
/// </summary>
|
||||
[WindowsOnly]
|
||||
[Serial]
|
||||
[Timeout(300_000)]
|
||||
public sealed class SettingsScreenSmokeTests
|
||||
{
|
||||
[Test]
|
||||
public Task SettingsShowCurrentValuesAndNeverCutLabelsOrRows() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
var shell = app.Shell;
|
||||
await app.Sample.FillAsync();
|
||||
await shell.Services.Server.RestoreAsync();
|
||||
var settings = shell.Settings;
|
||||
|
||||
// The open archive and the server connected to were set after Settings was built: it shows them when opened.
|
||||
shell.Navigate(SectionKey.Settings);
|
||||
Assert.Equal(@"D:\TitanoArchive", settings.ArchiveRoot.Text);
|
||||
Assert.Equal("https://nas.local:8443", settings.DefaultServer.Text);
|
||||
Assert.False(settings.ArchiveRoot.IsDirty || settings.DefaultServer.IsDirty, "values loaded, not edits");
|
||||
|
||||
// The section list shows where keyboard focus is.
|
||||
await app.ExpectAsync<SettingsView>("settings-general");
|
||||
Assert.True(app.FindAll<ListBoxItem>().Where(i => i.DataContext is SettingsPageItem).All(i => i.FocusVisualStyle is not null), "sections have a focus ring");
|
||||
|
||||
// At the minimum window width the cache folder row stays one line: Clear beside the path, not under it.
|
||||
settings.Page = SettingsPage.Storage;
|
||||
await app.ExpectAsync<SettingsView>("settings-storage");
|
||||
var window = Window.GetWindow(app.FindAll<SettingsView>().First(v => v.IsVisible));
|
||||
var width = window.Width;
|
||||
window.Width = 1200;
|
||||
window.UpdateLayout();
|
||||
var cache = Field(app, Loc.L("Settings.Storage.Folder"));
|
||||
var clear = app.FindAll<Button>().First(b => b.Content as string == Loc.L("Settings.Storage.Clear") && b.IsVisible);
|
||||
Assert.Approximately(Middle(cache), Middle(clear), 2, "Clear is on the path's line");
|
||||
Assert.Equal(FlowDirection.LeftToRight, cache.FlowDirection);
|
||||
window.Width = width;
|
||||
|
||||
// Long translations are never cut: German labels show whole (or wrap) in the shared label column.
|
||||
UiLanguage.Apply("de");
|
||||
try
|
||||
{
|
||||
await app.ExpectAsync<SettingsView>("settings-storage-de");
|
||||
foreach (var label in Labels(app)) Assert.True(IsWhole(label), $"\"{label.Text}\" is shown whole");
|
||||
}
|
||||
finally
|
||||
{
|
||||
UiLanguage.Apply("en");
|
||||
}
|
||||
|
||||
// Auto values are text with their reason in the tooltip, not buttons that do nothing.
|
||||
settings.Page = SettingsPage.Rendering;
|
||||
await app.ExpectAsync<SettingsView>("settings-rendering");
|
||||
Assert.False(app.FindAll<Button>().Any(b => b.Content is string text && (text == settings.MemoryAutoText || text == settings.ParallelismAutoText)), "no dead Auto buttons");
|
||||
|
||||
// Paths, addresses and fingerprints read left to right; read-only paths show whole in their tooltip.
|
||||
settings.Page = SettingsPage.Advanced;
|
||||
await app.ExpectAsync<SettingsView>("settings-advanced");
|
||||
var data = Field(app, Loc.L("Settings.Advanced.DataFolder"));
|
||||
Assert.Equal(FlowDirection.LeftToRight, data.FlowDirection);
|
||||
Assert.Equal(settings.DataFolder, data.ToolTip);
|
||||
// Advanced has nothing to reset: no Reset section there.
|
||||
Assert.False(settings.CanResetSection);
|
||||
Assert.False(settings.ResetSectionCommand.CanExecute(null));
|
||||
Assert.False(app.FindAll<Button>().Any(b => b.Content as string == Loc.L("Settings.ResetSection") && b.IsVisible), "no Reset section on Advanced");
|
||||
|
||||
// Forgetting a trusted certificate asks first, as on the Server screen; a "no" keeps it and the session.
|
||||
settings.Page = SettingsPage.Server;
|
||||
await app.ExpectAsync<SettingsView>("settings-server");
|
||||
Assert.True(settings.CanResetSection);
|
||||
Assert.Equal(FlowDirection.LeftToRight, Field(app, Loc.L("Settings.Server.Default")).FlowDirection);
|
||||
var certificate = Assert.Contains(settings.Certificates, _ => true);
|
||||
Assert.Contains(certificate.Server, certificate.ForgetName);
|
||||
certificate.ForgetCommand.Execute(null);
|
||||
Assert.Count(1, settings.Certificates);
|
||||
Assert.True(shell.Server.IsConnected, "the session on the certificate stays");
|
||||
Assert.True(ServerSession.ForgetRequest(certificate.FullFingerprint).IsDestructive);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task TheFirstRunDialogKeepsTheKeyboardInside() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
app.Shell.ShowWelcome();
|
||||
await app.ExpectAsync<WelcomeView>("welcome");
|
||||
|
||||
var welcome = app.FindAll<WelcomeView>().First(v => v.IsVisible);
|
||||
var dialog = (FrameworkElement)welcome.Content;
|
||||
Assert.Equal(KeyboardNavigationMode.Cycle, KeyboardNavigation.GetTabNavigation(dialog));
|
||||
Assert.Equal(KeyboardNavigationMode.Cycle, KeyboardNavigation.GetControlTabNavigation(dialog));
|
||||
Assert.Equal(KeyboardNavigationMode.Contained, KeyboardNavigation.GetDirectionalNavigation(dialog));
|
||||
// It opens with focus on the chosen card (a local archive by default).
|
||||
var focused = FocusManager.GetFocusedElement(Window.GetWindow(welcome)) as RadioButton;
|
||||
Assert.NotNull(focused, "a card has focus");
|
||||
Assert.True(focused.IsChecked == true && welcome.IsAncestorOf(focused), "the chosen card of the dialog has focus");
|
||||
// The logo is not mirrored in right-to-left languages.
|
||||
Assert.True(app.FindAll<Titano.Ui.Controls.BrandMarkIcon>().Where(b => b.IsVisible).All(b => b.FlowDirection == FlowDirection.LeftToRight));
|
||||
app.Shell.CompleteWelcome();
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task ARightToLeftLanguageMirrorsEveryWindowAlsoThoseOpenedLater() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
app.Shell.About.SetResult(null);
|
||||
app.Shell.Navigate(SectionKey.About);
|
||||
await app.ExpectAsync<AboutView>("about");
|
||||
var main = Window.GetWindow(app.FindAll<AboutView>().First(v => v.IsVisible));
|
||||
Assert.Equal(FlowDirection.LeftToRight, main.FlowDirection);
|
||||
|
||||
UiLanguage.Apply("ar");
|
||||
var dialog = new Window
|
||||
{
|
||||
WindowStartupLocation = WindowStartupLocation.Manual,
|
||||
Left = -20000,
|
||||
Top = -20000,
|
||||
Width = 320,
|
||||
Height = 200,
|
||||
ShowActivated = false,
|
||||
ShowInTaskbar = false,
|
||||
};
|
||||
try
|
||||
{
|
||||
Assert.Equal(FlowDirection.RightToLeft, main.FlowDirection);
|
||||
dialog.Show();
|
||||
await dialog.Dispatcher.InvokeAsync(() => { }, DispatcherPriority.ApplicationIdle);
|
||||
Assert.Equal(FlowDirection.RightToLeft, dialog.FlowDirection, "a window opened after the switch (a dialog) is mirrored too");
|
||||
await app.ExpectAsync<AboutView>("about-ar");
|
||||
|
||||
// Inside the mirrored window, paths and the logo keep their left-to-right order.
|
||||
var path = app.FindAll<TextBlock>().First(t => t.IsVisible && t.Text == app.Shell.About.DataFolder);
|
||||
Assert.Equal(FlowDirection.LeftToRight, path.FlowDirection);
|
||||
Assert.Equal(app.Shell.About.DataFolder, path.ToolTip);
|
||||
// The update result is a live region: screen readers hear each new state.
|
||||
var update = app.FindAll<Titano.Ui.Controls.StatusGlyph>().First(g => g.IsVisible && g.Text == app.Shell.About.UpdateText);
|
||||
Assert.Equal(AutomationLiveSetting.Polite, AutomationProperties.GetLiveSetting(update));
|
||||
Assert.Equal(app.Shell.About.UpdateAnnouncement, AutomationProperties.GetName(update));
|
||||
}
|
||||
finally
|
||||
{
|
||||
dialog.Close();
|
||||
UiLanguage.Apply("en");
|
||||
}
|
||||
Assert.Equal(FlowDirection.LeftToRight, main.FlowDirection);
|
||||
});
|
||||
|
||||
private static TextBox Field(ScreenSmokeTests.SampleApp app, string name) =>
|
||||
app.FindAll<TextBox>().First(t => t.IsVisible && AutomationProperties.GetName(t) == name);
|
||||
|
||||
private static double Middle(FrameworkElement element) =>
|
||||
element.TranslatePoint(new Point(0, element.ActualHeight / 2), Window.GetWindow(element)).Y;
|
||||
|
||||
/// <summary>The label of every visible Settings row (the first text of the row template).</summary>
|
||||
private static IEnumerable<TextBlock> Labels(ScreenSmokeTests.SampleApp app) =>
|
||||
app.FindAll<HeaderedContentControl>().Where(h => h.IsVisible).Select(h => Descendants<TextBlock>(h).First());
|
||||
|
||||
/// <summary>The label's text fits its width on one line, or wraps onto more lines; never trimmed.</summary>
|
||||
private static bool IsWhole(TextBlock label)
|
||||
{
|
||||
var probe = new TextBlock { Text = label.Text, FontFamily = label.FontFamily, FontSize = label.FontSize, FontWeight = label.FontWeight };
|
||||
probe.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
|
||||
return label.TextTrimming == TextTrimming.None || probe.DesiredSize.Width <= label.ActualWidth + 0.5;
|
||||
}
|
||||
|
||||
private static IEnumerable<T> Descendants<T>(DependencyObject node)
|
||||
where T : DependencyObject
|
||||
{
|
||||
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(node); i++)
|
||||
{
|
||||
var child = VisualTreeHelper.GetChild(node, i);
|
||||
if (child is T match) yield return match;
|
||||
foreach (var nested in Descendants<T>(child)) yield return nested;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user