test(app): Arabic shell, toasts, chrome names and paddings; RTL captures are drawn mirrored

- Smoke tests: the main window opens mirrored when Arabic is applied before it exists, directional icons
  follow while other glyphs, the logo, the preview surface and the charts do not; the shell behind the
  first-run dialog is disabled; toasts draw, are named and close after their action; caption buttons,
  the job bar and the pause button have names; text boxes pad once.
- --capture draws right-to-left windows through the window's mirror, as the Uploader and Setup do.
- DESIGN §5 states the directional icon rule and the left-to-right islands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-06 08:10:36 +00:00
1 parent 1757a5b9e9
commit 739d51eb7e
3 files changed
+148 -5

No files matched your search

+6 -1
View File
@@ -84,7 +84,12 @@ Label column left of controls: 116 px in panels, 180 px in Settings.
16 px, 1.5 px strokes, round caps and joins, `currentColor`, drawn as `PathGeometry` /
`DrawingImage` resources in `Titano.App/Icons/Icons.xaml` (source SVGs in `branding/ui-icons/`
if generated by a tool). No icon fonts, no emoji in shipped UI (the mockups use a few glyphs
only as placeholders: replace ⟳ ▾ ✕ ■ ❚❚ ≡ with drawn icons). Directional icons mirror in RTL.
only as placeholders: replace ⟳ ▾ ✕ ■ ❚❚ ≡ with drawn icons). Directional icons mirror in RTL:
`IconData.IsDirectional` marks the glyphs that point along the reading direction (back/forward, chevrons
left/right, external link, start-aligned lines); `ui:Bidi.IsDirectional` overrides it for a subtree (a ▶ used
as "next", a chevron on a left-to-right time axis). Every other glyph (clocks, media controls, the ▶ rendered
status) and the brand mark keep their drawn orientation. Photos, previews, charts, numbers, paths and
templates are left-to-right islands (`FlowDirection="LeftToRight"` on the smallest element holding them).
## 6. App icon (`branding/`)
+15 -1
View File
@@ -321,11 +321,25 @@ public static class ScreenCapture
return false;
}
var bitmap = new RenderTargetBitmap(width, height, dpi.PixelsPerInchX, dpi.PixelsPerInchY, PixelFormats.Pbgra32);
bitmap.Render(root);
bitmap.Render(window.FlowDirection == FlowDirection.RightToLeft ? Mirrored(root) : root);
var encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bitmap));
using var stream = File.Create(path);
encoder.Save(stream);
return true;
}
/// <summary>
/// A right-to-left window is mirrored by a transform on the window itself, which rendering its content alone
/// would leave out (mirrored glyphs, left-to-right layout): draw the content through that mirror.
/// </summary>
private static DrawingVisual Mirrored(FrameworkElement root)
{
var size = new Rect(0, 0, root.ActualWidth, root.ActualHeight);
var visual = new DrawingVisual();
using var dc = visual.RenderOpen();
dc.PushTransform(new MatrixTransform(-1, 0, 0, 1, size.Width, 0));
dc.DrawRectangle(new VisualBrush(root) { Stretch = Stretch.Fill, ViewboxUnits = BrushMappingMode.Absolute, Viewbox = size }, null, size);
return visual;
}
}
@@ -1,4 +1,9 @@
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.Media;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
@@ -8,8 +13,10 @@ using Titano.App.Sections;
using Titano.App.Server;
using Titano.App.Settings;
using Titano.App.Shell;
using Titano.Core.Localization;
using Titano.Testing;
using Titano.Ui.Controls;
using Titano.Ui.Mvvm;
using Titano.Ui.Theming;
using Titano.Ui.Visuals;
@@ -121,6 +128,108 @@ public sealed class ScreenSmokeTests
Assert.Equal(english, app.Shell.Library.Title);
});
[Test]
public Task ArabicMirrorsTheShellFromStartButNotItsPicturesOrLogo() => ScreenHost.RunAsync(async () =>
{
// The language is applied before the window exists, as at start-up with Arabic saved in the settings.
await using var app = await SampleApp.StartAsync("ar");
try
{
var window = app.Window;
Assert.Equal(FlowDirection.RightToLeft, window.FlowDirection, "the main window opens mirrored");
var rail = (FrameworkElement)window.FindName("Rail");
Assert.Equal(FlowDirection.RightToLeft, rail.FlowDirection, "the rail mirrors with the window (it starts on the right)");
// The first-run dialog keeps the shell behind it out of reach.
Assert.True(app.Shell.IsWelcomeOpen);
Assert.False(rail.IsEnabled, "the rail behind the first-run dialog takes no input");
app.Shell.CompleteWelcome();
Assert.True(rail.IsEnabled);
var id = await app.Sample.FillEditorAsync();
app.Shell.OpenSequence(id);
await app.Shell.Sequence.OpenAsync(id);
var editor = Assert.NotNull(app.Shell.Sequence.Editor);
Assert.True(await editor.WhenIdleAsync(TimeSpan.FromSeconds(60)), "the editor settled");
await app.ExpectAsync<SequenceView>("sequence-ar");
// Directional glyphs follow the reading direction; the others, the logo, the picture and the charts do not.
var back = Assert.NotNull(app.FindAll<Button>().FirstOrDefault(b => b.IsVisible && ReferenceEquals(b.Command, editor.BackCommand)), "the editor's Back button");
var arrow = Descendants<Icon>(back).Single();
Assert.True(arrow.Glyph!.IsDirectional);
Assert.Equal(FlowDirection.RightToLeft, arrow.FlowDirection, "Back points the way Arabic reads");
foreach (var icon in app.FindAll<Icon>().Where(i => i.Glyph is { IsDirectional: false } && Bidi.GetIsDirectional(i) is null))
Assert.Equal(FlowDirection.LeftToRight, icon.FlowDirection, "a glyph that does not point anywhere keeps its drawing");
Assert.True(app.FindAll<BrandMarkIcon>().All(m => m.FlowDirection == FlowDirection.LeftToRight), "the logo never mirrors");
var viewport = app.FindAll<PreviewViewport>().Single(v => v.IsVisible);
Assert.Equal(FlowDirection.LeftToRight, ((FrameworkElement)viewport.Template.FindName(PreviewViewport.PartSurface, viewport)).FlowDirection, "the photo is not mirrored");
Assert.Equal(FlowDirection.RightToLeft, ((FrameworkElement)viewport.Template.FindName(PreviewViewport.PartTools, viewport)).FlowDirection, "the preview tools follow the layout");
Assert.True(app.FindAll<DrawingElement>().All(d => d.FlowDirection == FlowDirection.LeftToRight), "charts, filmstrip and curves keep their time axis");
}
finally
{
UiLanguage.Apply("en");
}
});
[Test]
public Task ToastsDrawSpeakAndCloseAfterTheirAction() => ScreenHost.RunAsync(async () =>
{
await using var app = await SampleApp.StartAsync();
app.Shell.CompleteWelcome();
var ran = false;
app.Shell.ShowToast(new Toast { Title = "Harbour sunset rendered", ActionText = "Open", ActionCommand = new RelayCommand(() => ran = true) });
await app.ExpectAsync<LibraryView>("library-toast");
var host = app.Window.Toasts;
Assert.Equal(1, host.Toasts.Count);
var toast = Assert.NotNull(host.ItemContainerGenerator.ContainerFromIndex(0) as FrameworkElement, "the toast's container");
Assert.Greater(toast.ActualHeight, 0, "the toast is drawn");
Assert.Equal("Harbour sunset rendered", AutomationProperties.GetName(toast));
var dismiss = Descendants<Button>(toast).Single(b => ReferenceEquals(b.Command, ToastHost.DismissCommand));
Assert.Equal(Loc.L("Tooltips.Common.Dismiss"), AutomationProperties.GetName(dismiss));
var action = Descendants<Button>(toast).Single(b => b.IsVisible && !ReferenceEquals(b.Command, ToastHost.DismissCommand));
Assert.True(action.Command!.CanExecute(null));
((IInvokeProvider)new ButtonAutomationPeer(action)).Invoke();
await app.ExpectAsync<LibraryView>("library-toast-done");
Assert.True(ran, "the action ran");
Assert.Equal(0, host.Toasts.Count, "the toast closes once its action has run");
});
[Test]
public Task TheChromeAndTheJobBarHaveNamesAndStates() => ScreenHost.RunAsync(async () =>
{
await using var app = await SampleApp.StartAsync();
app.Shell.CompleteWelcome();
await app.ExpectAsync<LibraryView>("library-empty");
var window = app.Window;
var captions = Descendants<Button>(window).Where(b => b.Command is RoutedCommand).ToList();
Assert.Equal(Loc.L("Tooltips.Window.Minimize"), AutomationProperties.GetName(captions.Single(b => b.Command == SystemCommands.MinimizeWindowCommand)));
Assert.Equal(Loc.L("Tooltips.Window.Maximize"), AutomationProperties.GetName(captions.Single(b => b.Command == SystemCommands.MaximizeWindowCommand)));
Assert.Equal(Loc.L("Tooltips.Window.Close"), AutomationProperties.GetName(captions.Single(b => b.Command == SystemCommands.CloseWindowCommand)));
var bar = (JobBar)window.FindName("JobBar");
Assert.Equal(AutomationLiveSetting.Polite, AutomationProperties.GetLiveSetting(bar));
Assert.Equal(app.Shell.JobAnnouncement, AutomationProperties.GetName(bar), "screen readers hear the job state, not its progress");
Assert.Equal(AutomationControlType.StatusBar, UIElementAutomationPeer.CreatePeerForElement(bar).GetAutomationControlType());
var pause = Descendants<Button>(bar).Single();
Assert.Equal(Loc.L("Shell.JobBar.Pause"), AutomationProperties.GetName(pause), "a short name; the sentence is the tooltip");
// A text box hands its padding to the text itself; the template adds none (8 px after a leading icon).
app.Shell.Navigate(SectionKey.Settings);
await app.ExpectAsync<SettingsView>("settings");
var boxes = app.FindAll<TextBox>().Where(t => t.IsVisible).ToList();
Assert.Contains(boxes, t => Field.GetGlyph(t) is not null);
Assert.Contains(boxes, t => Field.GetGlyph(t) is null);
foreach (var box in boxes)
{
var host = (ScrollViewer)box.Template.FindName("PART_ContentHost", box);
Assert.Equal(box.Padding, host.Padding);
Assert.Equal(new Thickness(0), ((FrameworkElement)VisualTreeHelper.GetParent(host)).Margin, "no second padding around the text");
Assert.Equal(Field.GetGlyph(box) is null ? 0.0 : 22.0, host.Margin.Left);
}
});
/// <summary>A <see cref="MainWindow"/> on capture services and sample data, shown off screen like <c>--capture</c>.</summary>
internal sealed class SampleApp : IAsyncDisposable
{
@@ -143,13 +252,15 @@ public sealed class ScreenSmokeTests
public AppServices Services { get; }
public SampleData Sample { get; }
public ShellViewModel Shell { get; }
public MainWindow Window => _window;
public static async Task<SampleApp> StartAsync()
/// <param name="language">The UI language, applied before the window is created (as at start-up).</param>
public static async Task<SampleApp> StartAsync(string language = "en")
{
var environment = AppEnvironment.ForCapture();
UiLanguage.Apply("en");
UiLanguage.Apply(language);
ThemeManager.Apply(AppTheme.Dark);
var services = new AppServices(environment, new AppSettings { Language = "en" }, () => { }, new NoDialogs());
var services = new AppServices(environment, new AppSettings { Language = language }, () => { }, new NoDialogs());
var sample = SampleData.Configure(services);
var shell = new ShellViewModel(services);
@@ -273,6 +384,19 @@ public sealed class ScreenSmokeTests
}
}
private static List<T> Descendants<T>(DependencyObject root)
where T : DependencyObject
{
var found = new List<T>();
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(root); i++)
{
var child = VisualTreeHelper.GetChild(root, i);
if (child is T match) found.Add(match);
found.AddRange(Descendants<T>(child));
}
return found;
}
/// <summary>Dialogs that answer like a user who cancels everything.</summary>
private sealed class NoDialogs : IAppDialogs
{