From efa109d405b346e5e2bfe3055623b7003d713d06 Mon Sep 17 00:00:00 2001 From: Tess Strickland Date: Thu, 12 Dec 2024 14:46:38 +0100 Subject: [PATCH] Add entry-point annotations for test-only code. (#160158) This change adds entry-point annotations to methods and classes accessed by native code during Flutter tests. Currently, entry point annotations are not checked by the Dart VM when running in JIT mode, only in AOT mode. In order to also enforce entry point annotations in JIT mode, first tests in Flutter must be appropriately annotated to avoid roll failures. Related issues: * https://github.com/flutter/flutter/issues/118608 * https://github.com/dart-lang/sdk/issues/50649 ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [X] I signed the [CLA]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I added new tests to check the change I am making, or this PR is [test-exempt]. - [X] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [X] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --- packages/flutter/test/cupertino/dialog_test.dart | 1 + packages/flutter/test/cupertino/route_test.dart | 1 + packages/flutter/test/material/date_picker_test.dart | 1 + packages/flutter/test/material/date_range_picker_test.dart | 1 + packages/flutter/test/material/dialog_test.dart | 1 + packages/flutter/test/material/time_picker_test.dart | 1 + packages/flutter/test/widgets/routes_test.dart | 1 + 7 files changed, 7 insertions(+) diff --git a/packages/flutter/test/cupertino/dialog_test.dart b/packages/flutter/test/cupertino/dialog_test.dart index 8476e0bdf2..fb0100bf17 100644 --- a/packages/flutter/test/cupertino/dialog_test.dart +++ b/packages/flutter/test/cupertino/dialog_test.dart @@ -2063,6 +2063,7 @@ Widget createAppWithCenteredButton(Widget child) { } +@pragma('vm:entry-point') class _RestorableDialogTestWidget extends StatelessWidget { const _RestorableDialogTestWidget(); diff --git a/packages/flutter/test/cupertino/route_test.dart b/packages/flutter/test/cupertino/route_test.dart index fa71528806..184eaad42a 100644 --- a/packages/flutter/test/cupertino/route_test.dart +++ b/packages/flutter/test/cupertino/route_test.dart @@ -3177,6 +3177,7 @@ class _TestPostRouteCancelState extends State<_TestPostRouteCancel> { } } +@pragma('vm:entry-point') class _RestorableModalTestWidget extends StatelessWidget { const _RestorableModalTestWidget(); diff --git a/packages/flutter/test/material/date_picker_test.dart b/packages/flutter/test/material/date_picker_test.dart index 810fa5e2cf..251f61355d 100644 --- a/packages/flutter/test/material/date_picker_test.dart +++ b/packages/flutter/test/material/date_picker_test.dart @@ -2620,6 +2620,7 @@ class _RestorableDatePickerDialogTestWidget extends StatefulWidget { _RestorableDatePickerDialogTestWidgetState createState() => _RestorableDatePickerDialogTestWidgetState(); } +@pragma('vm:entry-point') class _RestorableDatePickerDialogTestWidgetState extends State<_RestorableDatePickerDialogTestWidget> with RestorationMixin { @override String? get restorationId => 'scaffold_state'; diff --git a/packages/flutter/test/material/date_range_picker_test.dart b/packages/flutter/test/material/date_range_picker_test.dart index cbe73bdcc7..0651828073 100644 --- a/packages/flutter/test/material/date_range_picker_test.dart +++ b/packages/flutter/test/material/date_range_picker_test.dart @@ -1785,6 +1785,7 @@ class _RestorableDateRangePickerDialogTestWidget extends StatefulWidget { _RestorableDateRangePickerDialogTestWidgetState createState() => _RestorableDateRangePickerDialogTestWidgetState(); } +@pragma('vm:entry-point') class _RestorableDateRangePickerDialogTestWidgetState extends State<_RestorableDateRangePickerDialogTestWidget> with RestorationMixin { @override String? get restorationId => 'scaffold_state'; diff --git a/packages/flutter/test/material/dialog_test.dart b/packages/flutter/test/material/dialog_test.dart index 9c0db0b2b8..42b9d4a731 100644 --- a/packages/flutter/test/material/dialog_test.dart +++ b/packages/flutter/test/material/dialog_test.dart @@ -2975,6 +2975,7 @@ void main() { }); } +@pragma('vm:entry-point') class _RestorableDialogTestWidget extends StatelessWidget { const _RestorableDialogTestWidget(); diff --git a/packages/flutter/test/material/time_picker_test.dart b/packages/flutter/test/material/time_picker_test.dart index bbdbacc6ac..615b439049 100644 --- a/packages/flutter/test/material/time_picker_test.dart +++ b/packages/flutter/test/material/time_picker_test.dart @@ -2212,6 +2212,7 @@ class _TimePickerLauncher extends StatefulWidget { _TimePickerLauncherState createState() => _TimePickerLauncherState(); } +@pragma('vm:entry-point') class _TimePickerLauncherState extends State<_TimePickerLauncher> with RestorationMixin { @override String? get restorationId => widget.restorationId; diff --git a/packages/flutter/test/widgets/routes_test.dart b/packages/flutter/test/widgets/routes_test.dart index 461088284c..ac834bb53b 100644 --- a/packages/flutter/test/widgets/routes_test.dart +++ b/packages/flutter/test/widgets/routes_test.dart @@ -2600,6 +2600,7 @@ class WidgetWithNoLocalHistoryState extends State { } } +@pragma('vm:entry-point') class _RestorableDialogTestWidget extends StatelessWidget { const _RestorableDialogTestWidget();