-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Test WidgetTester handling test pointers #83337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Gold has detected about 1 untriaged digest(s) on patchset 9. |
|
Gold has detected about 3 new digest(s) on patchset 11. |
|
Gold has detected about 3 new digest(s) on patchset 12. |
|
Gold has detected about 3 new digest(s) on patchset 14. |
|
Gold has detected about 3 new digest(s) on patchset 15. |
|
Gold has detected about 3 new digest(s) on patchset 16. |
goderbauer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
|
||
| final Widget display = await builder.display(); | ||
| await tester.binding.setSurfaceSize(builder.sheetSize()); | ||
| final Widget display = await builder.display(); // ignore: deprecated_member_use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these just be migrated to the new API? If not, maybe leave a comment explaining the ignore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to test the deprecated APIs are still working. I'll add a comment.
| await tester.pumpWidget(display); | ||
|
|
||
| final ui.Image image = await animationSheet.collate(20); | ||
| // The deprecated `sheetSize` is used only for the migration from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this comment mean? Should these be migrated to the new API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan to submit a new PR for the migration because the migration will break golden tests (because they'll be 1/3 in size), and in this way we're more sure what exactly caused the golden tests. It does look a bit redundant. Should I do them in the same PR?
| */ | ||
|
|
||
| LiveTestWidgetsFlutterBinding(); | ||
| testWidgets('Should show event indicator for pointer events', (WidgetTester tester) async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add a blank line before this one to help readability.
| import 'package:flutter/material.dart'; | ||
| import 'package:flutter/rendering.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove extra blank line?
| return _storeDebugPrints == null ? | ||
| super.debugPrintOverride : | ||
| ((String? message, { int? wrapWidth }) => _storeDebugPrints!.add(message)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return _storeDebugPrints == null ? | |
| super.debugPrintOverride : | |
| ((String? message, { int? wrapWidth }) => _storeDebugPrints!.add(message)); | |
| return _storeDebugPrints == null | |
| ? super.debugPrintOverride | |
| : ((String? message, { int? wrapWidth }) => _storeDebugPrints!.add(message)); |
| await tester.pump(); | ||
| expect(invocations, 0); | ||
|
|
||
| expect(printedMessages, equals(''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe to verify that it doesn't just list all possibilities also check what it prints when the tap misses the Text widget?
|
Gold has detected about 5 new digest(s) on patchset 18. |
|
Gold has detected about 6 new digest(s) on patchset 19. |
This PR adds tests to the following behaviors, which have existed without tests:
API change to
TestWidgetsFlutterBindingTestWidgetsFlutterBinding.handlePointerEventno longer shadowsGestureBinding.handlePointerEventwith a different signature. Its source-specified version is renamed tohandlePointerEventForSource. This allows subclasses to redefine only how pointer events are handled (for each source) without having to change the source storing process.New feature of
AnimationSheetBuilderAnimationSheetBuildernow supports a new option at construction:allLayers. The current behavior isallLayers: false. IfallLayersis true, the recorder records the resulting image composited by the entire tree, clipped by the region of this recorder. This is useful when it is impossible for the recorder to include the target image in its subtree, which is needed for the test of this PR.New way to use
AnimationSheetBuilderand deprecationAnimationSheetBuilder's output step used to require two calls:displayandsurfaceSize. This PR introduced a new way:collate.The
collatefunction directly puts the images together and asynchronously returns an image. It requires less boilerplate, and outputs smaller images (1/3 the width & height) without any compromise to quality.The current APIs (
displayandsurfaceSize) are thus deprecated. A migration guide is provided (although these APIs are probably not used by customer tests or g3): flutter/website#5862.Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.