«Pagina iniziale» solo finché Alberto guida, e la vista che non si blocca (#52)
Una verifica indipendente di 654076d ha trovato tre punti deboli.
- «Pagina iniziale» guardava il permesso di guida una volta sola, prima di
aspettare fino a 15 s la fine della sessione e 15 s il turno della pagina
(che poi prendeva comunque). Se nel frattempo Alberto chiudeva la finestra,
Febe navigava senza permesso e fuori dal Governatore (regole 7 e 8). Ora la
pressione vale finché dura il permesso di chi l'ha premuta: la finestra di
Windows passa un gettone che si annulla con il suo permesso, la vista remota
quello della propria vita. Con il turno della pagina in mano la connessione
guarda di nuovo che Alberto guidi ancora; senza turno rinuncia invece di
prendere la pagina a un passo della ricerca. L'attesa del turno è
BrowserConnectionService.PageTurnWait (15 s, le prove la accorciano).
- Nella vista remota «Pagina iniziale» aspettava dentro il ciclo di ricezione:
la vista restava ferma fino a mezzo minuto e poi riversava clic e tasti sulla
pagina nuova. Ora la pressione corre a parte, una per volta, e intanto clic,
tasti, «Indietro» e «Ricarica» si scartano.
- Repaint chiedeva un ridisegno sincrono (RDW_UPDATENOW) a finestre figlie del
processo del browser di WebView2: uno bloccato avrebbe fermato il thread
dell'interfaccia. Ora si chiede solo di ridisegnare.
Prove nuove, che senza le correzioni non passano: la pressione dimenticata se
Alberto lascia il browser, quella che finisce con il permesso di chi l'ha
premuta, la pagina mai tolta a un passo della ricerca, la vista che non si
blocca e scarta l'input; su Windows con WebView2 vero, il gettone che si
annulla quando la finestra si chiude. PROTOCOLLO.md, la guida e decisioni.md
dicono il comportamento nuovo.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
654076d280
commit
2bbad2e9b7
12 files changed
+340
-24
No files matched your search
@@ -121,6 +121,42 @@ public sealed class BrowserWindowTests
|
||||
TestContext.WriteLine($"Nascosta fuori vista {await bed.OnUiAsync(() => hides)} volte per il pulsante nella barra delle applicazioni.");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(120_000, CooperativeCancellation = true)]
|
||||
public async Task PaginaInizialeLastsAsLongAsTheWindowsLease()
|
||||
{
|
||||
var ct = TestContext.CancellationToken;
|
||||
var pressedWith = new TaskCompletionSource<CancellationToken>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
// As the connection while a session ends or a search step holds the page: it waits, here until the press is over.
|
||||
await using var bed = await BrowserBed.CreateAsync("finestra-pagina-iniziale-chiusa", openStartPage: async token =>
|
||||
{
|
||||
pressedWith.TrySetResult(token);
|
||||
await Task.Delay(Timeout.Infinite, token);
|
||||
});
|
||||
await bed.StartAsync(ct);
|
||||
var window = await bed.OnUiAsync(() => bed.Browser.Host.Window) ?? throw new AssertFailedException("nessuna finestra");
|
||||
await Task.Run(() => bed.Browser.ShowToUserAsync(ct), ct);
|
||||
|
||||
await bed.OnUiAsync(() =>
|
||||
{
|
||||
Button(window, "Pagina iniziale").RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
|
||||
return true;
|
||||
});
|
||||
var token = await pressedWith.Task.WaitAsync(TimeSpan.FromSeconds(30), ct);
|
||||
Assert.IsFalse(token.IsCancellationRequested, "the window is still on screen");
|
||||
|
||||
// Alberto closes the window before the start page opened: the press is over with the window's lease.
|
||||
await bed.OnUiAsync(() =>
|
||||
{
|
||||
window.Close();
|
||||
return true;
|
||||
});
|
||||
Assert.IsFalse(bed.Browser.UserIsDriving);
|
||||
await bed.WaitUntilAsync(() => token.IsCancellationRequested, TimeSpan.FromSeconds(10), "la fine della «Pagina iniziale» con la finestra", ct);
|
||||
Assert.IsFalse(bed.Lines.Any("non aperta"), "a press given up is no failure: " + bed.Lines.Text);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(120_000, CooperativeCancellation = true)]
|
||||
public async Task AMinimisedWindowKeepsAlbertoAtTheWheelUntilItIsMinimisedTooLong()
|
||||
|
||||
@@ -49,7 +49,8 @@ internal sealed class BrowserBed : IAsyncDisposable
|
||||
/// Where «Pagina iniziale» goes, opened as the connection would (here without an engine to wait for); null: the button
|
||||
/// does nothing (never the default login page of the options, which is Instagram's).
|
||||
/// </param>
|
||||
public static async Task<BrowserBed> CreateAsync(string name, BrowserHosting hosting = BrowserHosting.Window, Func<string>? startPage = null)
|
||||
/// <param name="openStartPage">What «Pagina iniziale» does instead (it wins over <paramref name="startPage"/>).</param>
|
||||
public static async Task<BrowserBed> CreateAsync(string name, BrowserHosting hosting = BrowserHosting.Window, Func<string>? startPage = null, Func<CancellationToken, Task>? openStartPage = null)
|
||||
{
|
||||
var folder = new TestFolder(name);
|
||||
var ui = await UiThread.StartAsync();
|
||||
@@ -61,7 +62,7 @@ internal sealed class BrowserBed : IAsyncDisposable
|
||||
var options = new FebeAppOptions { DataFolder = data.Root, LibraryFolder = folder.Combine("libreria") };
|
||||
var tracker = new BrowserUseTracker();
|
||||
WebView2Browser? built = null;
|
||||
Func<CancellationToken, Task>? openStartPage = startPage is null ? null : async ct => await built!.Cdp.NavigateAsync(startPage(), ct);
|
||||
openStartPage ??= startPage is null ? null : async ct => await built!.Cdp.NavigateAsync(startPage(), ct);
|
||||
var context = new FebePlatformContext(options, data, database, clock, log, tracker, openStartPage);
|
||||
var settings = new WebView2BrowserSettings(data.BrowserProfile, 1280, 900, hosting, BrowserArguments.ForWebView2());
|
||||
|
||||
|
||||
Reference in new issue
Block a user