L'equivalente per Windows della prova d'insieme del server su Chromium: FebeApp composto come lo compone Febe.exe (DesktopPlatform, DesktopShell, la finestra «Browser di Febe» su un thread di WPF), contro il sito di prova con accesso automatico, un orologio dieci volte più veloce e un fuso in cui è mezzogiorno. Il browser parte da un thread della composizione (il percorso che falliva sul PC di Alberto), si aggiungono marta.prova e luca.prova dall'interfaccia con il gettone di questo avvio, «Controlla ora» su marta.prova, e una sessione del motore agisce sul sito attraverso WebView2 con i permessi del Governatore: i file arrivano interi nella libreria temporanea, scaricati dal CDN del sito di prova attraverso il browser. Nel registro nessun avvio fallito e nessun indirizzo firmato. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
79 lines
2.2 KiB
C#
79 lines
2.2 KiB
C#
using Febe.Core.Abstractions;
|
|
using Febe.Desktop.Core;
|
|
|
|
namespace Febe.Tests.Windows.Support;
|
|
|
|
/// <summary>
|
|
/// A clock that compresses time, like the one of the Linux suite: <see cref="Delay"/> waits for real only a fraction
|
|
/// of the requested time and <see cref="Now"/> moves on by the whole of it, so the engine keeps its order of events
|
|
/// while a session lasts minutes instead of hours.
|
|
/// </summary>
|
|
internal sealed class CompressedClock(double factor, TimeZoneInfo zone) : IClock
|
|
{
|
|
private readonly Lock _gate = new();
|
|
private TimeSpan _offset;
|
|
|
|
public TimeZoneInfo LocalZone { get; } = zone;
|
|
|
|
public DateTimeOffset Now
|
|
{
|
|
get
|
|
{
|
|
lock (_gate)
|
|
{
|
|
return DateTimeOffset.UtcNow + _offset;
|
|
}
|
|
}
|
|
}
|
|
|
|
public async Task Delay(TimeSpan time, CancellationToken ct)
|
|
{
|
|
if (time <= TimeSpan.Zero)
|
|
{
|
|
ct.ThrowIfCancellationRequested();
|
|
return;
|
|
}
|
|
|
|
var real = TimeSpan.FromTicks((long)(time.Ticks / factor));
|
|
if (real >= TimeSpan.FromMilliseconds(1))
|
|
{
|
|
await Task.Delay(real, ct).ConfigureAwait(false);
|
|
}
|
|
else
|
|
{
|
|
ct.ThrowIfCancellationRequested();
|
|
await Task.Yield();
|
|
}
|
|
|
|
lock (_gate)
|
|
{
|
|
_offset += time - real;
|
|
}
|
|
}
|
|
}
|
|
|
|
internal static class TestZones
|
|
{
|
|
/// <summary>
|
|
/// A fixed-offset zone where it is between 12:00 and 13:00 now: inside the active window of every caution profile,
|
|
/// whatever the hour of the test.
|
|
/// </summary>
|
|
public static TimeZoneInfo Noon()
|
|
{
|
|
var offset = 12 - DateTimeOffset.UtcNow.Hour;
|
|
return TimeZoneInfo.CreateCustomTimeZone("Febe/Mezzogiorno", TimeSpan.FromHours(offset), "Mezzogiorno di prova", "Mezzogiorno di prova");
|
|
}
|
|
}
|
|
|
|
/// <summary>The registry values «CartellaDati» and «NuovaCartellaDati», in memory.</summary>
|
|
internal sealed class MemoryLocations : IDataFolderLocationStore
|
|
{
|
|
public string? Current { get; private set; }
|
|
|
|
public string? Pending { get; private set; }
|
|
|
|
public void SetCurrent(string? folder) => Current = folder;
|
|
|
|
public void SetPending(string? folder) => Pending = folder;
|
|
}
|