Setup registered .titano with Titano.exe "%1", but nothing wrote such a file
and Titano ignored the argument (BRIEF §18).
- Core ProjectBundle: versioned UTF-8 JSON ("titano-project", format 1) with
the archive (id, name, path), the sequence (id, folder, title, frame
count) and the project settings as project.json holds them; newer or
foreign files are refused, frame positions apply only to the frames they
were saved for, saving never replaces an earlier file.
- Data ProjectBundles: the file for a sequence of the index, and the sequence
a file names (by id, else the same folder of the same archive).
- Editor: "Save project file" on the Export tab (sequences of this PC's
archives); opening a file shows its sequence and applies the settings as
one undo step with an Undo toast, or says in one sentence why not (not in
the library, unreadable, a job runs).
- Titano.exe opens its file argument once the index is open and runs once
per data folder: a later launch hands its file over a current-user named
pipe, lets the running window come to the front and exits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
105 lines
5.0 KiB
C#
105 lines
5.0 KiB
C#
using Titano.Core.Project;
|
|
using Titano.Testing;
|
|
|
|
namespace Titano.Core.Tests.Project;
|
|
|
|
/// <summary>The <c>.titano</c> project file (BRIEF §18): a sequence reference plus the settings to open it with.</summary>
|
|
public sealed class ProjectBundleTests(TestContext context)
|
|
{
|
|
private static readonly Guid ArchiveId = Guid.Parse("0192a4c1-7b3e-7cc0-8a51-2f9d0e6b1a01");
|
|
private static readonly Guid SequenceId = Guid.Parse("0192a4c1-7b3e-7cc0-8a51-2f9d0e6b1a02");
|
|
|
|
[Test]
|
|
public void ARoundTripKeepsTheReferenceAndTheSettings()
|
|
{
|
|
var bundle = Sample();
|
|
var path = Path.Combine(context.CreateTempDirectory("bundle"), ProjectBundle.FileNameFor("Harbour sunset"));
|
|
bundle.Save(path);
|
|
|
|
var back = ProjectBundle.Load(path);
|
|
Assert.Equal(bundle.Archive, back.Archive);
|
|
Assert.Equal(bundle.Sequence, back.Sequence);
|
|
Assert.Equal(bundle.Saved, back.Saved);
|
|
Assert.Equal(bundle.Project.ToJson(), back.Project.ToJson());
|
|
Assert.Equal(0.8, back.Project.Exposure.DeflickerStrength.Resolve(1.0));
|
|
Assert.SequenceEqual([3, 7], back.Project.ExcludedFrames);
|
|
|
|
var json = File.ReadAllText(path);
|
|
Assert.Contains("\"format\": \"titano-project\"", json);
|
|
Assert.Contains("\"formatVersion\": 1", json);
|
|
}
|
|
|
|
[Test]
|
|
public void OtherFilesAreRefusedAsNotProjectFiles()
|
|
{
|
|
Assert.Throws<InvalidDataException>(() => ProjectBundle.Parse("not json"));
|
|
Assert.Throws<InvalidDataException>(() => ProjectBundle.Parse("[1, 2]"));
|
|
// The archive's own meta files are JSON too, but not project files.
|
|
Assert.Throws<InvalidDataException>(() => ProjectBundle.Parse("""{ "schemaVersion": 1, "id": "0192a4c1-7b3e-7cc0-8a51-2f9d0e6b1a01" }"""));
|
|
var json = Sample().ToJson();
|
|
Assert.Throws<InvalidDataException>(() => ProjectBundle.Parse(json.Replace("\"formatVersion\": 1", "\"formatVersion\": 2", StringComparison.Ordinal)));
|
|
Assert.Throws<InvalidDataException>(() => ProjectBundle.Parse(json.Replace(SequenceId.ToString(), "not-a-guid", StringComparison.Ordinal)));
|
|
Assert.Throws<InvalidDataException>(() => ProjectBundle.Parse(json.Replace("\"version\": 1", "\"version\": 99", StringComparison.Ordinal)));
|
|
Assert.Throws<InvalidDataException>(() => ProjectBundle.Parse(json.Replace("\"folder\"", "\"place\"", StringComparison.Ordinal)));
|
|
}
|
|
|
|
[Test]
|
|
public void AFileTooLargeToBeAProjectIsNotRead()
|
|
{
|
|
var path = Path.Combine(context.CreateTempDirectory("bundle"), "huge.titano");
|
|
using (var stream = File.Create(path)) stream.SetLength(ProjectBundle.MaxBytes + 1L);
|
|
Assert.Throws<InvalidDataException>(() => ProjectBundle.Load(path));
|
|
}
|
|
|
|
[Test]
|
|
public void FramePositionsApplyOnlyToTheFramesTheyWereSavedFor()
|
|
{
|
|
var bundle = Sample();
|
|
var current = new ProjectSettings
|
|
{
|
|
ExcludedFrames = [1],
|
|
HeroFrame = 2,
|
|
Camera = new CameraSettings { Keyframes = [new CameraKey(0, 0.5, 0.5, 1, 0)] },
|
|
};
|
|
|
|
Assert.Same(bundle.Project, bundle.ProjectFor(current, frameCount: 3600));
|
|
|
|
var changed = bundle.ProjectFor(current, frameCount: 3610);
|
|
Assert.SequenceEqual([1], changed.ExcludedFrames);
|
|
Assert.Equal(2, changed.HeroFrame);
|
|
Assert.Same(current.Camera.Keyframes, changed.Camera.Keyframes);
|
|
// Everything else comes from the file.
|
|
Assert.Equal(0.8, changed.Exposure.DeflickerStrength.Resolve(1.0));
|
|
Assert.Equal(bundle.Project.Camera.Crop, changed.Camera.Crop);
|
|
}
|
|
|
|
[Theory]
|
|
[Case("Harbour sunset", "Harbour sunset.titano")]
|
|
[Case("Roof: 12/03 \"storm\"?", "Roof_ 12_03 _storm__.titano")]
|
|
[Case("CON", "_CON.titano")]
|
|
[Case(" ", "Titano.titano")]
|
|
public void TheFileNameComesFromTheTitle(string title, string expected) => Assert.Equal(expected, ProjectBundle.FileNameFor(title));
|
|
|
|
[Test]
|
|
public void SavingNeverReplacesAnEarlierProjectFile()
|
|
{
|
|
var folder = context.CreateTempDirectory("bundle");
|
|
Assert.Equal(Path.Combine(folder, "Harbour sunset.titano"), ProjectBundle.FreePathIn(folder, "Harbour sunset"));
|
|
File.WriteAllText(Path.Combine(folder, "Harbour sunset.titano"), "{}");
|
|
Directory.CreateDirectory(Path.Combine(folder, "Harbour sunset (2).titano"));
|
|
Assert.Equal(Path.Combine(folder, "Harbour sunset (3).titano"), ProjectBundle.FreePathIn(folder, "Harbour sunset"));
|
|
}
|
|
|
|
private static ProjectBundle Sample() => new(
|
|
new BundleArchive(ArchiveId, "Main archive", @"D:\Timelapse"),
|
|
new BundleSequence(SequenceId, "2026/2026-09-28 Harbour sunset", "Harbour sunset", 3600),
|
|
new ProjectSettings
|
|
{
|
|
Exposure = new ExposureSettings { DeflickerStrength = new Auto<double>().WithManual(0.8) },
|
|
Camera = new CameraSettings { Crop = [0.1, 0.1, 0.9, 0.9], Keyframes = [new CameraKey(120, 0.4, 0.5, 1.2, 0)] },
|
|
ExcludedFrames = [3, 7],
|
|
HeroFrame = 1800,
|
|
},
|
|
new DateTimeOffset(2026, 10, 12, 9, 30, 0, TimeSpan.Zero));
|
|
}
|