[leak-tracking] Cover testwidgets with leak tracking in test/gestures (#136166)

This commit is contained in:
droidbg 2023-10-10 01:39:24 +05:30 committed by GitHub
parent a1e10ee49e
commit 3df6078bc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -11,7 +11,7 @@ import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
group('Horizontal', () { group('Horizontal', () {
testWidgets('gets local coordinates', (WidgetTester tester) async { testWidgetsWithLeakTracking('gets local coordinates', (WidgetTester tester) async {
int dragCancelCount = 0; int dragCancelCount = 0;
final List<DragDownDetails> downDetails = <DragDownDetails>[]; final List<DragDownDetails> downDetails = <DragDownDetails>[];
final List<DragEndDetails> endDetails = <DragEndDetails>[]; final List<DragEndDetails> endDetails = <DragEndDetails>[];

View File

@ -4,9 +4,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgets('gets local coordinates', (WidgetTester tester) async { testWidgetsWithLeakTracking('gets local coordinates', (WidgetTester tester) async {
final List<ScaleStartDetails> startDetails = <ScaleStartDetails>[]; final List<ScaleStartDetails> startDetails = <ScaleStartDetails>[];
final List<ScaleUpdateDetails> updateDetails = <ScaleUpdateDetails>[]; final List<ScaleUpdateDetails> updateDetails = <ScaleUpdateDetails>[];
@ -30,7 +31,7 @@ void main() {
), ),
); );
await tester.startGesture(tester.getCenter(find.byKey(redContainer)) - const Offset(20, 20)); final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byKey(redContainer)) - const Offset(20, 20));
final TestGesture pointer2 = await tester.startGesture(tester.getCenter(find.byKey(redContainer)) + const Offset(30, 30)); final TestGesture pointer2 = await tester.startGesture(tester.getCenter(find.byKey(redContainer)) + const Offset(30, 30));
await pointer2.moveTo(tester.getCenter(find.byKey(redContainer)) + const Offset(20, 20)); await pointer2.moveTo(tester.getCenter(find.byKey(redContainer)) + const Offset(20, 20));
@ -42,5 +43,11 @@ void main() {
expect(startDetails.first.focalPoint, const Offset(380, 280)); expect(startDetails.first.focalPoint, const Offset(380, 280));
expect(startDetails.last.localFocalPoint, const Offset(50, 50)); expect(startDetails.last.localFocalPoint, const Offset(50, 50));
expect(startDetails.last.focalPoint, const Offset(400, 300)); expect(startDetails.last.focalPoint, const Offset(400, 300));
await tester.pumpAndSettle();
await gesture.up();
await pointer2.up();
await tester.pumpAndSettle();
}); });
} }