flutter / flutter/devtools

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

Đang mở
#6,719 5 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug devtools extensions P2
Ngôn ngữ chính
Dart
Star
1.7k
Fork
404
Merge trung bình
6 ngày 17 giờ
Pull request đã merge (30 ngày)
18

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.