flutter / flutter/devtools

DevTools set `debugDefaultTargetPlatformOverride` but don't reset it, causing assertions to be broken

Aperta
#6,719 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug devtools extensions P2
Lingua principale
Dart
Stelle
1.7k
Fork
404
Merge medio
6g 17h
PR unite (30g)
18

Descrizione

### Problem

The DevTools call `FoundationServiceExtensions.platformOverride`, which [modifies](https://github.com/flutter/flutter/blob/f70a01c69165561d7754a6882a124d11fe6da4e6/packages/flutter/lib/src/foundation/binding.dart#L568) the value of [`debugDefaultTargetPlatformOverride`](https://github.com/flutter/flutter/blob/f70a01c69165561d7754a6882a124d11fe6da4e6/packages/flutter/lib/src/foundation/platform.dart#L98).

This causes tests (that are being run when the DevTools are enable) to fail because the assertion in [`TestWidgetsFlutterBinding._runTestBody()`](https://github.com/flutter/flutter/blob/3.16.0/packages/flutter_test/lib/src/binding.dart#L996) is violated:

https://github.com/flutter/flutter/blob/0cdb3bf582f00cbb9bc4a3701263ab655b09db69/packages/flutter/lib/src/foundation/debug.dart#L28-L39

### Proposed solution

- DevTools should take care of resettnig `debugDefaultTargetPlatformOverride` (and possibly other values it might set) during the tests.

- DevTools (and its extension ecosystem) should probably be tested on more test-like scenarious – when the app's entrypoint is a widget/integration tests. This would prevent issues like this in the future.

### Workaround

We have adopted [a temporary workaround](https://github.com/leancodepl/patrol/pull/1829/commits/778b4ede1e153c4505489d59a71e1c8c0fa46575) - save the value of `debugDefaultTargetPlatformOverride` sometime at the beginning of the test, and restore it near the end.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.