Files
Chronos/tests/Chronos.App.Tests/Editor/StraightenGridBindingTests.cs
T
Alby96andClaude Opus 5.5 eeaddc2d14 fix(phase4): close the owner review 1 phase 4 findings
Routing sizes render jobs from the resolved preset, and the node wait
applies the same routing as the claim, so a re-routed job neither keeps a
stale size nor waits for a node that will never take it. Settings an older
server cannot read stay on this side for the remote editor, archive sync
and workspace push, and the reason is shown where it applies. A turn on
one side and a framing on the other merge as one conflict.

Orientation and framing fixes: an out-of-range crop turns with the content
it shows, the aspect text transposes exactly, the Rotation row counts
turns as shown on screen, and Reset framing undoes the orientation press
by press, so keyframes and aspect stay on their content. The advisor
places the horizon in the view as shown. A look at zero strength is
cleared and no longer reaches the motion vectors.

Preview changes: the middle button pans, a press inside a box with no
slack pans while zoomed, the selected box shows a ring, and screen readers
hear when the crop value changes. Tooltips in en and it updated; stale
translations of changed tooltips removed so they fall back to English.

Test changes: the pinned hash is OS-independent, and the tautological
encoder and warning assertions became real checks. Added a non-screen
test of the Straighten slider binding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 21:40:07 +01:00

82 lines
3.6 KiB
C#

using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Chronos.App.Editor;
using Chronos.App.Shell;
using Chronos.Core.Localization;
using Chronos.Testing;
namespace Chronos.App.Tests.Editor;
/// <summary>
/// The Camera step's Straighten slider reports its use to the editor (owner review 1, R6): the NumberRow template of
/// <c>Editor/EditorPanels.xaml</c> turns <see cref="SliderActivity"/> on for the row that shows the grid, and binds its
/// <see cref="SliderActivity.IsActiveProperty"/> one way to the source <c>Editor.IsStraightening</c> of the step. Built off
/// screen on the test dispatcher (no window): the slider's activity is set as <see cref="SliderActivity"/> sets it when the
/// slider takes the focus or the mouse capture.
/// </summary>
[WindowsOnly]
[Serial]
public sealed class StraightenGridBindingTests
{
[Test]
public async Task UsingTheStraightenSliderTellsTheEditor()
{
var content = EditorFixture.Content(EditorFixture.Sunset);
var session = new EditorSession(new FakeSequenceSource(EditorFixture.Sunset, content), content, [], TimeSpan.FromMilliseconds(20));
await using (session)
{
var rows = CameraTab.FramingRows(session);
Windows.WpfApplication.Dispatcher.Invoke(() =>
{
AppResources.Merge(Application.Current);
var step = new FakeStep();
var items = new ItemsControl { ItemsSource = rows, DataContext = step };
items.Resources.MergedDictionaries.Add(new ResourceDictionary
{
Source = new Uri("pack://application:,,,/Chronos;component/Editor/EditorPanels.xaml", UriKind.Absolute),
});
var host = new Border { Child = items };
host.Measure(new Size(320, 2000));
host.Arrange(new Rect(0, 0, 320, 2000));
host.UpdateLayout();
var sliders = Descendants<Slider>(host).ToList();
Assert.Equal(rows.OfType<NumberRow>().Count(), sliders.Count);
var straighten = Assert.NotNull(sliders.SingleOrDefault(s => s.DataContext is NumberRow { ShowsGrid: true }));
Assert.Equal(Loc.L("Editor.Camera.Straighten"), ((NumberRow)straighten.DataContext).Header);
Assert.True(SliderActivity.GetTracks(straighten), "the Straighten slider is tracked");
Assert.False(sliders.Where(s => !ReferenceEquals(s, straighten)).Any(SliderActivity.GetTracks), "no other slider is");
Assert.False(step.Editor.IsStraightening);
straighten.SetCurrentValue(SliderActivity.IsActiveProperty, true);
Assert.True(step.Editor.IsStraightening, "focused or dragged: the editor shows the grid");
straighten.SetCurrentValue(SliderActivity.IsActiveProperty, false);
Assert.False(step.Editor.IsStraightening, "let go: the grid goes");
});
}
}
private static IEnumerable<T> Descendants<T>(DependencyObject root)
where T : DependencyObject
{
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(root); i++)
{
var child = VisualTreeHelper.GetChild(root, i);
if (child is T match) yield return match;
foreach (var nested in Descendants<T>(child)) yield return nested;
}
}
/// <summary>The step's data context as the template reads it: <c>Editor.IsStraightening</c>.</summary>
public sealed class FakeStep
{
public FakeEditor Editor { get; } = new();
}
public sealed class FakeEditor
{
public bool IsStraightening { get; set; }
}
}