feat: wider rail and admin sidebar that collapse to icons
Owner review 1, phase 3a (docs/requests/2026-10-15-owner-review-1.md, R1). The desktop rail is 200 px wide, so the section names fit in every language, and collapses to 48 px of icons with its ≡ button or Ctrl+B. Collapsed, each icon's tooltip names its section before saying what it is for, while screen readers keep the name and the description. The choice is written to the settings file the moment it changes (nothing else restarts) and survives Settings › Reset all and Import; Ctrl+B waits behind the first-run dialog like Ctrl+1…6, and a held key toggles once. The admin panel's sidebar is 256 px and collapses to icons the same way, with its own ≡ button or Ctrl+B (on the physical key where the layout's B types no Latin letter, so Cyrillic, Greek, Hebrew and Arabic layouts work). The choice is kept in the browser, for the page when the browser refuses storage, and the tables fit their columns again after each toggle. At 900 px and below it stays the top bar and Ctrl+B stays the browser's. The wider rail leaves 49-72 px less for every screen at the 1200 px minimum. Six adversarial review rounds found what that cut, and in every shipped language no action is cut off now: the Jobs columns share their width (Target and Progress give way first, Kind/Where/State capped on wide windows), the editor's preview tools take a second line, a server job's Cancel has its own header column, the Archive tree keeps a year's label, the Import rows and result, the certificates and cache rows and the frame table fit. Headers, titles and cells that may be shortened end in an ellipsis and show their text in their tooltip; state tooltips start with the state, and their explanations were reworded not to repeat it (a queued job "waits for its turn", jobs running one at a time). The crop-result tool sits beside Crop mask, disabled with its reason while the mask is off. Tests check these rows in all 38 languages at 1200 px; the App test program now shuts WPF down in order, so its exit no longer crashes after every test passed. Phase 3 lands as two commits: R7 (the Edit section) edits the same shell files and follows. Also updates BRIEF (12.1, 14.8, 24), DECISIONS, CHANGELOG, STATUS, the request file, DESIGN and the mockups; every new or reworded string is in all 38 languages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
43b6871cdc
commit
4ea44bb917
131 files changed
+1458
-670
No files matched your search
@@ -310,6 +310,9 @@ public sealed class ArchiveLogicTests
|
||||
Assert.Equal(StatusKind.Running, recent[0].StateKind);
|
||||
Assert.Equal(JobState.Done, recent[1].State);
|
||||
Assert.Equal(StatusKind.Done, recent[1].StateKind, "a finished run is a green dot, a failed one a red cross");
|
||||
// The row shows a running job's percentage, so its tooltip names the state first; a finished one has no run time to explain.
|
||||
Assert.Equal(string.Join(Loc.Separator, Loc.L("Jobs.State.Running"), Loc.L("Tooltips.Jobs.State.Running")), recent[0].StateToolTip);
|
||||
Assert.Equal(Loc.L("Jobs.State.Done"), recent[1].StateToolTip);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -254,6 +254,83 @@ public sealed class ArchiveScreenSmokeTests
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Beside the 200 px rail at the 1200 px minimum (owner review 1, R1), in every shipped language: a year row shows its year
|
||||
/// whole (its figures give way, and stay inside the row).
|
||||
/// </summary>
|
||||
[Test]
|
||||
public Task YearRowsKeepTheirYearAtTheMinimumWidthInEveryLanguage() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
await app.Sample.FillAsync();
|
||||
await ArchiveScenes.ShowAsync(app.Shell, "overview");
|
||||
var window = app.Window;
|
||||
window.Width = 1200;
|
||||
window.Height = 788;
|
||||
try
|
||||
{
|
||||
foreach (var language in Languages.Shipped)
|
||||
{
|
||||
UiLanguage.Apply(language);
|
||||
window.UpdateLayout();
|
||||
await window.Dispatcher.InvokeAsync(() => { }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
|
||||
var years = TreeItems(app).Where(i => ((ArchiveTreeRowViewModel)i.DataContext).IsYear).ToList();
|
||||
Assert.True(years.Count > 0, $"{language}: year rows show");
|
||||
foreach (var item in years)
|
||||
{
|
||||
var row = (ArchiveTreeRowViewModel)item.DataContext;
|
||||
var texts = Descendants<TextBlock>(item).Where(t => t.IsVisible).ToList();
|
||||
var title = texts.Single(t => t.Text == row.Title);
|
||||
// A copy with the same font, measured by the same layout engine, needs no more room than the year got (layout
|
||||
// rounding aside: a cut year keeps barely half of it).
|
||||
var probe = new TextBlock
|
||||
{
|
||||
Text = title.Text,
|
||||
FontFamily = title.FontFamily,
|
||||
FontSize = title.FontSize,
|
||||
FontStyle = title.FontStyle,
|
||||
FontWeight = title.FontWeight,
|
||||
FontStretch = title.FontStretch,
|
||||
FlowDirection = title.FlowDirection,
|
||||
Language = title.Language,
|
||||
};
|
||||
TextOptions.SetTextFormattingMode(probe, TextOptions.GetTextFormattingMode(title));
|
||||
probe.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
|
||||
Assert.True(probe.DesiredSize.Width <= title.ActualWidth + 1, $"{language}: the year '{row.Title}' is cut ({title.ActualWidth:0} of {probe.DesiredSize.Width:0} px)");
|
||||
var (left, right) = Span(item, window);
|
||||
foreach (var text in texts)
|
||||
{
|
||||
var (start, end) = Span(text, window);
|
||||
Assert.True(start >= left - 0.5 && end <= right + 0.5, $"{language}: '{text.Text}' spans {start:0}–{end:0} px, its row {left:0}–{right:0} px");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
UiLanguage.Apply("en");
|
||||
}
|
||||
});
|
||||
|
||||
/// <summary>The left and right edges of an element in window coordinates, whichever way the window reads.</summary>
|
||||
private static (double Left, double Right) Span(FrameworkElement element, Window window)
|
||||
{
|
||||
var a = element.TranslatePoint(new Point(0, 0), window).X;
|
||||
var b = element.TranslatePoint(new Point(element.ActualWidth, 0), window).X;
|
||||
return (Math.Min(a, b), Math.Max(a, b));
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A dialog that has not failed shows no error line.</summary>
|
||||
private static void AssertNoErrorShown(ScreenSmokeTests.SampleApp app) =>
|
||||
Assert.False(app.FindAll<StatusGlyph>().Any(g => g.IsVisible && g.Kind == StatusKind.Error && IsInArchive(g)), "no error state before anything failed");
|
||||
|
||||
@@ -330,6 +330,165 @@ public sealed class EditorSmokeTests
|
||||
}
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// At the 1200 px minimum beside the 200 px rail (owner review 1, R1), the preview's tools stay inside the preview in
|
||||
/// every language, crop mask on (the crop-result tool enabled): they take a second line rather than lose Play and Full screen.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public Task ThePreviewToolsStayInsideThePreviewInEveryLanguage() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
app.Window.Width = 1200;
|
||||
app.Window.Height = 788;
|
||||
var id = await app.Sample.FillEditorAsync();
|
||||
app.Shell.OpenSequence(id);
|
||||
await app.Shell.Sequence.OpenAsync(id);
|
||||
var editor = Assert.NotNull(app.Shell.Sequence.Editor);
|
||||
try
|
||||
{
|
||||
editor.SelectedTab = editor.Exposure;
|
||||
editor.ShowCropMask = true;
|
||||
foreach (var language in Languages.Shipped)
|
||||
{
|
||||
UiLanguage.Apply(language);
|
||||
await SettleAsync(app.Window);
|
||||
var viewport = Find<PreviewViewport>(app.Window).Single(v => v.IsVisible);
|
||||
var (left, right) = Span(viewport, app.Window);
|
||||
var tools = Find<System.Windows.Controls.Primitives.ButtonBase>(viewport).Where(b => b.IsVisible).ToList();
|
||||
Assert.True(tools.Count >= 8, $"{language}: every tool shows ({tools.Count})");
|
||||
foreach (var tool in tools)
|
||||
{
|
||||
var (start, end) = Span(tool, app.Window);
|
||||
Assert.True(start >= left - 0.5 && end <= right + 0.5,
|
||||
$"{language}: the tool '{System.Windows.Automation.AutomationProperties.GetName(tool)}{tool.Content}' spans {start:0}–{end:0} px, the preview {left:0}–{right:0} px");
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
UiLanguage.Apply("en");
|
||||
await app.Shell.Sequence.CloseAsync();
|
||||
}
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// At the 1200 px minimum beside the 200 px rail (owner review 1, R1), a server sequence's job keeps its Cancel whole in every
|
||||
/// language, also read-only (the longest place line): the title and the summary give way first (BRIEF §11.5, cancel always stays).
|
||||
/// </summary>
|
||||
[Test]
|
||||
public Task AServerJobKeepsItsCancelAtTheMinimumWidthInEveryLanguage() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
app.Window.Width = 1200;
|
||||
app.Window.Height = 788;
|
||||
await app.Sample.FillAsync();
|
||||
await app.Services.Server.RestoreAsync();
|
||||
await app.Services.Sync.RefreshAsync();
|
||||
await app.Sample.CacheProxiesAsync();
|
||||
await app.Sample.RestrictAccountAsync();
|
||||
var id = app.Sample.ProxiedSequenceId;
|
||||
app.Shell.OpenSequence(id);
|
||||
await app.Shell.Sequence.OpenAsync(id);
|
||||
var editor = Assert.NotNull(app.Shell.Sequence.Editor);
|
||||
try
|
||||
{
|
||||
Assert.True(editor.IsReadOnly, "the account may not edit");
|
||||
app.Sample.RunServerRender();
|
||||
await editor.AttachJobsAsync();
|
||||
Assert.NotNull(editor.ServerJobText, "the server's render shows");
|
||||
foreach (var language in Languages.Shipped)
|
||||
{
|
||||
UiLanguage.Apply(language);
|
||||
await SettleAsync(app.Window);
|
||||
var cancel = Find<Button>(app.Window).Single(b => b.IsVisible && ReferenceEquals(b.Command, editor.CancelServerJobCommand));
|
||||
// Drawn whole: its left edge, its middle and its right edge each take the pointer (a layout clip would not).
|
||||
foreach (var x in new[] { 2.0, cancel.ActualWidth / 2, cancel.ActualWidth - 2 })
|
||||
{
|
||||
var point = cancel.TranslatePoint(new Point(x, cancel.ActualHeight / 2), app.Window);
|
||||
Assert.True(app.Window.InputHitTest(point) is DependencyObject hit && IsWithin(hit, cancel),
|
||||
$"{language}: Cancel is cut at {x:0} px of its {cancel.ActualWidth:0}");
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
UiLanguage.Apply("en");
|
||||
app.Sample.EndServerJobs();
|
||||
await app.Shell.Sequence.CloseAsync();
|
||||
}
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// At the 1200 px minimum beside the 200 px rail (owner review 1, R1), the frame table's Time column holds the widest time
|
||||
/// of every shipped language (two-digit hours, morning and afternoon marks).
|
||||
/// </summary>
|
||||
[Test]
|
||||
public Task TheFrameTableShowsWholeTimesInEveryLanguage() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
app.Window.Width = 1200;
|
||||
app.Window.Height = 788;
|
||||
var id = await app.Sample.FillEditorAsync();
|
||||
app.Shell.OpenSequence(id);
|
||||
await app.Shell.Sequence.OpenAsync(id);
|
||||
var editor = Assert.NotNull(app.Shell.Sequence.Editor);
|
||||
try
|
||||
{
|
||||
editor.SelectedTab = editor.Frames;
|
||||
var times = new[] { new DateTime(2026, 1, 1, 12, 59, 59), new DateTime(2026, 1, 1, 22, 58, 48), new DateTime(2026, 1, 1, 10, 48, 58) };
|
||||
foreach (var language in Languages.Shipped)
|
||||
{
|
||||
UiLanguage.Apply(language);
|
||||
await SettleAsync(app.Window);
|
||||
var cell = Find<TextBlock>(app.Window).First(t => t.IsVisible && t.DataContext is FrameRow row && row.Time.Length > 0 && t.Text == row.Time);
|
||||
var widest = times.Max(t => Measure(cell, t.ToString("T", Loc.Culture)));
|
||||
Assert.True(widest <= cell.ActualWidth + 1, $"{language}: the widest time needs {widest:0} px, the column gives {cell.ActualWidth:0}");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
UiLanguage.Apply("en");
|
||||
await app.Shell.Sequence.CloseAsync();
|
||||
}
|
||||
});
|
||||
|
||||
/// <summary>The width <paramref name="text"/> needs in the font, numerals and formatting of <paramref name="like"/>.</summary>
|
||||
private static double Measure(TextBlock like, string text)
|
||||
{
|
||||
var probe = new TextBlock
|
||||
{
|
||||
Text = text,
|
||||
FontFamily = like.FontFamily,
|
||||
FontSize = like.FontSize,
|
||||
FontStyle = like.FontStyle,
|
||||
FontWeight = like.FontWeight,
|
||||
FontStretch = like.FontStretch,
|
||||
FlowDirection = like.FlowDirection,
|
||||
Language = like.Language,
|
||||
};
|
||||
System.Windows.Documents.Typography.SetNumeralAlignment(probe, System.Windows.Documents.Typography.GetNumeralAlignment(like));
|
||||
TextOptions.SetTextFormattingMode(probe, TextOptions.GetTextFormattingMode(like));
|
||||
probe.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
|
||||
return probe.DesiredSize.Width;
|
||||
}
|
||||
|
||||
private static bool IsWithin(DependencyObject node, DependencyObject ancestor)
|
||||
{
|
||||
for (var at = node; at is not null; at = VisualTreeHelper.GetParent(at))
|
||||
{
|
||||
if (ReferenceEquals(at, ancestor)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>The left and right edges of an element in window coordinates, whichever way the window reads.</summary>
|
||||
private static (double Left, double Right) Span(FrameworkElement element, Window window)
|
||||
{
|
||||
var a = element.TranslatePoint(new Point(0, 0), window).X;
|
||||
var b = element.TranslatePoint(new Point(element.ActualWidth, 0), window).X;
|
||||
return (Math.Min(a, b), Math.Max(a, b));
|
||||
}
|
||||
|
||||
/// <summary>The measuring tool of each section has content.</summary>
|
||||
private static void ExpectMeasure(SequenceView view, EditorTab tab)
|
||||
{
|
||||
|
||||
@@ -300,6 +300,72 @@ public sealed class ImportScreenSmokeTests
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Beside the 200 px rail at the 1200 px minimum (owner review 1, R1), in every shipped language: the session rows' Merge and the
|
||||
/// plan rows' Split stay inside their rows (shown or not yet revealed), and the result line inside its card.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public Task RowButtonsAndTheResultFitAtTheMinimumWidthInEveryLanguage() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
await app.Sample.FillAsync();
|
||||
foreach (var (state, list) in new[] { ("plan", "SessionRows"), ("showplan", "PlanRows") })
|
||||
{
|
||||
await ShowAsync(app, state);
|
||||
await UseCaptureSizeAsync(app);
|
||||
await InEveryLanguageAsync(app, language =>
|
||||
{
|
||||
var rows = Named<ListBox>(app, list);
|
||||
var viewport = Descendants(rows).OfType<ScrollContentPresenter>().First();
|
||||
var (left, right) = Span(viewport, WindowOf(app));
|
||||
foreach (var button in Descendants(rows).OfType<Button>().Where(b => b.Visibility != Visibility.Collapsed && b.ActualWidth > 0))
|
||||
{
|
||||
var (start, end) = Span(button, WindowOf(app));
|
||||
Assert.True(start >= left - 0.5 && end <= right + 0.5, $"{language} {state}: '{button.Content}' spans {start:0}–{end:0} px, its rows {left:0}–{right:0} px");
|
||||
}
|
||||
});
|
||||
}
|
||||
await ShowAsync(app, "done");
|
||||
await UseCaptureSizeAsync(app);
|
||||
await InEveryLanguageAsync(app, language =>
|
||||
{
|
||||
var result = app.FindAll<StatusGlyph>().First(g => g.IsVisible && g.DataContext is ImportResultViewModel && IsInImport(g));
|
||||
var line = (FrameworkElement)VisualTreeHelper.GetParent(result);
|
||||
var card = (FrameworkElement)VisualTreeHelper.GetParent(line);
|
||||
var (left, right) = Span(card, WindowOf(app));
|
||||
foreach (var text in Descendants(line).OfType<TextBlock>().Where(t => t.IsVisible))
|
||||
{
|
||||
var (start, end) = Span(text, WindowOf(app));
|
||||
Assert.True(start >= left - 0.5 && end <= right + 0.5, $"{language}: '{text.Text}' spans {start:0}–{end:0} px, its card {left:0}–{right:0} px");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
private static async Task InEveryLanguageAsync(ScreenSmokeTests.SampleApp app, Action<string> check)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var language in Languages.Shipped)
|
||||
{
|
||||
UiLanguage.Apply(language);
|
||||
await SettleAsync(app);
|
||||
check(language);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
UiLanguage.Apply("en");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The left and right edges of an element in window coordinates, whichever way the window reads.</summary>
|
||||
private static (double Left, double Right) Span(FrameworkElement element, Window window)
|
||||
{
|
||||
var a = element.TranslatePoint(new Point(0, 0), window).X;
|
||||
var b = element.TranslatePoint(new Point(element.ActualWidth, 0), window).X;
|
||||
return (Math.Min(a, b), Math.Max(a, b));
|
||||
}
|
||||
|
||||
private static Window WindowOf(ScreenSmokeTests.SampleApp app) => Window.GetWindow(app.FindAll<FrameworkElement>().First())!;
|
||||
|
||||
private static ImportView View(ScreenSmokeTests.SampleApp app) => app.FindAll<ImportView>().First(v => v.IsVisible);
|
||||
|
||||
@@ -87,6 +87,56 @@ public sealed class JobsScreenSmokeTests
|
||||
Assert.Equal(bar, shell.JobText);
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// Beside the 200 px rail (owner review 1, R1), at the 1200 px minimum width, every row's buttons stay inside the row
|
||||
/// in every shipped language. A row's content is clipped where the row's padding begins, so that is the edge checked.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public Task RowActionsStayInsideTheirRowAtTheMinimumWidthInEveryLanguage() => 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");
|
||||
app.Window.Width = 1200;
|
||||
try
|
||||
{
|
||||
foreach (var language in Languages.Shipped)
|
||||
{
|
||||
UiLanguage.Apply(language);
|
||||
app.Window.UpdateLayout();
|
||||
await app.Window.Dispatcher.InvokeAsync(() => { }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
|
||||
var items = app.FindAll<ListBoxItem>().Where(i => i.DataContext is JobRowViewModel && i.IsVisible).ToList();
|
||||
Assert.True(items.Count > 3, $"{language}: several rows are on screen");
|
||||
foreach (var item in items)
|
||||
{
|
||||
var row = Descendants<Border>(item).First(b => b.Name == "Row");
|
||||
var (left, right) = Span(row, app.Window);
|
||||
foreach (var button in Descendants<Button>(row).Where(b => b.IsVisible))
|
||||
{
|
||||
var (start, end) = Span(button, app.Window);
|
||||
Assert.True(start >= left + row.Padding.Left - 0.5 && end <= right - row.Padding.Right + 0.5,
|
||||
$"{language}: '{AutomationProperties.GetName(button)}' spans {start:0}–{end:0} px, its row's content {left + row.Padding.Left:0}–{right - row.Padding.Right:0} px");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
UiLanguage.Apply("en");
|
||||
}
|
||||
});
|
||||
|
||||
/// <summary>The left and right edges of an element in window coordinates, whichever way the window reads.</summary>
|
||||
private static (double Left, double Right) Span(FrameworkElement element, Window window)
|
||||
{
|
||||
var a = element.TranslatePoint(new Point(0, 0), window).X;
|
||||
var b = element.TranslatePoint(new Point(element.ActualWidth, 0), window).X;
|
||||
return (Math.Min(a, b), Math.Max(a, b));
|
||||
}
|
||||
|
||||
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>
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Titano.App.Tests;
|
||||
|
||||
internal static class TestMain
|
||||
{
|
||||
public static Task<int> Main(string[] args)
|
||||
public static async Task<int> Main(string[] args)
|
||||
{
|
||||
// The UI language is process-wide: a test that leaves English outside a serial class races with the English
|
||||
// assertions of the classes running beside it, so it fails at the switch instead of making another one flaky.
|
||||
@@ -19,6 +19,10 @@ internal static class TestMain
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
throw new AssertionException($"{test.TestName} switched the UI language to '{culture}' outside a [Serial] class");
|
||||
};
|
||||
return TestRunner.RunAsync(args, typeof(TestMain).Assembly);
|
||||
var result = await TestRunner.RunAsync(args, typeof(TestMain).Assembly);
|
||||
// WPF's binding engine cleans up on its dispatcher; stopped with the process instead, that cleanup can run against a
|
||||
// half-torn-down engine and crash the exit after every test passed.
|
||||
Windows.WpfApplication.Shutdown();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,9 @@ public sealed class ServerScreenSmokeTests
|
||||
var conflict = Row(table, "Holy grail · Monviso");
|
||||
Assert.Equal(StatusKind.Warning, conflict.StateKind);
|
||||
Assert.SequenceEqual([SyncAction.KeepMine, SyncAction.TakeServer, SyncAction.SaveBoth], Actions(conflict));
|
||||
Assert.Equal(Loc.L("Server.Conflict.Difference", Loc.L("Server.Setting.DeflickerWindow"), "41", "33"), conflict.StateToolTip);
|
||||
// The state whole first (its fixed column cuts longer ones), then what differs.
|
||||
Assert.Equal(string.Join(Loc.Separator, conflict.StateText, Loc.L("Server.Conflict.Difference", Loc.L("Server.Setting.DeflickerWindow"), "41", "33")),
|
||||
conflict.StateToolTip);
|
||||
Assert.NotNull(table.LastSyncText);
|
||||
Assert.NotNull(table.ArchiveText);
|
||||
Assert.True(table.UploadAllCommand.CanExecute(null), "the table filled after the view bound");
|
||||
|
||||
@@ -53,6 +53,8 @@ public sealed class SettingsScreenSmokeTests
|
||||
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);
|
||||
// Beside the 200 px rail, Clear stays inside the page in every language (owner review 1, R1).
|
||||
await InsidePageInEveryLanguageAsync(window, () => app.FindAll<Button>().First(b => ReferenceEquals(b.Command, settings.ClearCacheCommand) && b.IsVisible));
|
||||
window.Width = width;
|
||||
|
||||
// Long translations are never cut: German labels show whole (or wrap) in the shared label column.
|
||||
@@ -90,6 +92,11 @@ public sealed class SettingsScreenSmokeTests
|
||||
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);
|
||||
// Beside the 200 px rail at the minimum width, Forget stays whole inside the page in every language (owner review 1, R1).
|
||||
window.Width = 1200;
|
||||
// (A language switch makes the certificate rows again: each round finds Forget in the row it shows.)
|
||||
await InsidePageInEveryLanguageAsync(window, () => app.FindAll<Button>().First(b => b is { DataContext: TrustedCertificateRow, IsVisible: true }));
|
||||
window.Width = width;
|
||||
certificate.ForgetCommand.Execute(null);
|
||||
Assert.Count(1, settings.Certificates);
|
||||
Assert.True(shell.Server.IsConnected, "the session on the certificate stays");
|
||||
@@ -379,6 +386,48 @@ public sealed class SettingsScreenSmokeTests
|
||||
private static double Middle(FrameworkElement element) =>
|
||||
element.TranslatePoint(new Point(0, element.ActualHeight / 2), Window.GetWindow(element)).Y;
|
||||
|
||||
/// <summary>In every shipped language, the button <paramref name="find"/> returns lies inside its page's viewport (either reading direction).</summary>
|
||||
private static async Task InsidePageInEveryLanguageAsync(Window window, Func<Button> find)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var language in Languages.Shipped)
|
||||
{
|
||||
UiLanguage.Apply(language);
|
||||
window.UpdateLayout();
|
||||
await window.Dispatcher.InvokeAsync(() => { }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
|
||||
var button = find();
|
||||
var page = Ancestor<ScrollViewer>(button);
|
||||
var (left, right) = Span(page, page.ViewportWidth, window);
|
||||
var (start, end) = Span(button, button.ActualWidth, window);
|
||||
Assert.True(start >= left - 0.5 && end <= right + 0.5, $"{language}: '{button.Content}' spans {start:0}–{end:0} px, the page {left:0}–{right:0} px");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
UiLanguage.Apply("en");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The left and right edges of the first <paramref name="width"/> pixels of an element in window coordinates.</summary>
|
||||
private static (double Left, double Right) Span(FrameworkElement element, double width, Window window)
|
||||
{
|
||||
var a = element.TranslatePoint(new Point(0, 0), window).X;
|
||||
var b = element.TranslatePoint(new Point(width, 0), window).X;
|
||||
return (Math.Min(a, b), Math.Max(a, b));
|
||||
}
|
||||
|
||||
/// <summary>The nearest <typeparamref name="T"/> above <paramref name="node"/>.</summary>
|
||||
private static T Ancestor<T>(DependencyObject node)
|
||||
where T : DependencyObject
|
||||
{
|
||||
for (var parent = VisualTreeHelper.GetParent(node); parent is not null; parent = VisualTreeHelper.GetParent(parent))
|
||||
{
|
||||
if (parent is T match) return match;
|
||||
}
|
||||
throw new InvalidOperationException($"No {typeof(T).Name} above {node}");
|
||||
}
|
||||
|
||||
/// <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());
|
||||
|
||||
@@ -271,13 +271,14 @@ public sealed class ScreenSmokeTests
|
||||
|
||||
/// <param name="language">The UI language, applied before the window is created (as at start-up).</param>
|
||||
/// <param name="firstRun">Opens with the first-run dialog, which keeps the shell behind it disabled.</param>
|
||||
public static async Task<SampleApp> StartAsync(string language = "en", bool firstRun = false)
|
||||
/// <param name="saveSettings">Runs where the app writes its settings file (nothing is written by default).</param>
|
||||
public static async Task<SampleApp> StartAsync(string language = "en", bool firstRun = false, Action? saveSettings = null)
|
||||
{
|
||||
var environment = AppEnvironment.ForCapture();
|
||||
UiLanguage.Apply(language);
|
||||
ThemeManager.Apply(AppTheme.Dark);
|
||||
var settings = new AppSettings { Language = language, FirstRunCompleted = !firstRun };
|
||||
var services = new AppServices(environment, settings, () => { }, new NoDialogs());
|
||||
var services = new AppServices(environment, settings, saveSettings ?? (() => { }), new NoDialogs());
|
||||
var sample = SampleData.Configure(services);
|
||||
var shell = new ShellViewModel(services);
|
||||
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Automation;
|
||||
using System.Windows.Automation.Peers;
|
||||
using System.Windows.Automation.Provider;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Shell;
|
||||
using System.Windows.Threading;
|
||||
using Titano.App.Editor;
|
||||
using Titano.App.Infrastructure;
|
||||
using Titano.App.Library;
|
||||
@@ -72,10 +76,13 @@ public sealed class ShellNotificationTests
|
||||
(Key.D5, SectionKey.Jobs), (Key.D6, SectionKey.Server), (Key.OemComma, SectionKey.Settings),
|
||||
};
|
||||
|
||||
// The first-run dialog keeps the shell behind it: no shortcut moves it.
|
||||
// The first-run dialog keeps the shell behind it: no shortcut moves it, nor folds its rail.
|
||||
var library = bindings.Single(b => b.Key == Key.D1 && b.Modifiers == ModifierKeys.Control);
|
||||
Assert.False(library.Command.CanExecute(library.CommandParameter), "no navigation behind the first-run dialog");
|
||||
var rail = bindings.Single(b => b.Key == Key.B && b.Modifiers == ModifierKeys.Control);
|
||||
Assert.False(rail.Command.CanExecute(rail.CommandParameter), "Ctrl+B waits for the first-run dialog too");
|
||||
shell.CompleteWelcome();
|
||||
Assert.True(rail.Command.CanExecute(rail.CommandParameter));
|
||||
|
||||
foreach (var (key, section) in expected)
|
||||
{
|
||||
@@ -95,6 +102,49 @@ public sealed class ShellNotificationTests
|
||||
Assert.Contains("Ctrl+Shift+1", Loc.L("Tooltips.Editor.Preview.OneToOne"));
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task TheRailCollapsesToIconsThatNameTheirSectionByCtrlB() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
// Owner review 1: 200 px with names, 48 px of icons whose tooltips name their section, by the button or Ctrl+B.
|
||||
var saves = 0;
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync(saveSettings: () => saves++);
|
||||
var shell = app.Shell;
|
||||
var rail = (FrameworkElement)app.Window.FindName("Rail");
|
||||
var toggle = app.Window.InputBindings.OfType<KeyBinding>().Single(b => b.Key == Key.B && b.Modifiers == ModifierKeys.Control);
|
||||
Assert.False(shell.IsRailCollapsed);
|
||||
app.Window.UpdateLayout();
|
||||
Assert.Approximately(200, rail.ActualWidth, 0.5);
|
||||
var buttons = app.FindAll<NavRailButton>().Where(b => b.IsVisible).ToList();
|
||||
Assert.Count(shell.AllSections.Count(), buttons);
|
||||
foreach (var button in buttons) Assert.Equal(((SectionViewModel)button.DataContext).ToolTip, button.ToolTip);
|
||||
|
||||
toggle.Command.Execute(toggle.CommandParameter);
|
||||
app.Window.UpdateLayout();
|
||||
Assert.True(shell.IsRailCollapsed);
|
||||
Assert.True(shell.Services.Settings.RailCollapsed);
|
||||
Assert.Equal(1, saves, "the choice is written at once");
|
||||
Assert.Approximately(48, rail.ActualWidth, 0.5);
|
||||
foreach (var button in buttons)
|
||||
{
|
||||
var section = (SectionViewModel)button.DataContext;
|
||||
// The icon's tooltip names the section; screen readers hear the name once (the name, then what it is for).
|
||||
Assert.Equal($"{section.Label} · {section.ToolTip}", button.ToolTip);
|
||||
Assert.Equal(section.Label, AutomationProperties.GetName(button));
|
||||
Assert.Equal(section.ToolTip, AutomationProperties.GetHelpText(button));
|
||||
}
|
||||
Assert.Contains("Ctrl+B", shell.RailToggleToolTip);
|
||||
|
||||
// The ≡ button does the same, and the choice is written again.
|
||||
var menu = app.FindAll<Button>().Single(b => b.IsVisible && ReferenceEquals(b.Command, shell.ToggleRailCommand));
|
||||
((IInvokeProvider)new ButtonAutomationPeer(menu)).Invoke();
|
||||
await app.Window.Dispatcher.InvokeAsync(() => { }, DispatcherPriority.ApplicationIdle);
|
||||
app.Window.UpdateLayout();
|
||||
Assert.False(shell.IsRailCollapsed);
|
||||
Assert.Equal(2, saves);
|
||||
Assert.Approximately(200, rail.ActualWidth, 0.5);
|
||||
foreach (var button in buttons) Assert.Equal(((SectionViewModel)button.DataContext).ToolTip, button.ToolTip);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task JobsThatEndRaiseOneToastAndFailuresCountUntilSeen() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
|
||||
@@ -10,11 +10,23 @@ namespace Titano.App.Tests.Windows;
|
||||
/// </summary>
|
||||
internal static class WpfApplication
|
||||
{
|
||||
private static readonly Lazy<Dispatcher> Instance = new(Start, LazyThreadSafetyMode.ExecutionAndPublication);
|
||||
private static readonly Lazy<(Dispatcher Dispatcher, Thread Thread)> Instance = new(Start, LazyThreadSafetyMode.ExecutionAndPublication);
|
||||
|
||||
public static Dispatcher Dispatcher => Instance.Value;
|
||||
public static Dispatcher Dispatcher => Instance.Value.Dispatcher;
|
||||
|
||||
private static Dispatcher Start()
|
||||
/// <summary>
|
||||
/// Stops the dispatcher in order (its binding engine and windows clean up on their own thread) and waits for it, so the
|
||||
/// process exits without WPF work racing its teardown. Nothing to do when no WPF test ran.
|
||||
/// </summary>
|
||||
public static void Shutdown()
|
||||
{
|
||||
if (!Instance.IsValueCreated) return;
|
||||
var (dispatcher, thread) = Instance.Value;
|
||||
if (!dispatcher.HasShutdownStarted) dispatcher.InvokeShutdown();
|
||||
thread.Join(TimeSpan.FromSeconds(10));
|
||||
}
|
||||
|
||||
private static (Dispatcher, Thread) Start()
|
||||
{
|
||||
Dispatcher? dispatcher = null;
|
||||
using var ready = new ManualResetEventSlim();
|
||||
@@ -30,6 +42,6 @@ internal static class WpfApplication
|
||||
thread.IsBackground = true;
|
||||
thread.Start();
|
||||
ready.Wait();
|
||||
return dispatcher!;
|
||||
return (dispatcher!, thread);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user