Fixes some gesture recognizers are not disposed. (#146072)
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||
|
||||
import 'gesture_tester.dart';
|
||||
|
||||
@@ -766,8 +765,6 @@ void main() {
|
||||
});
|
||||
|
||||
testGesture('Horizontal drag with multiple pointers - averageBoundaryPointers',
|
||||
// TODO(polina-c): dispose gesture recognizers https://github.com/flutter/flutter/issues/145605 [leaks-to-clean]
|
||||
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
|
||||
(GestureTester tester) {
|
||||
final HorizontalDragGestureRecognizer drag =
|
||||
HorizontalDragGestureRecognizer()
|
||||
@@ -903,6 +900,8 @@ void main() {
|
||||
// Tear down 'currentSystemFrameTimeStamp'
|
||||
SchedulerBinding.instance.handleBeginFrame(Duration.zero);
|
||||
SchedulerBinding.instance.handleDrawFrame();
|
||||
// Dispose gesture
|
||||
drag.dispose();
|
||||
|
||||
expect(log, <String>[
|
||||
'-a',
|
||||
@@ -929,8 +928,6 @@ void main() {
|
||||
});
|
||||
|
||||
testGesture('Vertical drag with multiple pointers - averageBoundaryPointers',
|
||||
// TODO(polina-c): dispose gesture recognizers https://github.com/flutter/flutter/issues/145605 [leaks-to-clean]
|
||||
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
|
||||
(GestureTester tester) {
|
||||
final VerticalDragGestureRecognizer drag =
|
||||
VerticalDragGestureRecognizer()
|
||||
@@ -1066,6 +1063,8 @@ void main() {
|
||||
// Tear down 'currentSystemFrameTimeStamp'
|
||||
SchedulerBinding.instance.handleBeginFrame(Duration.zero);
|
||||
SchedulerBinding.instance.handleDrawFrame();
|
||||
// Dispose gesture
|
||||
drag.dispose();
|
||||
|
||||
expect(log, <String>[
|
||||
'-a',
|
||||
@@ -1092,8 +1091,6 @@ void main() {
|
||||
});
|
||||
|
||||
testGesture('Pan drag with multiple pointers - averageBoundaryPointers',
|
||||
// TODO(polina-c): dispose gesture recognizers https://github.com/flutter/flutter/issues/145605 [leaks-to-clean]
|
||||
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
|
||||
(GestureTester tester) {
|
||||
final PanGestureRecognizer drag =
|
||||
PanGestureRecognizer()
|
||||
@@ -1251,6 +1248,9 @@ void main() {
|
||||
SchedulerBinding.instance.handleBeginFrame(Duration.zero);
|
||||
SchedulerBinding.instance.handleDrawFrame();
|
||||
|
||||
// Dispose gesture
|
||||
drag.dispose();
|
||||
|
||||
expect(log, <String>[
|
||||
'-a',
|
||||
'drag-update (Offset(100.0, 100.0))',
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||
|
||||
class HoverClient extends StatefulWidget {
|
||||
const HoverClient({
|
||||
@@ -1838,8 +1837,6 @@ void main() {
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/67044
|
||||
testWidgets('Handle mouse events should ignore the detached MouseTrackerAnnotation',
|
||||
// TODO(polina-c): dispose gesture recognizers https://github.com/flutter/flutter/issues/145605 [leaks-to-clean]
|
||||
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Center(
|
||||
@@ -1866,6 +1863,9 @@ void main() {
|
||||
|
||||
// Continue drag mouse should not trigger any assert.
|
||||
await gesture.moveBy(const Offset(10.0, 10.0));
|
||||
|
||||
// Dispose gesture
|
||||
await gesture.cancel();
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user