Correzione: il motore non rimette a riposo la pagina che Alberto ha appena ripreso
verifica / controlli (push) Successful in 28s
verifica / prove (push) Failing after 39m9s
verifica / installatore (push) Skipped
verifica / immagine (push) Skipped

Le prove di BrowserStartPageTests fallivano a volte (pagina «about:blank» invece
della pagina iniziale, o la pagina iniziale invece di quella aperta da Alberto).
Non era l'attesa del browser di #67: la stessa corsa si vede anche con il codice
di main. Dopo «Ho finito» il giro del motore vede che Alberto ha lasciato il
browser e chiede il turno della pagina per il riposo; se nel frattempo Alberto
riprende il browser e la sua navigazione prende il turno per prima, il riposo
arriva subito dopo e gli porta via la pagina (una finestra bianca, #52).

Ora il riposo dopo la guida e quello di fine sessione guardano di nuovo, con il
turno in mano, se Alberto guida (o se una verifica tiene la pagina), come fa già
la ricerca dei profili; il riposo resta dovuto per quando lascia il browser.
Nuova prova deterministica in EngineHostTests.

Il motore conta come avviato già in StartAsync, non solo quando il pool di
thread arriva al suo giro: «Scollega» che fallisce lo dice subito (l'altra prova
che falliva a volte, DesktopCompositionTests).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-29 13:26:58 +01:00
1 parent 8d1b344366
commit 98769b5870
2 files changed
+75 -3

No files matched your search

@@ -519,6 +519,49 @@ public sealed class EngineHostTests
Assert.AreEqual(restsWhenTaken + 1, runner.Rests, "The verification page is left as it is.");
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task ARestThatGetsThePageOnlyAfterAlbertoTookTheBrowserAgainLeavesHisPage()
{
var driving = false;
await using var bed = await EngineTestBed.CreateAsync(Morning, userIsDriving: () => driving);
await bed.AddAccountAsync("uno.demo", followed: true);
var runner = new ScriptedRunner(bed.Governor, bed.Clock);
var host = bed.Start(runner);
await host.PauseAsync();
driving = true;
host.NotifyUserDrivingChanged();
await bed.RunForAsync(TimeSpan.FromSeconds(1));
var rests = runner.Rests;
// He lets go while his own navigation still holds the page (the turn of «Usa il browser»): the rest waits for it.
var turns = bed.Services.PageTurns;
var albertos = await turns.TakeAsync(PageUser.Engine, CancellationToken.None);
driving = false;
host.NotifyUserDrivingChanged();
// Real time: the loop, woken, waits for the turn and for no timer of the virtual clock.
var watch = System.Diagnostics.Stopwatch.StartNew();
while (!turns.IsWaiting(PageUser.Engine))
{
Assert.IsLessThan(TimeSpan.FromSeconds(10), watch.Elapsed, "the rest waits for the page turn");
await Task.Delay(TimeSpan.FromMilliseconds(10));
}
// He takes the browser again and his page opens before the rest gets the turn: the page is his, not rested.
driving = true;
host.NotifyUserDrivingChanged();
albertos.Dispose();
await bed.RunForAsync(TimeSpan.FromSeconds(1));
Assert.AreEqual(rests, runner.Rests, "the page he took is not put to rest under him");
Assert.IsFalse(turns.IsWaiting(PageUser.Engine));
// The rest is still owed: when he lets go again, the page goes back to rest.
driving = false;
host.NotifyUserDrivingChanged();
await bed.RunForAsync(TimeSpan.FromSeconds(1));
Assert.AreEqual(rests + 1, runner.Rests, "back to rest once he lets go");
}
[TestMethod]
public async Task ChangingTheAccountsDuringARecipeDoesNotBringItsNextCheckForward()
{