Unverified Commit ff10c52a authored by Kostia Sokolovskyi's avatar Kostia Sokolovskyi Committed by GitHub

Cover more test/widgets tests with leak tracking #3 (#134576)

parent ba233b8a
......@@ -6,9 +6,10 @@ 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';
void main() {
testWidgets('onSaved callback is called', (WidgetTester tester) async {
testWidgetsWithLeakTracking('onSaved callback is called', (WidgetTester tester) async {
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
String? fieldValue;
......@@ -48,7 +49,7 @@ void main() {
await checkText('');
});
testWidgets('onChanged callback is called', (WidgetTester tester) async {
testWidgetsWithLeakTracking('onChanged callback is called', (WidgetTester tester) async {
String? fieldValue;
Widget builder() {
......@@ -85,7 +86,7 @@ void main() {
await checkText('');
});
testWidgets('Validator sets the error text only when validate is called', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Validator sets the error text only when validate is called', (WidgetTester tester) async {
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
String? errorText(String? value) => '${value ?? ''}/error';
......@@ -139,7 +140,7 @@ void main() {
await checkErrorText('');
});
testWidgets('Should announce error text when validate returns error', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Should announce error text when validate returns error', (WidgetTester tester) async {
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
await tester.pumpWidget(
MaterialApp(
......@@ -178,7 +179,7 @@ void main() {
});
testWidgets('isValid returns true when a field is valid', (WidgetTester tester) async {
testWidgetsWithLeakTracking('isValid returns true when a field is valid', (WidgetTester tester) async {
final GlobalKey<FormFieldState<String>> fieldKey1 = GlobalKey<FormFieldState<String>>();
final GlobalKey<FormFieldState<String>> fieldKey2 = GlobalKey<FormFieldState<String>>();
const String validString = 'Valid string';
......@@ -223,7 +224,7 @@ void main() {
expect(fieldKey2.currentState!.isValid, isTrue);
});
testWidgets(
testWidgetsWithLeakTracking(
'isValid returns false when the field is invalid and does not change error display',
(WidgetTester tester) async {
final GlobalKey<FormFieldState<String>> fieldKey1 = GlobalKey<FormFieldState<String>>();
......@@ -272,7 +273,7 @@ void main() {
},
);
testWidgets('Multiple TextFormFields communicate', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Multiple TextFormFields communicate', (WidgetTester tester) async {
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
final GlobalKey<FormFieldState<String>> fieldKey = GlobalKey<FormFieldState<String>>();
// Input 2's validator depends on a input 1's value.
......@@ -322,7 +323,7 @@ void main() {
await checkErrorText('');
});
testWidgets('Provide initial value to input when no controller is specified', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Provide initial value to input when no controller is specified', (WidgetTester tester) async {
const String initialValue = 'hello';
final GlobalKey<FormFieldState<String>> inputKey = GlobalKey<FormFieldState<String>>();
......@@ -366,8 +367,9 @@ void main() {
expect(editableText.widget.controller.text, equals('world'));
});
testWidgets('Controller defines initial value', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Controller defines initial value', (WidgetTester tester) async {
final TextEditingController controller = TextEditingController(text: 'hello');
addTearDown(controller.dispose);
const String initialValue = 'hello';
final GlobalKey<FormFieldState<String>> inputKey = GlobalKey<FormFieldState<String>>();
......@@ -413,10 +415,11 @@ void main() {
expect(controller.text, equals('world'));
});
testWidgets('TextFormField resets to its initial value', (WidgetTester tester) async {
testWidgetsWithLeakTracking('TextFormField resets to its initial value', (WidgetTester tester) async {
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
final GlobalKey<FormFieldState<String>> inputKey = GlobalKey<FormFieldState<String>>();
final TextEditingController controller = TextEditingController(text: 'Plover');
addTearDown(controller.dispose);
Widget builder() {
return MaterialApp(
......@@ -459,9 +462,11 @@ void main() {
expect(controller.text, equals('Plover'));
});
testWidgets('TextEditingController updates to/from form field value', (WidgetTester tester) async {
testWidgetsWithLeakTracking('TextEditingController updates to/from form field value', (WidgetTester tester) async {
final TextEditingController controller1 = TextEditingController(text: 'Foo');
addTearDown(controller1.dispose);
final TextEditingController controller2 = TextEditingController(text: 'Bar');
addTearDown(controller2.dispose);
final GlobalKey<FormFieldState<String>> inputKey = GlobalKey<FormFieldState<String>>();
TextEditingController? currentController;
......@@ -566,7 +571,7 @@ void main() {
expect(controller2.text, equals('Xyzzy'));
});
testWidgets('No crash when a TextFormField is removed from the tree', (WidgetTester tester) async {
testWidgetsWithLeakTracking('No crash when a TextFormField is removed from the tree', (WidgetTester tester) async {
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
String? fieldValue;
......@@ -620,7 +625,7 @@ void main() {
expect(formKey.currentState!.validate(), isTrue);
});
testWidgets('Does not auto-validate before value changes when autovalidateMode is set to onUserInteraction', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Does not auto-validate before value changes when autovalidateMode is set to onUserInteraction', (WidgetTester tester) async {
late FormFieldState<String> formFieldState;
String? errorText(String? value) => '$value/error';
......@@ -656,7 +661,7 @@ void main() {
expect(find.text(errorText('foo')!), findsNothing);
});
testWidgets('auto-validate before value changes if autovalidateMode was set to always', (WidgetTester tester) async {
testWidgetsWithLeakTracking('auto-validate before value changes if autovalidateMode was set to always', (WidgetTester tester) async {
late FormFieldState<String> formFieldState;
String? errorText(String? value) => '$value/error';
......@@ -689,7 +694,7 @@ void main() {
expect(formFieldState.hasError, isTrue);
});
testWidgets('Form auto-validates form fields only after one of them changes if autovalidateMode is onUserInteraction', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Form auto-validates form fields only after one of them changes if autovalidateMode is onUserInteraction', (WidgetTester tester) async {
const String initialValue = 'foo';
String? errorText(String? value) => 'error/$value';
......@@ -743,7 +748,7 @@ void main() {
expect(find.text(errorText(initialValue)!), findsNWidgets(2));
});
testWidgets('Form auto-validates form fields even before any have changed if autovalidateMode is set to always', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Form auto-validates form fields even before any have changed if autovalidateMode is set to always', (WidgetTester tester) async {
String? errorText(String? value) => 'error/$value';
Widget builder() {
......@@ -773,7 +778,7 @@ void main() {
expect(find.text(errorText('')!), findsOneWidget);
});
testWidgets('Form.reset() resets form fields, and auto validation will only happen on the next user interaction if autovalidateMode is onUserInteraction', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Form.reset() resets form fields, and auto validation will only happen on the next user interaction if autovalidateMode is onUserInteraction', (WidgetTester tester) async {
final GlobalKey<FormState> formState = GlobalKey<FormState>();
String? errorText(String? value) => '$value/error';
......@@ -818,7 +823,7 @@ void main() {
});
// Regression test for https://github.com/flutter/flutter/issues/63753.
testWidgets('Validate form should return correct validation if the value is composing', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Validate form should return correct validation if the value is composing', (WidgetTester tester) async {
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
String? fieldValue;
......@@ -855,7 +860,7 @@ void main() {
expect(formKey.currentState!.validate(), isFalse);
});
testWidgets('hasInteractedByUser returns false when the input has not changed', (WidgetTester tester) async {
testWidgetsWithLeakTracking('hasInteractedByUser returns false when the input has not changed', (WidgetTester tester) async {
final GlobalKey<FormFieldState<String>> fieldKey = GlobalKey<FormFieldState<String>>();
final Widget widget = MaterialApp(
......@@ -879,7 +884,7 @@ void main() {
expect(fieldKey.currentState!.hasInteractedByUser, isFalse);
});
testWidgets('hasInteractedByUser returns true after the input has changed', (WidgetTester tester) async {
testWidgetsWithLeakTracking('hasInteractedByUser returns true after the input has changed', (WidgetTester tester) async {
final GlobalKey<FormFieldState<String>> fieldKey = GlobalKey<FormFieldState<String>>();
final Widget widget = MaterialApp(
......@@ -908,7 +913,7 @@ void main() {
expect(fieldKey.currentState!.hasInteractedByUser, isTrue);
});
testWidgets('hasInteractedByUser returns false after the field is reset', (WidgetTester tester) async {
testWidgetsWithLeakTracking('hasInteractedByUser returns false after the field is reset', (WidgetTester tester) async {
final GlobalKey<FormFieldState<String>> fieldKey = GlobalKey<FormFieldState<String>>();
final Widget widget = MaterialApp(
......
......@@ -4,9 +4,10 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('FractionallySizedBox', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FractionallySizedBox', (WidgetTester tester) async {
final GlobalKey inner = GlobalKey();
await tester.pumpWidget(OverflowBox(
minWidth: 0.0,
......@@ -29,7 +30,7 @@ void main() {
expect(box.localToGlobal(Offset.zero), equals(const Offset(25.0, 37.5)));
});
testWidgets('FractionallySizedBox alignment', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FractionallySizedBox alignment', (WidgetTester tester) async {
final GlobalKey inner = GlobalKey();
await tester.pumpWidget(Directionality(
textDirection: TextDirection.rtl,
......@@ -45,7 +46,7 @@ void main() {
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(800.0 - 400.0 / 2.0, 0.0 + 300.0 / 2.0)));
});
testWidgets('FractionallySizedBox alignment (direction-sensitive)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FractionallySizedBox alignment (direction-sensitive)', (WidgetTester tester) async {
final GlobalKey inner = GlobalKey();
await tester.pumpWidget(Directionality(
textDirection: TextDirection.rtl,
......@@ -61,7 +62,7 @@ void main() {
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(0.0 + 400.0 / 2.0, 0.0 + 300.0 / 2.0)));
});
testWidgets('OverflowBox alignment with FractionallySizedBox', (WidgetTester tester) async {
testWidgetsWithLeakTracking('OverflowBox alignment with FractionallySizedBox', (WidgetTester tester) async {
final GlobalKey inner = GlobalKey();
await tester.pumpWidget(Directionality(
textDirection: TextDirection.rtl,
......
......@@ -6,11 +6,12 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'semantics_tester.dart';
void main() {
testWidgets('Vertical gesture detector has up/down actions', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Vertical gesture detector has up/down actions', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
int callCount = 0;
......@@ -44,7 +45,7 @@ void main() {
semantics.dispose();
});
testWidgets('Horizontal gesture detector has up/down actions', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Horizontal gesture detector has up/down actions', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
int callCount = 0;
......@@ -78,7 +79,7 @@ void main() {
semantics.dispose();
});
testWidgets('All registered handlers for the gesture kind are called', (WidgetTester tester) async {
testWidgetsWithLeakTracking('All registered handlers for the gesture kind are called', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
final Set<String> logs = <String>{};
......@@ -102,7 +103,7 @@ void main() {
semantics.dispose();
});
testWidgets('Replacing recognizers should update semantic handlers', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Replacing recognizers should update semantic handlers', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
// How the test is set up:
......@@ -173,7 +174,7 @@ void main() {
});
group("RawGestureDetector's custom semantics delegate", () {
testWidgets('should update semantics notations when switching from the default delegate', (WidgetTester tester) async {
testWidgetsWithLeakTracking('should update semantics notations when switching from the default delegate', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
final Map<Type, GestureRecognizerFactory> gestures =
_buildGestureMap(() => LongPressGestureRecognizer(), null)
......@@ -208,7 +209,7 @@ void main() {
semantics.dispose();
});
testWidgets('should update semantics notations when switching to the default delegate', (WidgetTester tester) async {
testWidgetsWithLeakTracking('should update semantics notations when switching to the default delegate', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
final Map<Type, GestureRecognizerFactory> gestures =
_buildGestureMap(() => LongPressGestureRecognizer(), null)
......@@ -243,7 +244,7 @@ void main() {
semantics.dispose();
});
testWidgets('should update semantics notations when switching from a different custom delegate', (WidgetTester tester) async {
testWidgetsWithLeakTracking('should update semantics notations when switching from a different custom delegate', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
final Map<Type, GestureRecognizerFactory> gestures =
_buildGestureMap(() => LongPressGestureRecognizer(), null)
......@@ -279,7 +280,7 @@ void main() {
semantics.dispose();
});
testWidgets('should correctly call callbacks', (WidgetTester tester) async {
testWidgetsWithLeakTracking('should correctly call callbacks', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
final List<String> logs = <String>[];
final GlobalKey<RawGestureDetectorState> detectorKey = GlobalKey();
......@@ -321,7 +322,7 @@ void main() {
group("RawGestureDetector's default semantics delegate", () {
group('should map onTap to', () {
testWidgets('null when there is no TapGR', (WidgetTester tester) async {
testWidgetsWithLeakTracking('null when there is no TapGR', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(
Center(
......@@ -339,7 +340,7 @@ void main() {
semantics.dispose();
});
testWidgets('non-null when there is TapGR with no callbacks', (WidgetTester tester) async {
testWidgetsWithLeakTracking('non-null when there is TapGR with no callbacks', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(
Center(
......@@ -360,7 +361,7 @@ void main() {
semantics.dispose();
});
testWidgets('a callback that correctly calls callbacks', (WidgetTester tester) async {
testWidgetsWithLeakTracking('a callback that correctly calls callbacks', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
final GlobalKey detectorKey = GlobalKey();
final List<String> logs = <String>[];
......@@ -394,7 +395,7 @@ void main() {
});
group('should map onLongPress to', () {
testWidgets('null when there is no LongPressGR ', (WidgetTester tester) async {
testWidgetsWithLeakTracking('null when there is no LongPressGR ', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(
Center(
......@@ -412,7 +413,7 @@ void main() {
semantics.dispose();
});
testWidgets('non-null when there is LongPressGR with no callbacks', (WidgetTester tester) async {
testWidgetsWithLeakTracking('non-null when there is LongPressGR with no callbacks', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(
Center(
......@@ -433,7 +434,7 @@ void main() {
semantics.dispose();
});
testWidgets('a callback that correctly calls callbacks', (WidgetTester tester) async {
testWidgetsWithLeakTracking('a callback that correctly calls callbacks', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
final GlobalKey detectorKey = GlobalKey();
final List<String> logs = <String>[];
......@@ -466,7 +467,7 @@ void main() {
});
group('should map onHorizontalDragUpdate to', () {
testWidgets('null when there is no matching recognizers ', (WidgetTester tester) async {
testWidgetsWithLeakTracking('null when there is no matching recognizers ', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(
Center(
......@@ -484,7 +485,7 @@ void main() {
semantics.dispose();
});
testWidgets('non-null when there is either matching recognizer with no callbacks', (WidgetTester tester) async {
testWidgetsWithLeakTracking('non-null when there is either matching recognizer with no callbacks', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(
Center(
......@@ -526,7 +527,7 @@ void main() {
semantics.dispose();
});
testWidgets('a callback that correctly calls callbacks', (WidgetTester tester) async {
testWidgetsWithLeakTracking('a callback that correctly calls callbacks', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
final GlobalKey detectorKey = GlobalKey();
final List<String> logs = <String>[];
......@@ -576,7 +577,7 @@ void main() {
});
group('should map onVerticalDragUpdate to', () {
testWidgets('null when there is no matching recognizers ', (WidgetTester tester) async {
testWidgetsWithLeakTracking('null when there is no matching recognizers ', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(
Center(
......@@ -594,7 +595,7 @@ void main() {
semantics.dispose();
});
testWidgets('non-null when there is either matching recognizer with no callbacks', (WidgetTester tester) async {
testWidgetsWithLeakTracking('non-null when there is either matching recognizer with no callbacks', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(
Center(
......@@ -617,7 +618,7 @@ void main() {
semantics.dispose();
});
testWidgets('a callback that correctly calls callbacks', (WidgetTester tester) async {
testWidgetsWithLeakTracking('a callback that correctly calls callbacks', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
final GlobalKey detectorKey = GlobalKey();
final List<String> logs = <String>[];
......@@ -666,7 +667,7 @@ void main() {
});
});
testWidgets('should update semantics notations when receiving new gestures', (WidgetTester tester) async {
testWidgetsWithLeakTracking('should update semantics notations when receiving new gestures', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(
Center(
......
......@@ -6,11 +6,12 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
const Offset forcePressOffset = Offset(400.0, 50.0);
testWidgets('Uncontested scrolls start immediately', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Uncontested scrolls start immediately', (WidgetTester tester) async {
bool didStartDrag = false;
double? updatedDragDelta;
bool didEndDrag = false;
......@@ -58,7 +59,7 @@ void main() {
await tester.pumpWidget(Container());
});
testWidgets('Match two scroll gestures in succession', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Match two scroll gestures in succession', (WidgetTester tester) async {
int gestureCount = 0;
double dragDistance = 0.0;
......@@ -91,7 +92,7 @@ void main() {
await tester.pumpWidget(Container());
});
testWidgets("Pan doesn't crash", (WidgetTester tester) async {
testWidgetsWithLeakTracking("Pan doesn't crash", (WidgetTester tester) async {
bool didStartPan = false;
Offset? panDelta;
bool didEndPan = false;
......@@ -135,7 +136,7 @@ void main() {
},
);
testWidgets('Translucent', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Translucent', (WidgetTester tester) async {
bool didReceivePointerDown;
bool didTap;
......@@ -206,7 +207,7 @@ void main() {
expect(didTap, isTrue);
}, variant: buttonVariant);
testWidgets('Empty', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Empty', (WidgetTester tester) async {
bool didTap = false;
await tester.pumpWidget(
Center(
......@@ -228,7 +229,7 @@ void main() {
expect(didTap, isTrue);
}, variant: buttonVariant);
testWidgets('Only container', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Only container', (WidgetTester tester) async {
bool didTap = false;
await tester.pumpWidget(
Center(
......@@ -251,7 +252,7 @@ void main() {
expect(didTap, isFalse);
}, variant: buttonVariant);
testWidgets('cache render object', (WidgetTester tester) async {
testWidgetsWithLeakTracking('cache render object', (WidgetTester tester) async {
void inputCallback() { }
await tester.pumpWidget(
......@@ -283,7 +284,7 @@ void main() {
expect(renderObj1, same(renderObj2));
}, variant: buttonVariant);
testWidgets('Tap down occurs after kPressTimeout', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Tap down occurs after kPressTimeout', (WidgetTester tester) async {
int tapDown = 0;
int tap = 0;
int tapCancel = 0;
......@@ -391,7 +392,7 @@ void main() {
expect(longPress, 1);
}, variant: buttonVariant);
testWidgets('Long Press Up Callback called after long press', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Long Press Up Callback called after long press', (WidgetTester tester) async {
int longPressUp = 0;
await tester.pumpWidget(
......@@ -441,7 +442,7 @@ void main() {
}, variant: buttonVariant);
});
testWidgets('Primary and secondary long press callbacks should work together in GestureDetector', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Primary and secondary long press callbacks should work together in GestureDetector', (WidgetTester tester) async {
bool primaryLongPress = false, secondaryLongPress = false;
await tester.pumpWidget(
......@@ -477,7 +478,7 @@ void main() {
expect(secondaryLongPress, isTrue);
});
testWidgets('Force Press Callback called after force press', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Force Press Callback called after force press', (WidgetTester tester) async {
int forcePressStart = 0;
int forcePressPeaked = 0;
int forcePressUpdate = 0;
......@@ -580,7 +581,7 @@ void main() {
expect(forcePressEnded, 1);
});
testWidgets('Force Press Callback not called if long press triggered before force press', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Force Press Callback not called if long press triggered before force press', (WidgetTester tester) async {
int forcePressStart = 0;
int longPressTimes = 0;
......@@ -645,7 +646,7 @@ void main() {
expect(forcePressStart, 0);
});
testWidgets('Force Press Callback not called if drag triggered before force press', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Force Press Callback not called if drag triggered before force press', (WidgetTester tester) async {
int forcePressStart = 0;
int horizontalDragStart = 0;
......@@ -706,7 +707,7 @@ void main() {
});
group("RawGestureDetectorState's debugFillProperties", () {
testWidgets('when default', (WidgetTester tester) async {
testWidgetsWithLeakTracking('when default', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
final GlobalKey key = GlobalKey();
await tester.pumpWidget(RawGestureDetector(
......@@ -724,7 +725,7 @@ void main() {
]);
});
testWidgets('should show gestures, custom semantics and behavior', (WidgetTester tester) async {
testWidgetsWithLeakTracking('should show gestures, custom semantics and behavior', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
final GlobalKey key = GlobalKey();
await tester.pumpWidget(RawGestureDetector(
......@@ -761,7 +762,7 @@ void main() {
]);
});
testWidgets('should not show semantics when excludeFromSemantics is true', (WidgetTester tester) async {
testWidgetsWithLeakTracking('should not show semantics when excludeFromSemantics is true', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
final GlobalKey key = GlobalKey();
await tester.pumpWidget(RawGestureDetector(
......@@ -832,7 +833,7 @@ void main() {
}
});
testWidgets('replaceGestureRecognizers not during layout', (WidgetTester tester) async {
testWidgetsWithLeakTracking('replaceGestureRecognizers not during layout', (WidgetTester tester) async {
final GlobalKey<RawGestureDetectorState> key = GlobalKey<RawGestureDetectorState>();
await tester.pumpWidget(
Directionality(
......@@ -876,7 +877,7 @@ void main() {
});
});
testWidgets('supportedDevices update test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('supportedDevices update test', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/111716
bool didStartPan = false;
Offset? panDelta;
......@@ -946,7 +947,7 @@ void main() {
expect(didEndPan, isTrue);
});
testWidgets('supportedDevices is respected', (WidgetTester tester) async {
testWidgetsWithLeakTracking('supportedDevices is respected', (WidgetTester tester) async {
bool didStartPan = false;
Offset? panDelta;
bool didEndPan = false;
......@@ -994,7 +995,7 @@ void main() {
});
group('DoubleTap', () {
testWidgets('onDoubleTap is called even if onDoubleTapDown has not been not provided', (WidgetTester tester) async {
testWidgetsWithLeakTracking('onDoubleTap is called even if onDoubleTapDown has not been not provided', (WidgetTester tester) async {
final List<String> log = <String>[];
await tester.pumpWidget(
Directionality(
......@@ -1017,7 +1018,7 @@ void main() {
expect(log, <String>['double-tap']);
});
testWidgets('onDoubleTapDown is called even if onDoubleTap has not been not provided', (WidgetTester tester) async {
testWidgetsWithLeakTracking('onDoubleTapDown is called even if onDoubleTap has not been not provided', (WidgetTester tester) async {
final List<String> log = <String>[];
await tester.pumpWidget(
Directionality(
......
......@@ -4,9 +4,10 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('onTap detection with canceled pointer and a drag listener', (WidgetTester tester) async {
testWidgetsWithLeakTracking('onTap detection with canceled pointer and a drag listener', (WidgetTester tester) async {
int detector1TapCount = 0;
int detector2TapCount = 0;
......
......@@ -5,11 +5,12 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
// There's also some duplicate GlobalKey tests in the framework_test.dart file.
void main() {
testWidgets('GlobalKey children of one node', (WidgetTester tester) async {
testWidgetsWithLeakTracking('GlobalKey children of one node', (WidgetTester tester) async {
// This is actually a test of the regular duplicate key logic, which
// happens before the duplicate GlobalKey logic.
await tester.pumpWidget(const Stack(children: <Widget>[
......@@ -23,7 +24,7 @@ void main() {
expect(error.toString(), contains('[GlobalObjectKey ${describeIdentity(0)}]'));
});
testWidgets('GlobalKey children of two nodes - A', (WidgetTester tester) async {
testWidgetsWithLeakTracking('GlobalKey children of two nodes - A', (WidgetTester tester) async {
await tester.pumpWidget(const Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
......@@ -43,7 +44,7 @@ void main() {
expect(error.toString(), endsWith('\nA GlobalKey can only be specified on one widget at a time in the widget tree.'));
});
testWidgets('GlobalKey children of two different nodes - B', (WidgetTester tester) async {
testWidgetsWithLeakTracking('GlobalKey children of two different nodes - B', (WidgetTester tester) async {
await tester.pumpWidget(const Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
......@@ -61,7 +62,7 @@ void main() {
expect(error.toString(), endsWith('\nA GlobalKey can only be specified on one widget at a time in the widget tree.'));
});
testWidgets('GlobalKey children of two nodes - C', (WidgetTester tester) async {
testWidgetsWithLeakTracking('GlobalKey children of two nodes - C', (WidgetTester tester) async {
late StateSetter nestedSetState;
bool flag = false;
await tester.pumpWidget(Stack(
......
......@@ -4,6 +4,7 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
class Item {
GlobalKey key1 = GlobalKey();
......@@ -55,7 +56,7 @@ Widget builder() {
}
void main() {
testWidgets('moving subtrees with global keys - smoketest', (WidgetTester tester) async {
testWidgetsWithLeakTracking('moving subtrees with global keys - smoketest', (WidgetTester tester) async {
await tester.pumpWidget(builder());
final StatefulLeafState leaf = tester.firstState(find.byType(StatefulLeaf));
leaf.markNeedsBuild();
......
......@@ -5,9 +5,10 @@
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('GridPaper control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('GridPaper control test', (WidgetTester tester) async {
await tester.pumpWidget(const GridPaper());
final List<Layer> layers1 = tester.layers;
await tester.pumpWidget(const GridPaper());
......
......@@ -4,9 +4,10 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('Empty GridView', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Empty GridView', (WidgetTester tester) async {
final List<Widget> children = <Widget>[
const DecoratedBox(decoration: BoxDecoration()),
const DecoratedBox(decoration: BoxDecoration()),
......
......@@ -6,16 +6,17 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('toString control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('toString control test', (WidgetTester tester) async {
await tester.pumpWidget(const Center(child: Text('Hello', textDirection: TextDirection.ltr)));
final HitTestResult result = tester.hitTestOnBinding(Offset.zero);
expect(result, hasOneLineDescription);
expect(result.path.first, hasOneLineDescription);
});
testWidgets('A mouse click should only cause one hit test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('A mouse click should only cause one hit test', (WidgetTester tester) async {
int hitCount = 0;
await tester.pumpWidget(
_HitTestCounter(
......@@ -31,7 +32,7 @@ void main() {
expect(hitCount, 1);
});
testWidgets('Non-mouse events should not cause movement hit tests', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Non-mouse events should not cause movement hit tests', (WidgetTester tester) async {
int hitCount = 0;
await tester.pumpWidget(
_HitTestCounter(
......
......@@ -5,9 +5,10 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('Can tap a hyperlink', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Can tap a hyperlink', (WidgetTester tester) async {
bool didTapLeft = false;
final TapGestureRecognizer tapLeft = TapGestureRecognizer()
..onTap = () {
......
......@@ -6,11 +6,12 @@ import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'semantics_tester.dart';
void main() {
testWidgets('Can set opacity for an Icon', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Can set opacity for an Icon', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -27,7 +28,7 @@ void main() {
expect(text.text.style!.color, const Color(0xFF666666).withOpacity(0.5));
});
testWidgets('Icon sizing - no theme, default size', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Icon sizing - no theme, default size', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -41,7 +42,7 @@ void main() {
expect(renderObject.size, equals(const Size.square(24.0)));
});
testWidgets('Icon sizing - no theme, explicit size', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Icon sizing - no theme, explicit size', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -58,7 +59,7 @@ void main() {
expect(renderObject.size, equals(const Size.square(96.0)));
});
testWidgets('Icon sizing - sized theme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Icon sizing - sized theme', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -75,7 +76,7 @@ void main() {
expect(renderObject.size, equals(const Size.square(36.0)));
});
testWidgets('Icon sizing - sized theme, explicit size', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Icon sizing - sized theme, explicit size', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -95,7 +96,7 @@ void main() {
expect(renderObject.size, equals(const Size.square(48.0)));
});
testWidgets('Icon sizing - sizeless theme, default size', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Icon sizing - sizeless theme, default size', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -113,7 +114,7 @@ void main() {
});
testWidgets('Icon with custom font', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Icon with custom font', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -127,7 +128,7 @@ void main() {
expect(richText.text.style!.fontFamily, equals('Roboto'));
});
testWidgets('Icon with custom fontFamilyFallback', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Icon with custom fontFamilyFallback', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -141,7 +142,7 @@ void main() {
expect(richText.text.style!.fontFamilyFallback, equals(<String>['FallbackFont']));
});
testWidgets('Icon with semantic label', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Icon with semantic label', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(
......@@ -161,7 +162,7 @@ void main() {
semantics.dispose();
});
testWidgets('Null icon with semantic label', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Null icon with semantic label', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(
......@@ -181,7 +182,7 @@ void main() {
semantics.dispose();
});
testWidgets("Changing semantic label from null doesn't rebuild tree ", (WidgetTester tester) async {
testWidgetsWithLeakTracking("Changing semantic label from null doesn't rebuild tree ", (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -212,7 +213,7 @@ void main() {
expect(richText2, same(richText1));
});
testWidgets('IconData comparison', (WidgetTester tester) async {
testWidgetsWithLeakTracking('IconData comparison', (WidgetTester tester) async {
expect(const IconData(123), const IconData(123));
expect(const IconData(123), isNot(const IconData(123, matchTextDirection: true)));
expect(const IconData(123), isNot(const IconData(123, fontFamily: 'f')));
......@@ -225,7 +226,7 @@ void main() {
});
testWidgets('Fill, weight, grade, and optical size variations are passed', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Fill, weight, grade, and optical size variations are passed', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -258,7 +259,7 @@ void main() {
]);
});
testWidgets('Fill, weight, grade, and optical size can be set at the theme-level', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Fill, weight, grade, and optical size can be set at the theme-level', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -283,7 +284,7 @@ void main() {
]);
});
testWidgets('Theme-level fill, weight, grade, and optical size can be overridden', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Theme-level fill, weight, grade, and optical size can be overridden', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......
......@@ -13,17 +13,18 @@ import 'dart:ui' as ui;
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('Image at default filterQuality', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image at default filterQuality', (WidgetTester tester) async {
await testImageQuality(tester, null);
});
testWidgets('Image at high filterQuality', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image at high filterQuality', (WidgetTester tester) async {
await testImageQuality(tester, ui.FilterQuality.high);
});
testWidgets('Image at none filterQuality', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image at none filterQuality', (WidgetTester tester) async {
await testImageQuality(tester, ui.FilterQuality.none);
});
}
......
......@@ -14,9 +14,10 @@ import 'package:flutter/foundation.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() {
testWidgets('Image filter - blur', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image filter - blur', (WidgetTester tester) async {
await tester.pumpWidget(
RepaintBoundary(
child: ImageFiltered(
......@@ -31,7 +32,7 @@ void main() {
);
});
testWidgets('Image filter - blur with offset', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image filter - blur with offset', (WidgetTester tester) async {
final Key key = GlobalKey();
await tester.pumpWidget(
RepaintBoundary(
......@@ -51,7 +52,7 @@ void main() {
);
});
testWidgets('Image filter - dilate', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image filter - dilate', (WidgetTester tester) async {
await tester.pumpWidget(
RepaintBoundary(
child: ImageFiltered(
......@@ -66,7 +67,7 @@ void main() {
);
}, skip: kIsWeb); // https://github.com/flutter/flutter/issues/101874
testWidgets('Image filter - erode', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image filter - erode', (WidgetTester tester) async {
await tester.pumpWidget(
RepaintBoundary(
child: ImageFiltered(
......@@ -82,7 +83,7 @@ void main() {
);
}, skip: kIsWeb); // https://github.com/flutter/flutter/issues/101874
testWidgets('Image filter - matrix', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image filter - matrix', (WidgetTester tester) async {
final ImageFilter matrix = ImageFilter.matrix(Float64List.fromList(<double>[
0.5, 0.0, 0.0, 0.0, //
0.0, 0.5, 0.0, 0.0, //
......@@ -119,7 +120,7 @@ void main() {
);
});
testWidgets('Image filter - matrix with offset', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image filter - matrix with offset', (WidgetTester tester) async {
final Matrix4 matrix = Matrix4.rotationZ(pi / 18);
final ImageFilter matrixFilter = ImageFilter.matrix(matrix.storage);
final Key key = GlobalKey();
......@@ -157,7 +158,7 @@ void main() {
);
});
testWidgets('Image filter - reuses its layer', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image filter - reuses its layer', (WidgetTester tester) async {
Future<void> pumpWithSigma(double sigma) async {
await tester.pumpWidget(
RepaintBoundary(
......@@ -178,7 +179,7 @@ void main() {
expect(renderObject.debugLayer, same(originalLayer));
});
testWidgets('Image filter - enabled and disabled', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image filter - enabled and disabled', (WidgetTester tester) async {
Future<void> pumpWithEnabledState(bool enabled) async {
await tester.pumpWidget(
RepaintBoundary(
......
......@@ -7,13 +7,14 @@ import 'dart:io';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../image_data.dart';
void main() {
final MockHttpClient client = MockHttpClient();
testWidgets('Headers', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Headers', (WidgetTester tester) async {
HttpOverrides.runZoned<Future<void>>(() async {
await tester.pumpWidget(Image.network(
'https://www.example.com/images/frame.png',
......
......@@ -5,6 +5,7 @@
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../painting/mocks_for_image_cache.dart';
......@@ -20,7 +21,7 @@ void main() {
);
});
testWidgets('ImageIcon sizing - no theme, default size', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ImageIcon sizing - no theme, default size', (WidgetTester tester) async {
await tester.pumpWidget(
Center(
child: ImageIcon(image),
......@@ -32,7 +33,7 @@ void main() {
expect(find.byType(Image), findsOneWidget);
});
testWidgets('Icon opacity', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Icon opacity', (WidgetTester tester) async {
await tester.pumpWidget(
Center(
child: IconTheme(
......@@ -45,7 +46,7 @@ void main() {
expect(tester.widget<Image>(find.byType(Image)).color!.alpha, equals(128));
});
testWidgets('ImageIcon sizing - no theme, explicit size', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ImageIcon sizing - no theme, explicit size', (WidgetTester tester) async {
await tester.pumpWidget(
const Center(
child: ImageIcon(
......@@ -59,7 +60,7 @@ void main() {
expect(renderObject.size, equals(const Size.square(96.0)));
});
testWidgets('ImageIcon sizing - sized theme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ImageIcon sizing - sized theme', (WidgetTester tester) async {
await tester.pumpWidget(
const Center(
child: IconTheme(
......@@ -73,7 +74,7 @@ void main() {
expect(renderObject.size, equals(const Size.square(36.0)));
});
testWidgets('ImageIcon sizing - sized theme, explicit size', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ImageIcon sizing - sized theme, explicit size', (WidgetTester tester) async {
await tester.pumpWidget(
const Center(
child: IconTheme(
......@@ -90,7 +91,7 @@ void main() {
expect(renderObject.size, equals(const Size.square(48.0)));
});
testWidgets('ImageIcon sizing - sizeless theme, default size', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ImageIcon sizing - sizeless theme, default size', (WidgetTester tester) async {
await tester.pumpWidget(
const Center(
child: IconTheme(
......@@ -104,7 +105,7 @@ void main() {
expect(renderObject.size, equals(const Size.square(24.0)));
});
testWidgets('ImageIcon has semantics data', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ImageIcon has semantics data', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
const Directionality(
......
......@@ -13,6 +13,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../image_data.dart';
......@@ -155,6 +156,7 @@ void main() {
const String image = 'assets/image.png';
final Map<double, ui.Image> images = <double, ui.Image>{};
setUpAll(() async {
for (final double scale in const <double>[0.5, 1.0, 1.5, 2.0, 4.0, 10.0]) {
final int dimension = (48 * scale).floor();
......@@ -162,7 +164,13 @@ void main() {
}
});
testWidgets('Image for device pixel ratio 1.0', (WidgetTester tester) async {
tearDownAll(() {
for (final ui.Image image in images.values) {
image.dispose();
}
});
testWidgetsWithLeakTracking('Image for device pixel ratio 1.0', (WidgetTester tester) async {
const double ratio = 1.0;
Key key = GlobalKey();
await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, false, images));
......@@ -174,7 +182,7 @@ void main() {
expect(getRenderImage(tester, key).scale, 1.0);
});
testWidgets('Image for device pixel ratio 0.5', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image for device pixel ratio 0.5', (WidgetTester tester) async {
const double ratio = 0.5;
Key key = GlobalKey();
await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, false, images));
......@@ -186,7 +194,7 @@ void main() {
expect(getRenderImage(tester, key).scale, 1.0);
});
testWidgets('Image for device pixel ratio 1.5', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image for device pixel ratio 1.5', (WidgetTester tester) async {
const double ratio = 1.5;
Key key = GlobalKey();
await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, false, images));
......@@ -201,7 +209,7 @@ void main() {
// A 1.75 DPR screen is typically a low-resolution screen, such that physical
// pixels are visible to the user. For such screens we prefer to pick the
// higher resolution image, if available.
testWidgets('Image for device pixel ratio 1.75', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image for device pixel ratio 1.75', (WidgetTester tester) async {
const double ratio = 1.75;
Key key = GlobalKey();
await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, false, images));
......@@ -213,7 +221,7 @@ void main() {
expect(getRenderImage(tester, key).scale, 2.0);
});
testWidgets('Image for device pixel ratio 2.3', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image for device pixel ratio 2.3', (WidgetTester tester) async {
const double ratio = 2.3;
Key key = GlobalKey();
await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, false, images));
......@@ -225,7 +233,7 @@ void main() {
expect(getRenderImage(tester, key).scale, 2.0);
});
testWidgets('Image for device pixel ratio 3.7', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image for device pixel ratio 3.7', (WidgetTester tester) async {
const double ratio = 3.7;
Key key = GlobalKey();
await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, false, images));
......@@ -237,7 +245,7 @@ void main() {
expect(getRenderImage(tester, key).scale, 4.0);
});
testWidgets('Image for device pixel ratio 5.1', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image for device pixel ratio 5.1', (WidgetTester tester) async {
const double ratio = 5.1;
Key key = GlobalKey();
await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, false, images));
......@@ -249,7 +257,7 @@ void main() {
expect(getRenderImage(tester, key).scale, 4.0);
});
testWidgets('Image for device pixel ratio 1.0, with a main asset and a 1.0x asset', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image for device pixel ratio 1.0, with a main asset and a 1.0x asset', (WidgetTester tester) async {
// If both a main asset and a 1.0x asset are specified, then prefer
// the 1.0x asset.
......@@ -279,19 +287,19 @@ void main() {
expect(getRenderImage(tester, key).image!.height, 480);
});
testWidgets('Image cache resize upscale display 5', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image cache resize upscale display 5', (WidgetTester tester) async {
final Key key = GlobalKey();
await pumpTreeToLayout(tester, buildImageCacheResized(image, key, 5, 5, 20, 20));
expect(getRenderImage(tester, key).size, const Size(5.0, 5.0));
});
testWidgets('Image cache resize upscale display 50', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image cache resize upscale display 50', (WidgetTester tester) async {
final Key key = GlobalKey();
await pumpTreeToLayout(tester, buildImageCacheResized(image, key, 50, 50, 20, 20));
expect(getRenderImage(tester, key).size, const Size(50.0, 50.0));
});
testWidgets('Image cache resize downscale display 5', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image cache resize downscale display 5', (WidgetTester tester) async {
final Key key = GlobalKey();
await pumpTreeToLayout(tester, buildImageCacheResized(image, key, 5, 5, 1, 1));
expect(getRenderImage(tester, key).size, const Size(5.0, 5.0));
......@@ -301,7 +309,7 @@ void main() {
// visible physical pixel size (see the test for 1.75 DPR above). However,
// if higher resolution assets are not available we will pick the best
// available.
testWidgets('Low-resolution assets', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Low-resolution assets', (WidgetTester tester) async {
const Map<Object?, Object?> manifest = <Object?, Object?>{
'assets/image.png': <Map<String, Object>>[
<String, Object>{'asset': 'assets/image.png'},
......
......@@ -7,6 +7,7 @@ import 'dart:ui' as ui show Image;
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
class TestImageProvider extends ImageProvider<TestImageProvider> {
const TestImageProvider(this.image);
......@@ -28,10 +29,16 @@ class TestImageProvider extends ImageProvider<TestImageProvider> {
void main() {
late ui.Image testImage;
setUpAll(() async {
testImage = await createTestImage(width: 16, height: 9);
});
testWidgets('DecorationImage RTL with alignment topEnd and match', (WidgetTester tester) async {
tearDownAll(() {
testImage.dispose();
});
testWidgetsWithLeakTracking('DecorationImage RTL with alignment topEnd and match', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.rtl,
......@@ -70,7 +77,7 @@ void main() {
expect(find.byType(Container), isNot(paints..scale()..scale()));
});
testWidgets('DecorationImage LTR with alignment topEnd (and pointless match)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DecorationImage LTR with alignment topEnd (and pointless match)', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
......@@ -106,7 +113,7 @@ void main() {
expect(find.byType(Container), isNot(paints..scale()));
});
testWidgets('DecorationImage RTL with alignment topEnd', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DecorationImage RTL with alignment topEnd', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.rtl,
......@@ -141,7 +148,7 @@ void main() {
expect(find.byType(Container), isNot(paints..scale()));
});
testWidgets('DecorationImage LTR with alignment topEnd', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DecorationImage LTR with alignment topEnd', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
......@@ -176,7 +183,7 @@ void main() {
expect(find.byType(Container), isNot(paints..scale()));
});
testWidgets('DecorationImage RTL with alignment center-right and match', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DecorationImage RTL with alignment center-right and match', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.rtl,
......@@ -208,7 +215,7 @@ void main() {
expect(find.byType(Container), isNot(paints..drawImageRect()..drawImageRect()));
});
testWidgets('DecorationImage RTL with alignment center-right and no match', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DecorationImage RTL with alignment center-right and no match', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.rtl,
......@@ -235,7 +242,7 @@ void main() {
expect(find.byType(Container), isNot(paints..drawImageRect()..drawImageRect()));
});
testWidgets('DecorationImage LTR with alignment center-right and match', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DecorationImage LTR with alignment center-right and match', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
......@@ -263,7 +270,7 @@ void main() {
expect(find.byType(Container), isNot(paints..drawImageRect()..drawImageRect()));
});
testWidgets('DecorationImage LTR with alignment center-right and no match', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DecorationImage LTR with alignment center-right and no match', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
......@@ -291,7 +298,7 @@ void main() {
expect(find.byType(Container), isNot(paints..drawImageRect()..drawImageRect()));
});
testWidgets('Image RTL with alignment topEnd and match', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image RTL with alignment topEnd and match', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.rtl,
......@@ -328,7 +335,7 @@ void main() {
expect(find.byType(SizedBox), isNot(paints..scale()..scale()));
});
testWidgets('Image LTR with alignment topEnd (and pointless match)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image LTR with alignment topEnd (and pointless match)', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
......@@ -362,7 +369,7 @@ void main() {
expect(find.byType(SizedBox), isNot(paints..scale()));
});
testWidgets('Image RTL with alignment topEnd', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image RTL with alignment topEnd', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.rtl,
......@@ -395,7 +402,7 @@ void main() {
expect(find.byType(SizedBox), isNot(paints..scale()));
});
testWidgets('Image LTR with alignment topEnd', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image LTR with alignment topEnd', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
......@@ -428,7 +435,7 @@ void main() {
expect(find.byType(SizedBox), isNot(paints..scale()));
});
testWidgets('Image RTL with alignment center-right and match', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image RTL with alignment center-right and match', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.rtl,
......@@ -456,7 +463,7 @@ void main() {
expect(find.byType(SizedBox), isNot(paints..drawImageRect()..drawImageRect()));
});
testWidgets('Image RTL with alignment center-right and no match', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image RTL with alignment center-right and no match', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.rtl,
......@@ -481,7 +488,7 @@ void main() {
expect(find.byType(SizedBox), isNot(paints..drawImageRect()..drawImageRect()));
});
testWidgets('Image LTR with alignment center-right and match', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image LTR with alignment center-right and match', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
......@@ -507,7 +514,7 @@ void main() {
expect(find.byType(SizedBox), isNot(paints..drawImageRect()..drawImageRect()));
});
testWidgets('Image LTR with alignment center-right and no match', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image LTR with alignment center-right and no match', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
......@@ -533,7 +540,7 @@ void main() {
expect(find.byType(SizedBox), isNot(paints..drawImageRect()..drawImageRect()));
});
testWidgets('Image - Switch needing direction', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Image - Switch needing direction', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
......
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