flutter / flutter/devtools

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

Offen
#6,719 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug devtools extensions P2
Vorherrschende Sprache
Dart
Sterne
1.7k
Forks
404
Ø Merge
6 T. 17 Std.
Gemergte PRs (30 T.)
18

Beschreibung

### 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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.