merge: Server, Jobs, Settings, About and Welcome after the visual, accessibility and RTL review
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
40 files changed
+1314
-323
No files matched your search
@@ -167,6 +167,31 @@ public sealed class JobListModelTests
|
||||
Assert.Equal("done · 3:00", JobText.State(done));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheWorkersReadoutCountsOnlyJobsOfThisPc()
|
||||
{
|
||||
var model = new JobListModel();
|
||||
model.Apply(Job(JobState.Running, started: -1) with { NodeId = "STUDIO#0" });
|
||||
model.Apply(Job(JobState.Running, started: -2) with { NodeId = "studio#3" });
|
||||
model.Apply(Job(JobState.Running, started: -3) with { NodeId = "render-box#0" });
|
||||
model.Apply(Job(JobState.Running, started: -4));
|
||||
model.Apply(Job(JobState.Done, started: -9, finished: -8) with { NodeId = "studio#1" });
|
||||
|
||||
Assert.Equal(4, model.RunningCount);
|
||||
Assert.Equal(2, model.RunningOn("studio"));
|
||||
Assert.True(JobText.IsLocal("studio#2", "STUDIO"));
|
||||
Assert.False(JobText.IsLocal("studio-2", "studio"));
|
||||
Assert.False(JobText.IsLocal(null, "studio"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RowsAreNamedByKindAndTarget()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
Assert.Equal("Render · Harbour sunset", JobText.Name(Job(JobState.Running, kind: JobKind.Render, label: "Harbour sunset")));
|
||||
Assert.Equal("Proxies", JobText.Name(Job(JobState.Queued)));
|
||||
}
|
||||
|
||||
private static Job Job(JobState state, int created = 0, int? started = null, int? finished = null, JobPriority priority = JobPriority.Normal,
|
||||
JobKind kind = JobKind.Proxies, string? label = null, long done = 0, long total = 0) => new()
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -153,6 +153,24 @@ public sealed class SyncTextTests
|
||||
Assert.Equal(0, rows.Count(r => SyncText.Matches(r, SyncFilter.Conflicts, "comet")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ATransferCountsWhereItsOriginalsAre()
|
||||
{
|
||||
var uploadNotOnServer = Entry(SyncStatus.Transferring, transfer: Upload(JobState.Queued)) with { Link = null };
|
||||
var download = new Job { Id = Guid.CreateVersion7(), Kind = JobKind.Download, State = JobState.Running };
|
||||
var downloadNotHere = Entry(SyncStatus.Transferring, transfer: download) with { Local = null };
|
||||
var uploadOnBoth = Entry(SyncStatus.Transferring, transfer: Upload(JobState.Running));
|
||||
|
||||
Assert.True(SyncText.Matches(uploadNotOnServer, SyncFilter.LocalOnly, string.Empty));
|
||||
Assert.False(SyncText.Matches(uploadNotOnServer, SyncFilter.Remote, string.Empty));
|
||||
Assert.True(SyncText.Matches(downloadNotHere, SyncFilter.Remote, string.Empty));
|
||||
Assert.False(SyncText.Matches(downloadNotHere, SyncFilter.LocalOnly, string.Empty));
|
||||
// Partly on both sides: neither "only here" nor "only on the server".
|
||||
Assert.False(SyncText.Matches(uploadOnBoth, SyncFilter.LocalOnly, string.Empty));
|
||||
Assert.False(SyncText.Matches(uploadOnBoth, SyncFilter.Remote, string.Empty));
|
||||
Assert.True(SyncText.Matches(uploadOnBoth, SyncFilter.All, string.Empty));
|
||||
}
|
||||
|
||||
private static (StatusKind, string) Kind(SyncEntry entry)
|
||||
{
|
||||
var (kind, text, _) = SyncText.State(entry);
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.IO;
|
||||
using Titano.App.Settings;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Core.Naming;
|
||||
using Titano.Core.Video;
|
||||
using Titano.Testing;
|
||||
|
||||
namespace Titano.App.Tests.Settings;
|
||||
@@ -132,6 +133,37 @@ public sealed class SettingsLogicTests
|
||||
Assert.Equal("en", LanguageCatalog.Match(CultureInfo.GetCultureInfo("sw")).Code);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EachEncoderNamesThePresetsItServes()
|
||||
{
|
||||
var hevc = new EncoderRow("HEVC", "NVIDIA HEVC Encoder MFT", "NVIDIA", EncoderSource.MediaFoundation, true, true, 8192, 8192, VideoCodec.Hevc);
|
||||
var av1 = hevc with { Codec = "AV1", Name = "NVIDIA AV1 Encoder MFT", VideoCodec = VideoCodec.Av1 };
|
||||
var h264 = new EncoderRow("H.264", "H264 Encoder MFT", "Microsoft", EncoderSource.MediaFoundation, false, false, 4096, 2304, VideoCodec.H264);
|
||||
var animation = new EncoderRow("GIF · APNG", "Titano", null, EncoderSource.BuiltInAnimation, false, false, 0, 0, null);
|
||||
|
||||
Assert.SequenceEqual(["8K archive", "4K archive", "4K HEVC", "DCI 4K", "Cinema 21:9", "4K 60 fps"], EncoderUse.Presets(hevc));
|
||||
Assert.Equal("Animated GIF · Animated PNG", EncoderUse.Text(animation));
|
||||
Assert.Contains("Share 1080p", EncoderUse.Presets(h264));
|
||||
Assert.Equal("4K AV1", EncoderUse.Text(av1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ARenderNodeOffersHardwareEncodersOnlyWhenRendersMayUseThem()
|
||||
{
|
||||
EncoderRow[] rows =
|
||||
[
|
||||
new("HEVC", "NVIDIA HEVC Encoder MFT", "NVIDIA", EncoderSource.MediaFoundation, true, true, 8192, 8192, VideoCodec.Hevc),
|
||||
new("H.264", "NVIDIA H.264 Encoder MFT", "NVIDIA", EncoderSource.MediaFoundation, true, false, 4096, 4096, VideoCodec.H264),
|
||||
new("H.264", "H264 Encoder MFT", "Microsoft", EncoderSource.MediaFoundation, false, false, 4096, 2304, VideoCodec.H264),
|
||||
new("MJPEG · AVI", "Titano", null, EncoderSource.BuiltInMjpeg, false, false, 0, 0, VideoCodec.Mjpeg),
|
||||
];
|
||||
|
||||
Assert.Equal("HEVC · H.264", EncoderUse.Codecs(EncoderUse.Node(rows, allowsHardware: true)));
|
||||
Assert.Equal(3, EncoderUse.Node(rows, allowsHardware: true).Count);
|
||||
Assert.Equal("H.264", EncoderUse.Codecs(EncoderUse.Node(rows, allowsHardware: false)));
|
||||
Assert.Null(EncoderUse.Codecs([]));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EnumDrivenKeysExistInEveryRequiredLanguage()
|
||||
{
|
||||
|
||||
@@ -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