Unverified Commit a8e69924 authored by Polina Cherkasova's avatar Polina Cherkasova Committed by GitHub

Ignore or fix leaks. (#141468)

parent 3d112429
...@@ -80,7 +80,7 @@ void main() { ...@@ -80,7 +80,7 @@ void main() {
testWidgets('Should show event indicator for pointer events with setSurfaceSize', testWidgets('Should show event indicator for pointer events with setSurfaceSize',
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 // TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(), experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async { (WidgetTester tester) async {
final AnimationSheetBuilder animationSheet = AnimationSheetBuilder(frameSize: const Size(200, 200), allLayers: true); final AnimationSheetBuilder animationSheet = AnimationSheetBuilder(frameSize: const Size(200, 200), allLayers: true);
addTearDown(animationSheet.dispose); addTearDown(animationSheet.dispose);
......
...@@ -20,7 +20,7 @@ import '_goldens_io.dart' if (dart.library.html) '_goldens_web.dart' ...@@ -20,7 +20,7 @@ import '_goldens_io.dart' if (dart.library.html) '_goldens_web.dart'
/// `--dart-define LEAK_TRACKING=true` or invoke `export LEAK_TRACKING=true`. /// `--dart-define LEAK_TRACKING=true` or invoke `export LEAK_TRACKING=true`.
/// ///
/// See documentation for [testWidgets] on how to except individual tests. /// See documentation for [testWidgets] on how to except individual tests.
bool isLeakTrackingEnabled() { bool _isLeakTrackingEnabled() {
if (kIsWeb) { if (kIsWeb) {
return false; return false;
} }
...@@ -41,7 +41,7 @@ Future<void> testExecutable(FutureOr<void> Function() testMain) { ...@@ -41,7 +41,7 @@ Future<void> testExecutable(FutureOr<void> Function() testMain) {
// receive the event. // receive the event.
WidgetController.hitTestWarningShouldBeFatal = true; WidgetController.hitTestWarningShouldBeFatal = true;
if (isLeakTrackingEnabled()) { if (_isLeakTrackingEnabled()) {
LeakTesting.enable(); LeakTesting.enable();
LeakTracking.warnForUnsupportedPlatforms = false; LeakTracking.warnForUnsupportedPlatforms = false;
......
...@@ -2951,6 +2951,7 @@ void main() { ...@@ -2951,6 +2951,7 @@ void main() {
testWidgets('Block entering text on disabled widget', (WidgetTester tester) async { testWidgets('Block entering text on disabled widget', (WidgetTester tester) async {
const String initValue = 'init'; const String initValue = 'init';
final TextEditingController controller = TextEditingController(text: initValue); final TextEditingController controller = TextEditingController(text: initValue);
addTearDown(controller.dispose);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -2972,13 +2973,15 @@ void main() { ...@@ -2972,13 +2973,15 @@ void main() {
testWidgets('Disabled SearchBar semantics node still contains value', (WidgetTester tester) async { testWidgets('Disabled SearchBar semantics node still contains value', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
final TextEditingController controller = TextEditingController(text: 'text');
addTearDown(controller.dispose);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Material( home: Material(
child: Center( child: Center(
child: SearchBar( child: SearchBar(
controller: TextEditingController(text: 'text'), controller: controller,
enabled: false, enabled: false,
), ),
), ),
......
...@@ -7,8 +7,13 @@ import 'dart:ui' as ui; ...@@ -7,8 +7,13 @@ import 'dart:ui' as ui;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.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() {
// LeakTesting is turned off because it adds subscriptions to
// [FlutterMemoryAllocations], that may interfere with the tests.
LeakTesting.settings = LeakTesting.settings.withIgnoredAll();
final FlutterMemoryAllocations ma = FlutterMemoryAllocations.instance; final FlutterMemoryAllocations ma = FlutterMemoryAllocations.instance;
setUp(() { setUp(() {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.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';
import 'clipboard_utils.dart'; import 'clipboard_utils.dart';
import 'editable_text_utils.dart'; import 'editable_text_utils.dart';
...@@ -90,7 +91,10 @@ void main() { ...@@ -90,7 +91,10 @@ void main() {
expect(find.byKey(key2), findsNothing); expect(find.byKey(key2), findsNothing);
}); });
testWidgets('A menu can be hidden and then reshown', (WidgetTester tester) async { testWidgets('A menu can be hidden and then reshown',
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async {
final GlobalKey key1 = GlobalKey(); final GlobalKey key1 = GlobalKey();
late final BuildContext context; late final BuildContext context;
...@@ -178,7 +182,10 @@ void main() { ...@@ -178,7 +182,10 @@ void main() {
controller.remove(); controller.remove();
}); });
testWidgets('Calling show when a built-in widget is already showing its context menu hides the built-in menu', (WidgetTester tester) async { testWidgets('Calling show when a built-in widget is already showing its context menu hides the built-in menu',
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async {
final GlobalKey builtInKey = GlobalKey(); final GlobalKey builtInKey = GlobalKey();
final GlobalKey directKey = GlobalKey(); final GlobalKey directKey = GlobalKey();
late final BuildContext context; late final BuildContext context;
......
...@@ -1853,7 +1853,10 @@ void main() { ...@@ -1853,7 +1853,10 @@ void main() {
skip: kIsWeb, // https://github.com/flutter/flutter/issues/87933. skip: kIsWeb, // https://github.com/flutter/flutter/issues/87933.
); );
testWidgets('Reports image size when painted', (WidgetTester tester) async { testWidgets('Reports image size when painted',
// TODO(polina-c): make sure images are disposed, https://github.com/flutter/flutter/issues/141388
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async {
late ImageSizeInfo imageSizeInfo; late ImageSizeInfo imageSizeInfo;
int count = 0; int count = 0;
debugOnPaintImage = (ImageSizeInfo info) { debugOnPaintImage = (ImageSizeInfo info) {
......
...@@ -5,11 +5,16 @@ ...@@ -5,11 +5,16 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.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';
int _creations = 0; int _creations = 0;
int _disposals = 0; int _disposals = 0;
void main() { void main() {
// LeakTesting is turned off because it adds subscriptions to
// [FlutterMemoryAllocations], that may interfere with the tests.
LeakTesting.settings = LeakTesting.settings.withIgnoredAll();
final FlutterMemoryAllocations ma = FlutterMemoryAllocations.instance; final FlutterMemoryAllocations ma = FlutterMemoryAllocations.instance;
test('Publishers dispatch events in debug mode', () async { test('Publishers dispatch events in debug mode', () async {
......
...@@ -535,9 +535,8 @@ void main() { ...@@ -535,9 +535,8 @@ void main() {
}); });
testWidgets('Three NestedScrollViews with one ScrollController', testWidgets('Three NestedScrollViews with one ScrollController',
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
// TODO(polina-c): Remove when PageView is fixed, https://github.com/flutter/flutter/issues/141119 // TODO(polina-c): Remove when PageView is fixed, https://github.com/flutter/flutter/issues/141119
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async { (WidgetTester tester) async {
final TrackingScrollController controller = TrackingScrollController(); final TrackingScrollController controller = TrackingScrollController();
addTearDown(controller.dispose); addTearDown(controller.dispose);
......
...@@ -419,7 +419,10 @@ void main() { ...@@ -419,7 +419,10 @@ void main() {
expect(previousPageCompleted, true); expect(previousPageCompleted, true);
}); });
testWidgets('PageView in zero-size container', (WidgetTester tester) async { testWidgets('PageView in zero-size container',
// TODO(polina-c): Remove when PageView is fixed, https://github.com/flutter/flutter/issues/141119
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async {
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Center( child: Center(
...@@ -599,7 +602,10 @@ void main() { ...@@ -599,7 +602,10 @@ void main() {
expect(tester.getTopLeft(find.text('Idaho')), const Offset(790.0, 0.0)); expect(tester.getTopLeft(find.text('Idaho')), const Offset(790.0, 0.0));
}); });
testWidgets('Page snapping disable and reenable', (WidgetTester tester) async { testWidgets('Page snapping disable and reenable',
// TODO(polina-c): Remove when PageView is fixed, https://github.com/flutter/flutter/issues/141119
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async {
final List<int> log = <int>[]; final List<int> log = <int>[];
Widget build({ required bool pageSnapping }) { Widget build({ required bool pageSnapping }) {
......
...@@ -34,7 +34,10 @@ void main() { ...@@ -34,7 +34,10 @@ void main() {
return Scrollable.of(find.byType(TestWidget).evaluate().first).position; return Scrollable.of(find.byType(TestWidget).evaluate().first).position;
} }
testWidgets('ScrollAwareImageProvider does not delay if widget is not in scrollable', (WidgetTester tester) async { testWidgets('ScrollAwareImageProvider does not delay if widget is not in scrollable',
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async {
final GlobalKey<TestWidgetState> key = GlobalKey<TestWidgetState>(); final GlobalKey<TestWidgetState> key = GlobalKey<TestWidgetState>();
await tester.pumpWidget(TestWidget(key)); await tester.pumpWidget(TestWidget(key));
...@@ -99,7 +102,10 @@ void main() { ...@@ -99,7 +102,10 @@ void main() {
expect(findPhysics<RecordingPhysics>(tester).velocities, <double>[0]); expect(findPhysics<RecordingPhysics>(tester).velocities, <double>[0]);
}); });
testWidgets('ScrollAwareImageProvider does not delay if in scrollable that is scrolling slowly', (WidgetTester tester) async { testWidgets('ScrollAwareImageProvider does not delay if in scrollable that is scrolling slowly',
// TODO(polina-c): make sure images are disposed, https://github.com/flutter/flutter/issues/141388
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async {
final List<GlobalKey<TestWidgetState>> keys = <GlobalKey<TestWidgetState>>[]; final List<GlobalKey<TestWidgetState>> keys = <GlobalKey<TestWidgetState>>[];
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
......
...@@ -282,7 +282,10 @@ void main() { ...@@ -282,7 +282,10 @@ void main() {
await pageViewScrollAndRestore(tester); await pageViewScrollAndRestore(tester);
}); });
testWidgets('PageView.builder restoration', (WidgetTester tester) async { testWidgets('PageView.builder restoration',
// TODO(polina-c): Remove when PageView is fixed, https://github.com/flutter/flutter/issues/141119
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
TestHarness( TestHarness(
child: PageView.builder( child: PageView.builder(
...@@ -298,7 +301,10 @@ void main() { ...@@ -298,7 +301,10 @@ void main() {
await pageViewScrollAndRestore(tester); await pageViewScrollAndRestore(tester);
}); });
testWidgets('PageView.custom restoration', (WidgetTester tester) async { testWidgets('PageView.custom restoration',
// TODO(polina-c): Remove when PageView is fixed, https://github.com/flutter/flutter/issues/141119
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
TestHarness( TestHarness(
child: PageView.custom( child: PageView.custom(
......
...@@ -64,7 +64,10 @@ void main() { ...@@ -64,7 +64,10 @@ void main() {
expect(controller.initialScrollOffset, 0.0); expect(controller.initialScrollOffset, 0.0);
}); });
testWidgets('TrackingScrollController saves offset', (WidgetTester tester) async { testWidgets('TrackingScrollController saves offset',
// TODO(polina-c): Remove when PageView is fixed, https://github.com/flutter/flutter/issues/141119
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async {
int attach = 0; int attach = 0;
int detach = 0; int detach = 0;
final TrackingScrollController controller = TrackingScrollController( final TrackingScrollController controller = TrackingScrollController(
......
...@@ -123,7 +123,7 @@ E? _lastWhereOrNull<E>(Iterable<E> list, bool Function(E) test) { ...@@ -123,7 +123,7 @@ E? _lastWhereOrNull<E>(Iterable<E> list, bool Function(E) test) {
/// during test execution. /// during test execution.
/// Otherwise [LeakTesting.settings] is used. /// Otherwise [LeakTesting.settings] is used.
/// Adjust [LeakTesting.settings] in flutter_test_config.dart /// Adjust [LeakTesting.settings] in flutter_test_config.dart
/// (see https://github.com/flutter/flutter/blob/master/packages/flutter_test/lib/flutter_test.dart) /// (see https://api.flutter.dev/flutter/flutter_test/flutter_test-library.html)
/// for the entire package or folder, or in the test's main for a test file /// for the entire package or folder, or in the test's main for a test file
/// (don't use [setUp] or [setUpAll]). /// (don't use [setUp] or [setUpAll]).
/// To turn off leak tracking just for one test, set [experimentalLeakTesting] to /// To turn off leak tracking just for one test, set [experimentalLeakTesting] to
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment