mirror of
https://github.com/flutter/flutter
synced 2024-08-25 11:07:06 +00:00
Fix memory leak in editable_gesture_test.dart
(#144691)
This commit is contained in:
parent
3e63c7385d
commit
96dd1984ec
|
@ -6,23 +6,21 @@ import 'package:flutter/gestures.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||
|
||||
void main() {
|
||||
final TestWidgetsFlutterBinding binding = _GestureBindingSpy();
|
||||
|
||||
testWidgets('attach and detach correctly handle gesture',
|
||||
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787
|
||||
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
|
||||
(_) async {
|
||||
testWidgets('attach and detach correctly handle gesture', (_) async {
|
||||
expect(WidgetsBinding.instance, binding);
|
||||
final TextSelectionDelegate delegate = FakeEditableTextState();
|
||||
final ViewportOffset offset = ViewportOffset.zero();
|
||||
addTearDown(offset.dispose);
|
||||
final RenderEditable editable = RenderEditable(
|
||||
backgroundCursorColor: Colors.grey,
|
||||
selectionColor: Colors.black,
|
||||
textDirection: TextDirection.ltr,
|
||||
cursorColor: Colors.red,
|
||||
offset: ViewportOffset.zero(),
|
||||
offset: offset,
|
||||
textSelectionDelegate: delegate,
|
||||
text: const TextSpan(
|
||||
text: 'test',
|
||||
|
@ -36,13 +34,17 @@ void main() {
|
|||
affinity: TextAffinity.upstream,
|
||||
),
|
||||
);
|
||||
addTearDown(editable.dispose);
|
||||
editable.layout(BoxConstraints.loose(const Size(1000.0, 1000.0)));
|
||||
|
||||
final PipelineOwner owner = PipelineOwner(onNeedVisualUpdate: () {});
|
||||
final _PointerRouterSpy spy = GestureBinding.instance.pointerRouter as _PointerRouterSpy;
|
||||
addTearDown(owner.dispose);
|
||||
final _PointerRouterSpy spy =
|
||||
GestureBinding.instance.pointerRouter as _PointerRouterSpy;
|
||||
editable.attach(owner);
|
||||
// This should register pointer into GestureBinding.instance.pointerRouter.
|
||||
editable.handleEvent(const PointerDownEvent(), BoxHitTestEntry(editable, const Offset(10,10)));
|
||||
editable.handleEvent(const PointerDownEvent(),
|
||||
BoxHitTestEntry(editable, const Offset(10, 10)));
|
||||
GestureBinding.instance.pointerRouter.route(const PointerDownEvent());
|
||||
expect(spy.routeCount, greaterThan(0));
|
||||
editable.detach();
|
||||
|
|
Loading…
Reference in a new issue