diff --git a/i18n/en/Settings.resx b/i18n/en/Settings.resx index e3e90a41..0447eb74 100644 --- a/i18n/en/Settings.resx +++ b/i18n/en/Settings.resx @@ -62,7 +62,6 @@ 10-bit Used for of {0} logical cores - Custom only {0} (built in) {0} (hardware) {0} (software) diff --git a/i18n/it/Settings.it.resx b/i18n/it/Settings.it.resx index a79933c8..d559b97b 100644 --- a/i18n/it/Settings.it.resx +++ b/i18n/it/Settings.it.resx @@ -62,7 +62,6 @@ 10 bit Usato per di {0} core logici - Solo Personalizzato {0} (integrato) {0} (hardware) {0} (software) diff --git a/src/Titano.App/Settings/EncoderUse.cs b/src/Titano.App/Settings/EncoderUse.cs index aa2237fd..0ea94f22 100644 --- a/src/Titano.App/Settings/EncoderUse.cs +++ b/src/Titano.App/Settings/EncoderUse.cs @@ -37,8 +37,8 @@ public static class EncoderUse .Select(p => Loc.L(p.NameKey)), ]; - /// "4K archive · 4K HEVC · …" for the Used for column, or "Custom only" when no preset uses the codec. - public static string Text(EncoderRow row) => Presets(row) is { Count: > 0 } names ? string.Join(" · ", names) : Loc.L("Settings.Rendering.CustomOnly"); + /// "4K archive · 4K HEVC · …" for the Used for column (every codec of this PC has built-in presets). + public static string Text(EncoderRow row) => string.Join(" · ", Presets(row)); /// /// The Media Foundation encoders a render node on this PC offers the server: the software ones, and the hardware ones diff --git a/tests/Titano.App.Tests/Jobs/JobListModelTests.cs b/tests/Titano.App.Tests/Jobs/JobListModelTests.cs index 400b72e7..be90578c 100644 --- a/tests/Titano.App.Tests/Jobs/JobListModelTests.cs +++ b/tests/Titano.App.Tests/Jobs/JobListModelTests.cs @@ -167,6 +167,31 @@ public sealed class JobListModelTests Assert.Equal("done · 3:00", JobText.State(done)); } + [Test] + public void TheWorkersReadoutCountsOnlyJobsOfThisPc() + { + var model = new JobListModel(); + model.Apply(Job(JobState.Running, started: -1) with { NodeId = "STUDIO#0" }); + model.Apply(Job(JobState.Running, started: -2) with { NodeId = "studio#3" }); + model.Apply(Job(JobState.Running, started: -3) with { NodeId = "render-box#0" }); + model.Apply(Job(JobState.Running, started: -4)); + model.Apply(Job(JobState.Done, started: -9, finished: -8) with { NodeId = "studio#1" }); + + Assert.Equal(4, model.RunningCount); + Assert.Equal(2, model.RunningOn("studio")); + Assert.True(JobText.IsLocal("studio#2", "STUDIO")); + Assert.False(JobText.IsLocal("studio-2", "studio")); + Assert.False(JobText.IsLocal(null, "studio")); + } + + [Test] + public void RowsAreNamedByKindAndTarget() + { + Loc.SetCulture(CultureInfo.GetCultureInfo("en")); + Assert.Equal("Render · Harbour sunset", JobText.Name(Job(JobState.Running, kind: JobKind.Render, label: "Harbour sunset"))); + Assert.Equal("Proxies", JobText.Name(Job(JobState.Queued))); + } + private static Job Job(JobState state, int created = 0, int? started = null, int? finished = null, JobPriority priority = JobPriority.Normal, JobKind kind = JobKind.Proxies, string? label = null, long done = 0, long total = 0) => new() { diff --git a/tests/Titano.App.Tests/Server/SyncTextTests.cs b/tests/Titano.App.Tests/Server/SyncTextTests.cs index d655eac9..5b26df27 100644 --- a/tests/Titano.App.Tests/Server/SyncTextTests.cs +++ b/tests/Titano.App.Tests/Server/SyncTextTests.cs @@ -153,6 +153,24 @@ public sealed class SyncTextTests Assert.Equal(0, rows.Count(r => SyncText.Matches(r, SyncFilter.Conflicts, "comet"))); } + [Test] + public void ATransferCountsWhereItsOriginalsAre() + { + var uploadNotOnServer = Entry(SyncStatus.Transferring, transfer: Upload(JobState.Queued)) with { Link = null }; + var download = new Job { Id = Guid.CreateVersion7(), Kind = JobKind.Download, State = JobState.Running }; + var downloadNotHere = Entry(SyncStatus.Transferring, transfer: download) with { Local = null }; + var uploadOnBoth = Entry(SyncStatus.Transferring, transfer: Upload(JobState.Running)); + + Assert.True(SyncText.Matches(uploadNotOnServer, SyncFilter.LocalOnly, string.Empty)); + Assert.False(SyncText.Matches(uploadNotOnServer, SyncFilter.Remote, string.Empty)); + Assert.True(SyncText.Matches(downloadNotHere, SyncFilter.Remote, string.Empty)); + Assert.False(SyncText.Matches(downloadNotHere, SyncFilter.LocalOnly, string.Empty)); + // Partly on both sides: neither "only here" nor "only on the server". + Assert.False(SyncText.Matches(uploadOnBoth, SyncFilter.LocalOnly, string.Empty)); + Assert.False(SyncText.Matches(uploadOnBoth, SyncFilter.Remote, string.Empty)); + Assert.True(SyncText.Matches(uploadOnBoth, SyncFilter.All, string.Empty)); + } + private static (StatusKind, string) Kind(SyncEntry entry) { var (kind, text, _) = SyncText.State(entry); diff --git a/tests/Titano.App.Tests/Settings/SettingsLogicTests.cs b/tests/Titano.App.Tests/Settings/SettingsLogicTests.cs index cf95d401..79fea520 100644 --- a/tests/Titano.App.Tests/Settings/SettingsLogicTests.cs +++ b/tests/Titano.App.Tests/Settings/SettingsLogicTests.cs @@ -4,6 +4,7 @@ using System.IO; using Titano.App.Settings; using Titano.Core.Localization; using Titano.Core.Naming; +using Titano.Core.Video; using Titano.Testing; namespace Titano.App.Tests.Settings; @@ -132,6 +133,37 @@ public sealed class SettingsLogicTests Assert.Equal("en", LanguageCatalog.Match(CultureInfo.GetCultureInfo("sw")).Code); } + [Test] + public void EachEncoderNamesThePresetsItServes() + { + var hevc = new EncoderRow("HEVC", "NVIDIA HEVC Encoder MFT", "NVIDIA", EncoderSource.MediaFoundation, true, true, 8192, 8192, VideoCodec.Hevc); + var av1 = hevc with { Codec = "AV1", Name = "NVIDIA AV1 Encoder MFT", VideoCodec = VideoCodec.Av1 }; + var h264 = new EncoderRow("H.264", "H264 Encoder MFT", "Microsoft", EncoderSource.MediaFoundation, false, false, 4096, 2304, VideoCodec.H264); + var animation = new EncoderRow("GIF · APNG", "Titano", null, EncoderSource.BuiltInAnimation, false, false, 0, 0, null); + + Assert.SequenceEqual(["8K archive", "4K archive", "4K HEVC", "DCI 4K", "Cinema 21:9", "4K 60 fps"], EncoderUse.Presets(hevc)); + Assert.Equal("Animated GIF · Animated PNG", EncoderUse.Text(animation)); + Assert.Contains("Share 1080p", EncoderUse.Presets(h264)); + Assert.Equal("4K AV1", EncoderUse.Text(av1)); + } + + [Test] + public void ARenderNodeOffersHardwareEncodersOnlyWhenRendersMayUseThem() + { + EncoderRow[] rows = + [ + new("HEVC", "NVIDIA HEVC Encoder MFT", "NVIDIA", EncoderSource.MediaFoundation, true, true, 8192, 8192, VideoCodec.Hevc), + new("H.264", "NVIDIA H.264 Encoder MFT", "NVIDIA", EncoderSource.MediaFoundation, true, false, 4096, 4096, VideoCodec.H264), + new("H.264", "H264 Encoder MFT", "Microsoft", EncoderSource.MediaFoundation, false, false, 4096, 2304, VideoCodec.H264), + new("MJPEG · AVI", "Titano", null, EncoderSource.BuiltInMjpeg, false, false, 0, 0, VideoCodec.Mjpeg), + ]; + + Assert.Equal("HEVC · H.264", EncoderUse.Codecs(EncoderUse.Node(rows, allowsHardware: true))); + Assert.Equal(3, EncoderUse.Node(rows, allowsHardware: true).Count); + Assert.Equal("H.264", EncoderUse.Codecs(EncoderUse.Node(rows, allowsHardware: false))); + Assert.Null(EncoderUse.Codecs([])); + } + [Test] public void EnumDrivenKeysExistInEveryRequiredLanguage() {