Let a probe misfire not restart the stall detection

This commit is contained in:
Roland Geider
2026-08-15 20:16:06 +02:00
parent 9a97202dd4
commit 5e866de396
2 changed files with 27 additions and 2 deletions

View File

@@ -191,7 +191,25 @@ void main() {
});
});
test('going offline cancels a pending timer and clears the flag', () {
test('a probe misfiring under load does not restart the detection', () {
fakeAsync((async) {
// The reachability probe times out while a large download saturates
// the line and recovers right after. If that restarted the clock, the
// watchdog would never reach its timeout on exactly the connection it
// is meant to flag.
watchdog.onStatus(buildSyncStatus(connecting: true));
async.elapse(watchdog.timeout - const Duration(seconds: 10));
watchdog.offline = true;
watchdog.offline = false;
watchdog.onStatus(buildSyncStatus(connecting: true));
async.elapse(const Duration(seconds: 11));
expect(watchdog.stalled.value, isTrue);
});
});
test('going offline clears the flag and reports nothing further', () {
fakeAsync((async) {
watchdog.onStatus(buildSyncStatus(connecting: true));
async.elapse(watchdog.timeout);