[cupertino_ui] Migrate picker_test.dart to SemanticsHandle#12008
[cupertino_ui] Migrate picker_test.dart to SemanticsHandle#12008Renzo-Olivares wants to merge 2 commits into
picker_test.dart to SemanticsHandle#12008Conversation
There was a problem hiding this comment.
Code Review
This pull request removes the skip annotation from picker_test.dart and refactors the semantics tests to use SemanticsHandle and tester.getSemantics instead of SemanticsTester. The review feedback suggests replacing the use of private class name strings (_CupertinoPickerSemantics) in widget predicates with a cleaner search for the public ListWheelScrollView widget.
| tester.getSemantics( | ||
| find.byWidgetPredicate( | ||
| (Widget widget) => widget.runtimeType.toString() == '_CupertinoPickerSemantics', | ||
| ), | ||
| ), |
There was a problem hiding this comment.
Instead of finding the private _CupertinoPickerSemantics widget by matching its runtimeType.toString(), we can find the public ListWheelScrollView widget. Since ListWheelScrollView is a direct descendant of _CupertinoPickerSemantics, tester.getSemantics will automatically walk up the tree and return the semantics node of _CupertinoPickerSemantics (which is the nearest ancestor semantics boundary). This is cleaner, more robust, and avoids relying on private class name strings.
| tester.getSemantics( | |
| find.byWidgetPredicate( | |
| (Widget widget) => widget.runtimeType.toString() == '_CupertinoPickerSemantics', | |
| ), | |
| ), | |
| tester.getSemantics(find.byType(ListWheelScrollView)), |
There was a problem hiding this comment.
Tried the suggestion but it does not work, tester.getSemantics(find.byType(ListWheelScrollView) does not return the node of _CupertinoPickerSemantics (ancestor).
| tester.getSemantics( | ||
| find.byWidgetPredicate( | ||
| (Widget widget) => widget.runtimeType.toString() == '_CupertinoPickerSemantics', | ||
| ), | ||
| ), |
There was a problem hiding this comment.
Instead of finding the private _CupertinoPickerSemantics widget by matching its runtimeType.toString(), we can find the public ListWheelScrollView widget. Since ListWheelScrollView is a direct descendant of _CupertinoPickerSemantics, tester.getSemantics will automatically walk up the tree and return the semantics node of _CupertinoPickerSemantics (which is the nearest ancestor semantics boundary). This is cleaner, more robust, and avoids relying on private class name strings.
| tester.getSemantics( | |
| find.byWidgetPredicate( | |
| (Widget widget) => widget.runtimeType.toString() == '_CupertinoPickerSemantics', | |
| ), | |
| ), | |
| tester.getSemantics(find.byType(ListWheelScrollView)), |
| tester.getSemantics( | ||
| find.byWidgetPredicate( | ||
| (Widget widget) => widget.runtimeType.toString() == '_CupertinoPickerSemantics', | ||
| ), | ||
| ), |
There was a problem hiding this comment.
Instead of finding the private _CupertinoPickerSemantics widget by matching its runtimeType.toString(), we can find the public ListWheelScrollView widget. Since ListWheelScrollView is a direct descendant of _CupertinoPickerSemantics, tester.getSemantics will automatically walk up the tree and return the semantics node of _CupertinoPickerSemantics (which is the nearest ancestor semantics boundary). This is cleaner, more robust, and avoids relying on private class name strings.
| tester.getSemantics( | |
| find.byWidgetPredicate( | |
| (Widget widget) => widget.runtimeType.toString() == '_CupertinoPickerSemantics', | |
| ), | |
| ), | |
| tester.getSemantics(find.byType(ListWheelScrollView)), |
| tester.getSemantics( | ||
| find.byWidgetPredicate( | ||
| (Widget widget) => widget.runtimeType.toString() == '_CupertinoPickerSemantics', | ||
| ), | ||
| ), |
There was a problem hiding this comment.
Instead of finding the private _CupertinoPickerSemantics widget by matching its runtimeType.toString(), we can find the public ListWheelScrollView widget. Since ListWheelScrollView is a direct descendant of _CupertinoPickerSemantics, tester.getSemantics will automatically walk up the tree and return the semantics node of _CupertinoPickerSemantics (which is the nearest ancestor semantics boundary). This is cleaner, more robust, and avoids relying on private class name strings.
| tester.getSemantics( | |
| find.byWidgetPredicate( | |
| (Widget widget) => widget.runtimeType.toString() == '_CupertinoPickerSemantics', | |
| ), | |
| ), | |
| tester.getSemantics(find.byType(ListWheelScrollView)), |
| tester.getSemantics( | ||
| find.byWidgetPredicate( | ||
| (Widget widget) => widget.runtimeType.toString() == '_CupertinoPickerSemantics', | ||
| ), | ||
| ), |
There was a problem hiding this comment.
Instead of finding the private _CupertinoPickerSemantics widget by matching its runtimeType.toString(), we can find the public ListWheelScrollView widget. Since ListWheelScrollView is a direct descendant of _CupertinoPickerSemantics, tester.getSemantics will automatically walk up the tree and return the semantics node of _CupertinoPickerSemantics (which is the nearest ancestor semantics boundary). This is cleaner, more robust, and avoids relying on private class name strings.
| tester.getSemantics( | |
| find.byWidgetPredicate( | |
| (Widget widget) => widget.runtimeType.toString() == '_CupertinoPickerSemantics', | |
| ), | |
| ), | |
| tester.getSemantics(find.byType(ListWheelScrollView)), |
Part of flutter/flutter#182636 and flutter/flutter#188395
This PR:
widgets/semantics_tester.dart. ReplacedSemanticsTesterwithSemanticsHandle.@Skipannotation, all tests in this file has passed.semantics_tester.darthas existed incupertino_ui, so we can directly importsemantics_tester.dart;test/folder.Pre-Review Checklist
[shared_preferences]///).