Files
Chronos/tests/Chronos.App.Tests/Editor/StraightenGridBindingTests.cs
T
Alby96andClaude Opus 5.5 188b2c2e55
CI / Build and test (push) Successful in 8m19s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 12m9s
CI / PostgreSQL 16 integration (push) Successful in 7m49s
CI / PostgreSQL 17 integration (push) Successful in 7m19s
CI / Docker image (push) Successful in 46s
Release / Server image (push) Successful in 1m14s
feat(editor): visual crop, rotate/mirror/flip/straighten, colour looks (owner review 1 phase 4) (#26)
Owner review 1 R5 + R6. Camera rotation, mirror, flip, straighten and crop handles locked to the output; an Exposure Look group; Export output size ("proportions win"); settings format 2 with older-node gates. Also fixes project text and hashes differing between Windows and Linux.

Closes #19
Closes #20

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
2026-11-05 01:09:09 +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; }
}
}