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

Cover some test/widgets tests with leak tracking (#133803)

parent 0d198c7b
...@@ -4,11 +4,12 @@ ...@@ -4,11 +4,12 @@
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';
import 'semantics_tester.dart'; import 'semantics_tester.dart';
void main() { void main() {
testWidgets('AbsorbPointers do not block siblings', (WidgetTester tester) async { testWidgetsWithLeakTracking('AbsorbPointers do not block siblings', (WidgetTester tester) async {
bool tapped = false; bool tapped = false;
await tester.pumpWidget( await tester.pumpWidget(
Column( Column(
...@@ -29,7 +30,7 @@ void main() { ...@@ -29,7 +30,7 @@ void main() {
}); });
group('AbsorbPointer semantics', () { group('AbsorbPointer semantics', () {
testWidgets('does not change semantics when not absorbing', (WidgetTester tester) async { testWidgetsWithLeakTracking('does not change semantics when not absorbing', (WidgetTester tester) async {
final UniqueKey key = UniqueKey(); final UniqueKey key = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -56,7 +57,7 @@ void main() { ...@@ -56,7 +57,7 @@ void main() {
); );
}); });
testWidgets('drops semantics when its ignoreSemantics is true', (WidgetTester tester) async { testWidgetsWithLeakTracking('drops semantics when its ignoreSemantics is true', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
final UniqueKey key = UniqueKey(); final UniqueKey key = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -75,7 +76,7 @@ void main() { ...@@ -75,7 +76,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgets('ignores user interactions', (WidgetTester tester) async { testWidgetsWithLeakTracking('ignores user interactions', (WidgetTester tester) async {
final UniqueKey key = UniqueKey(); final UniqueKey key = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
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';
void main() { void main() {
testWidgets('Align smoke test', (WidgetTester tester) async { testWidgetsWithLeakTracking('Align smoke test', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Align( Align(
alignment: const Alignment(0.50, 0.50), alignment: const Alignment(0.50, 0.50),
...@@ -38,7 +39,7 @@ void main() { ...@@ -38,7 +39,7 @@ void main() {
); );
}); });
testWidgets('Align control test (LTR)', (WidgetTester tester) async { testWidgetsWithLeakTracking('Align control test (LTR)', (WidgetTester tester) async {
await tester.pumpWidget(const Directionality( await tester.pumpWidget(const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Align( child: Align(
...@@ -62,7 +63,7 @@ void main() { ...@@ -62,7 +63,7 @@ void main() {
expect(tester.getBottomRight(find.byType(SizedBox)).dx, 100.0); expect(tester.getBottomRight(find.byType(SizedBox)).dx, 100.0);
}); });
testWidgets('Align control test (RTL)', (WidgetTester tester) async { testWidgetsWithLeakTracking('Align control test (RTL)', (WidgetTester tester) async {
await tester.pumpWidget(const Directionality( await tester.pumpWidget(const Directionality(
textDirection: TextDirection.rtl, textDirection: TextDirection.rtl,
child: Align( child: Align(
...@@ -86,7 +87,7 @@ void main() { ...@@ -86,7 +87,7 @@ void main() {
expect(tester.getBottomRight(find.byType(SizedBox)).dx, 100.0); expect(tester.getBottomRight(find.byType(SizedBox)).dx, 100.0);
}); });
testWidgets('Shrink wraps in finite space', (WidgetTester tester) async { testWidgetsWithLeakTracking('Shrink wraps in finite space', (WidgetTester tester) async {
final GlobalKey alignKey = GlobalKey(); final GlobalKey alignKey = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
SingleChildScrollView( SingleChildScrollView(
...@@ -105,7 +106,7 @@ void main() { ...@@ -105,7 +106,7 @@ void main() {
expect(size.height, equals(10.0)); expect(size.height, equals(10.0));
}); });
testWidgets('Align widthFactor', (WidgetTester tester) async { testWidgetsWithLeakTracking('Align widthFactor', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -128,7 +129,7 @@ void main() { ...@@ -128,7 +129,7 @@ void main() {
expect(box.size.width, equals(50.0)); expect(box.size.width, equals(50.0));
}); });
testWidgets('Align heightFactor', (WidgetTester tester) async { testWidgetsWithLeakTracking('Align heightFactor', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
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';
void main() { void main() {
testWidgets('AnimatedAlign.debugFillProperties', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedAlign.debugFillProperties', (WidgetTester tester) async {
const AnimatedAlign box = AnimatedAlign( const AnimatedAlign box = AnimatedAlign(
alignment: Alignment.topCenter, alignment: Alignment.topCenter,
curve: Curves.ease, curve: Curves.ease,
...@@ -15,7 +16,7 @@ void main() { ...@@ -15,7 +16,7 @@ void main() {
expect(box, hasOneLineDescription); expect(box, hasOneLineDescription);
}); });
testWidgets('AnimatedAlign alignment visual-to-directional animation', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedAlign alignment visual-to-directional animation', (WidgetTester tester) async {
final Key target = UniqueKey(); final Key target = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -57,7 +58,7 @@ void main() { ...@@ -57,7 +58,7 @@ void main() {
expect(tester.getTopRight(find.byKey(target)), const Offset(800.0, 400.0)); expect(tester.getTopRight(find.byKey(target)), const Offset(800.0, 400.0));
}); });
testWidgets('AnimatedAlign widthFactor', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedAlign widthFactor', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -82,7 +83,7 @@ void main() { ...@@ -82,7 +83,7 @@ void main() {
expect(box.size.width, equals(50.0)); expect(box.size.width, equals(50.0));
}); });
testWidgets('AnimatedAlign heightFactor', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedAlign heightFactor', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -106,7 +107,7 @@ void main() { ...@@ -106,7 +107,7 @@ void main() {
expect(box.size.height, equals( 50.0)); expect(box.size.height, equals( 50.0));
}); });
testWidgets('AnimatedAlign null height factor', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedAlign null height factor', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -130,7 +131,7 @@ void main() { ...@@ -130,7 +131,7 @@ void main() {
expect(box.size, equals(const Size(100.0, 100))); expect(box.size, equals(const Size(100.0, 100)));
}); });
testWidgets('AnimatedAlign null widthFactor', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedAlign null widthFactor', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
......
...@@ -5,9 +5,10 @@ ...@@ -5,9 +5,10 @@
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.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';
void main() { void main() {
testWidgets('AnimatedContainer.debugFillProperties', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedContainer.debugFillProperties', (WidgetTester tester) async {
final AnimatedContainer container = AnimatedContainer( final AnimatedContainer container = AnimatedContainer(
constraints: const BoxConstraints.tightFor(width: 17.0, height: 23.0), constraints: const BoxConstraints.tightFor(width: 17.0, height: 23.0),
decoration: const BoxDecoration(color: Color(0xFF00FF00)), decoration: const BoxDecoration(color: Color(0xFF00FF00)),
...@@ -24,7 +25,7 @@ void main() { ...@@ -24,7 +25,7 @@ void main() {
expect(container, hasOneLineDescription); expect(container, hasOneLineDescription);
}); });
testWidgets('AnimatedContainer control test', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedContainer control test', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
const BoxDecoration decorationA = BoxDecoration( const BoxDecoration decorationA = BoxDecoration(
...@@ -102,7 +103,7 @@ void main() { ...@@ -102,7 +103,7 @@ void main() {
); );
}); });
testWidgets('AnimatedContainer overanimate test', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedContainer overanimate test', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
AnimatedContainer( AnimatedContainer(
duration: const Duration(milliseconds: 200), duration: const Duration(milliseconds: 200),
...@@ -139,7 +140,7 @@ void main() { ...@@ -139,7 +140,7 @@ void main() {
expect(tester.binding.transientCallbackCount, 0); expect(tester.binding.transientCallbackCount, 0);
}); });
testWidgets('AnimatedContainer padding visual-to-directional animation', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedContainer padding visual-to-directional animation', (WidgetTester tester) async {
final Key target = UniqueKey(); final Key target = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -181,7 +182,7 @@ void main() { ...@@ -181,7 +182,7 @@ void main() {
expect(tester.getTopRight(find.byKey(target)), const Offset(700.0, 0.0)); expect(tester.getTopRight(find.byKey(target)), const Offset(700.0, 0.0));
}); });
testWidgets('AnimatedContainer alignment visual-to-directional animation', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedContainer alignment visual-to-directional animation', (WidgetTester tester) async {
final Key target = UniqueKey(); final Key target = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -223,7 +224,7 @@ void main() { ...@@ -223,7 +224,7 @@ void main() {
expect(tester.getTopRight(find.byKey(target)), const Offset(800.0, 400.0)); expect(tester.getTopRight(find.byKey(target)), const Offset(800.0, 400.0));
}); });
testWidgets('Animation rerun', (WidgetTester tester) async { testWidgetsWithLeakTracking('Animation rerun', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Center( Center(
child: AnimatedContainer( child: AnimatedContainer(
...@@ -291,7 +292,7 @@ void main() { ...@@ -291,7 +292,7 @@ void main() {
expect(text.size.height, equals(100.0)); expect(text.size.height, equals(100.0));
}); });
testWidgets('AnimatedContainer sets transformAlignment', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedContainer sets transformAlignment', (WidgetTester tester) async {
final Key target = UniqueKey(); final Key target = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -339,7 +340,7 @@ void main() { ...@@ -339,7 +340,7 @@ void main() {
expect(tester.getTopLeft(find.byKey(target)), const Offset(400.0, 300.0)); expect(tester.getTopLeft(find.byKey(target)), const Offset(400.0, 300.0));
}); });
testWidgets('AnimatedContainer sets clipBehavior', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedContainer sets clipBehavior', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
AnimatedContainer( AnimatedContainer(
decoration: const BoxDecoration( decoration: const BoxDecoration(
......
...@@ -5,9 +5,10 @@ ...@@ -5,9 +5,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.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('AnimatedCrossFade test', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedCrossFade test', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -61,7 +62,7 @@ void main() { ...@@ -61,7 +62,7 @@ void main() {
expect(box.size.height, equals(150.0)); expect(box.size.height, equals(150.0));
}); });
testWidgets('AnimatedCrossFade test showSecond', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedCrossFade test showSecond', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -88,7 +89,7 @@ void main() { ...@@ -88,7 +89,7 @@ void main() {
expect(box.size.height, equals(200.0)); expect(box.size.height, equals(200.0));
}); });
testWidgets('AnimatedCrossFade alignment (VISUAL)', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedCrossFade alignment (VISUAL)', (WidgetTester tester) async {
final Key firstKey = UniqueKey(); final Key firstKey = UniqueKey();
final Key secondKey = UniqueKey(); final Key secondKey = UniqueKey();
...@@ -146,7 +147,7 @@ void main() { ...@@ -146,7 +147,7 @@ void main() {
expect(box2.localToGlobal(Offset.zero), const Offset(275.0, 175.0)); expect(box2.localToGlobal(Offset.zero), const Offset(275.0, 175.0));
}); });
testWidgets('AnimatedCrossFade alignment (LTR)', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedCrossFade alignment (LTR)', (WidgetTester tester) async {
final Key firstKey = UniqueKey(); final Key firstKey = UniqueKey();
final Key secondKey = UniqueKey(); final Key secondKey = UniqueKey();
...@@ -204,7 +205,7 @@ void main() { ...@@ -204,7 +205,7 @@ void main() {
expect(box2.localToGlobal(Offset.zero), const Offset(275.0, 175.0)); expect(box2.localToGlobal(Offset.zero), const Offset(275.0, 175.0));
}); });
testWidgets('AnimatedCrossFade alignment (RTL)', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedCrossFade alignment (RTL)', (WidgetTester tester) async {
final Key firstKey = UniqueKey(); final Key firstKey = UniqueKey();
final Key secondKey = UniqueKey(); final Key secondKey = UniqueKey();
...@@ -274,7 +275,7 @@ void main() { ...@@ -274,7 +275,7 @@ void main() {
); );
} }
testWidgets('AnimatedCrossFade preserves widget state', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedCrossFade preserves widget state', (WidgetTester tester) async {
await tester.pumpWidget(crossFadeWithWatcher()); await tester.pumpWidget(crossFadeWithWatcher());
_TickerWatchingWidgetState findState() => tester.state(find.byType(_TickerWatchingWidget)); _TickerWatchingWidgetState findState() => tester.state(find.byType(_TickerWatchingWidget));
...@@ -287,7 +288,7 @@ void main() { ...@@ -287,7 +288,7 @@ void main() {
} }
}); });
testWidgets('AnimatedCrossFade switches off TickerMode and semantics on faded out widget', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedCrossFade switches off TickerMode and semantics on faded out widget', (WidgetTester tester) async {
ExcludeSemantics findSemantics() { ExcludeSemantics findSemantics() {
return tester.widget(find.descendant( return tester.widget(find.descendant(
of: find.byKey(const ValueKey<CrossFadeState>(CrossFadeState.showFirst)), of: find.byKey(const ValueKey<CrossFadeState>(CrossFadeState.showFirst)),
...@@ -317,7 +318,7 @@ void main() { ...@@ -317,7 +318,7 @@ void main() {
expect(findSemantics().excluding, true); expect(findSemantics().excluding, true);
}); });
testWidgets('AnimatedCrossFade.layoutBuilder', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedCrossFade.layoutBuilder', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -361,7 +362,7 @@ void main() { ...@@ -361,7 +362,7 @@ void main() {
expect(find.text('AAA'), findsNothing); expect(find.text('AAA'), findsNothing);
}); });
testWidgets('AnimatedCrossFade test focus', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedCrossFade test focus', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -385,7 +386,7 @@ void main() { ...@@ -385,7 +386,7 @@ void main() {
expect(hiddenNode.hasPrimaryFocus, isFalse); expect(hiddenNode.hasPrimaryFocus, isFalse);
}); });
testWidgets('AnimatedCrossFade bottom child can have focus', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedCrossFade bottom child can have focus', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -410,7 +411,7 @@ void main() { ...@@ -410,7 +411,7 @@ void main() {
expect(hiddenNode.hasPrimaryFocus, isTrue); expect(hiddenNode.hasPrimaryFocus, isTrue);
}); });
testWidgets('AnimatedCrossFade second child do not receive touch events', testWidgetsWithLeakTracking('AnimatedCrossFade second child do not receive touch events',
(WidgetTester tester) async { (WidgetTester tester) async {
int numberOfTouchEventNoticed = 0; int numberOfTouchEventNoticed = 0;
......
...@@ -5,10 +5,11 @@ ...@@ -5,10 +5,11 @@
import 'package:flutter/src/foundation/diagnostics.dart'; import 'package:flutter/src/foundation/diagnostics.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';
void main() { void main() {
// Regression test for https://github.com/flutter/flutter/issues/100451 // Regression test for https://github.com/flutter/flutter/issues/100451
testWidgets('SliverAnimatedGrid.builder respects findChildIndexCallback', (WidgetTester tester) async { testWidgetsWithLeakTracking('SliverAnimatedGrid.builder respects findChildIndexCallback', (WidgetTester tester) async {
bool finderCalled = false; bool finderCalled = false;
int itemCount = 7; int itemCount = 7;
late StateSetter stateSetter; late StateSetter stateSetter;
...@@ -50,7 +51,7 @@ void main() { ...@@ -50,7 +51,7 @@ void main() {
expect(finderCalled, true); expect(finderCalled, true);
}); });
testWidgets('AnimatedGrid', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedGrid', (WidgetTester tester) async {
Widget builder(BuildContext context, int index, Animation<double> animation) { Widget builder(BuildContext context, int index, Animation<double> animation) {
return SizedBox( return SizedBox(
height: 100.0, height: 100.0,
...@@ -132,7 +133,7 @@ void main() { ...@@ -132,7 +133,7 @@ void main() {
}); });
group('SliverAnimatedGrid', () { group('SliverAnimatedGrid', () {
testWidgets('initialItemCount', (WidgetTester tester) async { testWidgetsWithLeakTracking('initialItemCount', (WidgetTester tester) async {
final Map<int, Animation<double>> animations = <int, Animation<double>>{}; final Map<int, Animation<double>> animations = <int, Animation<double>>{};
await tester.pumpWidget( await tester.pumpWidget(
...@@ -170,7 +171,7 @@ void main() { ...@@ -170,7 +171,7 @@ void main() {
expect(animations[1]!.value, 1.0); expect(animations[1]!.value, 1.0);
}); });
testWidgets('insert', (WidgetTester tester) async { testWidgetsWithLeakTracking('insert', (WidgetTester tester) async {
final GlobalKey<SliverAnimatedGridState> listKey = GlobalKey<SliverAnimatedGridState>(); final GlobalKey<SliverAnimatedGridState> listKey = GlobalKey<SliverAnimatedGridState>();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -250,7 +251,7 @@ void main() { ...@@ -250,7 +251,7 @@ void main() {
expect(itemRight(2), 300.0); expect(itemRight(2), 300.0);
}); });
testWidgets('insertAll', (WidgetTester tester) async { testWidgetsWithLeakTracking('insertAll', (WidgetTester tester) async {
final GlobalKey<SliverAnimatedGridState> listKey = GlobalKey<SliverAnimatedGridState>(); final GlobalKey<SliverAnimatedGridState> listKey = GlobalKey<SliverAnimatedGridState>();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -306,7 +307,7 @@ void main() { ...@@ -306,7 +307,7 @@ void main() {
expect(itemRight(1), 200.0); expect(itemRight(1), 200.0);
}); });
testWidgets('remove', (WidgetTester tester) async { testWidgetsWithLeakTracking('remove', (WidgetTester tester) async {
final GlobalKey<SliverAnimatedGridState> listKey = GlobalKey<SliverAnimatedGridState>(); final GlobalKey<SliverAnimatedGridState> listKey = GlobalKey<SliverAnimatedGridState>();
final List<int> items = <int>[0, 1, 2]; final List<int> items = <int>[0, 1, 2];
...@@ -384,7 +385,7 @@ void main() { ...@@ -384,7 +385,7 @@ void main() {
expect(itemRight(2), 200.0); expect(itemRight(2), 200.0);
}); });
testWidgets('removeAll', (WidgetTester tester) async { testWidgetsWithLeakTracking('removeAll', (WidgetTester tester) async {
final GlobalKey<SliverAnimatedGridState> listKey = GlobalKey<SliverAnimatedGridState>(); final GlobalKey<SliverAnimatedGridState> listKey = GlobalKey<SliverAnimatedGridState>();
final List<int> items = <int>[0, 1, 2]; final List<int> items = <int>[0, 1, 2];
...@@ -436,7 +437,7 @@ void main() { ...@@ -436,7 +437,7 @@ void main() {
expect(find.text('item 2'), findsNothing); expect(find.text('item 2'), findsNothing);
}); });
testWidgets('works in combination with other slivers', (WidgetTester tester) async { testWidgetsWithLeakTracking('works in combination with other slivers', (WidgetTester tester) async {
final GlobalKey<SliverAnimatedGridState> listKey = GlobalKey<SliverAnimatedGridState>(); final GlobalKey<SliverAnimatedGridState> listKey = GlobalKey<SliverAnimatedGridState>();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -505,7 +506,7 @@ void main() { ...@@ -505,7 +506,7 @@ void main() {
expect(tester.getTopLeft(find.text('item 0')).dx, 0); expect(tester.getTopLeft(find.text('item 0')).dx, 0);
}); });
testWidgets('passes correctly derived index of findChildIndexCallback to the inner SliverChildBuilderDelegate', testWidgetsWithLeakTracking('passes correctly derived index of findChildIndexCallback to the inner SliverChildBuilderDelegate',
(WidgetTester tester) async { (WidgetTester tester) async {
final List<int> items = <int>[0, 1, 2, 3]; final List<int> items = <int>[0, 1, 2, 3];
final GlobalKey<SliverAnimatedGridState> listKey = GlobalKey<SliverAnimatedGridState>(); final GlobalKey<SliverAnimatedGridState> listKey = GlobalKey<SliverAnimatedGridState>();
...@@ -573,7 +574,7 @@ void main() { ...@@ -573,7 +574,7 @@ void main() {
}); });
}); });
testWidgets( testWidgetsWithLeakTracking(
'AnimatedGrid.of() and maybeOf called with a context that does not contain AnimatedGrid', 'AnimatedGrid.of() and maybeOf called with a context that does not contain AnimatedGrid',
(WidgetTester tester) async { (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
...@@ -618,7 +619,7 @@ void main() { ...@@ -618,7 +619,7 @@ void main() {
}, },
); );
testWidgets('AnimatedGrid.clipBehavior is forwarded to its inner CustomScrollView', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedGrid.clipBehavior is forwarded to its inner CustomScrollView', (WidgetTester tester) async {
const Clip clipBehavior = Clip.none; const Clip clipBehavior = Clip.none;
await tester.pumpWidget( await tester.pumpWidget(
...@@ -647,7 +648,7 @@ void main() { ...@@ -647,7 +648,7 @@ void main() {
expect(tester.widget<CustomScrollView>(find.byType(CustomScrollView)).clipBehavior, clipBehavior); expect(tester.widget<CustomScrollView>(find.byType(CustomScrollView)).clipBehavior, clipBehavior);
}); });
testWidgets('AnimatedGrid applies MediaQuery padding', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedGrid applies MediaQuery padding', (WidgetTester tester) async {
const EdgeInsets padding = EdgeInsets.all(30.0); const EdgeInsets padding = EdgeInsets.all(30.0);
EdgeInsets? innerMediaQueryPadding; EdgeInsets? innerMediaQueryPadding;
await tester.pumpWidget( await tester.pumpWidget(
......
...@@ -7,9 +7,10 @@ import 'dart:ui'; ...@@ -7,9 +7,10 @@ import 'dart:ui';
import 'package:flutter/material.dart'; import 'package:flutter/material.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() {
testWidgets('ImageFiltered avoids repainting child as it animates', (WidgetTester tester) async { testWidgetsWithLeakTracking('ImageFiltered avoids repainting child as it animates', (WidgetTester tester) async {
RenderTestObject.paintCount = 0; RenderTestObject.paintCount = 0;
await tester.pumpWidget( await tester.pumpWidget(
ColoredBox( ColoredBox(
......
...@@ -5,10 +5,11 @@ ...@@ -5,10 +5,11 @@
import 'package:flutter/src/foundation/diagnostics.dart'; import 'package:flutter/src/foundation/diagnostics.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';
void main() { void main() {
// Regression test for https://github.com/flutter/flutter/issues/100451 // Regression test for https://github.com/flutter/flutter/issues/100451
testWidgets('SliverAnimatedList.builder respects findChildIndexCallback', (WidgetTester tester) async { testWidgetsWithLeakTracking('SliverAnimatedList.builder respects findChildIndexCallback', (WidgetTester tester) async {
bool finderCalled = false; bool finderCalled = false;
int itemCount = 7; int itemCount = 7;
late StateSetter stateSetter; late StateSetter stateSetter;
...@@ -47,7 +48,7 @@ void main() { ...@@ -47,7 +48,7 @@ void main() {
expect(finderCalled, true); expect(finderCalled, true);
}); });
testWidgets('AnimatedList', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedList', (WidgetTester tester) async {
Widget builder(BuildContext context, int index, Animation<double> animation) { Widget builder(BuildContext context, int index, Animation<double> animation) {
return SizedBox( return SizedBox(
height: 100.0, height: 100.0,
...@@ -126,7 +127,7 @@ void main() { ...@@ -126,7 +127,7 @@ void main() {
}); });
group('SliverAnimatedList', () { group('SliverAnimatedList', () {
testWidgets('initialItemCount', (WidgetTester tester) async { testWidgetsWithLeakTracking('initialItemCount', (WidgetTester tester) async {
final Map<int, Animation<double>> animations = <int, Animation<double>>{}; final Map<int, Animation<double>> animations = <int, Animation<double>>{};
await tester.pumpWidget( await tester.pumpWidget(
...@@ -159,7 +160,7 @@ void main() { ...@@ -159,7 +160,7 @@ void main() {
expect(animations[1]!.value, 1.0); expect(animations[1]!.value, 1.0);
}); });
testWidgets('insert', (WidgetTester tester) async { testWidgetsWithLeakTracking('insert', (WidgetTester tester) async {
final GlobalKey<SliverAnimatedListState> listKey = GlobalKey<SliverAnimatedListState>(); final GlobalKey<SliverAnimatedListState> listKey = GlobalKey<SliverAnimatedListState>();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -245,7 +246,7 @@ void main() { ...@@ -245,7 +246,7 @@ void main() {
}); });
// Test for insertAllItems with SliverAnimatedList // Test for insertAllItems with SliverAnimatedList
testWidgets('insertAll', (WidgetTester tester) async { testWidgetsWithLeakTracking('insertAll', (WidgetTester tester) async {
final GlobalKey<SliverAnimatedListState> listKey = GlobalKey<SliverAnimatedListState>(); final GlobalKey<SliverAnimatedListState> listKey = GlobalKey<SliverAnimatedListState>();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -302,7 +303,7 @@ void main() { ...@@ -302,7 +303,7 @@ void main() {
}); });
// Test for removeAllItems with SliverAnimatedList // Test for removeAllItems with SliverAnimatedList
testWidgets('remove', (WidgetTester tester) async { testWidgetsWithLeakTracking('remove', (WidgetTester tester) async {
final GlobalKey<SliverAnimatedListState> listKey = GlobalKey<SliverAnimatedListState>(); final GlobalKey<SliverAnimatedListState> listKey = GlobalKey<SliverAnimatedListState>();
final List<int> items = <int>[0, 1, 2]; final List<int> items = <int>[0, 1, 2];
...@@ -379,7 +380,7 @@ void main() { ...@@ -379,7 +380,7 @@ void main() {
}); });
// Test for removeAllItems with SliverAnimatedList // Test for removeAllItems with SliverAnimatedList
testWidgets('removeAll', (WidgetTester tester) async { testWidgetsWithLeakTracking('removeAll', (WidgetTester tester) async {
final GlobalKey<SliverAnimatedListState> listKey = GlobalKey<SliverAnimatedListState>(); final GlobalKey<SliverAnimatedListState> listKey = GlobalKey<SliverAnimatedListState>();
final List<int> items = <int>[0, 1, 2]; final List<int> items = <int>[0, 1, 2];
...@@ -429,7 +430,7 @@ void main() { ...@@ -429,7 +430,7 @@ void main() {
expect(find.text('item 2'), findsNothing); expect(find.text('item 2'), findsNothing);
}); });
testWidgets('works in combination with other slivers', (WidgetTester tester) async { testWidgetsWithLeakTracking('works in combination with other slivers', (WidgetTester tester) async {
final GlobalKey<SliverAnimatedListState> listKey = GlobalKey<SliverAnimatedListState>(); final GlobalKey<SliverAnimatedListState> listKey = GlobalKey<SliverAnimatedListState>();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -494,7 +495,7 @@ void main() { ...@@ -494,7 +495,7 @@ void main() {
expect(tester.getTopLeft(find.text('item 0')).dy, 200); expect(tester.getTopLeft(find.text('item 0')).dy, 200);
}); });
testWidgets('passes correctly derived index of findChildIndexCallback to the inner SliverChildBuilderDelegate', (WidgetTester tester) async { testWidgetsWithLeakTracking('passes correctly derived index of findChildIndexCallback to the inner SliverChildBuilderDelegate', (WidgetTester tester) async {
final List<int> items = <int>[0, 1, 2, 3]; final List<int> items = <int>[0, 1, 2, 3];
final GlobalKey<SliverAnimatedListState> listKey = GlobalKey<SliverAnimatedListState>(); final GlobalKey<SliverAnimatedListState> listKey = GlobalKey<SliverAnimatedListState>();
...@@ -556,7 +557,7 @@ void main() { ...@@ -556,7 +557,7 @@ void main() {
}); });
}); });
testWidgets( testWidgetsWithLeakTracking(
'AnimatedList.of() and maybeOf called with a context that does not contain AnimatedList', 'AnimatedList.of() and maybeOf called with a context that does not contain AnimatedList',
(WidgetTester tester) async { (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
...@@ -601,7 +602,7 @@ void main() { ...@@ -601,7 +602,7 @@ void main() {
}, },
); );
testWidgets('AnimatedList.clipBehavior is forwarded to its inner CustomScrollView', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedList.clipBehavior is forwarded to its inner CustomScrollView', (WidgetTester tester) async {
const Clip clipBehavior = Clip.none; const Clip clipBehavior = Clip.none;
await tester.pumpWidget( await tester.pumpWidget(
...@@ -625,9 +626,12 @@ void main() { ...@@ -625,9 +626,12 @@ void main() {
expect(tester.widget<CustomScrollView>(find.byType(CustomScrollView)).clipBehavior, clipBehavior); expect(tester.widget<CustomScrollView>(find.byType(CustomScrollView)).clipBehavior, clipBehavior);
}); });
testWidgets('AnimatedList.shrinkwrap is forwarded to its inner CustomScrollView', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedList.shrinkwrap is forwarded to its inner CustomScrollView', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/115040 // Regression test for https://github.com/flutter/flutter/issues/115040
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -650,7 +654,7 @@ void main() { ...@@ -650,7 +654,7 @@ void main() {
expect(tester.widget<CustomScrollView>(find.byType(CustomScrollView)).shrinkWrap, true); expect(tester.widget<CustomScrollView>(find.byType(CustomScrollView)).shrinkWrap, true);
}); });
testWidgets('AnimatedList applies MediaQuery padding', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedList applies MediaQuery padding', (WidgetTester tester) async {
const EdgeInsets padding = EdgeInsets.all(30.0); const EdgeInsets padding = EdgeInsets.all(30.0);
EdgeInsets? innerMediaQueryPadding; EdgeInsets? innerMediaQueryPadding;
await tester.pumpWidget( await tester.pumpWidget(
......
...@@ -5,9 +5,10 @@ ...@@ -5,9 +5,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.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() {
testWidgets('RenderAnimatedOpacityMixin does not drop layer when animating to 1', (WidgetTester tester) async { testWidgetsWithLeakTracking('RenderAnimatedOpacityMixin does not drop layer when animating to 1', (WidgetTester tester) async {
RenderTestObject.paintCount = 0; RenderTestObject.paintCount = 0;
final AnimationController controller = AnimationController(vsync: const TestVSync(), duration: const Duration(seconds: 1)); final AnimationController controller = AnimationController(vsync: const TestVSync(), duration: const Duration(seconds: 1));
final Tween<double> opacityTween = Tween<double>(begin: 0, end: 1); final Tween<double> opacityTween = Tween<double>(begin: 0, end: 1);
...@@ -40,7 +41,7 @@ void main() { ...@@ -40,7 +41,7 @@ void main() {
expect(RenderTestObject.paintCount, 1); expect(RenderTestObject.paintCount, 1);
}); });
testWidgets('RenderAnimatedOpacityMixin avoids repainting child as it animates', (WidgetTester tester) async { testWidgetsWithLeakTracking('RenderAnimatedOpacityMixin avoids repainting child as it animates', (WidgetTester tester) async {
RenderTestObject.paintCount = 0; RenderTestObject.paintCount = 0;
final AnimationController controller = AnimationController(vsync: const TestVSync(), duration: const Duration(seconds: 1)); final AnimationController controller = AnimationController(vsync: const TestVSync(), duration: const Duration(seconds: 1));
final Tween<double> opacityTween = Tween<double>(begin: 0, end: 0.99); // Layer is dropped at 1 final Tween<double> opacityTween = Tween<double>(begin: 0, end: 0.99); // Layer is dropped at 1
...@@ -73,10 +74,13 @@ void main() { ...@@ -73,10 +74,13 @@ void main() {
expect(RenderTestObject.paintCount, 1); expect(RenderTestObject.paintCount, 1);
}); });
testWidgets('RenderAnimatedOpacityMixin allows opacity layer to be disposed when animating to 0 opacity', (WidgetTester tester) async { testWidgetsWithLeakTracking('RenderAnimatedOpacityMixin allows opacity layer to be disposed when animating to 0 opacity', (WidgetTester tester) async {
RenderTestObject.paintCount = 0; RenderTestObject.paintCount = 0;
final AnimationController controller = AnimationController(vsync: const TestVSync(), duration: const Duration(seconds: 1)); final AnimationController controller = AnimationController(vsync: const TestVSync(), duration: const Duration(seconds: 1));
final Tween<double> opacityTween = Tween<double>(begin: 0.99, end: 0); final Tween<double> opacityTween = Tween<double>(begin: 0.99, end: 0);
addTearDown(controller.dispose);
await tester.pumpWidget( await tester.pumpWidget(
ColoredBox( ColoredBox(
color: Colors.red, color: Colors.red,
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
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';
void main() { void main() {
testWidgets('AnimatedPadding.debugFillProperties', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedPadding.debugFillProperties', (WidgetTester tester) async {
final AnimatedPadding padding = AnimatedPadding( final AnimatedPadding padding = AnimatedPadding(
padding: const EdgeInsets.all(7.0), padding: const EdgeInsets.all(7.0),
curve: Curves.ease, curve: Curves.ease,
...@@ -16,7 +17,7 @@ void main() { ...@@ -16,7 +17,7 @@ void main() {
expect(padding, hasOneLineDescription); expect(padding, hasOneLineDescription);
}); });
testWidgets('AnimatedPadding padding visual-to-directional animation', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedPadding padding visual-to-directional animation', (WidgetTester tester) async {
final Key target = UniqueKey(); final Key target = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -58,7 +59,7 @@ void main() { ...@@ -58,7 +59,7 @@ void main() {
expect(tester.getTopRight(find.byKey(target)), const Offset(700.0, 0.0)); expect(tester.getTopRight(find.byKey(target)), const Offset(700.0, 0.0));
}); });
testWidgets('AnimatedPadding animated padding clamped to positive values', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedPadding animated padding clamped to positive values', (WidgetTester tester) async {
final Key target = UniqueKey(); final Key target = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
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';
void main() { void main() {
testWidgets('AnimatedPositioned.fromRect control test', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedPositioned.fromRect control test', (WidgetTester tester) async {
final AnimatedPositioned positioned = AnimatedPositioned.fromRect( final AnimatedPositioned positioned = AnimatedPositioned.fromRect(
rect: const Rect.fromLTWH(7.0, 5.0, 12.0, 16.0), rect: const Rect.fromLTWH(7.0, 5.0, 12.0, 16.0),
duration: const Duration(milliseconds: 200), duration: const Duration(milliseconds: 200),
...@@ -20,7 +21,7 @@ void main() { ...@@ -20,7 +21,7 @@ void main() {
expect(positioned, hasOneLineDescription); expect(positioned, hasOneLineDescription);
}); });
testWidgets('AnimatedPositioned - basics (VISUAL)', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedPositioned - basics (VISUAL)', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
RenderBox box; RenderBox box;
...@@ -102,7 +103,7 @@ void main() { ...@@ -102,7 +103,7 @@ void main() {
); );
}); });
testWidgets('AnimatedPositionedDirectional - basics (LTR)', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedPositionedDirectional - basics (LTR)', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
RenderBox box; RenderBox box;
...@@ -188,7 +189,7 @@ void main() { ...@@ -188,7 +189,7 @@ void main() {
); );
}); });
testWidgets('AnimatedPositionedDirectional - basics (RTL)', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedPositionedDirectional - basics (RTL)', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
RenderBox box; RenderBox box;
...@@ -274,7 +275,7 @@ void main() { ...@@ -274,7 +275,7 @@ void main() {
); );
}); });
testWidgets('AnimatedPositioned - interrupted animation (VISUAL)', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedPositioned - interrupted animation (VISUAL)', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
RenderBox box; RenderBox box;
...@@ -357,7 +358,7 @@ void main() { ...@@ -357,7 +358,7 @@ void main() {
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(200.0, 200.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(200.0, 200.0)));
}); });
testWidgets('AnimatedPositioned - switching variables (VISUAL)', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedPositioned - switching variables (VISUAL)', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
RenderBox box; RenderBox box;
...@@ -416,7 +417,7 @@ void main() { ...@@ -416,7 +417,7 @@ void main() {
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 150.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 150.0)));
}); });
testWidgets('AnimatedPositionedDirectional - interrupted animation (LTR)', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedPositionedDirectional - interrupted animation (LTR)', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
RenderBox box; RenderBox box;
...@@ -505,7 +506,7 @@ void main() { ...@@ -505,7 +506,7 @@ void main() {
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(200.0, 200.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(200.0, 200.0)));
}); });
testWidgets('AnimatedPositionedDirectional - switching variables (LTR)', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedPositionedDirectional - switching variables (LTR)', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
RenderBox box; RenderBox box;
...@@ -568,7 +569,7 @@ void main() { ...@@ -568,7 +569,7 @@ void main() {
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 150.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 150.0)));
}); });
testWidgets('AnimatedPositionedDirectional - interrupted animation (RTL)', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedPositionedDirectional - interrupted animation (RTL)', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
RenderBox box; RenderBox box;
...@@ -657,7 +658,7 @@ void main() { ...@@ -657,7 +658,7 @@ void main() {
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(600.0, 200.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(600.0, 200.0)));
}); });
testWidgets('AnimatedPositionedDirectional - switching variables (RTL)', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedPositionedDirectional - switching variables (RTL)', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
RenderBox box; RenderBox box;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.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';
class TestPaintingContext implements PaintingContext { class TestPaintingContext implements PaintingContext {
final List<Invocation> invocations = <Invocation>[]; final List<Invocation> invocations = <Invocation>[];
...@@ -17,7 +18,7 @@ class TestPaintingContext implements PaintingContext { ...@@ -17,7 +18,7 @@ class TestPaintingContext implements PaintingContext {
void main() { void main() {
group('AnimatedSize', () { group('AnimatedSize', () {
testWidgets('animates forwards then backwards with stable-sized children', (WidgetTester tester) async { testWidgetsWithLeakTracking('animates forwards then backwards with stable-sized children', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Center( const Center(
child: AnimatedSize( child: AnimatedSize(
...@@ -87,7 +88,7 @@ void main() { ...@@ -87,7 +88,7 @@ void main() {
expect(box.size.height, equals(100.0)); expect(box.size.height, equals(100.0));
}); });
testWidgets('clamps animated size to constraints', (WidgetTester tester) async { testWidgetsWithLeakTracking('clamps animated size to constraints', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Center( const Center(
child: SizedBox ( child: SizedBox (
...@@ -132,7 +133,7 @@ void main() { ...@@ -132,7 +133,7 @@ void main() {
expect(box.size.height, equals(100.0)); expect(box.size.height, equals(100.0));
}); });
testWidgets('tracks unstable child, then resumes animation when child stabilizes', (WidgetTester tester) async { testWidgetsWithLeakTracking('tracks unstable child, then resumes animation when child stabilizes', (WidgetTester tester) async {
Future<void> pumpMillis(int millis) async { Future<void> pumpMillis(int millis) async {
await tester.pump(Duration(milliseconds: millis)); await tester.pump(Duration(milliseconds: millis));
} }
...@@ -215,7 +216,7 @@ void main() { ...@@ -215,7 +216,7 @@ void main() {
verify(size: 100.0, state: RenderAnimatedSizeState.stable); verify(size: 100.0, state: RenderAnimatedSizeState.stable);
}); });
testWidgets('resyncs its animation controller', (WidgetTester tester) async { testWidgetsWithLeakTracking('resyncs its animation controller', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Center( const Center(
child: AnimatedSize( child: AnimatedSize(
...@@ -246,7 +247,7 @@ void main() { ...@@ -246,7 +247,7 @@ void main() {
expect(box.size.width, equals(150.0)); expect(box.size.width, equals(150.0));
}); });
testWidgets('does not run animation unnecessarily', (WidgetTester tester) async { testWidgetsWithLeakTracking('does not run animation unnecessarily', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Center( const Center(
child: AnimatedSize( child: AnimatedSize(
...@@ -269,7 +270,7 @@ void main() { ...@@ -269,7 +270,7 @@ void main() {
} }
}); });
testWidgets('can set and update clipBehavior', (WidgetTester tester) async { testWidgetsWithLeakTracking('can set and update clipBehavior', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Center( const Center(
child: AnimatedSize( child: AnimatedSize(
...@@ -303,7 +304,7 @@ void main() { ...@@ -303,7 +304,7 @@ void main() {
} }
}); });
testWidgets('works wrapped in IntrinsicHeight and Wrap', (WidgetTester tester) async { testWidgetsWithLeakTracking('works wrapped in IntrinsicHeight and Wrap', (WidgetTester tester) async {
Future<void> pumpWidget(Size size, [Duration? duration]) async { Future<void> pumpWidget(Size size, [Duration? duration]) async {
return tester.pumpWidget( return tester.pumpWidget(
Center( Center(
...@@ -350,7 +351,7 @@ void main() { ...@@ -350,7 +351,7 @@ void main() {
expect(tester.renderObject<RenderBox>(find.byType(IntrinsicHeight)).size, const Size(222, 222)); expect(tester.renderObject<RenderBox>(find.byType(IntrinsicHeight)).size, const Size(222, 222));
}); });
testWidgets('re-attach with interrupted animation', (WidgetTester tester) async { testWidgetsWithLeakTracking('re-attach with interrupted animation', (WidgetTester tester) async {
const Key key1 = ValueKey<String>('key1'); const Key key1 = ValueKey<String>('key1');
const Key key2 = ValueKey<String>('key2'); const Key key2 = ValueKey<String>('key2');
late StateSetter setState; late StateSetter setState;
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
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';
void main() { void main() {
testWidgets('AnimatedSwitcher fades in a new child.', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedSwitcher fades in a new child.', (WidgetTester tester) async {
final UniqueKey containerOne = UniqueKey(); final UniqueKey containerOne = UniqueKey();
final UniqueKey containerTwo = UniqueKey(); final UniqueKey containerTwo = UniqueKey();
final UniqueKey containerThree = UniqueKey(); final UniqueKey containerThree = UniqueKey();
...@@ -50,7 +51,7 @@ void main() { ...@@ -50,7 +51,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgets('AnimatedSwitcher can handle back-to-back changes.', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedSwitcher can handle back-to-back changes.', (WidgetTester tester) async {
final UniqueKey container1 = UniqueKey(); final UniqueKey container1 = UniqueKey();
final UniqueKey container2 = UniqueKey(); final UniqueKey container2 = UniqueKey();
final UniqueKey container3 = UniqueKey(); final UniqueKey container3 = UniqueKey();
...@@ -85,7 +86,7 @@ void main() { ...@@ -85,7 +86,7 @@ void main() {
expect(find.byKey(container3), findsOneWidget); expect(find.byKey(container3), findsOneWidget);
}); });
testWidgets("AnimatedSwitcher doesn't transition in a new child of the same type.", (WidgetTester tester) async { testWidgetsWithLeakTracking("AnimatedSwitcher doesn't transition in a new child of the same type.", (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
AnimatedSwitcher( AnimatedSwitcher(
duration: const Duration(milliseconds: 100), duration: const Duration(milliseconds: 100),
...@@ -111,7 +112,7 @@ void main() { ...@@ -111,7 +112,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgets('AnimatedSwitcher handles null children.', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedSwitcher handles null children.', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const AnimatedSwitcher( const AnimatedSwitcher(
duration: Duration(milliseconds: 100), duration: Duration(milliseconds: 100),
...@@ -166,7 +167,7 @@ void main() { ...@@ -166,7 +167,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgets("AnimatedSwitcher doesn't start any animations after dispose.", (WidgetTester tester) async { testWidgetsWithLeakTracking("AnimatedSwitcher doesn't start any animations after dispose.", (WidgetTester tester) async {
await tester.pumpWidget(AnimatedSwitcher( await tester.pumpWidget(AnimatedSwitcher(
duration: const Duration(milliseconds: 100), duration: const Duration(milliseconds: 100),
child: Container(color: const Color(0xff000000)), child: Container(color: const Color(0xff000000)),
...@@ -178,7 +179,7 @@ void main() { ...@@ -178,7 +179,7 @@ void main() {
expect(await tester.pumpAndSettle(), equals(1)); expect(await tester.pumpAndSettle(), equals(1));
}); });
testWidgets('AnimatedSwitcher uses custom layout.', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedSwitcher uses custom layout.', (WidgetTester tester) async {
Widget newLayoutBuilder(Widget? currentChild, List<Widget> previousChildren) { Widget newLayoutBuilder(Widget? currentChild, List<Widget> previousChildren) {
return Column( return Column(
children: <Widget>[ children: <Widget>[
...@@ -199,7 +200,7 @@ void main() { ...@@ -199,7 +200,7 @@ void main() {
expect(find.byType(Column), findsOneWidget); expect(find.byType(Column), findsOneWidget);
}); });
testWidgets('AnimatedSwitcher uses custom transitions.', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedSwitcher uses custom transitions.', (WidgetTester tester) async {
late List<Widget> foundChildren; late List<Widget> foundChildren;
Widget newLayoutBuilder(Widget? currentChild, List<Widget> previousChildren) { Widget newLayoutBuilder(Widget? currentChild, List<Widget> previousChildren) {
foundChildren = <Widget>[ foundChildren = <Widget>[
...@@ -254,7 +255,7 @@ void main() { ...@@ -254,7 +255,7 @@ void main() {
} }
}); });
testWidgets("AnimatedSwitcher doesn't reset state of the children in transitions.", (WidgetTester tester) async { testWidgetsWithLeakTracking("AnimatedSwitcher doesn't reset state of the children in transitions.", (WidgetTester tester) async {
final UniqueKey statefulOne = UniqueKey(); final UniqueKey statefulOne = UniqueKey();
final UniqueKey statefulTwo = UniqueKey(); final UniqueKey statefulTwo = UniqueKey();
final UniqueKey statefulThree = UniqueKey(); final UniqueKey statefulThree = UniqueKey();
...@@ -305,7 +306,7 @@ void main() { ...@@ -305,7 +306,7 @@ void main() {
expect(StatefulTestState.generation, equals(3)); expect(StatefulTestState.generation, equals(3));
}); });
testWidgets('AnimatedSwitcher updates widgets without animating if they are isomorphic.', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedSwitcher updates widgets without animating if they are isomorphic.', (WidgetTester tester) async {
Future<void> pumpChild(Widget child) async { Future<void> pumpChild(Widget child) async {
return tester.pumpWidget( return tester.pumpWidget(
Directionality( Directionality(
...@@ -332,7 +333,7 @@ void main() { ...@@ -332,7 +333,7 @@ void main() {
expect(find.text('2'), findsOneWidget); expect(find.text('2'), findsOneWidget);
}); });
testWidgets('AnimatedSwitcher updates previous child transitions if the transitionBuilder changes.', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedSwitcher updates previous child transitions if the transitionBuilder changes.', (WidgetTester tester) async {
final UniqueKey containerOne = UniqueKey(); final UniqueKey containerOne = UniqueKey();
final UniqueKey containerTwo = UniqueKey(); final UniqueKey containerTwo = UniqueKey();
final UniqueKey containerThree = UniqueKey(); final UniqueKey containerThree = UniqueKey();
...@@ -416,7 +417,7 @@ void main() { ...@@ -416,7 +417,7 @@ void main() {
} }
}); });
testWidgets('AnimatedSwitcher does not duplicate animations if the same child is entered twice.', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedSwitcher does not duplicate animations if the same child is entered twice.', (WidgetTester tester) async {
Future<void> pumpChild(Widget child) async { Future<void> pumpChild(Widget child) async {
return tester.pumpWidget( return tester.pumpWidget(
Directionality( Directionality(
......
...@@ -5,9 +5,10 @@ ...@@ -5,9 +5,10 @@
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.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';
void main() { void main() {
testWidgets('provides a value to the layer tree', (WidgetTester tester) async { testWidgetsWithLeakTracking('provides a value to the layer tree', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const AnnotatedRegion<int>( const AnnotatedRegion<int>(
value: 1, value: 1,
...@@ -18,7 +19,8 @@ void main() { ...@@ -18,7 +19,8 @@ void main() {
final AnnotatedRegionLayer<int> layer = layers.whereType<AnnotatedRegionLayer<int>>().first; final AnnotatedRegionLayer<int> layer = layers.whereType<AnnotatedRegionLayer<int>>().first;
expect(layer.value, 1); expect(layer.value, 1);
}); });
testWidgets('provides a value to the layer tree in a particular region', (WidgetTester tester) async {
testWidgetsWithLeakTracking('provides a value to the layer tree in a particular region', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Transform.translate( Transform.translate(
offset: const Offset(25.0, 25.0), offset: const Offset(25.0, 25.0),
......
...@@ -7,6 +7,7 @@ import 'dart:ui'; ...@@ -7,6 +7,7 @@ import 'dart:ui';
import 'package:flutter/services.dart'; import 'package:flutter/services.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';
void main() { void main() {
late AppLifecycleListener listener; late AppLifecycleListener listener;
...@@ -47,13 +48,13 @@ void main() { ...@@ -47,13 +48,13 @@ void main() {
'There were ${TestAppLifecycleListener.registerCount} listeners that were not disposed of in tests.'); 'There were ${TestAppLifecycleListener.registerCount} listeners that were not disposed of in tests.');
}); });
testWidgets('Default Diagnostics', (WidgetTester tester) async { testWidgetsWithLeakTracking('Default Diagnostics', (WidgetTester tester) async {
listener = TestAppLifecycleListener(binding: tester.binding); listener = TestAppLifecycleListener(binding: tester.binding);
expect(listener.toString(), expect(listener.toString(),
equalsIgnoringHashCodes('TestAppLifecycleListener#00000(binding: <AutomatedTestWidgetsFlutterBinding>)')); equalsIgnoringHashCodes('TestAppLifecycleListener#00000(binding: <AutomatedTestWidgetsFlutterBinding>)'));
}); });
testWidgets('Diagnostics', (WidgetTester tester) async { testWidgetsWithLeakTracking('Diagnostics', (WidgetTester tester) async {
Future<AppExitResponse> handleExitRequested() async { Future<AppExitResponse> handleExitRequested() async {
return AppExitResponse.cancel; return AppExitResponse.cancel;
} }
...@@ -69,7 +70,7 @@ void main() { ...@@ -69,7 +70,7 @@ void main() {
'TestAppLifecycleListener#00000(binding: <AutomatedTestWidgetsFlutterBinding>, onStateChange, onExitRequested)')); 'TestAppLifecycleListener#00000(binding: <AutomatedTestWidgetsFlutterBinding>, onStateChange, onExitRequested)'));
}); });
testWidgets('listens to AppLifecycleState', (WidgetTester tester) async { testWidgetsWithLeakTracking('listens to AppLifecycleState', (WidgetTester tester) async {
final List<AppLifecycleState> states = <AppLifecycleState>[tester.binding.lifecycleState!]; final List<AppLifecycleState> states = <AppLifecycleState>[tester.binding.lifecycleState!];
void stateChange(AppLifecycleState state) { void stateChange(AppLifecycleState state) {
states.add(state); states.add(state);
...@@ -95,7 +96,7 @@ void main() { ...@@ -95,7 +96,7 @@ void main() {
])); ]));
}); });
testWidgets('Triggers correct state transition callbacks', (WidgetTester tester) async { testWidgetsWithLeakTracking('Triggers correct state transition callbacks', (WidgetTester tester) async {
final List<String> transitions = <String>[]; final List<String> transitions = <String>[];
listener = TestAppLifecycleListener( listener = TestAppLifecycleListener(
binding: WidgetsBinding.instance, binding: WidgetsBinding.instance,
...@@ -148,7 +149,7 @@ void main() { ...@@ -148,7 +149,7 @@ void main() {
await setAppLifeCycleState(AppLifecycleState.detached); await setAppLifeCycleState(AppLifecycleState.detached);
}); });
testWidgets('Receives exit requests', (WidgetTester tester) async { testWidgetsWithLeakTracking('Receives exit requests', (WidgetTester tester) async {
bool exitRequested = false; bool exitRequested = false;
Future<AppExitResponse> handleExitRequested() async { Future<AppExitResponse> handleExitRequested() async {
exitRequested = true; exitRequested = true;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
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';
Route<void> generateRoute(RouteSettings settings) => PageRouteBuilder<void>( Route<void> generateRoute(RouteSettings settings) => PageRouteBuilder<void>(
settings: settings, settings: settings,
...@@ -13,7 +14,7 @@ Route<void> generateRoute(RouteSettings settings) => PageRouteBuilder<void>( ...@@ -13,7 +14,7 @@ Route<void> generateRoute(RouteSettings settings) => PageRouteBuilder<void>(
); );
void main() { void main() {
testWidgets('WidgetsApp.navigatorKey', (WidgetTester tester) async { testWidgetsWithLeakTracking('WidgetsApp.navigatorKey', (WidgetTester tester) async {
final GlobalKey<NavigatorState> key = GlobalKey<NavigatorState>(); final GlobalKey<NavigatorState> key = GlobalKey<NavigatorState>();
await tester.pumpWidget(WidgetsApp( await tester.pumpWidget(WidgetsApp(
navigatorKey: key, navigatorKey: key,
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
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';
class TestRoute<T> extends PageRoute<T> { class TestRoute<T> extends PageRoute<T> {
TestRoute({ required this.child, super.settings }); TestRoute({ required this.child, super.settings });
...@@ -40,7 +41,7 @@ Future<void> pumpApp(WidgetTester tester) async { ...@@ -40,7 +41,7 @@ Future<void> pumpApp(WidgetTester tester) async {
} }
void main() { void main() {
testWidgets('WidgetsApp control test', (WidgetTester tester) async { testWidgetsWithLeakTracking('WidgetsApp control test', (WidgetTester tester) async {
await pumpApp(tester); await pumpApp(tester);
expect(find.byType(WidgetsApp), findsOneWidget); expect(find.byType(WidgetsApp), findsOneWidget);
expect(find.byType(Navigator), findsOneWidget); expect(find.byType(Navigator), findsOneWidget);
...@@ -48,7 +49,7 @@ void main() { ...@@ -48,7 +49,7 @@ void main() {
expect(find.byType(CheckedModeBanner), findsOneWidget); expect(find.byType(CheckedModeBanner), findsOneWidget);
}); });
testWidgets('showPerformanceOverlayOverride true', (WidgetTester tester) async { testWidgetsWithLeakTracking('showPerformanceOverlayOverride true', (WidgetTester tester) async {
expect(WidgetsApp.showPerformanceOverlayOverride, false); expect(WidgetsApp.showPerformanceOverlayOverride, false);
WidgetsApp.showPerformanceOverlayOverride = true; WidgetsApp.showPerformanceOverlayOverride = true;
await pumpApp(tester); await pumpApp(tester);
...@@ -59,7 +60,7 @@ void main() { ...@@ -59,7 +60,7 @@ void main() {
WidgetsApp.showPerformanceOverlayOverride = false; WidgetsApp.showPerformanceOverlayOverride = false;
}); });
testWidgets('showPerformanceOverlayOverride false', (WidgetTester tester) async { testWidgetsWithLeakTracking('showPerformanceOverlayOverride false', (WidgetTester tester) async {
WidgetsApp.showPerformanceOverlayOverride = true; WidgetsApp.showPerformanceOverlayOverride = true;
expect(WidgetsApp.showPerformanceOverlayOverride, true); expect(WidgetsApp.showPerformanceOverlayOverride, true);
WidgetsApp.showPerformanceOverlayOverride = false; WidgetsApp.showPerformanceOverlayOverride = false;
...@@ -70,7 +71,7 @@ void main() { ...@@ -70,7 +71,7 @@ void main() {
expect(find.byType(CheckedModeBanner), findsOneWidget); expect(find.byType(CheckedModeBanner), findsOneWidget);
}); });
testWidgets('debugAllowBannerOverride false', (WidgetTester tester) async { testWidgetsWithLeakTracking('debugAllowBannerOverride false', (WidgetTester tester) async {
expect(WidgetsApp.showPerformanceOverlayOverride, false); expect(WidgetsApp.showPerformanceOverlayOverride, false);
expect(WidgetsApp.debugAllowBannerOverride, true); expect(WidgetsApp.debugAllowBannerOverride, true);
WidgetsApp.debugAllowBannerOverride = false; WidgetsApp.debugAllowBannerOverride = false;
...@@ -82,7 +83,7 @@ void main() { ...@@ -82,7 +83,7 @@ void main() {
WidgetsApp.debugAllowBannerOverride = true; // restore to default value WidgetsApp.debugAllowBannerOverride = true; // restore to default value
}); });
testWidgets('debugAllowBannerOverride true', (WidgetTester tester) async { testWidgetsWithLeakTracking('debugAllowBannerOverride true', (WidgetTester tester) async {
WidgetsApp.debugAllowBannerOverride = false; WidgetsApp.debugAllowBannerOverride = false;
expect(WidgetsApp.showPerformanceOverlayOverride, false); expect(WidgetsApp.showPerformanceOverlayOverride, false);
expect(WidgetsApp.debugAllowBannerOverride, false); expect(WidgetsApp.debugAllowBannerOverride, false);
......
This diff is collapsed.
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
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';
const Color kTitleColor = Color(0xFF333333); const Color kTitleColor = Color(0xFF333333);
const String kTitleString = 'Hello World'; const String kTitleString = 'Hello World';
...@@ -30,13 +31,13 @@ Future<void> pumpApp(WidgetTester tester, { GenerateAppTitle? onGenerateTitle, C ...@@ -30,13 +31,13 @@ Future<void> pumpApp(WidgetTester tester, { GenerateAppTitle? onGenerateTitle, C
} }
void main() { void main() {
testWidgets('Specified title and color are used to build a Title', (WidgetTester tester) async { testWidgetsWithLeakTracking('Specified title and color are used to build a Title', (WidgetTester tester) async {
await pumpApp(tester); await pumpApp(tester);
expect(tester.widget<Title>(find.byType(Title)).title, kTitleString); expect(tester.widget<Title>(find.byType(Title)).title, kTitleString);
expect(tester.widget<Title>(find.byType(Title)).color, kTitleColor); expect(tester.widget<Title>(find.byType(Title)).color, kTitleColor);
}); });
testWidgets('Specified color is made opaque for Title', (WidgetTester tester) async { testWidgetsWithLeakTracking('Specified color is made opaque for Title', (WidgetTester tester) async {
// The Title widget can only handle fully opaque colors, the WidgetApp should // The Title widget can only handle fully opaque colors, the WidgetApp should
// ensure it only uses a fully opaque version of its color for the title. // ensure it only uses a fully opaque version of its color for the title.
const Color transparentBlue = Color(0xDD0000ff); const Color transparentBlue = Color(0xDD0000ff);
...@@ -45,7 +46,7 @@ void main() { ...@@ -45,7 +46,7 @@ void main() {
expect(tester.widget<Title>(find.byType(Title)).color, opaqueBlue); expect(tester.widget<Title>(find.byType(Title)).color, opaqueBlue);
}); });
testWidgets('onGenerateTitle handles changing locales', (WidgetTester tester) async { testWidgetsWithLeakTracking('onGenerateTitle handles changing locales', (WidgetTester tester) async {
String generateTitle(BuildContext context) { String generateTitle(BuildContext context) {
return Localizations.localeOf(context).toString(); return Localizations.localeOf(context).toString();
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
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';
Future<Size> _getSize(WidgetTester tester, BoxConstraints constraints, double aspectRatio) async { Future<Size> _getSize(WidgetTester tester, BoxConstraints constraints, double aspectRatio) async {
final Key childKey = UniqueKey(); final Key childKey = UniqueKey();
...@@ -25,12 +26,12 @@ Future<Size> _getSize(WidgetTester tester, BoxConstraints constraints, double as ...@@ -25,12 +26,12 @@ Future<Size> _getSize(WidgetTester tester, BoxConstraints constraints, double as
} }
void main() { void main() {
testWidgets('Aspect ratio control test', (WidgetTester tester) async { testWidgetsWithLeakTracking('Aspect ratio control test', (WidgetTester tester) async {
expect(await _getSize(tester, BoxConstraints.loose(const Size(500.0, 500.0)), 2.0), equals(const Size(500.0, 250.0))); expect(await _getSize(tester, BoxConstraints.loose(const Size(500.0, 500.0)), 2.0), equals(const Size(500.0, 250.0)));
expect(await _getSize(tester, BoxConstraints.loose(const Size(500.0, 500.0)), 0.5), equals(const Size(250.0, 500.0))); expect(await _getSize(tester, BoxConstraints.loose(const Size(500.0, 500.0)), 0.5), equals(const Size(250.0, 500.0)));
}); });
testWidgets('Aspect ratio infinite width', (WidgetTester tester) async { testWidgetsWithLeakTracking('Aspect ratio infinite width', (WidgetTester tester) async {
final Key childKey = UniqueKey(); final Key childKey = UniqueKey();
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
......
...@@ -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';
class User { class User {
const User({ const User({
...@@ -45,7 +46,7 @@ void main() { ...@@ -45,7 +46,7 @@ void main() {
User(name: 'Charlie', email: 'charlie123@gmail.com'), User(name: 'Charlie', email: 'charlie123@gmail.com'),
]; ];
testWidgets('can filter and select a list of string options', (WidgetTester tester) async { testWidgetsWithLeakTracking('can filter and select a list of string options', (WidgetTester tester) async {
final GlobalKey fieldKey = GlobalKey(); final GlobalKey fieldKey = GlobalKey();
final GlobalKey optionsKey = GlobalKey(); final GlobalKey optionsKey = GlobalKey();
late Iterable<String> lastOptions; late Iterable<String> lastOptions;
...@@ -129,7 +130,7 @@ void main() { ...@@ -129,7 +130,7 @@ void main() {
expect(lastOptions.elementAt(5), 'northern white rhinoceros'); expect(lastOptions.elementAt(5), 'northern white rhinoceros');
}); });
testWidgets('tapping on an option selects it', (WidgetTester tester) async { testWidgetsWithLeakTracking('tapping on an option selects it', (WidgetTester tester) async {
final GlobalKey fieldKey = GlobalKey(); final GlobalKey fieldKey = GlobalKey();
final GlobalKey optionsKey = GlobalKey(); final GlobalKey optionsKey = GlobalKey();
late Iterable<String> lastOptions; late Iterable<String> lastOptions;
...@@ -199,7 +200,7 @@ void main() { ...@@ -199,7 +200,7 @@ void main() {
expect(textEditingController.text, equals(kOptions[2])); expect(textEditingController.text, equals(kOptions[2]));
}); });
testWidgets('can filter and select a list of custom User options', (WidgetTester tester) async { testWidgetsWithLeakTracking('can filter and select a list of custom User options', (WidgetTester tester) async {
final GlobalKey fieldKey = GlobalKey(); final GlobalKey fieldKey = GlobalKey();
final GlobalKey optionsKey = GlobalKey(); final GlobalKey optionsKey = GlobalKey();
late Iterable<User> lastOptions; late Iterable<User> lastOptions;
...@@ -277,7 +278,7 @@ void main() { ...@@ -277,7 +278,7 @@ void main() {
expect(lastOptions.elementAt(0), kOptionsUsers[1]); expect(lastOptions.elementAt(0), kOptionsUsers[1]);
}); });
testWidgets('can specify a custom display string for a list of custom User options', (WidgetTester tester) async { testWidgetsWithLeakTracking('can specify a custom display string for a list of custom User options', (WidgetTester tester) async {
final GlobalKey fieldKey = GlobalKey(); final GlobalKey fieldKey = GlobalKey();
final GlobalKey optionsKey = GlobalKey(); final GlobalKey optionsKey = GlobalKey();
late Iterable<User> lastOptions; late Iterable<User> lastOptions;
...@@ -360,7 +361,7 @@ void main() { ...@@ -360,7 +361,7 @@ void main() {
expect(lastOptions.elementAt(0), kOptionsUsers[1]); expect(lastOptions.elementAt(0), kOptionsUsers[1]);
}); });
testWidgets('onFieldSubmitted selects the first option', (WidgetTester tester) async { testWidgetsWithLeakTracking('onFieldSubmitted selects the first option', (WidgetTester tester) async {
final GlobalKey fieldKey = GlobalKey(); final GlobalKey fieldKey = GlobalKey();
final GlobalKey optionsKey = GlobalKey(); final GlobalKey optionsKey = GlobalKey();
late Iterable<String> lastOptions; late Iterable<String> lastOptions;
...@@ -422,7 +423,7 @@ void main() { ...@@ -422,7 +423,7 @@ void main() {
}); });
group('optionsViewOpenDirection', () { group('optionsViewOpenDirection', () {
testWidgets('unset (default behavior): open downward', (WidgetTester tester) async { testWidgetsWithLeakTracking('unset (default behavior): open downward', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
...@@ -445,7 +446,7 @@ void main() { ...@@ -445,7 +446,7 @@ void main() {
offsetMoreOrLessEquals(tester.getTopLeft(find.text('a')))); offsetMoreOrLessEquals(tester.getTopLeft(find.text('a'))));
}); });
testWidgets('down: open downward', (WidgetTester tester) async { testWidgetsWithLeakTracking('down: open downward', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
...@@ -469,7 +470,7 @@ void main() { ...@@ -469,7 +470,7 @@ void main() {
offsetMoreOrLessEquals(tester.getTopLeft(find.text('a')))); offsetMoreOrLessEquals(tester.getTopLeft(find.text('a'))));
}); });
testWidgets('up: open upward', (WidgetTester tester) async { testWidgetsWithLeakTracking('up: open upward', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
...@@ -494,10 +495,12 @@ void main() { ...@@ -494,10 +495,12 @@ void main() {
}); });
group('fieldViewBuilder not passed', () { group('fieldViewBuilder not passed', () {
testWidgets('down', (WidgetTester tester) async { testWidgetsWithLeakTracking('down', (WidgetTester tester) async {
final GlobalKey autocompleteKey = GlobalKey(); final GlobalKey autocompleteKey = GlobalKey();
final TextEditingController controller = TextEditingController(); final TextEditingController controller = TextEditingController();
addTearDown(controller.dispose);
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
...@@ -525,10 +528,12 @@ void main() { ...@@ -525,10 +528,12 @@ void main() {
offsetMoreOrLessEquals(tester.getTopLeft(find.text('a')))); offsetMoreOrLessEquals(tester.getTopLeft(find.text('a'))));
}); });
testWidgets('up', (WidgetTester tester) async { testWidgetsWithLeakTracking('up', (WidgetTester tester) async {
final GlobalKey autocompleteKey = GlobalKey(); final GlobalKey autocompleteKey = GlobalKey();
final TextEditingController controller = TextEditingController(); final TextEditingController controller = TextEditingController();
addTearDown(controller.dispose);
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
...@@ -559,7 +564,7 @@ void main() { ...@@ -559,7 +564,7 @@ void main() {
}); });
}); });
testWidgets('options follow field when it moves', (WidgetTester tester) async { testWidgetsWithLeakTracking('options follow field when it moves', (WidgetTester tester) async {
final GlobalKey fieldKey = GlobalKey(); final GlobalKey fieldKey = GlobalKey();
final GlobalKey optionsKey = GlobalKey(); final GlobalKey optionsKey = GlobalKey();
late StateSetter setState; late StateSetter setState;
...@@ -633,7 +638,7 @@ void main() { ...@@ -633,7 +638,7 @@ void main() {
expect(optionsOffsetOpen.dy, fieldOffset.dy + fieldSize.height); expect(optionsOffsetOpen.dy, fieldOffset.dy + fieldSize.height);
}); });
testWidgets('can prevent options from showing by returning an empty iterable', (WidgetTester tester) async { testWidgetsWithLeakTracking('can prevent options from showing by returning an empty iterable', (WidgetTester tester) async {
final GlobalKey fieldKey = GlobalKey(); final GlobalKey fieldKey = GlobalKey();
final GlobalKey optionsKey = GlobalKey(); final GlobalKey optionsKey = GlobalKey();
late Iterable<String> lastOptions; late Iterable<String> lastOptions;
...@@ -696,13 +701,15 @@ void main() { ...@@ -696,13 +701,15 @@ void main() {
expect(lastOptions.elementAt(1), 'elephant'); expect(lastOptions.elementAt(1), 'elephant');
}); });
testWidgets('can create a field outside of fieldViewBuilder', (WidgetTester tester) async { testWidgetsWithLeakTracking('can create a field outside of fieldViewBuilder', (WidgetTester tester) async {
final GlobalKey fieldKey = GlobalKey(); final GlobalKey fieldKey = GlobalKey();
final GlobalKey optionsKey = GlobalKey(); final GlobalKey optionsKey = GlobalKey();
final GlobalKey autocompleteKey = GlobalKey(); final GlobalKey autocompleteKey = GlobalKey();
late Iterable<String> lastOptions; late Iterable<String> lastOptions;
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose);
final TextEditingController textEditingController = TextEditingController(); final TextEditingController textEditingController = TextEditingController();
addTearDown(textEditingController.dispose);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -762,7 +769,7 @@ void main() { ...@@ -762,7 +769,7 @@ void main() {
expect(textEditingController.text, lastOptions.elementAt(0)); expect(textEditingController.text, lastOptions.elementAt(0));
}); });
testWidgets('initialValue sets initial text field value', (WidgetTester tester) async { testWidgetsWithLeakTracking('initialValue sets initial text field value', (WidgetTester tester) async {
final GlobalKey fieldKey = GlobalKey(); final GlobalKey fieldKey = GlobalKey();
final GlobalKey optionsKey = GlobalKey(); final GlobalKey optionsKey = GlobalKey();
late Iterable<String> lastOptions; late Iterable<String> lastOptions;
...@@ -822,9 +829,11 @@ void main() { ...@@ -822,9 +829,11 @@ void main() {
expect(textEditingController.text, selection); expect(textEditingController.text, selection);
}); });
testWidgets('initialValue cannot be defined if TextEditingController is defined', (WidgetTester tester) async { testWidgetsWithLeakTracking('initialValue cannot be defined if TextEditingController is defined', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose);
final TextEditingController textEditingController = TextEditingController(); final TextEditingController textEditingController = TextEditingController();
addTearDown(textEditingController.dispose);
expect( expect(
() { () {
...@@ -854,7 +863,7 @@ void main() { ...@@ -854,7 +863,7 @@ void main() {
); );
}); });
testWidgets('support asynchronous options builder', (WidgetTester tester) async { testWidgetsWithLeakTracking('support asynchronous options builder', (WidgetTester tester) async {
final GlobalKey fieldKey = GlobalKey(); final GlobalKey fieldKey = GlobalKey();
final GlobalKey optionsKey = GlobalKey(); final GlobalKey optionsKey = GlobalKey();
late FocusNode focusNode; late FocusNode focusNode;
...@@ -915,7 +924,7 @@ void main() { ...@@ -915,7 +924,7 @@ void main() {
expect(lastOptions, <String>['dingo', 'flamingo']); expect(lastOptions, <String>['dingo', 'flamingo']);
}); });
testWidgets('can navigate options with the keyboard', (WidgetTester tester) async { testWidgetsWithLeakTracking('can navigate options with the keyboard', (WidgetTester tester) async {
final GlobalKey fieldKey = GlobalKey(); final GlobalKey fieldKey = GlobalKey();
final GlobalKey optionsKey = GlobalKey(); final GlobalKey optionsKey = GlobalKey();
late Iterable<String> lastOptions; late Iterable<String> lastOptions;
...@@ -1001,7 +1010,7 @@ void main() { ...@@ -1001,7 +1010,7 @@ void main() {
expect(textEditingController.text, 'goose'); expect(textEditingController.text, 'goose');
}); });
testWidgets('can hide and show options with the keyboard', (WidgetTester tester) async { testWidgetsWithLeakTracking('can hide and show options with the keyboard', (WidgetTester tester) async {
final GlobalKey fieldKey = GlobalKey(); final GlobalKey fieldKey = GlobalKey();
final GlobalKey optionsKey = GlobalKey(); final GlobalKey optionsKey = GlobalKey();
late Iterable<String> lastOptions; late Iterable<String> lastOptions;
...@@ -1091,7 +1100,7 @@ void main() { ...@@ -1091,7 +1100,7 @@ void main() {
expect(find.byKey(optionsKey), findsNothing); expect(find.byKey(optionsKey), findsNothing);
}); });
testWidgets('re-invokes DismissIntent if options not shown', (WidgetTester tester) async { testWidgetsWithLeakTracking('re-invokes DismissIntent if options not shown', (WidgetTester tester) async {
final GlobalKey fieldKey = GlobalKey(); final GlobalKey fieldKey = GlobalKey();
final GlobalKey optionsKey = GlobalKey(); final GlobalKey optionsKey = GlobalKey();
late FocusNode focusNode; late FocusNode focusNode;
...@@ -1150,7 +1159,7 @@ void main() { ...@@ -1150,7 +1159,7 @@ void main() {
expect(wrappingActionInvoked, true); expect(wrappingActionInvoked, true);
}); });
testWidgets('optionsViewBuilders can use AutocompleteHighlightedOption to highlight selected option', (WidgetTester tester) async { testWidgetsWithLeakTracking('optionsViewBuilders can use AutocompleteHighlightedOption to highlight selected option', (WidgetTester tester) async {
final GlobalKey fieldKey = GlobalKey(); final GlobalKey fieldKey = GlobalKey();
final GlobalKey optionsKey = GlobalKey(); final GlobalKey optionsKey = GlobalKey();
late Iterable<String> lastOptions; late Iterable<String> lastOptions;
...@@ -1231,7 +1240,7 @@ void main() { ...@@ -1231,7 +1240,7 @@ void main() {
expect(lastHighlighted, 5); expect(lastHighlighted, 5);
}); });
testWidgets('floating menu goes away on select', (WidgetTester tester) async { testWidgetsWithLeakTracking('floating menu goes away on select', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/99749. // Regression test for https://github.com/flutter/flutter/issues/99749.
final GlobalKey fieldKey = GlobalKey(); final GlobalKey fieldKey = GlobalKey();
final GlobalKey optionsKey = GlobalKey(); final GlobalKey optionsKey = GlobalKey();
......
...@@ -4,12 +4,13 @@ ...@@ -4,12 +4,13 @@
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';
final Matcher _matchesCommit = isMethodCall('TextInput.finishAutofillContext', arguments: true); final Matcher _matchesCommit = isMethodCall('TextInput.finishAutofillContext', arguments: true);
final Matcher _matchesCancel = isMethodCall('TextInput.finishAutofillContext', arguments: false); final Matcher _matchesCancel = isMethodCall('TextInput.finishAutofillContext', arguments: false);
void main() { void main() {
testWidgets('AutofillGroup has the right clients', (WidgetTester tester) async { testWidgetsWithLeakTracking('AutofillGroup has the right clients', (WidgetTester tester) async {
const Key outerKey = Key('outer'); const Key outerKey = Key('outer');
const Key innerKey = Key('inner'); const Key innerKey = Key('inner');
...@@ -44,7 +45,7 @@ void main() { ...@@ -44,7 +45,7 @@ void main() {
expect(innerState.autofillClients.toList(), <State<TextField>>[clientState2]); expect(innerState.autofillClients.toList(), <State<TextField>>[clientState2]);
}); });
testWidgets('new clients can be added & removed to a scope', (WidgetTester tester) async { testWidgetsWithLeakTracking('new clients can be added & removed to a scope', (WidgetTester tester) async {
const Key scopeKey = Key('scope'); const Key scopeKey = Key('scope');
const TextField client1 = TextField(autofillHints: <String>['1']); const TextField client1 = TextField(autofillHints: <String>['1']);
...@@ -92,7 +93,7 @@ void main() { ...@@ -92,7 +93,7 @@ void main() {
expect(scopeState.autofillClients, <State<TextField>>[clientState1]); expect(scopeState.autofillClients, <State<TextField>>[clientState1]);
}); });
testWidgets('AutofillGroup has the right clients after reparenting', (WidgetTester tester) async { testWidgetsWithLeakTracking('AutofillGroup has the right clients after reparenting', (WidgetTester tester) async {
const Key outerKey = Key('outer'); const Key outerKey = Key('outer');
const Key innerKey = Key('inner'); const Key innerKey = Key('inner');
final GlobalKey keyClient3 = GlobalKey(); final GlobalKey keyClient3 = GlobalKey();
...@@ -151,7 +152,7 @@ void main() { ...@@ -151,7 +152,7 @@ void main() {
expect(innerState.autofillClients, <State<TextField>>[clientState2]); expect(innerState.autofillClients, <State<TextField>>[clientState2]);
}); });
testWidgets('disposing AutofillGroups', (WidgetTester tester) async { testWidgetsWithLeakTracking('disposing AutofillGroups', (WidgetTester tester) async {
late StateSetter setState; late StateSetter setState;
const Key group1 = Key('group1'); const Key group1 = Key('group1');
const Key group2 = Key('group2'); const Key group2 = Key('group2');
......
...@@ -7,6 +7,7 @@ import 'package:flutter/gestures.dart' show DragStartBehavior; ...@@ -7,6 +7,7 @@ import 'package:flutter/gestures.dart' show DragStartBehavior;
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.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';
class Leaf extends StatefulWidget { class Leaf extends StatefulWidget {
const Leaf({ required Key key, required this.child }) : super(key: key); const Leaf({ required Key key, required this.child }) : super(key: key);
...@@ -21,7 +22,7 @@ class _LeafState extends State<Leaf> { ...@@ -21,7 +22,7 @@ class _LeafState extends State<Leaf> {
@override @override
void deactivate() { void deactivate() {
_handle?.release(); _handle?.dispose();
_handle = null; _handle = null;
super.deactivate(); super.deactivate();
} }
...@@ -34,7 +35,7 @@ class _LeafState extends State<Leaf> { ...@@ -34,7 +35,7 @@ class _LeafState extends State<Leaf> {
KeepAliveNotification(_handle!).dispatch(context); KeepAliveNotification(_handle!).dispatch(context);
} }
} else { } else {
_handle?.release(); _handle?.dispose();
_handle = null; _handle = null;
} }
} }
...@@ -67,7 +68,7 @@ List<Widget> generateList(Widget child, { required bool impliedMode }) { ...@@ -67,7 +68,7 @@ List<Widget> generateList(Widget child, { required bool impliedMode }) {
} }
void tests({ required bool impliedMode }) { void tests({ required bool impliedMode }) {
testWidgets('AutomaticKeepAlive with ListView with itemExtent', (WidgetTester tester) async { testWidgetsWithLeakTracking('AutomaticKeepAlive with ListView with itemExtent', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -115,7 +116,7 @@ void tests({ required bool impliedMode }) { ...@@ -115,7 +116,7 @@ void tests({ required bool impliedMode }) {
expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing); expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
}); });
testWidgets('AutomaticKeepAlive with ListView without itemExtent', (WidgetTester tester) async { testWidgetsWithLeakTracking('AutomaticKeepAlive with ListView without itemExtent', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -165,7 +166,7 @@ void tests({ required bool impliedMode }) { ...@@ -165,7 +166,7 @@ void tests({ required bool impliedMode }) {
expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing); expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
}); });
testWidgets('AutomaticKeepAlive with GridView', (WidgetTester tester) async { testWidgetsWithLeakTracking('AutomaticKeepAlive with GridView', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -222,7 +223,7 @@ void main() { ...@@ -222,7 +223,7 @@ void main() {
group('Explicit automatic keep-alive', () { tests(impliedMode: false); }); group('Explicit automatic keep-alive', () { tests(impliedMode: false); });
group('Implied automatic keep-alive', () { tests(impliedMode: true); }); group('Implied automatic keep-alive', () { tests(impliedMode: true); });
testWidgets('AutomaticKeepAlive double', (WidgetTester tester) async { testWidgetsWithLeakTracking('AutomaticKeepAlive double', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -306,7 +307,7 @@ void main() { ...@@ -306,7 +307,7 @@ void main() {
expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget); expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
}); });
testWidgets('AutomaticKeepAlive double 2', (WidgetTester tester) async { testWidgetsWithLeakTracking('AutomaticKeepAlive double 2', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -474,7 +475,7 @@ void main() { ...@@ -474,7 +475,7 @@ void main() {
expect(find.byKey(const GlobalObjectKey<_LeafState>(0), skipOffstage: false), findsNothing); expect(find.byKey(const GlobalObjectKey<_LeafState>(0), skipOffstage: false), findsNothing);
}); });
testWidgets('AutomaticKeepAlive with keepAlive set to true before initState', (WidgetTester tester) async { testWidgetsWithLeakTracking('AutomaticKeepAlive with keepAlive set to true before initState', (WidgetTester tester) async {
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: ListView.builder( child: ListView.builder(
...@@ -509,7 +510,7 @@ void main() { ...@@ -509,7 +510,7 @@ void main() {
expect(find.text('FooBar 2'), findsNothing); expect(find.text('FooBar 2'), findsNothing);
}); });
testWidgets('AutomaticKeepAlive with keepAlive set to true before initState and widget goes out of scope', (WidgetTester tester) async { testWidgetsWithLeakTracking('AutomaticKeepAlive with keepAlive set to true before initState and widget goes out of scope', (WidgetTester tester) async {
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: ListView.builder( child: ListView.builder(
...@@ -548,19 +549,22 @@ void main() { ...@@ -548,19 +549,22 @@ void main() {
expect(find.text('FooBar 73'), findsOneWidget); expect(find.text('FooBar 73'), findsOneWidget);
}); });
testWidgets('AutomaticKeepAlive with SliverKeepAliveWidget', (WidgetTester tester) async { testWidgetsWithLeakTracking('AutomaticKeepAlive with SliverKeepAliveWidget', (WidgetTester tester) async {
// We're just doing a basic test here to make sure that the functionality of // We're just doing a basic test here to make sure that the functionality of
// RenderSliverWithKeepAliveMixin doesn't get regressed or deleted. As testing // RenderSliverWithKeepAliveMixin doesn't get regressed or deleted. As testing
// the full functionality would be cumbersome. // the full functionality would be cumbersome.
final RenderSliverMultiBoxAdaptorAlt alternate = RenderSliverMultiBoxAdaptorAlt(); final RenderSliverMultiBoxAdaptorAlt alternate = RenderSliverMultiBoxAdaptorAlt();
addTearDown(alternate.dispose);
final RenderBox child = RenderBoxKeepAlive(); final RenderBox child = RenderBoxKeepAlive();
addTearDown(child.dispose);
alternate.insert(child); alternate.insert(child);
expect(alternate.children.length, 1); expect(alternate.children.length, 1);
}); });
testWidgets('Keep alive Listenable has its listener removed once called', (WidgetTester tester) async { testWidgetsWithLeakTracking('Keep alive Listenable has its listener removed once called', (WidgetTester tester) async {
final LeakCheckerHandle handle = LeakCheckerHandle(); final LeakCheckerHandle handle = LeakCheckerHandle();
addTearDown(handle.dispose);
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: ListView.builder( child: ListView.builder(
......
...@@ -11,9 +11,10 @@ import 'dart:ui'; ...@@ -11,9 +11,10 @@ import 'dart:ui';
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("Material2 - BackdropFilter's cull rect does not shrink", (WidgetTester tester) async { testWidgetsWithLeakTracking("Material2 - BackdropFilter's cull rect does not shrink", (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
...@@ -51,7 +52,7 @@ void main() { ...@@ -51,7 +52,7 @@ void main() {
); );
}); });
testWidgets("Material3 - BackdropFilter's cull rect does not shrink", (WidgetTester tester) async { testWidgetsWithLeakTracking("Material3 - BackdropFilter's cull rect does not shrink", (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: true), theme: ThemeData(useMaterial3: true),
...@@ -89,7 +90,7 @@ void main() { ...@@ -89,7 +90,7 @@ void main() {
); );
}); });
testWidgets('Material2 - BackdropFilter blendMode on saveLayer', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material2 - BackdropFilter blendMode on saveLayer', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
...@@ -148,7 +149,7 @@ void main() { ...@@ -148,7 +149,7 @@ void main() {
); );
}); });
testWidgets('Material3 - BackdropFilter blendMode on saveLayer', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material3 - BackdropFilter blendMode on saveLayer', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: true), theme: ThemeData(useMaterial3: true),
......
...@@ -6,6 +6,7 @@ import 'dart:math' as math; ...@@ -6,6 +6,7 @@ import 'dart:math' as math;
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';
class TestCanvas implements Canvas { class TestCanvas implements Canvas {
final List<Invocation> invocations = <Invocation>[]; final List<Invocation> invocations = <Invocation>[];
...@@ -245,7 +246,7 @@ void main() { ...@@ -245,7 +246,7 @@ void main() {
expect(rotateCommand.positionalArguments[0], equals(math.pi / 4.0)); expect(rotateCommand.positionalArguments[0], equals(math.pi / 4.0));
}); });
testWidgets('Banner widget', (WidgetTester tester) async { testWidgetsWithLeakTracking('Banner widget', (WidgetTester tester) async {
debugDisableShadows = false; debugDisableShadows = false;
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
...@@ -265,7 +266,7 @@ void main() { ...@@ -265,7 +266,7 @@ void main() {
debugDisableShadows = true; debugDisableShadows = true;
}); });
testWidgets('Banner widget in MaterialApp', (WidgetTester tester) async { testWidgetsWithLeakTracking('Banner widget in MaterialApp', (WidgetTester tester) async {
debugDisableShadows = false; debugDisableShadows = false;
await tester.pumpWidget(const MaterialApp(home: Placeholder())); await tester.pumpWidget(const MaterialApp(home: Placeholder()));
expect(find.byType(CheckedModeBanner), paints expect(find.byType(CheckedModeBanner), paints
......
...@@ -4,9 +4,10 @@ ...@@ -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('Baseline - control test', (WidgetTester tester) async { testWidgetsWithLeakTracking('Baseline - control test', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Center( const Center(
child: DefaultTextStyle( child: DefaultTextStyle(
...@@ -20,7 +21,7 @@ void main() { ...@@ -20,7 +21,7 @@ void main() {
expect(tester.renderObject<RenderBox>(find.text('X')).size, const Size(100.0, 100.0)); expect(tester.renderObject<RenderBox>(find.text('X')).size, const Size(100.0, 100.0));
}); });
testWidgets('Baseline - position test', (WidgetTester tester) async { testWidgetsWithLeakTracking('Baseline - position test', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Center( const Center(
child: Baseline( child: Baseline(
...@@ -43,7 +44,7 @@ void main() { ...@@ -43,7 +44,7 @@ void main() {
); );
}); });
testWidgets('Chip caches baseline', (WidgetTester tester) async { testWidgetsWithLeakTracking('Chip caches baseline', (WidgetTester tester) async {
int calls = 0; int calls = 0;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -68,7 +69,7 @@ void main() { ...@@ -68,7 +69,7 @@ void main() {
expect(calls, 2); expect(calls, 2);
}); });
testWidgets('ListTile caches baseline', (WidgetTester tester) async { testWidgetsWithLeakTracking('ListTile caches baseline', (WidgetTester tester) async {
int calls = 0; int calls = 0;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -93,7 +94,7 @@ void main() { ...@@ -93,7 +94,7 @@ void main() {
expect(calls, 2); expect(calls, 2);
}); });
testWidgets("LayoutBuilder returns child's baseline", (WidgetTester tester) async { testWidgetsWithLeakTracking("LayoutBuilder returns child's baseline", (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Material( home: Material(
......
...@@ -8,12 +8,13 @@ import 'package:flutter/material.dart'; ...@@ -8,12 +8,13 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.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';
const String _actualContent = 'Actual Content'; const String _actualContent = 'Actual Content';
const String _loading = 'Loading...'; const String _loading = 'Loading...';
void main() { void main() {
testWidgets('deferFirstFrame/allowFirstFrame stops sending frames to engine', (WidgetTester tester) async { testWidgetsWithLeakTracking('deferFirstFrame/allowFirstFrame stops sending frames to engine', (WidgetTester tester) async {
expect(RendererBinding.instance.sendFramesToEngine, isTrue); expect(RendererBinding.instance.sendFramesToEngine, isTrue);
final Completer<void> completer = Completer<void>(); final Completer<void> completer = Completer<void>();
...@@ -50,7 +51,7 @@ void main() { ...@@ -50,7 +51,7 @@ void main() {
expect(RendererBinding.instance.sendFramesToEngine, isTrue); expect(RendererBinding.instance.sendFramesToEngine, isTrue);
}); });
testWidgets('Two widgets can defer frames', (WidgetTester tester) async { testWidgetsWithLeakTracking('Two widgets can defer frames', (WidgetTester tester) async {
expect(RendererBinding.instance.sendFramesToEngine, isTrue); expect(RendererBinding.instance.sendFramesToEngine, isTrue);
final Completer<void> completer1 = Completer<void>(); final Completer<void> completer1 = Completer<void>();
......
...@@ -8,6 +8,7 @@ import 'package:flutter/foundation.dart'; ...@@ -8,6 +8,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.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';
class MemoryPressureObserver with WidgetsBindingObserver { class MemoryPressureObserver with WidgetsBindingObserver {
bool sawMemoryPressure = false; bool sawMemoryPressure = false;
...@@ -143,7 +144,7 @@ void main() { ...@@ -143,7 +144,7 @@ void main() {
.handlePlatformMessage('flutter/lifecycle', message, (_) { }); .handlePlatformMessage('flutter/lifecycle', message, (_) { });
} }
testWidgets('Rentrant observer callbacks do not result in exceptions', (WidgetTester tester) async { testWidgetsWithLeakTracking('Rentrant observer callbacks do not result in exceptions', (WidgetTester tester) async {
final RentrantObserver observer = RentrantObserver(); final RentrantObserver observer = RentrantObserver();
WidgetsBinding.instance.handleAccessibilityFeaturesChanged(); WidgetsBinding.instance.handleAccessibilityFeaturesChanged();
WidgetsBinding.instance.handleAppLifecycleStateChanged(AppLifecycleState.resumed); WidgetsBinding.instance.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
...@@ -160,7 +161,7 @@ void main() { ...@@ -160,7 +161,7 @@ void main() {
expect(observer.removeSelf(), 0); expect(observer.removeSelf(), 0);
}); });
testWidgets('didHaveMemoryPressure callback', (WidgetTester tester) async { testWidgetsWithLeakTracking('didHaveMemoryPressure callback', (WidgetTester tester) async {
final MemoryPressureObserver observer = MemoryPressureObserver(); final MemoryPressureObserver observer = MemoryPressureObserver();
WidgetsBinding.instance.addObserver(observer); WidgetsBinding.instance.addObserver(observer);
final ByteData message = const JSONMessageCodec().encodeMessage(<String, dynamic>{'type': 'memoryPressure'})!; final ByteData message = const JSONMessageCodec().encodeMessage(<String, dynamic>{'type': 'memoryPressure'})!;
...@@ -169,7 +170,7 @@ void main() { ...@@ -169,7 +170,7 @@ void main() {
WidgetsBinding.instance.removeObserver(observer); WidgetsBinding.instance.removeObserver(observer);
}); });
testWidgets('handleLifecycleStateChanged callback', (WidgetTester tester) async { testWidgetsWithLeakTracking('handleLifecycleStateChanged callback', (WidgetTester tester) async {
final AppLifecycleStateObserver observer = AppLifecycleStateObserver(); final AppLifecycleStateObserver observer = AppLifecycleStateObserver();
WidgetsBinding.instance.addObserver(observer); WidgetsBinding.instance.addObserver(observer);
...@@ -228,7 +229,7 @@ void main() { ...@@ -228,7 +229,7 @@ void main() {
WidgetsBinding.instance.removeObserver(observer); WidgetsBinding.instance.removeObserver(observer);
}); });
testWidgets('didPushRoute callback', (WidgetTester tester) async { testWidgetsWithLeakTracking('didPushRoute callback', (WidgetTester tester) async {
final PushRouteObserver observer = PushRouteObserver(); final PushRouteObserver observer = PushRouteObserver();
WidgetsBinding.instance.addObserver(observer); WidgetsBinding.instance.addObserver(observer);
...@@ -240,7 +241,7 @@ void main() { ...@@ -240,7 +241,7 @@ void main() {
WidgetsBinding.instance.removeObserver(observer); WidgetsBinding.instance.removeObserver(observer);
}); });
testWidgets('didPushRouteInformation calls didPushRoute by default', (WidgetTester tester) async { testWidgetsWithLeakTracking('didPushRouteInformation calls didPushRoute by default', (WidgetTester tester) async {
final PushRouteObserver observer = PushRouteObserver(); final PushRouteObserver observer = PushRouteObserver();
WidgetsBinding.instance.addObserver(observer); WidgetsBinding.instance.addObserver(observer);
...@@ -258,7 +259,7 @@ void main() { ...@@ -258,7 +259,7 @@ void main() {
WidgetsBinding.instance.removeObserver(observer); WidgetsBinding.instance.removeObserver(observer);
}); });
testWidgets('didPushRouteInformation calls didPushRoute correctly when handling url', (WidgetTester tester) async { testWidgetsWithLeakTracking('didPushRouteInformation calls didPushRoute correctly when handling url', (WidgetTester tester) async {
final PushRouteObserver observer = PushRouteObserver(); final PushRouteObserver observer = PushRouteObserver();
WidgetsBinding.instance.addObserver(observer); WidgetsBinding.instance.addObserver(observer);
...@@ -290,7 +291,7 @@ void main() { ...@@ -290,7 +291,7 @@ void main() {
WidgetsBinding.instance.removeObserver(observer); WidgetsBinding.instance.removeObserver(observer);
}); });
testWidgets('didPushRouteInformation callback', (WidgetTester tester) async { testWidgetsWithLeakTracking('didPushRouteInformation callback', (WidgetTester tester) async {
final PushRouteInformationObserver observer = PushRouteInformationObserver(); final PushRouteInformationObserver observer = PushRouteInformationObserver();
WidgetsBinding.instance.addObserver(observer); WidgetsBinding.instance.addObserver(observer);
...@@ -307,7 +308,7 @@ void main() { ...@@ -307,7 +308,7 @@ void main() {
WidgetsBinding.instance.removeObserver(observer); WidgetsBinding.instance.removeObserver(observer);
}); });
testWidgets('didPushRouteInformation callback can handle url', (WidgetTester tester) async { testWidgetsWithLeakTracking('didPushRouteInformation callback can handle url', (WidgetTester tester) async {
final PushRouteInformationObserver observer = PushRouteInformationObserver(); final PushRouteInformationObserver observer = PushRouteInformationObserver();
WidgetsBinding.instance.addObserver(observer); WidgetsBinding.instance.addObserver(observer);
...@@ -325,7 +326,7 @@ void main() { ...@@ -325,7 +326,7 @@ void main() {
WidgetsBinding.instance.removeObserver(observer); WidgetsBinding.instance.removeObserver(observer);
}); });
testWidgets('didPushRouteInformation callback with null state', (WidgetTester tester) async { testWidgetsWithLeakTracking('didPushRouteInformation callback with null state', (WidgetTester tester) async {
final PushRouteInformationObserver observer = PushRouteInformationObserver(); final PushRouteInformationObserver observer = PushRouteInformationObserver();
WidgetsBinding.instance.addObserver(observer); WidgetsBinding.instance.addObserver(observer);
...@@ -343,7 +344,7 @@ void main() { ...@@ -343,7 +344,7 @@ void main() {
WidgetsBinding.instance.removeObserver(observer); WidgetsBinding.instance.removeObserver(observer);
}); });
testWidgets('Application lifecycle affects frame scheduling', (WidgetTester tester) async { testWidgetsWithLeakTracking('Application lifecycle affects frame scheduling', (WidgetTester tester) async {
expect(tester.binding.hasScheduledFrame, isFalse); expect(tester.binding.hasScheduledFrame, isFalse);
await setAppLifeCycleState(AppLifecycleState.paused); await setAppLifeCycleState(AppLifecycleState.paused);
...@@ -397,7 +398,7 @@ void main() { ...@@ -397,7 +398,7 @@ void main() {
await tester.pump(); await tester.pump();
}); });
testWidgets('scheduleFrameCallback error control test', (WidgetTester tester) async { testWidgetsWithLeakTracking('scheduleFrameCallback error control test', (WidgetTester tester) async {
late FlutterError error; late FlutterError error;
try { try {
tester.binding.scheduleFrameCallback((Duration _) { }, rescheduling: true); tester.binding.scheduleFrameCallback((Duration _) { }, rescheduling: true);
...@@ -429,7 +430,7 @@ void main() { ...@@ -429,7 +430,7 @@ void main() {
); );
}); });
testWidgets('defaultStackFilter elides framework Element mounting stacks', (WidgetTester tester) async { testWidgetsWithLeakTracking('defaultStackFilter elides framework Element mounting stacks', (WidgetTester tester) async {
final FlutterExceptionHandler? oldHandler = FlutterError.onError; final FlutterExceptionHandler? oldHandler = FlutterError.onError;
late FlutterErrorDetails errorDetails; late FlutterErrorDetails errorDetails;
FlutterError.onError = (FlutterErrorDetails details) { FlutterError.onError = (FlutterErrorDetails details) {
......
...@@ -9,6 +9,7 @@ import 'dart:ui' as ui show Image; ...@@ -9,6 +9,7 @@ import 'dart:ui' as ui show Image;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
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';
import '../image_data.dart'; import '../image_data.dart';
...@@ -36,7 +37,7 @@ Future<void> main() async { ...@@ -36,7 +37,7 @@ Future<void> main() async {
AutomatedTestWidgetsFlutterBinding(); AutomatedTestWidgetsFlutterBinding();
TestImageProvider.image = await decodeImageFromList(Uint8List.fromList(kTransparentImage)); TestImageProvider.image = await decodeImageFromList(Uint8List.fromList(kTransparentImage));
testWidgets('DecoratedBox handles loading images', (WidgetTester tester) async { testWidgetsWithLeakTracking('DecoratedBox handles loading images', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
final Completer<void> completer = Completer<void>(); final Completer<void> completer = Completer<void>();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -59,7 +60,7 @@ Future<void> main() async { ...@@ -59,7 +60,7 @@ Future<void> main() async {
expect(tester.binding.hasScheduledFrame, isFalse); expect(tester.binding.hasScheduledFrame, isFalse);
}); });
testWidgets('Moving a DecoratedBox', (WidgetTester tester) async { testWidgetsWithLeakTracking('Moving a DecoratedBox', (WidgetTester tester) async {
final Completer<void> completer = Completer<void>(); final Completer<void> completer = Completer<void>();
final Widget subtree = KeyedSubtree( final Widget subtree = KeyedSubtree(
key: GlobalKey(), key: GlobalKey(),
...@@ -88,7 +89,7 @@ Future<void> main() async { ...@@ -88,7 +89,7 @@ Future<void> main() async {
expect(tester.binding.hasScheduledFrame, isFalse); expect(tester.binding.hasScheduledFrame, isFalse);
}); });
testWidgets('Circles can have uniform borders', (WidgetTester tester) async { testWidgetsWithLeakTracking('Circles can have uniform borders', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Container( Container(
padding: const EdgeInsets.all(50.0), padding: const EdgeInsets.all(50.0),
...@@ -101,7 +102,7 @@ Future<void> main() async { ...@@ -101,7 +102,7 @@ Future<void> main() async {
); );
}); });
testWidgets('Bordered Container insets its child', (WidgetTester tester) async { testWidgetsWithLeakTracking('Bordered Container insets its child', (WidgetTester tester) async {
const Key key = Key('outerContainer'); const Key key = Key('outerContainer');
await tester.pumpWidget( await tester.pumpWidget(
Center( Center(
...@@ -118,7 +119,7 @@ Future<void> main() async { ...@@ -118,7 +119,7 @@ Future<void> main() async {
expect(tester.getSize(find.byKey(key)), equals(const Size(45.0, 45.0))); expect(tester.getSize(find.byKey(key)), equals(const Size(45.0, 45.0)));
}); });
testWidgets('BoxDecoration paints its border correctly', (WidgetTester tester) async { testWidgetsWithLeakTracking('BoxDecoration paints its border correctly', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/7672 // Regression test for https://github.com/flutter/flutter/issues/7672
const Key key = Key('Container with BoxDecoration'); const Key key = Key('Container with BoxDecoration');
...@@ -169,7 +170,7 @@ Future<void> main() async { ...@@ -169,7 +170,7 @@ Future<void> main() async {
); );
}); });
testWidgets('BoxDecoration paints its border correctly', (WidgetTester tester) async { testWidgetsWithLeakTracking('BoxDecoration paints its border correctly', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/12165 // Regression test for https://github.com/flutter/flutter/issues/12165
await tester.pumpWidget( await tester.pumpWidget(
Column( Column(
...@@ -254,7 +255,7 @@ Future<void> main() async { ...@@ -254,7 +255,7 @@ Future<void> main() async {
); );
}); });
testWidgets('Can hit test on BoxDecoration', (WidgetTester tester) async { testWidgetsWithLeakTracking('Can hit test on BoxDecoration', (WidgetTester tester) async {
late List<int> itemsTapped; late List<int> itemsTapped;
...@@ -291,7 +292,7 @@ Future<void> main() async { ...@@ -291,7 +292,7 @@ Future<void> main() async {
}); });
testWidgets('Can hit test on BoxDecoration circle', (WidgetTester tester) async { testWidgetsWithLeakTracking('Can hit test on BoxDecoration circle', (WidgetTester tester) async {
late List<int> itemsTapped; late List<int> itemsTapped;
...@@ -331,7 +332,7 @@ Future<void> main() async { ...@@ -331,7 +332,7 @@ Future<void> main() async {
}); });
testWidgets('Can hit test on BoxDecoration border', (WidgetTester tester) async { testWidgetsWithLeakTracking('Can hit test on BoxDecoration border', (WidgetTester tester) async {
late List<int> itemsTapped; late List<int> itemsTapped;
const Key key = Key('Container with BoxDecoration'); const Key key = Key('Container with BoxDecoration');
Widget buildFrame(Border border) { Widget buildFrame(Border border) {
...@@ -369,7 +370,7 @@ Future<void> main() async { ...@@ -369,7 +370,7 @@ Future<void> main() async {
expect(itemsTapped, <int>[1,1]); expect(itemsTapped, <int>[1,1]);
}); });
testWidgets('BoxDecoration not tap outside rounded angles - Top Left', (WidgetTester tester) async { testWidgetsWithLeakTracking('BoxDecoration not tap outside rounded angles - Top Left', (WidgetTester tester) async {
const double height = 50.0; const double height = 50.0;
const double width = 50.0; const double width = 50.0;
const double radius = 12.3; const double radius = 12.3;
...@@ -429,7 +430,7 @@ Future<void> main() async { ...@@ -429,7 +430,7 @@ Future<void> main() async {
}); });
testWidgets('BoxDecoration tap inside rounded angles - Top Left', (WidgetTester tester) async { testWidgetsWithLeakTracking('BoxDecoration tap inside rounded angles - Top Left', (WidgetTester tester) async {
const double height = 50.0; const double height = 50.0;
const double width = 50.0; const double width = 50.0;
const double radius = 12.3; const double radius = 12.3;
...@@ -477,7 +478,7 @@ Future<void> main() async { ...@@ -477,7 +478,7 @@ Future<void> main() async {
expect(itemsTapped, <int>[1,1,1,1]); expect(itemsTapped, <int>[1,1,1,1]);
}); });
testWidgets('BoxDecoration rounded angles other corner works', (WidgetTester tester) async { testWidgetsWithLeakTracking('BoxDecoration rounded angles other corner works', (WidgetTester tester) async {
const double height = 50.0; const double height = 50.0;
const double width = 50.0; const double width = 50.0;
const double radius = 20; const double radius = 20;
...@@ -545,7 +546,7 @@ Future<void> main() async { ...@@ -545,7 +546,7 @@ Future<void> main() async {
expect(itemsTapped, <int>[1,1,1,1,1], reason: 'top left tapped'); expect(itemsTapped, <int>[1,1,1,1,1], reason: 'top left tapped');
}); });
testWidgets("BoxDecoration doesn't crash with BorderRadiusDirectional", (WidgetTester tester) async { testWidgetsWithLeakTracking("BoxDecoration doesn't crash with BorderRadiusDirectional", (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/88039 // Regression test for https://github.com/flutter/flutter/issues/88039
await tester.pumpWidget( await tester.pumpWidget(
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
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';
void main() { void main() {
testWidgets('StatefulWidget BuildContext.mounted', (WidgetTester tester) async { testWidgetsWithLeakTracking('StatefulWidget BuildContext.mounted', (WidgetTester tester) async {
late BuildContext capturedContext; late BuildContext capturedContext;
await tester.pumpWidget(TestStatefulWidget( await tester.pumpWidget(TestStatefulWidget(
onBuild: (BuildContext context) { onBuild: (BuildContext context) {
...@@ -18,7 +19,7 @@ void main() { ...@@ -18,7 +19,7 @@ void main() {
expect(capturedContext.mounted, isFalse); expect(capturedContext.mounted, isFalse);
}); });
testWidgets('StatelessWidget BuildContext.mounted', (WidgetTester tester) async { testWidgetsWithLeakTracking('StatelessWidget BuildContext.mounted', (WidgetTester tester) async {
late BuildContext capturedContext; late BuildContext capturedContext;
await tester.pumpWidget(TestStatelessWidget( await tester.pumpWidget(TestStatelessWidget(
onBuild: (BuildContext context) { onBuild: (BuildContext context) {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
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';
import 'test_widgets.dart'; import 'test_widgets.dart';
...@@ -133,7 +134,7 @@ class Wrapper extends StatelessWidget { ...@@ -133,7 +134,7 @@ class Wrapper extends StatelessWidget {
} }
void main() { void main() {
testWidgets('Legal times for setState', (WidgetTester tester) async { testWidgetsWithLeakTracking('Legal times for setState', (WidgetTester tester) async {
final GlobalKey flipKey = GlobalKey(); final GlobalKey flipKey = GlobalKey();
expect(ProbeWidgetState.buildCount, equals(0)); expect(ProbeWidgetState.buildCount, equals(0));
await tester.pumpWidget(const ProbeWidget(key: Key('a'))); await tester.pumpWidget(const ProbeWidget(key: Key('a')));
...@@ -171,7 +172,7 @@ void main() { ...@@ -171,7 +172,7 @@ void main() {
expect(tester.takeException(), isNotNull); expect(tester.takeException(), isNotNull);
}); });
testWidgets('Dirty element list sort order', (WidgetTester tester) async { testWidgetsWithLeakTracking('Dirty element list sort order', (WidgetTester tester) async {
final GlobalKey key1 = GlobalKey(debugLabel: 'key1'); final GlobalKey key1 = GlobalKey(debugLabel: 'key1');
final GlobalKey key2 = GlobalKey(debugLabel: 'key2'); final GlobalKey key2 = GlobalKey(debugLabel: 'key2');
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
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';
void main() { void main() {
testWidgets('Can be placed in an infinite box', (WidgetTester tester) async { testWidgetsWithLeakTracking('Can be placed in an infinite box', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
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';
// Assuming that the test container is 800x600. The height of the // Assuming that the test container is 800x600. The height of the
// viewport's contents is 650.0, the top and bottom text children // viewport's contents is 650.0, the top and bottom text children
...@@ -32,7 +33,7 @@ Widget buildFrame(ScrollPhysics physics, { ScrollController? scrollController }) ...@@ -32,7 +33,7 @@ Widget buildFrame(ScrollPhysics physics, { ScrollController? scrollController })
} }
void main() { void main() {
testWidgets('ClampingScrollPhysics', (WidgetTester tester) async { testWidgetsWithLeakTracking('ClampingScrollPhysics', (WidgetTester tester) async {
// Scroll the target text widget by offset and then return its origin // Scroll the target text widget by offset and then return its origin
// in global coordinates. // in global coordinates.
...@@ -59,7 +60,7 @@ void main() { ...@@ -59,7 +60,7 @@ void main() {
expect(origin.dy, equals(500.0)); expect(origin.dy, equals(500.0));
}); });
testWidgets('ClampingScrollPhysics affects ScrollPosition', (WidgetTester tester) async { testWidgetsWithLeakTracking('ClampingScrollPhysics affects ScrollPosition', (WidgetTester tester) async {
// BouncingScrollPhysics // BouncingScrollPhysics
...@@ -91,9 +92,10 @@ void main() { ...@@ -91,9 +92,10 @@ void main() {
expect(scrollable.position.pixels, equals(50.0)); expect(scrollable.position.pixels, equals(50.0));
}); });
testWidgets('ClampingScrollPhysics handles out of bounds ScrollPosition', (WidgetTester tester) async { testWidgetsWithLeakTracking('ClampingScrollPhysics handles out of bounds ScrollPosition', (WidgetTester tester) async {
Future<void> testOutOfBounds(ScrollPhysics physics, double initialOffset, double expectedOffset) async { Future<void> testOutOfBounds(ScrollPhysics physics, double initialOffset, double expectedOffset) async {
final ScrollController scrollController = ScrollController(initialScrollOffset: initialOffset); final ScrollController scrollController = ScrollController(initialScrollOffset: initialOffset);
addTearDown(scrollController.dispose);
await tester.pumpWidget(buildFrame(physics, scrollController: scrollController)); await tester.pumpWidget(buildFrame(physics, scrollController: scrollController));
final ScrollableState scrollable = tester.state(find.byType(Scrollable)); final ScrollableState scrollable = tester.state(find.byType(Scrollable));
......
...@@ -11,6 +11,7 @@ library; ...@@ -11,6 +11,7 @@ library;
import 'package:flutter/material.dart'; import 'package:flutter/material.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';
import 'test_border.dart' show TestBorder; import 'test_border.dart' show TestBorder;
...@@ -58,7 +59,7 @@ class NotifyClipper<T> extends CustomClipper<T> { ...@@ -58,7 +59,7 @@ class NotifyClipper<T> extends CustomClipper<T> {
} }
void main() { void main() {
testWidgets('ClipRect with a FittedBox child sized to zero works with semantics', (WidgetTester tester) async { testWidgetsWithLeakTracking('ClipRect with a FittedBox child sized to zero works with semantics', (WidgetTester tester) async {
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: ClipRect( child: ClipRect(
...@@ -77,7 +78,7 @@ void main() { ...@@ -77,7 +78,7 @@ void main() {
expect(find.byType(FittedBox), findsOneWidget); expect(find.byType(FittedBox), findsOneWidget);
}); });
testWidgets('ClipRect updates clipBehavior in updateRenderObject', (WidgetTester tester) async { testWidgetsWithLeakTracking('ClipRect updates clipBehavior in updateRenderObject', (WidgetTester tester) async {
await tester.pumpWidget(const ClipRect()); await tester.pumpWidget(const ClipRect());
final RenderClipRect renderClip = tester.allRenderObjects.whereType<RenderClipRect>().first; final RenderClipRect renderClip = tester.allRenderObjects.whereType<RenderClipRect>().first;
...@@ -99,7 +100,7 @@ void main() { ...@@ -99,7 +100,7 @@ void main() {
expect(clipRRect.borderRadius, equals(BorderRadius.zero)); expect(clipRRect.borderRadius, equals(BorderRadius.zero));
}); });
testWidgets('ClipRRect updates clipBehavior in updateRenderObject', (WidgetTester tester) async { testWidgetsWithLeakTracking('ClipRRect updates clipBehavior in updateRenderObject', (WidgetTester tester) async {
await tester.pumpWidget(const ClipRRect()); await tester.pumpWidget(const ClipRRect());
final RenderClipRRect renderClip = tester.allRenderObjects.whereType<RenderClipRRect>().first; final RenderClipRRect renderClip = tester.allRenderObjects.whereType<RenderClipRRect>().first;
...@@ -115,7 +116,7 @@ void main() { ...@@ -115,7 +116,7 @@ void main() {
expect(renderClip.clipBehavior, equals(Clip.none)); expect(renderClip.clipBehavior, equals(Clip.none));
}); });
testWidgets('ClipOval updates clipBehavior in updateRenderObject', (WidgetTester tester) async { testWidgetsWithLeakTracking('ClipOval updates clipBehavior in updateRenderObject', (WidgetTester tester) async {
await tester.pumpWidget(const ClipOval()); await tester.pumpWidget(const ClipOval());
final RenderClipOval renderClip = tester.allRenderObjects.whereType<RenderClipOval>().first; final RenderClipOval renderClip = tester.allRenderObjects.whereType<RenderClipOval>().first;
...@@ -131,7 +132,7 @@ void main() { ...@@ -131,7 +132,7 @@ void main() {
expect(renderClip.clipBehavior, equals(Clip.none)); expect(renderClip.clipBehavior, equals(Clip.none));
}); });
testWidgets('ClipPath updates clipBehavior in updateRenderObject', (WidgetTester tester) async { testWidgetsWithLeakTracking('ClipPath updates clipBehavior in updateRenderObject', (WidgetTester tester) async {
await tester.pumpWidget(const ClipPath()); await tester.pumpWidget(const ClipPath());
final RenderClipPath renderClip = tester.allRenderObjects.whereType<RenderClipPath>().first; final RenderClipPath renderClip = tester.allRenderObjects.whereType<RenderClipPath>().first;
...@@ -147,7 +148,7 @@ void main() { ...@@ -147,7 +148,7 @@ void main() {
expect(renderClip.clipBehavior, equals(Clip.none)); expect(renderClip.clipBehavior, equals(Clip.none));
}); });
testWidgets('ClipPath', (WidgetTester tester) async { testWidgetsWithLeakTracking('ClipPath', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
ClipPath( ClipPath(
clipper: PathClipper(), clipper: PathClipper(),
...@@ -168,7 +169,7 @@ void main() { ...@@ -168,7 +169,7 @@ void main() {
log.clear(); log.clear();
}); });
testWidgets('ClipOval', (WidgetTester tester) async { testWidgetsWithLeakTracking('ClipOval', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
ClipOval( ClipOval(
child: GestureDetector( child: GestureDetector(
...@@ -188,7 +189,7 @@ void main() { ...@@ -188,7 +189,7 @@ void main() {
log.clear(); log.clear();
}); });
testWidgets('Transparent ClipOval hit test', (WidgetTester tester) async { testWidgetsWithLeakTracking('Transparent ClipOval hit test', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Opacity( Opacity(
opacity: 0.0, opacity: 0.0,
...@@ -211,7 +212,7 @@ void main() { ...@@ -211,7 +212,7 @@ void main() {
log.clear(); log.clear();
}); });
testWidgets('ClipRect', (WidgetTester tester) async { testWidgetsWithLeakTracking('ClipRect', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Align( Align(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
...@@ -334,7 +335,7 @@ void main() { ...@@ -334,7 +335,7 @@ void main() {
log.clear(); log.clear();
}); });
testWidgets('debugPaintSizeEnabled', (WidgetTester tester) async { testWidgetsWithLeakTracking('debugPaintSizeEnabled', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const ClipRect( const ClipRect(
child: Placeholder(), child: Placeholder(),
...@@ -356,7 +357,7 @@ void main() { ...@@ -356,7 +357,7 @@ void main() {
debugPaintSizeEnabled = false; debugPaintSizeEnabled = false;
}); });
testWidgets('ClipRect painting', (WidgetTester tester) async { testWidgetsWithLeakTracking('ClipRect painting', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Center( Center(
child: RepaintBoundary( child: RepaintBoundary(
...@@ -399,7 +400,7 @@ void main() { ...@@ -399,7 +400,7 @@ void main() {
); );
}); });
testWidgets('ClipRect save, overlay, and antialiasing', (WidgetTester tester) async { testWidgetsWithLeakTracking('ClipRect save, overlay, and antialiasing', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
RepaintBoundary( RepaintBoundary(
child: Stack( child: Stack(
...@@ -438,7 +439,7 @@ void main() { ...@@ -438,7 +439,7 @@ void main() {
); );
}); });
testWidgets('ClipRRect painting', (WidgetTester tester) async { testWidgetsWithLeakTracking('ClipRRect painting', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Center( Center(
child: RepaintBoundary( child: RepaintBoundary(
...@@ -487,7 +488,7 @@ void main() { ...@@ -487,7 +488,7 @@ void main() {
); );
}); });
testWidgets('ClipOval painting', (WidgetTester tester) async { testWidgetsWithLeakTracking('ClipOval painting', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Center( Center(
child: RepaintBoundary( child: RepaintBoundary(
...@@ -530,7 +531,7 @@ void main() { ...@@ -530,7 +531,7 @@ void main() {
); );
}); });
testWidgets('ClipPath painting', (WidgetTester tester) async { testWidgetsWithLeakTracking('ClipPath painting', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Center( Center(
child: RepaintBoundary( child: RepaintBoundary(
...@@ -615,7 +616,7 @@ void main() { ...@@ -615,7 +616,7 @@ void main() {
); );
} }
testWidgets('PhysicalModel painting with Clip.antiAlias', (WidgetTester tester) async { testWidgetsWithLeakTracking('PhysicalModel painting with Clip.antiAlias', (WidgetTester tester) async {
await tester.pumpWidget(genPhysicalModel(Clip.antiAlias)); await tester.pumpWidget(genPhysicalModel(Clip.antiAlias));
await expectLater( await expectLater(
find.byType(RepaintBoundary).first, find.byType(RepaintBoundary).first,
...@@ -623,7 +624,7 @@ void main() { ...@@ -623,7 +624,7 @@ void main() {
); );
}); });
testWidgets('PhysicalModel painting with Clip.hardEdge', (WidgetTester tester) async { testWidgetsWithLeakTracking('PhysicalModel painting with Clip.hardEdge', (WidgetTester tester) async {
await tester.pumpWidget(genPhysicalModel(Clip.hardEdge)); await tester.pumpWidget(genPhysicalModel(Clip.hardEdge));
await expectLater( await expectLater(
find.byType(RepaintBoundary).first, find.byType(RepaintBoundary).first,
...@@ -633,7 +634,7 @@ void main() { ...@@ -633,7 +634,7 @@ void main() {
// There will be bleeding edges on the rect edges, but there shouldn't be any bleeding edges on the // There will be bleeding edges on the rect edges, but there shouldn't be any bleeding edges on the
// round corners. // round corners.
testWidgets('PhysicalModel painting with Clip.antiAliasWithSaveLayer', (WidgetTester tester) async { testWidgetsWithLeakTracking('PhysicalModel painting with Clip.antiAliasWithSaveLayer', (WidgetTester tester) async {
await tester.pumpWidget(genPhysicalModel(Clip.antiAliasWithSaveLayer)); await tester.pumpWidget(genPhysicalModel(Clip.antiAliasWithSaveLayer));
await expectLater( await expectLater(
find.byType(RepaintBoundary).first, find.byType(RepaintBoundary).first,
...@@ -641,7 +642,7 @@ void main() { ...@@ -641,7 +642,7 @@ void main() {
); );
}); });
testWidgets('Default PhysicalModel painting', (WidgetTester tester) async { testWidgetsWithLeakTracking('Default PhysicalModel painting', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Center( Center(
child: RepaintBoundary( child: RepaintBoundary(
...@@ -724,7 +725,7 @@ void main() { ...@@ -724,7 +725,7 @@ void main() {
); );
} }
testWidgets('PhysicalShape painting with Clip.antiAlias', (WidgetTester tester) async { testWidgetsWithLeakTracking('PhysicalShape painting with Clip.antiAlias', (WidgetTester tester) async {
await tester.pumpWidget(genPhysicalShape(Clip.antiAlias)); await tester.pumpWidget(genPhysicalShape(Clip.antiAlias));
await expectLater( await expectLater(
find.byType(RepaintBoundary).first, find.byType(RepaintBoundary).first,
...@@ -732,7 +733,7 @@ void main() { ...@@ -732,7 +733,7 @@ void main() {
); );
}); });
testWidgets('PhysicalShape painting with Clip.hardEdge', (WidgetTester tester) async { testWidgetsWithLeakTracking('PhysicalShape painting with Clip.hardEdge', (WidgetTester tester) async {
await tester.pumpWidget(genPhysicalShape(Clip.hardEdge)); await tester.pumpWidget(genPhysicalShape(Clip.hardEdge));
await expectLater( await expectLater(
find.byType(RepaintBoundary).first, find.byType(RepaintBoundary).first,
...@@ -740,7 +741,7 @@ void main() { ...@@ -740,7 +741,7 @@ void main() {
); );
}); });
testWidgets('PhysicalShape painting with Clip.antiAliasWithSaveLayer', (WidgetTester tester) async { testWidgetsWithLeakTracking('PhysicalShape painting with Clip.antiAliasWithSaveLayer', (WidgetTester tester) async {
await tester.pumpWidget(genPhysicalShape(Clip.antiAliasWithSaveLayer)); await tester.pumpWidget(genPhysicalShape(Clip.antiAliasWithSaveLayer));
await expectLater( await expectLater(
find.byType(RepaintBoundary).first, find.byType(RepaintBoundary).first,
...@@ -748,7 +749,7 @@ void main() { ...@@ -748,7 +749,7 @@ void main() {
); );
}); });
testWidgets('PhysicalShape painting', (WidgetTester tester) async { testWidgetsWithLeakTracking('PhysicalShape painting', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Center( Center(
child: RepaintBoundary( child: RepaintBoundary(
...@@ -794,7 +795,7 @@ void main() { ...@@ -794,7 +795,7 @@ void main() {
); );
}); });
testWidgets('ClipPath.shape', (WidgetTester tester) async { testWidgetsWithLeakTracking('ClipPath.shape', (WidgetTester tester) async {
final List<String> logs = <String>[]; final List<String> logs = <String>[];
final ShapeBorder shape = TestBorder((String message) { logs.add(message); }); final ShapeBorder shape = TestBorder((String message) { logs.add(message); });
Widget buildClipPath() { Widget buildClipPath() {
...@@ -851,8 +852,9 @@ void main() { ...@@ -851,8 +852,9 @@ void main() {
]); ]);
}); });
testWidgets('CustomClipper reclips when notified', (WidgetTester tester) async { testWidgetsWithLeakTracking('CustomClipper reclips when notified', (WidgetTester tester) async {
final ValueNotifier<Rect> clip = ValueNotifier<Rect>(const Rect.fromLTWH(50.0, 50.0, 100.0, 100.0)); final ValueNotifier<Rect> clip = ValueNotifier<Rect>(const Rect.fromLTWH(50.0, 50.0, 100.0, 100.0));
addTearDown(clip.dispose);
await tester.pumpWidget( await tester.pumpWidget(
ClipRect( ClipRect(
...@@ -884,7 +886,7 @@ void main() { ...@@ -884,7 +886,7 @@ void main() {
); );
}); });
testWidgets('ClipRRect supports BorderRadiusDirectional', (WidgetTester tester) async { testWidgetsWithLeakTracking('ClipRRect supports BorderRadiusDirectional', (WidgetTester tester) async {
const Radius startRadius = Radius.circular(15.0); const Radius startRadius = Radius.circular(15.0);
const Radius endRadius = Radius.circular(30.0); const Radius endRadius = Radius.circular(30.0);
...@@ -911,7 +913,7 @@ void main() { ...@@ -911,7 +913,7 @@ void main() {
} }
}); });
testWidgets('ClipRRect is direction-aware', (WidgetTester tester) async { testWidgetsWithLeakTracking('ClipRRect is direction-aware', (WidgetTester tester) async {
const Radius startRadius = Radius.circular(15.0); const Radius startRadius = Radius.circular(15.0);
const Radius endRadius = Radius.circular(30.0); const Radius endRadius = Radius.circular(30.0);
TextDirection textDirection = TextDirection.ltr; TextDirection textDirection = TextDirection.ltr;
......
...@@ -11,9 +11,10 @@ library; ...@@ -11,9 +11,10 @@ library;
import 'package:flutter/material.dart'; import 'package:flutter/material.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() {
testWidgets('Color filter - red', (WidgetTester tester) async { testWidgetsWithLeakTracking('Color filter - red', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const RepaintBoundary( const RepaintBoundary(
child: ColorFiltered( child: ColorFiltered(
...@@ -28,7 +29,7 @@ void main() { ...@@ -28,7 +29,7 @@ void main() {
); );
}); });
testWidgets('Color filter - sepia', (WidgetTester tester) async { testWidgetsWithLeakTracking('Color filter - sepia', (WidgetTester tester) async {
const ColorFilter sepia = ColorFilter.matrix(<double>[ const ColorFilter sepia = ColorFilter.matrix(<double>[
0.39, 0.769, 0.189, 0, 0, // 0.39, 0.769, 0.189, 0, 0, //
0.349, 0.686, 0.168, 0, 0, // 0.349, 0.686, 0.168, 0, 0, //
...@@ -65,7 +66,7 @@ void main() { ...@@ -65,7 +66,7 @@ void main() {
); );
}); });
testWidgets('Color filter - reuses its layer', (WidgetTester tester) async { testWidgetsWithLeakTracking('Color filter - reuses its layer', (WidgetTester tester) async {
Future<void> pumpWithColor(Color color) async { Future<void> pumpWithColor(Color color) async {
await tester.pumpWidget( await tester.pumpWidget(
RepaintBoundary( RepaintBoundary(
......
...@@ -5,11 +5,12 @@ ...@@ -5,11 +5,12 @@
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.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';
void main() { void main() {
// DOWN (default) // DOWN (default)
testWidgets('Column with one flexible child', (WidgetTester tester) async { testWidgetsWithLeakTracking('Column with one flexible child', (WidgetTester tester) async {
const Key columnKey = Key('column'); const Key columnKey = Key('column');
const Key child0Key = Key('child0'); const Key child0Key = Key('child0');
const Key child1Key = Key('child1'); const Key child1Key = Key('child1');
...@@ -55,7 +56,7 @@ void main() { ...@@ -55,7 +56,7 @@ void main() {
expect(boxParentData.offset.dy, equals(500.0)); expect(boxParentData.offset.dy, equals(500.0));
}); });
testWidgets('Column with default main axis parameters', (WidgetTester tester) async { testWidgetsWithLeakTracking('Column with default main axis parameters', (WidgetTester tester) async {
const Key columnKey = Key('column'); const Key columnKey = Key('column');
const Key child0Key = Key('child0'); const Key child0Key = Key('child0');
const Key child1Key = Key('child1'); const Key child1Key = Key('child1');
...@@ -101,7 +102,7 @@ void main() { ...@@ -101,7 +102,7 @@ void main() {
expect(boxParentData.offset.dy, equals(200.0)); expect(boxParentData.offset.dy, equals(200.0));
}); });
testWidgets('Column with MainAxisAlignment.center', (WidgetTester tester) async { testWidgetsWithLeakTracking('Column with MainAxisAlignment.center', (WidgetTester tester) async {
const Key columnKey = Key('column'); const Key columnKey = Key('column');
const Key child0Key = Key('child0'); const Key child0Key = Key('child0');
const Key child1Key = Key('child1'); const Key child1Key = Key('child1');
...@@ -139,7 +140,7 @@ void main() { ...@@ -139,7 +140,7 @@ void main() {
expect(boxParentData.offset.dy, equals(300.0)); expect(boxParentData.offset.dy, equals(300.0));
}); });
testWidgets('Column with MainAxisAlignment.end', (WidgetTester tester) async { testWidgetsWithLeakTracking('Column with MainAxisAlignment.end', (WidgetTester tester) async {
const Key columnKey = Key('column'); const Key columnKey = Key('column');
const Key child0Key = Key('child0'); const Key child0Key = Key('child0');
const Key child1Key = Key('child1'); const Key child1Key = Key('child1');
...@@ -185,7 +186,7 @@ void main() { ...@@ -185,7 +186,7 @@ void main() {
expect(boxParentData.offset.dy, equals(500.0)); expect(boxParentData.offset.dy, equals(500.0));
}); });
testWidgets('Column with MainAxisAlignment.spaceBetween', (WidgetTester tester) async { testWidgetsWithLeakTracking('Column with MainAxisAlignment.spaceBetween', (WidgetTester tester) async {
const Key columnKey = Key('column'); const Key columnKey = Key('column');
const Key child0Key = Key('child0'); const Key child0Key = Key('child0');
const Key child1Key = Key('child1'); const Key child1Key = Key('child1');
...@@ -231,7 +232,7 @@ void main() { ...@@ -231,7 +232,7 @@ void main() {
expect(boxParentData.offset.dy, equals(500.0)); expect(boxParentData.offset.dy, equals(500.0));
}); });
testWidgets('Column with MainAxisAlignment.spaceAround', (WidgetTester tester) async { testWidgetsWithLeakTracking('Column with MainAxisAlignment.spaceAround', (WidgetTester tester) async {
const Key columnKey = Key('column'); const Key columnKey = Key('column');
const Key child0Key = Key('child0'); const Key child0Key = Key('child0');
const Key child1Key = Key('child1'); const Key child1Key = Key('child1');
...@@ -285,7 +286,7 @@ void main() { ...@@ -285,7 +286,7 @@ void main() {
expect(boxParentData.offset.dy, equals(475.0)); expect(boxParentData.offset.dy, equals(475.0));
}); });
testWidgets('Column with MainAxisAlignment.spaceEvenly', (WidgetTester tester) async { testWidgetsWithLeakTracking('Column with MainAxisAlignment.spaceEvenly', (WidgetTester tester) async {
const Key columnKey = Key('column'); const Key columnKey = Key('column');
const Key child0Key = Key('child0'); const Key child0Key = Key('child0');
const Key child1Key = Key('child1'); const Key child1Key = Key('child1');
...@@ -331,7 +332,7 @@ void main() { ...@@ -331,7 +332,7 @@ void main() {
expect(boxParentData.offset.dy, equals(445.0)); expect(boxParentData.offset.dy, equals(445.0));
}); });
testWidgets('Column and MainAxisSize.min', (WidgetTester tester) async { testWidgetsWithLeakTracking('Column and MainAxisSize.min', (WidgetTester tester) async {
const Key flexKey = Key('flexKey'); const Key flexKey = Key('flexKey');
// Default is MainAxisSize.max so the Column should be as high as the test: 600. // Default is MainAxisSize.max so the Column should be as high as the test: 600.
...@@ -364,7 +365,7 @@ void main() { ...@@ -364,7 +365,7 @@ void main() {
expect(renderBox.size.height, equals(250.0)); expect(renderBox.size.height, equals(250.0));
}); });
testWidgets('Column MainAxisSize.min layout at zero size', (WidgetTester tester) async { testWidgetsWithLeakTracking('Column MainAxisSize.min layout at zero size', (WidgetTester tester) async {
const Key childKey = Key('childKey'); const Key childKey = Key('childKey');
await tester.pumpWidget(const Center( await tester.pumpWidget(const Center(
...@@ -390,7 +391,7 @@ void main() { ...@@ -390,7 +391,7 @@ void main() {
// UP // UP
testWidgets('Column with one flexible child', (WidgetTester tester) async { testWidgetsWithLeakTracking('Column with one flexible child', (WidgetTester tester) async {
const Key columnKey = Key('column'); const Key columnKey = Key('column');
const Key child0Key = Key('child0'); const Key child0Key = Key('child0');
const Key child1Key = Key('child1'); const Key child1Key = Key('child1');
...@@ -437,7 +438,7 @@ void main() { ...@@ -437,7 +438,7 @@ void main() {
expect(boxParentData.offset.dy, equals(0.0)); expect(boxParentData.offset.dy, equals(0.0));
}); });
testWidgets('Column with default main axis parameters', (WidgetTester tester) async { testWidgetsWithLeakTracking('Column with default main axis parameters', (WidgetTester tester) async {
const Key columnKey = Key('column'); const Key columnKey = Key('column');
const Key child0Key = Key('child0'); const Key child0Key = Key('child0');
const Key child1Key = Key('child1'); const Key child1Key = Key('child1');
...@@ -484,7 +485,7 @@ void main() { ...@@ -484,7 +485,7 @@ void main() {
expect(boxParentData.offset.dy, equals(300.0)); expect(boxParentData.offset.dy, equals(300.0));
}); });
testWidgets('Column with MainAxisAlignment.center', (WidgetTester tester) async { testWidgetsWithLeakTracking('Column with MainAxisAlignment.center', (WidgetTester tester) async {
const Key columnKey = Key('column'); const Key columnKey = Key('column');
const Key child0Key = Key('child0'); const Key child0Key = Key('child0');
const Key child1Key = Key('child1'); const Key child1Key = Key('child1');
...@@ -523,7 +524,7 @@ void main() { ...@@ -523,7 +524,7 @@ void main() {
expect(boxParentData.offset.dy, equals(200.0)); expect(boxParentData.offset.dy, equals(200.0));
}); });
testWidgets('Column with MainAxisAlignment.end', (WidgetTester tester) async { testWidgetsWithLeakTracking('Column with MainAxisAlignment.end', (WidgetTester tester) async {
const Key columnKey = Key('column'); const Key columnKey = Key('column');
const Key child0Key = Key('child0'); const Key child0Key = Key('child0');
const Key child1Key = Key('child1'); const Key child1Key = Key('child1');
...@@ -570,7 +571,7 @@ void main() { ...@@ -570,7 +571,7 @@ void main() {
expect(boxParentData.offset.dy, equals(0.0)); expect(boxParentData.offset.dy, equals(0.0));
}); });
testWidgets('Column with MainAxisAlignment.spaceBetween', (WidgetTester tester) async { testWidgetsWithLeakTracking('Column with MainAxisAlignment.spaceBetween', (WidgetTester tester) async {
const Key columnKey = Key('column'); const Key columnKey = Key('column');
const Key child0Key = Key('child0'); const Key child0Key = Key('child0');
const Key child1Key = Key('child1'); const Key child1Key = Key('child1');
...@@ -617,7 +618,7 @@ void main() { ...@@ -617,7 +618,7 @@ void main() {
expect(boxParentData.offset.dy, equals(0.0)); expect(boxParentData.offset.dy, equals(0.0));
}); });
testWidgets('Column with MainAxisAlignment.spaceAround', (WidgetTester tester) async { testWidgetsWithLeakTracking('Column with MainAxisAlignment.spaceAround', (WidgetTester tester) async {
const Key columnKey = Key('column'); const Key columnKey = Key('column');
const Key child0Key = Key('child0'); const Key child0Key = Key('child0');
const Key child1Key = Key('child1'); const Key child1Key = Key('child1');
...@@ -672,7 +673,7 @@ void main() { ...@@ -672,7 +673,7 @@ void main() {
expect(boxParentData.offset.dy, equals(500.0 - 475.0)); expect(boxParentData.offset.dy, equals(500.0 - 475.0));
}); });
testWidgets('Column with MainAxisAlignment.spaceEvenly', (WidgetTester tester) async { testWidgetsWithLeakTracking('Column with MainAxisAlignment.spaceEvenly', (WidgetTester tester) async {
const Key columnKey = Key('column'); const Key columnKey = Key('column');
const Key child0Key = Key('child0'); const Key child0Key = Key('child0');
const Key child1Key = Key('child1'); const Key child1Key = Key('child1');
...@@ -719,7 +720,7 @@ void main() { ...@@ -719,7 +720,7 @@ void main() {
expect(boxParentData.offset.dy, equals(600.0 - 445.0 - 20.0)); expect(boxParentData.offset.dy, equals(600.0 - 445.0 - 20.0));
}); });
testWidgets('Column and MainAxisSize.min', (WidgetTester tester) async { testWidgetsWithLeakTracking('Column and MainAxisSize.min', (WidgetTester tester) async {
const Key flexKey = Key('flexKey'); const Key flexKey = Key('flexKey');
// Default is MainAxisSize.max so the Column should be as high as the test: 600. // Default is MainAxisSize.max so the Column should be as high as the test: 600.
...@@ -754,7 +755,7 @@ void main() { ...@@ -754,7 +755,7 @@ void main() {
expect(renderBox.size.height, equals(250.0)); expect(renderBox.size.height, equals(250.0));
}); });
testWidgets('Column MainAxisSize.min layout at zero size', (WidgetTester tester) async { testWidgetsWithLeakTracking('Column MainAxisSize.min layout at zero size', (WidgetTester tester) async {
const Key childKey = Key('childKey'); const Key childKey = Key('childKey');
await tester.pumpWidget(const Center( await tester.pumpWidget(const Center(
......
...@@ -7,11 +7,12 @@ import 'dart:ui' as ui; ...@@ -7,11 +7,12 @@ import 'dart:ui' as ui;
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.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';
void main() { void main() {
final LayerLink link = LayerLink(); final LayerLink link = LayerLink();
testWidgets('Change link during layout', (WidgetTester tester) async { testWidgetsWithLeakTracking('Change link during layout', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
Widget build({ LayerLink? linkToUse }) { Widget build({ LayerLink? linkToUse }) {
return Directionality( return Directionality(
...@@ -56,7 +57,7 @@ void main() { ...@@ -56,7 +57,7 @@ void main() {
expect(box.localToGlobal(Offset.zero), const Offset(118.0, 451.0)); expect(box.localToGlobal(Offset.zero), const Offset(118.0, 451.0));
}); });
testWidgets('LeaderLayer should not cause error', (WidgetTester tester) async { testWidgetsWithLeakTracking('LeaderLayer should not cause error', (WidgetTester tester) async {
final LayerLink link = LayerLink(); final LayerLink link = LayerLink();
Widget buildWidget({ Widget buildWidget({
...@@ -116,19 +117,19 @@ void main() { ...@@ -116,19 +117,19 @@ void main() {
); );
} }
testWidgets('topLeft', (WidgetTester tester) async { testWidgetsWithLeakTracking('topLeft', (WidgetTester tester) async {
await tester.pumpWidget(build(targetAlignment: Alignment.topLeft, followerAlignment: Alignment.topLeft)); await tester.pumpWidget(build(targetAlignment: Alignment.topLeft, followerAlignment: Alignment.topLeft));
final RenderBox box = key.currentContext!.findRenderObject()! as RenderBox; final RenderBox box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(Offset.zero), const Offset(123.0, 456.0)); expect(box.localToGlobal(Offset.zero), const Offset(123.0, 456.0));
}); });
testWidgets('center', (WidgetTester tester) async { testWidgetsWithLeakTracking('center', (WidgetTester tester) async {
await tester.pumpWidget(build(targetAlignment: Alignment.center, followerAlignment: Alignment.center)); await tester.pumpWidget(build(targetAlignment: Alignment.center, followerAlignment: Alignment.center));
final RenderBox box = key.currentContext!.findRenderObject()! as RenderBox; final RenderBox box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(Offset.zero), const Offset(118.0, 451.0)); expect(box.localToGlobal(Offset.zero), const Offset(118.0, 451.0));
}); });
testWidgets('bottomRight - topRight', (WidgetTester tester) async { testWidgetsWithLeakTracking('bottomRight - topRight', (WidgetTester tester) async {
await tester.pumpWidget(build(targetAlignment: Alignment.bottomRight, followerAlignment: Alignment.topRight)); await tester.pumpWidget(build(targetAlignment: Alignment.bottomRight, followerAlignment: Alignment.topRight));
final RenderBox box = key.currentContext!.findRenderObject()! as RenderBox; final RenderBox box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(Offset.zero), const Offset(113.0, 466.0)); expect(box.localToGlobal(Offset.zero), const Offset(113.0, 466.0));
...@@ -172,7 +173,7 @@ void main() { ...@@ -172,7 +173,7 @@ void main() {
), ),
); );
} }
testWidgets('topLeft', (WidgetTester tester) async { testWidgetsWithLeakTracking('topLeft', (WidgetTester tester) async {
await tester.pumpWidget(build(targetAlignment: Alignment.topLeft, followerAlignment: Alignment.topLeft)); await tester.pumpWidget(build(targetAlignment: Alignment.topLeft, followerAlignment: Alignment.topLeft));
final RenderBox box1 = key1.currentContext!.findRenderObject()! as RenderBox; final RenderBox box1 = key1.currentContext!.findRenderObject()! as RenderBox;
final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox; final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox;
...@@ -181,7 +182,7 @@ void main() { ...@@ -181,7 +182,7 @@ void main() {
expect(position1, offsetMoreOrLessEquals(position2)); expect(position1, offsetMoreOrLessEquals(position2));
}); });
testWidgets('center', (WidgetTester tester) async { testWidgetsWithLeakTracking('center', (WidgetTester tester) async {
await tester.pumpWidget(build(targetAlignment: Alignment.center, followerAlignment: Alignment.center)); await tester.pumpWidget(build(targetAlignment: Alignment.center, followerAlignment: Alignment.center));
final RenderBox box1 = key1.currentContext!.findRenderObject()! as RenderBox; final RenderBox box1 = key1.currentContext!.findRenderObject()! as RenderBox;
final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox; final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox;
...@@ -190,7 +191,7 @@ void main() { ...@@ -190,7 +191,7 @@ void main() {
expect(position1, offsetMoreOrLessEquals(position2)); expect(position1, offsetMoreOrLessEquals(position2));
}); });
testWidgets('bottomRight - topRight', (WidgetTester tester) async { testWidgetsWithLeakTracking('bottomRight - topRight', (WidgetTester tester) async {
await tester.pumpWidget(build(targetAlignment: Alignment.bottomRight, followerAlignment: Alignment.topRight)); await tester.pumpWidget(build(targetAlignment: Alignment.bottomRight, followerAlignment: Alignment.topRight));
final RenderBox box1 = key1.currentContext!.findRenderObject()! as RenderBox; final RenderBox box1 = key1.currentContext!.findRenderObject()! as RenderBox;
final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox; final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox;
...@@ -249,7 +250,7 @@ void main() { ...@@ -249,7 +250,7 @@ void main() {
), ),
); );
} }
testWidgets('topLeft', (WidgetTester tester) async { testWidgetsWithLeakTracking('topLeft', (WidgetTester tester) async {
await tester.pumpWidget(build(targetAlignment: Alignment.topLeft, followerAlignment: Alignment.topLeft)); await tester.pumpWidget(build(targetAlignment: Alignment.topLeft, followerAlignment: Alignment.topLeft));
final RenderBox box1 = key1.currentContext!.findRenderObject()! as RenderBox; final RenderBox box1 = key1.currentContext!.findRenderObject()! as RenderBox;
final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox; final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox;
...@@ -258,7 +259,7 @@ void main() { ...@@ -258,7 +259,7 @@ void main() {
expect(position1, offsetMoreOrLessEquals(position2)); expect(position1, offsetMoreOrLessEquals(position2));
}); });
testWidgets('center', (WidgetTester tester) async { testWidgetsWithLeakTracking('center', (WidgetTester tester) async {
await tester.pumpWidget(build(targetAlignment: Alignment.center, followerAlignment: Alignment.center)); await tester.pumpWidget(build(targetAlignment: Alignment.center, followerAlignment: Alignment.center));
final RenderBox box1 = key1.currentContext!.findRenderObject()! as RenderBox; final RenderBox box1 = key1.currentContext!.findRenderObject()! as RenderBox;
final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox; final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox;
...@@ -267,7 +268,7 @@ void main() { ...@@ -267,7 +268,7 @@ void main() {
expect(position1, offsetMoreOrLessEquals(position2)); expect(position1, offsetMoreOrLessEquals(position2));
}); });
testWidgets('bottomRight - topRight', (WidgetTester tester) async { testWidgetsWithLeakTracking('bottomRight - topRight', (WidgetTester tester) async {
await tester.pumpWidget(build(targetAlignment: Alignment.bottomRight, followerAlignment: Alignment.topRight)); await tester.pumpWidget(build(targetAlignment: Alignment.bottomRight, followerAlignment: Alignment.topRight));
final RenderBox box1 = key1.currentContext!.findRenderObject()! as RenderBox; final RenderBox box1 = key1.currentContext!.findRenderObject()! as RenderBox;
final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox; final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox;
...@@ -321,7 +322,7 @@ void main() { ...@@ -321,7 +322,7 @@ void main() {
for (final Alignment targetAlignment in alignments) { for (final Alignment targetAlignment in alignments) {
for (final Alignment followerAlignment in alignments) { for (final Alignment followerAlignment in alignments) {
testWidgets('$targetAlignment - $followerAlignment', (WidgetTester tester) async{ testWidgetsWithLeakTracking('$targetAlignment - $followerAlignment', (WidgetTester tester) async{
await tester.pumpWidget(build(targetAlignment: targetAlignment, followerAlignment: followerAlignment)); await tester.pumpWidget(build(targetAlignment: targetAlignment, followerAlignment: followerAlignment));
final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox; final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox;
expect(box2.size, const Size(2.0, 2.0)); expect(box2.size, const Size(2.0, 2.0));
...@@ -333,7 +334,7 @@ void main() { ...@@ -333,7 +334,7 @@ void main() {
} }
}); });
testWidgets('Leader after Follower asserts', (WidgetTester tester) async { testWidgetsWithLeakTracking('Leader after Follower asserts', (WidgetTester tester) async {
final LayerLink link = LayerLink(); final LayerLink link = LayerLink();
await tester.pumpWidget( await tester.pumpWidget(
CompositedTransformFollower( CompositedTransformFollower(
...@@ -351,7 +352,7 @@ void main() { ...@@ -351,7 +352,7 @@ void main() {
); );
}); });
testWidgets( testWidgetsWithLeakTracking(
'`FollowerLayer` (`CompositedTransformFollower`) has null pointer error when using with some kinds of `Layer`s', '`FollowerLayer` (`CompositedTransformFollower`) has null pointer error when using with some kinds of `Layer`s',
(WidgetTester tester) async { (WidgetTester tester) async {
final LayerLink link = LayerLink(); final LayerLink link = LayerLink();
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
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';
void main() { void main() {
testWidgets('Placeholder intrinsics', (WidgetTester tester) async { testWidgetsWithLeakTracking('Placeholder intrinsics', (WidgetTester tester) async {
await tester.pumpWidget(const Placeholder()); await tester.pumpWidget(const Placeholder());
expect(tester.renderObject<RenderBox>(find.byType(Placeholder)).getMinIntrinsicWidth(double.infinity), 0.0); expect(tester.renderObject<RenderBox>(find.byType(Placeholder)).getMinIntrinsicWidth(double.infinity), 0.0);
expect(tester.renderObject<RenderBox>(find.byType(Placeholder)).getMaxIntrinsicWidth(double.infinity), 0.0); expect(tester.renderObject<RenderBox>(find.byType(Placeholder)).getMaxIntrinsicWidth(double.infinity), 0.0);
...@@ -14,7 +15,7 @@ void main() { ...@@ -14,7 +15,7 @@ void main() {
expect(tester.renderObject<RenderBox>(find.byType(Placeholder)).getMaxIntrinsicHeight(double.infinity), 0.0); expect(tester.renderObject<RenderBox>(find.byType(Placeholder)).getMaxIntrinsicHeight(double.infinity), 0.0);
}); });
testWidgets('ConstrainedBox intrinsics - minHeight', (WidgetTester tester) async { testWidgetsWithLeakTracking('ConstrainedBox intrinsics - minHeight', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
ConstrainedBox( ConstrainedBox(
constraints: const BoxConstraints( constraints: const BoxConstraints(
...@@ -29,7 +30,7 @@ void main() { ...@@ -29,7 +30,7 @@ void main() {
expect(tester.renderObject<RenderBox>(find.byType(ConstrainedBox)).getMaxIntrinsicHeight(double.infinity), 20.0); expect(tester.renderObject<RenderBox>(find.byType(ConstrainedBox)).getMaxIntrinsicHeight(double.infinity), 20.0);
}); });
testWidgets('ConstrainedBox intrinsics - minWidth', (WidgetTester tester) async { testWidgetsWithLeakTracking('ConstrainedBox intrinsics - minWidth', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
ConstrainedBox( ConstrainedBox(
constraints: const BoxConstraints( constraints: const BoxConstraints(
...@@ -44,7 +45,7 @@ void main() { ...@@ -44,7 +45,7 @@ void main() {
expect(tester.renderObject<RenderBox>(find.byType(ConstrainedBox)).getMaxIntrinsicHeight(double.infinity), 0.0); expect(tester.renderObject<RenderBox>(find.byType(ConstrainedBox)).getMaxIntrinsicHeight(double.infinity), 0.0);
}); });
testWidgets('ConstrainedBox intrinsics - maxHeight', (WidgetTester tester) async { testWidgetsWithLeakTracking('ConstrainedBox intrinsics - maxHeight', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
ConstrainedBox( ConstrainedBox(
constraints: const BoxConstraints( constraints: const BoxConstraints(
...@@ -59,7 +60,7 @@ void main() { ...@@ -59,7 +60,7 @@ void main() {
expect(tester.renderObject<RenderBox>(find.byType(ConstrainedBox)).getMaxIntrinsicHeight(double.infinity), 0.0); expect(tester.renderObject<RenderBox>(find.byType(ConstrainedBox)).getMaxIntrinsicHeight(double.infinity), 0.0);
}); });
testWidgets('ConstrainedBox intrinsics - maxWidth', (WidgetTester tester) async { testWidgetsWithLeakTracking('ConstrainedBox intrinsics - maxWidth', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
ConstrainedBox( ConstrainedBox(
constraints: const BoxConstraints( constraints: const BoxConstraints(
...@@ -74,7 +75,7 @@ void main() { ...@@ -74,7 +75,7 @@ void main() {
expect(tester.renderObject<RenderBox>(find.byType(ConstrainedBox)).getMaxIntrinsicHeight(double.infinity), 0.0); expect(tester.renderObject<RenderBox>(find.byType(ConstrainedBox)).getMaxIntrinsicHeight(double.infinity), 0.0);
}); });
testWidgets('ConstrainedBox intrinsics - tight', (WidgetTester tester) async { testWidgetsWithLeakTracking('ConstrainedBox intrinsics - tight', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
ConstrainedBox( ConstrainedBox(
constraints: const BoxConstraints.tightFor(width: 10.0, height: 30.0), constraints: const BoxConstraints.tightFor(width: 10.0, height: 30.0),
...@@ -88,7 +89,7 @@ void main() { ...@@ -88,7 +89,7 @@ void main() {
}); });
testWidgets('ConstrainedBox intrinsics - minHeight - with infinite width', (WidgetTester tester) async { testWidgetsWithLeakTracking('ConstrainedBox intrinsics - minHeight - with infinite width', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
ConstrainedBox( ConstrainedBox(
constraints: const BoxConstraints( constraints: const BoxConstraints(
...@@ -104,7 +105,7 @@ void main() { ...@@ -104,7 +105,7 @@ void main() {
expect(tester.renderObject<RenderBox>(find.byType(ConstrainedBox)).getMaxIntrinsicHeight(double.infinity), 20.0); expect(tester.renderObject<RenderBox>(find.byType(ConstrainedBox)).getMaxIntrinsicHeight(double.infinity), 20.0);
}); });
testWidgets('ConstrainedBox intrinsics - minWidth - with infinite height', (WidgetTester tester) async { testWidgetsWithLeakTracking('ConstrainedBox intrinsics - minWidth - with infinite height', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
ConstrainedBox( ConstrainedBox(
constraints: const BoxConstraints( constraints: const BoxConstraints(
...@@ -120,7 +121,7 @@ void main() { ...@@ -120,7 +121,7 @@ void main() {
expect(tester.renderObject<RenderBox>(find.byType(ConstrainedBox)).getMaxIntrinsicHeight(double.infinity), 0.0); expect(tester.renderObject<RenderBox>(find.byType(ConstrainedBox)).getMaxIntrinsicHeight(double.infinity), 0.0);
}); });
testWidgets('ConstrainedBox intrinsics - infinite', (WidgetTester tester) async { testWidgetsWithLeakTracking('ConstrainedBox intrinsics - infinite', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
ConstrainedBox( ConstrainedBox(
constraints: const BoxConstraints.tightFor(width: double.infinity, height: double.infinity), constraints: const BoxConstraints.tightFor(width: double.infinity, height: double.infinity),
......
...@@ -9,6 +9,7 @@ library; ...@@ -9,6 +9,7 @@ library;
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() {
group('Container control tests:', () { group('Container control tests:', () {
...@@ -37,7 +38,7 @@ void main() { ...@@ -37,7 +38,7 @@ void main() {
), ),
); );
testWidgets('paints as expected', (WidgetTester tester) async { testWidgetsWithLeakTracking('paints as expected', (WidgetTester tester) async {
await tester.pumpWidget(Align( await tester.pumpWidget(Align(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: container, child: container,
...@@ -54,7 +55,7 @@ void main() { ...@@ -54,7 +55,7 @@ void main() {
}); });
group('diagnostics', () { group('diagnostics', () {
testWidgets('has reasonable default diagnostics', (WidgetTester tester) async { testWidgetsWithLeakTracking('has reasonable default diagnostics', (WidgetTester tester) async {
await tester.pumpWidget(Align( await tester.pumpWidget(Align(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: container, child: container,
...@@ -66,7 +67,7 @@ void main() { ...@@ -66,7 +67,7 @@ void main() {
expect(box, hasAGoodToStringDeep); expect(box, hasAGoodToStringDeep);
}); });
testWidgets('has expected info diagnostics', (WidgetTester tester) async { testWidgetsWithLeakTracking('has expected info diagnostics', (WidgetTester tester) async {
await tester.pumpWidget(Align( await tester.pumpWidget(Align(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: container, child: container,
...@@ -138,7 +139,7 @@ void main() { ...@@ -138,7 +139,7 @@ void main() {
); );
}); });
testWidgets('has expected debug diagnostics', (WidgetTester tester) async { testWidgetsWithLeakTracking('has expected debug diagnostics', (WidgetTester tester) async {
await tester.pumpWidget(Align( await tester.pumpWidget(Align(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: container, child: container,
...@@ -243,7 +244,7 @@ void main() { ...@@ -243,7 +244,7 @@ void main() {
); );
}); });
testWidgets('has expected fine diagnostics', (WidgetTester tester) async { testWidgetsWithLeakTracking('has expected fine diagnostics', (WidgetTester tester) async {
await tester.pumpWidget(Align( await tester.pumpWidget(Align(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: container, child: container,
...@@ -376,7 +377,7 @@ void main() { ...@@ -376,7 +377,7 @@ void main() {
); );
}); });
testWidgets('has expected hidden diagnostics', (WidgetTester tester) async { testWidgetsWithLeakTracking('has expected hidden diagnostics', (WidgetTester tester) async {
await tester.pumpWidget(Align( await tester.pumpWidget(Align(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: container, child: container,
...@@ -533,7 +534,7 @@ void main() { ...@@ -533,7 +534,7 @@ void main() {
); );
}); });
testWidgets('painting error has expected diagnostics', (WidgetTester tester) async { testWidgetsWithLeakTracking('painting error has expected diagnostics', (WidgetTester tester) async {
await tester.pumpWidget(Align( await tester.pumpWidget(Align(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: container, child: container,
...@@ -564,7 +565,7 @@ void main() { ...@@ -564,7 +565,7 @@ void main() {
}); });
}); });
testWidgets('Can be placed in an infinite box', (WidgetTester tester) async { testWidgetsWithLeakTracking('Can be placed in an infinite box', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -573,7 +574,7 @@ void main() { ...@@ -573,7 +574,7 @@ void main() {
); );
}); });
testWidgets('Container transformAlignment', (WidgetTester tester) async { testWidgetsWithLeakTracking('Container transformAlignment', (WidgetTester tester) async {
final Key key = UniqueKey(); final Key key = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -620,7 +621,7 @@ void main() { ...@@ -620,7 +621,7 @@ void main() {
expect(tester.getBottomRight(finder), equals(const Offset(200, 200))); expect(tester.getBottomRight(finder), equals(const Offset(200, 200)));
}); });
testWidgets('giving clipBehaviour Clip.None, will not add a ClipPath to the tree', (WidgetTester tester) async { testWidgetsWithLeakTracking('giving clipBehaviour Clip.None, will not add a ClipPath to the tree', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Container( Container(
decoration: const BoxDecoration( decoration: const BoxDecoration(
...@@ -635,7 +636,7 @@ void main() { ...@@ -635,7 +636,7 @@ void main() {
); );
}); });
testWidgets('giving clipBehaviour not a Clip.None, will add a ClipPath to the tree', (WidgetTester tester) async { testWidgetsWithLeakTracking('giving clipBehaviour not a Clip.None, will add a ClipPath to the tree', (WidgetTester tester) async {
final Container container = Container( final Container container = Container(
clipBehavior: Clip.hardEdge, clipBehavior: Clip.hardEdge,
decoration: const BoxDecoration( decoration: const BoxDecoration(
...@@ -652,7 +653,7 @@ void main() { ...@@ -652,7 +653,7 @@ void main() {
); );
}); });
testWidgets('getClipPath() works for lots of kinds of decorations', (WidgetTester tester) async { testWidgetsWithLeakTracking('getClipPath() works for lots of kinds of decorations', (WidgetTester tester) async {
Future<void> test(Decoration decoration) async { Future<void> test(Decoration decoration) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
...@@ -682,7 +683,7 @@ void main() { ...@@ -682,7 +683,7 @@ void main() {
await test(const FlutterLogoDecoration()); await test(const FlutterLogoDecoration());
}); });
testWidgets('Container is hittable only when having decorations', (WidgetTester tester) async { testWidgetsWithLeakTracking('Container is hittable only when having decorations', (WidgetTester tester) async {
bool tapped = false; bool tapped = false;
await tester.pumpWidget(GestureDetector( await tester.pumpWidget(GestureDetector(
onTap: () { tapped = true; }, onTap: () { tapped = true; },
...@@ -736,7 +737,7 @@ void main() { ...@@ -736,7 +737,7 @@ void main() {
expect(tapped, false); expect(tapped, false);
}); });
testWidgets('Container discards alignment when the child parameter is null and constraints is not Tight', (WidgetTester tester) async { testWidgetsWithLeakTracking('Container discards alignment when the child parameter is null and constraints is not Tight', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Container( Container(
decoration: const BoxDecoration( decoration: const BoxDecoration(
...@@ -751,7 +752,7 @@ void main() { ...@@ -751,7 +752,7 @@ void main() {
); );
}); });
testWidgets('using clipBehaviour and shadow, should not clip the shadow', (WidgetTester tester) async { testWidgetsWithLeakTracking('using clipBehaviour and shadow, should not clip the shadow', (WidgetTester tester) async {
final Container container = Container( final Container container = Container(
clipBehavior: Clip.hardEdge, clipBehavior: Clip.hardEdge,
decoration: const BoxDecoration( decoration: const BoxDecoration(
......
...@@ -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';
...@@ -20,7 +21,7 @@ void main() { ...@@ -20,7 +21,7 @@ void main() {
await Clipboard.setData(const ClipboardData(text: 'Clipboard data')); await Clipboard.setData(const ClipboardData(text: 'Clipboard data'));
}); });
testWidgets('Hides and shows only a single menu', (WidgetTester tester) async { testWidgetsWithLeakTracking('Hides and shows only a single menu', (WidgetTester tester) async {
final GlobalKey key1 = GlobalKey(); final GlobalKey key1 = GlobalKey();
final GlobalKey key2 = GlobalKey(); final GlobalKey key2 = GlobalKey();
late final BuildContext context; late final BuildContext context;
...@@ -90,7 +91,7 @@ void main() { ...@@ -90,7 +91,7 @@ void main() {
expect(find.byKey(key2), findsNothing); expect(find.byKey(key2), findsNothing);
}); });
testWidgets('A menu can be hidden and then reshown', (WidgetTester tester) async { testWidgetsWithLeakTracking('A menu can be hidden and then reshown', (WidgetTester tester) async {
final GlobalKey key1 = GlobalKey(); final GlobalKey key1 = GlobalKey();
late final BuildContext context; late final BuildContext context;
...@@ -141,7 +142,7 @@ void main() { ...@@ -141,7 +142,7 @@ void main() {
expect(find.byKey(key1), findsOneWidget); expect(find.byKey(key1), findsOneWidget);
}); });
testWidgets('markNeedsBuild causes the builder to update', (WidgetTester tester) async { testWidgetsWithLeakTracking('markNeedsBuild causes the builder to update', (WidgetTester tester) async {
int buildCount = 0; int buildCount = 0;
late final BuildContext context; late final BuildContext context;
...@@ -178,7 +179,7 @@ void main() { ...@@ -178,7 +179,7 @@ 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 { testWidgetsWithLeakTracking('Calling show when a built-in widget is already showing its context menu hides the built-in menu', (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;
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
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';
void main() { void main() {
testWidgets('Comparing coordinates', (WidgetTester tester) async { testWidgetsWithLeakTracking('Comparing coordinates', (WidgetTester tester) async {
final Key keyA = GlobalKey(); final Key keyA = GlobalKey();
final Key keyB = GlobalKey(); final Key keyB = GlobalKey();
......
...@@ -6,6 +6,7 @@ import 'package:flutter/foundation.dart'; ...@@ -6,6 +6,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.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';
class TestMultiChildLayoutDelegate extends MultiChildLayoutDelegate { class TestMultiChildLayoutDelegate extends MultiChildLayoutDelegate {
late BoxConstraints getSizeConstraints; late BoxConstraints getSizeConstraints;
...@@ -163,7 +164,7 @@ class LayoutWithMissingId extends ParentDataWidget<MultiChildLayoutParentData> { ...@@ -163,7 +164,7 @@ class LayoutWithMissingId extends ParentDataWidget<MultiChildLayoutParentData> {
} }
void main() { void main() {
testWidgets('Control test for CustomMultiChildLayout', (WidgetTester tester) async { testWidgetsWithLeakTracking('Control test for CustomMultiChildLayout', (WidgetTester tester) async {
final TestMultiChildLayoutDelegate delegate = TestMultiChildLayoutDelegate(); final TestMultiChildLayoutDelegate delegate = TestMultiChildLayoutDelegate();
await tester.pumpWidget(buildFrame(delegate)); await tester.pumpWidget(buildFrame(delegate));
...@@ -181,7 +182,7 @@ void main() { ...@@ -181,7 +182,7 @@ void main() {
expect(delegate.performLayoutIsChild, false); expect(delegate.performLayoutIsChild, false);
}); });
testWidgets('Test MultiChildDelegate shouldRelayout method', (WidgetTester tester) async { testWidgetsWithLeakTracking('Test MultiChildDelegate shouldRelayout method', (WidgetTester tester) async {
TestMultiChildLayoutDelegate delegate = TestMultiChildLayoutDelegate(); TestMultiChildLayoutDelegate delegate = TestMultiChildLayoutDelegate();
await tester.pumpWidget(buildFrame(delegate)); await tester.pumpWidget(buildFrame(delegate));
...@@ -204,7 +205,7 @@ void main() { ...@@ -204,7 +205,7 @@ void main() {
expect(delegate.performLayoutSize, isNotNull); expect(delegate.performLayoutSize, isNotNull);
}); });
testWidgets('Nested CustomMultiChildLayouts', (WidgetTester tester) async { testWidgetsWithLeakTracking('Nested CustomMultiChildLayouts', (WidgetTester tester) async {
final TestMultiChildLayoutDelegate delegate = TestMultiChildLayoutDelegate(); final TestMultiChildLayoutDelegate delegate = TestMultiChildLayoutDelegate();
await tester.pumpWidget(Center( await tester.pumpWidget(Center(
child: CustomMultiChildLayout( child: CustomMultiChildLayout(
...@@ -227,7 +228,7 @@ void main() { ...@@ -227,7 +228,7 @@ void main() {
}); });
testWidgets('Loose constraints', (WidgetTester tester) async { testWidgetsWithLeakTracking('Loose constraints', (WidgetTester tester) async {
final Key key = UniqueKey(); final Key key = UniqueKey();
await tester.pumpWidget(Center( await tester.pumpWidget(Center(
child: CustomMultiChildLayout( child: CustomMultiChildLayout(
...@@ -251,8 +252,9 @@ void main() { ...@@ -251,8 +252,9 @@ void main() {
expect(box.size.height, equals(250.0)); expect(box.size.height, equals(250.0));
}); });
testWidgets('Can use listener for relayout', (WidgetTester tester) async { testWidgetsWithLeakTracking('Can use listener for relayout', (WidgetTester tester) async {
final ValueNotifier<Size> size = ValueNotifier<Size>(const Size(100.0, 200.0)); final ValueNotifier<Size> size = ValueNotifier<Size>(const Size(100.0, 200.0));
addTearDown(size.dispose);
await tester.pumpWidget( await tester.pumpWidget(
Center( Center(
...@@ -302,7 +304,7 @@ void main() { ...@@ -302,7 +304,7 @@ void main() {
expect((errors.first.exception as FlutterError).toStringDeep(), equalsIgnoringHashCodes(message)); expect((errors.first.exception as FlutterError).toStringDeep(), equalsIgnoringHashCodes(message));
} }
testWidgets('layoutChild on non existent child', (WidgetTester tester) async { testWidgetsWithLeakTracking('layoutChild on non existent child', (WidgetTester tester) async {
await expectFlutterErrorMessage( await expectFlutterErrorMessage(
tester: tester, tester: tester,
delegate: ZeroAndOneIdLayoutDelegate(), delegate: ZeroAndOneIdLayoutDelegate(),
...@@ -314,7 +316,7 @@ void main() { ...@@ -314,7 +316,7 @@ void main() {
); );
}); });
testWidgets('layoutChild more than once', (WidgetTester tester) async { testWidgetsWithLeakTracking('layoutChild more than once', (WidgetTester tester) async {
await expectFlutterErrorMessage( await expectFlutterErrorMessage(
tester: tester, tester: tester,
delegate: DuplicateLayoutDelegate(), delegate: DuplicateLayoutDelegate(),
...@@ -326,7 +328,7 @@ void main() { ...@@ -326,7 +328,7 @@ void main() {
); );
}); });
testWidgets('layoutChild on invalid size constraint', (WidgetTester tester) async { testWidgetsWithLeakTracking('layoutChild on invalid size constraint', (WidgetTester tester) async {
await expectFlutterErrorMessage( await expectFlutterErrorMessage(
tester: tester, tester: tester,
delegate: InvalidConstraintsChildLayoutDelegate(), delegate: InvalidConstraintsChildLayoutDelegate(),
...@@ -345,7 +347,7 @@ void main() { ...@@ -345,7 +347,7 @@ void main() {
); );
}); });
testWidgets('positionChild on non existent child', (WidgetTester tester) async { testWidgetsWithLeakTracking('positionChild on non existent child', (WidgetTester tester) async {
await expectFlutterErrorMessage( await expectFlutterErrorMessage(
tester: tester, tester: tester,
delegate: NonExistentPositionDelegate(), delegate: NonExistentPositionDelegate(),
...@@ -357,7 +359,7 @@ void main() { ...@@ -357,7 +359,7 @@ void main() {
); );
}); });
testWidgets("_callPerformLayout on child that doesn't have id", (WidgetTester tester) async { testWidgetsWithLeakTracking("_callPerformLayout on child that doesn't have id", (WidgetTester tester) async {
await expectFlutterErrorMessage( await expectFlutterErrorMessage(
widget: Center( widget: Center(
child: CustomMultiChildLayout( child: CustomMultiChildLayout(
...@@ -383,7 +385,7 @@ void main() { ...@@ -383,7 +385,7 @@ void main() {
); );
}); });
testWidgets('performLayout did not layout a child', (WidgetTester tester) async { testWidgetsWithLeakTracking('performLayout did not layout a child', (WidgetTester tester) async {
await expectFlutterErrorMessage( await expectFlutterErrorMessage(
widget: Center( widget: Center(
child: CustomMultiChildLayout( child: CustomMultiChildLayout(
...@@ -405,7 +407,7 @@ void main() { ...@@ -405,7 +407,7 @@ void main() {
); );
}); });
testWidgets('performLayout did not layout multiple child', (WidgetTester tester) async { testWidgetsWithLeakTracking('performLayout did not layout multiple child', (WidgetTester tester) async {
await expectFlutterErrorMessage( await expectFlutterErrorMessage(
widget: Center( widget: Center(
child: CustomMultiChildLayout( child: CustomMultiChildLayout(
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.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';
class TestCustomPainter extends CustomPainter { class TestCustomPainter extends CustomPainter {
TestCustomPainter({ required this.log, this.name }); TestCustomPainter({ required this.log, this.name });
...@@ -40,7 +41,7 @@ class MockPaintingContext extends Fake implements PaintingContext { ...@@ -40,7 +41,7 @@ class MockPaintingContext extends Fake implements PaintingContext {
} }
void main() { void main() {
testWidgets('Control test for custom painting', (WidgetTester tester) async { testWidgetsWithLeakTracking('Control test for custom painting', (WidgetTester tester) async {
final List<String?> log = <String?>[]; final List<String?> log = <String?>[];
await tester.pumpWidget(CustomPaint( await tester.pumpWidget(CustomPaint(
painter: TestCustomPainter( painter: TestCustomPainter(
...@@ -62,7 +63,7 @@ void main() { ...@@ -62,7 +63,7 @@ void main() {
expect(log, equals(<String>['background', 'child', 'foreground'])); expect(log, equals(<String>['background', 'child', 'foreground']));
}); });
testWidgets('Throws FlutterError on custom painter incorrect restore/save calls', (WidgetTester tester) async { testWidgetsWithLeakTracking('Throws FlutterError on custom painter incorrect restore/save calls', (WidgetTester tester) async {
final GlobalKey target = GlobalKey(); final GlobalKey target = GlobalKey();
final List<String?> log = <String?>[]; final List<String?> log = <String?>[];
await tester.pumpWidget(CustomPaint( await tester.pumpWidget(CustomPaint(
...@@ -118,7 +119,7 @@ void main() { ...@@ -118,7 +119,7 @@ void main() {
expect(error.toStringDeep(), contains('2 more times')); expect(error.toStringDeep(), contains('2 more times'));
}); });
testWidgets('CustomPaint sizing', (WidgetTester tester) async { testWidgetsWithLeakTracking('CustomPaint sizing', (WidgetTester tester) async {
final GlobalKey target = GlobalKey(); final GlobalKey target = GlobalKey();
await tester.pumpWidget(Center( await tester.pumpWidget(Center(
...@@ -153,7 +154,7 @@ void main() { ...@@ -153,7 +154,7 @@ void main() {
}); });
testWidgets('Raster cache hints', (WidgetTester tester) async { testWidgetsWithLeakTracking('Raster cache hints', (WidgetTester tester) async {
final GlobalKey target = GlobalKey(); final GlobalKey target = GlobalKey();
final List<String?> log = <String?>[]; final List<String?> log = <String?>[];
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.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';
import 'semantics_tester.dart'; import 'semantics_tester.dart';
...@@ -22,7 +23,7 @@ void main() { ...@@ -22,7 +23,7 @@ void main() {
} }
void _defineTests() { void _defineTests() {
testWidgets('builds no semantics by default', (WidgetTester tester) async { testWidgetsWithLeakTracking('builds no semantics by default', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester); final SemanticsTester semanticsTester = SemanticsTester(tester);
await tester.pumpWidget(CustomPaint( await tester.pumpWidget(CustomPaint(
...@@ -36,7 +37,7 @@ void _defineTests() { ...@@ -36,7 +37,7 @@ void _defineTests() {
semanticsTester.dispose(); semanticsTester.dispose();
}); });
testWidgets('provides foreground semantics', (WidgetTester tester) async { testWidgetsWithLeakTracking('provides foreground semantics', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester); final SemanticsTester semanticsTester = SemanticsTester(tester);
await tester.pumpWidget(CustomPaint( await tester.pumpWidget(CustomPaint(
...@@ -72,7 +73,7 @@ void _defineTests() { ...@@ -72,7 +73,7 @@ void _defineTests() {
semanticsTester.dispose(); semanticsTester.dispose();
}); });
testWidgets('provides background semantics', (WidgetTester tester) async { testWidgetsWithLeakTracking('provides background semantics', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester); final SemanticsTester semanticsTester = SemanticsTester(tester);
await tester.pumpWidget(CustomPaint( await tester.pumpWidget(CustomPaint(
...@@ -108,7 +109,7 @@ void _defineTests() { ...@@ -108,7 +109,7 @@ void _defineTests() {
semanticsTester.dispose(); semanticsTester.dispose();
}); });
testWidgets('combines background, child and foreground semantics', (WidgetTester tester) async { testWidgetsWithLeakTracking('combines background, child and foreground semantics', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester); final SemanticsTester semanticsTester = SemanticsTester(tester);
await tester.pumpWidget(CustomPaint( await tester.pumpWidget(CustomPaint(
...@@ -167,7 +168,7 @@ void _defineTests() { ...@@ -167,7 +168,7 @@ void _defineTests() {
semanticsTester.dispose(); semanticsTester.dispose();
}); });
testWidgets('applies $SemanticsProperties', (WidgetTester tester) async { testWidgetsWithLeakTracking('applies $SemanticsProperties', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester); final SemanticsTester semanticsTester = SemanticsTester(tester);
await tester.pumpWidget(CustomPaint( await tester.pumpWidget(CustomPaint(
...@@ -270,7 +271,7 @@ void _defineTests() { ...@@ -270,7 +271,7 @@ void _defineTests() {
semanticsTester.dispose(); semanticsTester.dispose();
}); });
testWidgets('Can toggle semantics on, off, on without crash', (WidgetTester tester) async { testWidgetsWithLeakTracking('Can toggle semantics on, off, on without crash', (WidgetTester tester) async {
await tester.pumpWidget(CustomPaint( await tester.pumpWidget(CustomPaint(
painter: _PainterWithSemantics( painter: _PainterWithSemantics(
semantics: const CustomPainterSemantics( semantics: const CustomPainterSemantics(
...@@ -312,7 +313,7 @@ void _defineTests() { ...@@ -312,7 +313,7 @@ void _defineTests() {
semantics.dispose(); semantics.dispose();
}, semanticsEnabled: false); }, semanticsEnabled: false);
testWidgets('Supports all actions', (WidgetTester tester) async { testWidgetsWithLeakTracking('Supports all actions', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
final List<SemanticsAction> performedActions = <SemanticsAction>[]; final List<SemanticsAction> performedActions = <SemanticsAction>[];
...@@ -410,7 +411,7 @@ void _defineTests() { ...@@ -410,7 +411,7 @@ void _defineTests() {
semantics.dispose(); semantics.dispose();
}); });
testWidgets('Supports all flags', (WidgetTester tester) async { testWidgetsWithLeakTracking('Supports all flags', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
// checked state and toggled state are mutually exclusive. // checked state and toggled state are mutually exclusive.
await tester.pumpWidget(CustomPaint( await tester.pumpWidget(CustomPaint(
...@@ -525,7 +526,7 @@ void _defineTests() { ...@@ -525,7 +526,7 @@ void _defineTests() {
}); });
group('diffing', () { group('diffing', () {
testWidgets('complains about duplicate keys', (WidgetTester tester) async { testWidgetsWithLeakTracking('complains about duplicate keys', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester); final SemanticsTester semanticsTester = SemanticsTester(tester);
await tester.pumpWidget(CustomPaint( await tester.pumpWidget(CustomPaint(
painter: _SemanticsDiffTest(<String>[ painter: _SemanticsDiffTest(<String>[
...@@ -622,7 +623,7 @@ void _defineTests() { ...@@ -622,7 +623,7 @@ void _defineTests() {
}); });
}); });
testWidgets('rebuilds semantics upon resize', (WidgetTester tester) async { testWidgetsWithLeakTracking('rebuilds semantics upon resize', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester); final SemanticsTester semanticsTester = SemanticsTester(tester);
final _PainterWithSemantics painter = _PainterWithSemantics( final _PainterWithSemantics painter = _PainterWithSemantics(
...@@ -667,7 +668,7 @@ void _defineTests() { ...@@ -667,7 +668,7 @@ void _defineTests() {
semanticsTester.dispose(); semanticsTester.dispose();
}); });
testWidgets('does not rebuild when shouldRebuildSemantics is false', (WidgetTester tester) async { testWidgetsWithLeakTracking('does not rebuild when shouldRebuildSemantics is false', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester); final SemanticsTester semanticsTester = SemanticsTester(tester);
const CustomPainterSemantics testSemantics = CustomPainterSemantics( const CustomPainterSemantics testSemantics = CustomPainterSemantics(
...@@ -712,7 +713,7 @@ void _defineTests() { ...@@ -712,7 +713,7 @@ void _defineTests() {
} }
void _testDiff(String description, Future<void> Function(_DiffTester tester) testFunction) { void _testDiff(String description, Future<void> Function(_DiffTester tester) testFunction) {
testWidgets(description, (WidgetTester tester) async { testWidgetsWithLeakTracking(description, (WidgetTester tester) async {
await testFunction(_DiffTester(tester)); await testFunction(_DiffTester(tester));
}); });
} }
......
...@@ -4,10 +4,11 @@ ...@@ -4,10 +4,11 @@
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';
void main() { void main() {
// Regression test for https://github.com/flutter/flutter/issues/96024 // Regression test for https://github.com/flutter/flutter/issues/96024
testWidgets('CustomScrollView.center update test 1', (WidgetTester tester) async { testWidgetsWithLeakTracking('CustomScrollView.center update test 1', (WidgetTester tester) async {
final Key centerKey = UniqueKey(); final Key centerKey = UniqueKey();
late StateSetter setState; late StateSetter setState;
bool hasKey = false; bool hasKey = false;
...@@ -49,7 +50,7 @@ void main() { ...@@ -49,7 +50,7 @@ void main() {
// Pass without throw. // Pass without throw.
}); });
testWidgets('CustomScrollView.center update test 2', (WidgetTester tester) async { testWidgetsWithLeakTracking('CustomScrollView.center update test 2', (WidgetTester tester) async {
const List<Widget> slivers1 = <Widget>[ const List<Widget> slivers1 = <Widget>[
SliverToBoxAdapter(key: Key('a'), child: SizedBox(height: 100.0)), SliverToBoxAdapter(key: Key('a'), child: SizedBox(height: 100.0)),
SliverToBoxAdapter(key: Key('b'), child: SizedBox(height: 100.0)), SliverToBoxAdapter(key: Key('b'), child: SizedBox(height: 100.0)),
...@@ -81,7 +82,7 @@ void main() { ...@@ -81,7 +82,7 @@ void main() {
// Pass without throw. // Pass without throw.
}); });
testWidgets('CustomScrollView.center', (WidgetTester tester) async { testWidgetsWithLeakTracking('CustomScrollView.center', (WidgetTester tester) async {
await tester.pumpWidget(const Directionality( await tester.pumpWidget(const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: CustomScrollView( child: CustomScrollView(
...@@ -103,7 +104,7 @@ void main() { ...@@ -103,7 +104,7 @@ void main() {
); );
}); });
testWidgets('CustomScrollView.center', (WidgetTester tester) async { testWidgetsWithLeakTracking('CustomScrollView.center', (WidgetTester tester) async {
await tester.pumpWidget(const Directionality( await tester.pumpWidget(const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: CustomScrollView( child: CustomScrollView(
...@@ -135,7 +136,7 @@ void main() { ...@@ -135,7 +136,7 @@ void main() {
); );
}); });
testWidgets('CustomScrollView.anchor', (WidgetTester tester) async { testWidgetsWithLeakTracking('CustomScrollView.anchor', (WidgetTester tester) async {
await tester.pumpWidget(const Directionality( await tester.pumpWidget(const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: CustomScrollView( child: CustomScrollView(
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
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';
class TestSingleChildLayoutDelegate extends SingleChildLayoutDelegate { class TestSingleChildLayoutDelegate extends SingleChildLayoutDelegate {
late BoxConstraints constraintsFromGetSize; late BoxConstraints constraintsFromGetSize;
...@@ -93,7 +94,7 @@ Widget buildFrame(SingleChildLayoutDelegate delegate) { ...@@ -93,7 +94,7 @@ Widget buildFrame(SingleChildLayoutDelegate delegate) {
} }
void main() { void main() {
testWidgets('Control test for CustomSingleChildLayout', (WidgetTester tester) async { testWidgetsWithLeakTracking('Control test for CustomSingleChildLayout', (WidgetTester tester) async {
final TestSingleChildLayoutDelegate delegate = TestSingleChildLayoutDelegate(); final TestSingleChildLayoutDelegate delegate = TestSingleChildLayoutDelegate();
await tester.pumpWidget(buildFrame(delegate)); await tester.pumpWidget(buildFrame(delegate));
...@@ -114,7 +115,7 @@ void main() { ...@@ -114,7 +115,7 @@ void main() {
expect(delegate.childSizeFromGetPositionForChild.height, 400.0); expect(delegate.childSizeFromGetPositionForChild.height, 400.0);
}); });
testWidgets('Test SingleChildDelegate shouldRelayout method', (WidgetTester tester) async { testWidgetsWithLeakTracking('Test SingleChildDelegate shouldRelayout method', (WidgetTester tester) async {
TestSingleChildLayoutDelegate delegate = TestSingleChildLayoutDelegate delegate =
TestSingleChildLayoutDelegate(); TestSingleChildLayoutDelegate();
await tester.pumpWidget(buildFrame(delegate)); await tester.pumpWidget(buildFrame(delegate));
...@@ -138,7 +139,7 @@ void main() { ...@@ -138,7 +139,7 @@ void main() {
expect(delegate.constraintsFromGetConstraintsForChild, isNotNull); expect(delegate.constraintsFromGetConstraintsForChild, isNotNull);
}); });
testWidgets('Delegate can change size', (WidgetTester tester) async { testWidgetsWithLeakTracking('Delegate can change size', (WidgetTester tester) async {
await tester.pumpWidget(buildFrame(FixedSizeLayoutDelegate(const Size(100.0, 200.0)))); await tester.pumpWidget(buildFrame(FixedSizeLayoutDelegate(const Size(100.0, 200.0))));
RenderBox box = tester.renderObject(find.byType(CustomSingleChildLayout)); RenderBox box = tester.renderObject(find.byType(CustomSingleChildLayout));
...@@ -150,8 +151,9 @@ void main() { ...@@ -150,8 +151,9 @@ void main() {
expect(box.size, equals(const Size(150.0, 240.0))); expect(box.size, equals(const Size(150.0, 240.0)));
}); });
testWidgets('Can use listener for relayout', (WidgetTester tester) async { testWidgetsWithLeakTracking('Can use listener for relayout', (WidgetTester tester) async {
final ValueNotifier<Size> size = ValueNotifier<Size>(const Size(100.0, 200.0)); final ValueNotifier<Size> size = ValueNotifier<Size>(const Size(100.0, 200.0));
addTearDown(size.dispose);
await tester.pumpWidget(buildFrame(NotifierLayoutDelegate(size))); await tester.pumpWidget(buildFrame(NotifierLayoutDelegate(size)));
......
...@@ -7,6 +7,7 @@ import 'dart:ui'; ...@@ -7,6 +7,7 @@ import 'dart:ui';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
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() {
test('debugChildrenHaveDuplicateKeys control test', () { test('debugChildrenHaveDuplicateKeys control test', () {
...@@ -64,7 +65,7 @@ void main() { ...@@ -64,7 +65,7 @@ void main() {
} }
}); });
testWidgets('debugCheckHasTable control test', (WidgetTester tester) async { testWidgetsWithLeakTracking('debugCheckHasTable control test', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Builder( Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
...@@ -95,7 +96,7 @@ void main() { ...@@ -95,7 +96,7 @@ void main() {
); );
}); });
testWidgets('debugCheckHasMediaQuery control test', (WidgetTester tester) async { testWidgetsWithLeakTracking('debugCheckHasMediaQuery control test', (WidgetTester tester) async {
// Cannot use tester.pumpWidget here because it wraps the widget in a View, // Cannot use tester.pumpWidget here because it wraps the widget in a View,
// which introduces a MediaQuery ancestor. // which introduces a MediaQuery ancestor.
await pumpWidgetWithoutViewWrapper( await pumpWidgetWithoutViewWrapper(
...@@ -231,7 +232,7 @@ void main() { ...@@ -231,7 +232,7 @@ void main() {
} }
}); });
testWidgets('debugCheckHasWidgetsLocalizations throws', (WidgetTester tester) async { testWidgetsWithLeakTracking('debugCheckHasWidgetsLocalizations throws', (WidgetTester tester) async {
final GlobalKey noLocalizationsAvailable = GlobalKey(); final GlobalKey noLocalizationsAvailable = GlobalKey();
final GlobalKey localizationsAvailable = GlobalKey(); final GlobalKey localizationsAvailable = GlobalKey();
...@@ -280,7 +281,7 @@ void main() { ...@@ -280,7 +281,7 @@ void main() {
debugHighlightDeprecatedWidgets = false; debugHighlightDeprecatedWidgets = false;
}); });
testWidgets('debugCreator of layers should not be null', (WidgetTester tester) async { testWidgetsWithLeakTracking('debugCreator of layers should not be null', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Directionality( home: Directionality(
......
...@@ -9,9 +9,10 @@ library; ...@@ -9,9 +9,10 @@ library;
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('DecoratedSliver creates, paints, and disposes BoxPainter', (WidgetTester tester) async { testWidgetsWithLeakTracking('DecoratedSliver creates, paints, and disposes BoxPainter', (WidgetTester tester) async {
final TestDecoration decoration = TestDecoration(); final TestDecoration decoration = TestDecoration();
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Scaffold( home: Scaffold(
...@@ -39,7 +40,7 @@ void main() { ...@@ -39,7 +40,7 @@ void main() {
expect(decoration.painters.last.disposed, true); expect(decoration.painters.last.disposed, true);
}); });
testWidgets('DecoratedSliver can update box painter', (WidgetTester tester) async { testWidgetsWithLeakTracking('DecoratedSliver can update box painter', (WidgetTester tester) async {
final TestDecoration decorationA = TestDecoration(); final TestDecoration decorationA = TestDecoration();
final TestDecoration decorationB = TestDecoration(); final TestDecoration decorationB = TestDecoration();
...@@ -79,7 +80,7 @@ void main() { ...@@ -79,7 +80,7 @@ void main() {
expect(decorationB.painters.last.paintCount, 1); expect(decorationB.painters.last.paintCount, 1);
}); });
testWidgets('DecoratedSliver can update DecorationPosition', (WidgetTester tester) async { testWidgetsWithLeakTracking('DecoratedSliver can update DecorationPosition', (WidgetTester tester) async {
final TestDecoration decoration = TestDecoration(); final TestDecoration decoration = TestDecoration();
DecorationPosition activePosition = DecorationPosition.foreground; DecorationPosition activePosition = DecorationPosition.foreground;
...@@ -117,7 +118,7 @@ void main() { ...@@ -117,7 +118,7 @@ void main() {
expect(decoration.painters.last.paintCount, 2); expect(decoration.painters.last.paintCount, 2);
}); });
testWidgets('DecoratedSliver golden test', (WidgetTester tester) async { testWidgetsWithLeakTracking('DecoratedSliver golden test', (WidgetTester tester) async {
const BoxDecoration decoration = BoxDecoration( const BoxDecoration decoration = BoxDecoration(
color: Colors.blue, color: Colors.blue,
); );
...@@ -198,10 +199,11 @@ void main() { ...@@ -198,10 +199,11 @@ void main() {
await expectLater(find.byKey(foregroundKey), matchesGoldenFile('decorated_sliver.moon.foreground.png')); await expectLater(find.byKey(foregroundKey), matchesGoldenFile('decorated_sliver.moon.foreground.png'));
}); });
testWidgets('DecoratedSliver paints its border correctly vertically', (WidgetTester tester) async { testWidgetsWithLeakTracking('DecoratedSliver paints its border correctly vertically', (WidgetTester tester) async {
const Key key = Key('DecoratedSliver with border'); const Key key = Key('DecoratedSliver with border');
const Color black = Color(0xFF000000); const Color black = Color(0xFF000000);
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Align( child: Align(
...@@ -234,10 +236,11 @@ void main() { ...@@ -234,10 +236,11 @@ void main() {
)); ));
}); });
testWidgets('DecoratedSliver paints its border correctly vertically reverse', (WidgetTester tester) async { testWidgetsWithLeakTracking('DecoratedSliver paints its border correctly vertically reverse', (WidgetTester tester) async {
const Key key = Key('DecoratedSliver with border'); const Key key = Key('DecoratedSliver with border');
const Color black = Color(0xFF000000); const Color black = Color(0xFF000000);
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Align( child: Align(
...@@ -273,10 +276,11 @@ void main() { ...@@ -273,10 +276,11 @@ void main() {
testWidgets('DecoratedSliver paints its border correctly horizontally', (WidgetTester tester) async { testWidgetsWithLeakTracking('DecoratedSliver paints its border correctly horizontally', (WidgetTester tester) async {
const Key key = Key('DecoratedSliver with border'); const Key key = Key('DecoratedSliver with border');
const Color black = Color(0xFF000000); const Color black = Color(0xFF000000);
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Align( child: Align(
...@@ -310,10 +314,11 @@ void main() { ...@@ -310,10 +314,11 @@ void main() {
)); ));
}); });
testWidgets('DecoratedSliver paints its border correctly horizontally reverse', (WidgetTester tester) async { testWidgetsWithLeakTracking('DecoratedSliver paints its border correctly horizontally reverse', (WidgetTester tester) async {
const Key key = Key('DecoratedSliver with border'); const Key key = Key('DecoratedSliver with border');
const Color black = Color(0xFF000000); const Color black = Color(0xFF000000);
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Align( child: Align(
...@@ -349,10 +354,11 @@ void main() { ...@@ -349,10 +354,11 @@ void main() {
}); });
testWidgets('DecoratedSliver works with SliverMainAxisGroup', (WidgetTester tester) async { testWidgetsWithLeakTracking('DecoratedSliver works with SliverMainAxisGroup', (WidgetTester tester) async {
const Key key = Key('DecoratedSliver with border'); const Key key = Key('DecoratedSliver with border');
const Color black = Color(0xFF000000); const Color black = Color(0xFF000000);
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Align( child: Align(
...@@ -387,10 +393,11 @@ void main() { ...@@ -387,10 +393,11 @@ void main() {
)); ));
}); });
testWidgets('DecoratedSliver works with SliverCrossAxisGroup', (WidgetTester tester) async { testWidgetsWithLeakTracking('DecoratedSliver works with SliverCrossAxisGroup', (WidgetTester tester) async {
const Key key = Key('DecoratedSliver with border'); const Key key = Key('DecoratedSliver with border');
const Color black = Color(0xFF000000); const Color black = Color(0xFF000000);
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Align( child: Align(
...@@ -425,10 +432,11 @@ void main() { ...@@ -425,10 +432,11 @@ void main() {
)); ));
}); });
testWidgets('DecoratedSliver draws only up to the bottom cache when sliver has infinite scroll extent', (WidgetTester tester) async { testWidgetsWithLeakTracking('DecoratedSliver draws only up to the bottom cache when sliver has infinite scroll extent', (WidgetTester tester) async {
const Key key = Key('DecoratedSliver with border'); const Key key = Key('DecoratedSliver with border');
const Color black = Color(0xFF000000); const Color black = Color(0xFF000000);
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Align( child: Align(
......
...@@ -7,6 +7,7 @@ import 'dart:ui' as ui; ...@@ -7,6 +7,7 @@ import 'dart:ui' as ui;
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';
const double _crispText = 100.0; // this font size is selected to avoid needing any antialiasing. const double _crispText = 100.0; // this font size is selected to avoid needing any antialiasing.
const String _expText = 'Éxp'; // renders in the test font as: const String _expText = 'Éxp'; // renders in the test font as:
...@@ -19,7 +20,7 @@ const String _expText = 'Éxp'; // renders in the test font as: ...@@ -19,7 +20,7 @@ const String _expText = 'Éxp'; // renders in the test font as:
// ÉÉÉÉxxxxpppp // ÉÉÉÉxxxxpppp
void main() { void main() {
testWidgets('Default background', (WidgetTester tester) async { testWidgetsWithLeakTracking('Default background', (WidgetTester tester) async {
await tester.pumpWidget(const Align( await tester.pumpWidget(const Align(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: Text(_expText, textDirection: TextDirection.ltr, style: TextStyle(color: Color(0xFF345678), fontSize: _crispText))), child: Text(_expText, textDirection: TextDirection.ltr, style: TextStyle(color: Color(0xFF345678), fontSize: _crispText))),
...@@ -40,7 +41,7 @@ void main() { ...@@ -40,7 +41,7 @@ void main() {
); );
}, skip: !canCaptureImage); // [intended] Test relies on captureImage, which is not supported on web currently. }, skip: !canCaptureImage); // [intended] Test relies on captureImage, which is not supported on web currently.
testWidgets('Default text color', (WidgetTester tester) async { testWidgetsWithLeakTracking('Default text color', (WidgetTester tester) async {
await tester.pumpWidget(const ColoredBox( await tester.pumpWidget(const ColoredBox(
color: Color(0xFFABCDEF), color: Color(0xFFABCDEF),
child: Align( child: Align(
...@@ -65,8 +66,22 @@ void main() { ...@@ -65,8 +66,22 @@ void main() {
); );
}, skip: !canCaptureImage); // [intended] Test relies on captureImage, which is not supported on web currently. }, skip: !canCaptureImage); // [intended] Test relies on captureImage, which is not supported on web currently.
testWidgets('Default text selection color', (WidgetTester tester) async { testWidgetsWithLeakTracking('Default text selection color', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose);
final OverlayEntry overlayEntry = OverlayEntry(
builder: (BuildContext context) => SelectableRegion(
focusNode: focusNode,
selectionControls: emptyTextSelectionControls,
child: Align(
key: key,
alignment: Alignment.topLeft,
child: const Text('Éxp', textDirection: TextDirection.ltr, style: TextStyle(fontSize: _crispText, color: Color(0xFF000000))),
),
),
);
addTearDown(() => overlayEntry..remove()..dispose());
await tester.pumpWidget( await tester.pumpWidget(
ColoredBox( ColoredBox(
color: const Color(0xFFFFFFFF), color: const Color(0xFFFFFFFF),
...@@ -75,19 +90,7 @@ void main() { ...@@ -75,19 +90,7 @@ void main() {
child: MediaQuery( child: MediaQuery(
data: const MediaQueryData(), data: const MediaQueryData(),
child: Overlay( child: Overlay(
initialEntries: <OverlayEntry>[ initialEntries: <OverlayEntry>[overlayEntry],
OverlayEntry(
builder: (BuildContext context) => SelectableRegion(
focusNode: FocusNode(),
selectionControls: emptyTextSelectionControls,
child: Align(
key: key,
alignment: Alignment.topLeft,
child: const Text('Éxp', textDirection: TextDirection.ltr, style: TextStyle(fontSize: _crispText, color: Color(0xFF000000))),
),
),
),
],
), ),
), ),
), ),
...@@ -132,6 +135,7 @@ Color _getPixel(ByteData bytes, int x, int y, int width) { ...@@ -132,6 +135,7 @@ Color _getPixel(ByteData bytes, int x, int y, int width) {
Future<void> _expectColors(WidgetTester tester, Finder finder, Set<Color> allowedColors, [ Map<Offset, Color>? spotChecks ]) async { Future<void> _expectColors(WidgetTester tester, Finder finder, Set<Color> allowedColors, [ Map<Offset, Color>? spotChecks ]) async {
final TestWidgetsFlutterBinding binding = tester.binding; final TestWidgetsFlutterBinding binding = tester.binding;
final ui.Image image = (await binding.runAsync<ui.Image>(() => captureImage(finder.evaluate().single)))!; final ui.Image image = (await binding.runAsync<ui.Image>(() => captureImage(finder.evaluate().single)))!;
addTearDown(image.dispose);
final ByteData bytes = (await binding.runAsync<ByteData?>(() => image.toByteData(format: ui.ImageByteFormat.rawStraightRgba)))!; final ByteData bytes = (await binding.runAsync<ByteData?>(() => image.toByteData(format: ui.ImageByteFormat.rawStraightRgba)))!;
final Set<int> actualColorValues = <int>{}; final Set<int> actualColorValues = <int>{};
for (int offset = 0; offset < bytes.lengthInBytes; offset += 4) { for (int offset = 0; offset < bytes.lengthInBytes; offset += 4) {
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
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';
void main() { void main() {
testWidgets('Text widget parameter takes precedence over DefaultTextHeightBehavior', (WidgetTester tester) async { testWidgetsWithLeakTracking('Text widget parameter takes precedence over DefaultTextHeightBehavior', (WidgetTester tester) async {
const TextHeightBehavior behavior1 = TextHeightBehavior( const TextHeightBehavior behavior1 = TextHeightBehavior(
applyHeightToLastDescent: false, applyHeightToLastDescent: false,
applyHeightToFirstAscent: false, applyHeightToFirstAscent: false,
...@@ -31,7 +32,7 @@ void main() { ...@@ -31,7 +32,7 @@ void main() {
expect(text.textHeightBehavior, behavior1); expect(text.textHeightBehavior, behavior1);
}); });
testWidgets('DefaultTextStyle.textHeightBehavior takes precedence over DefaultTextHeightBehavior ', (WidgetTester tester) async { testWidgetsWithLeakTracking('DefaultTextStyle.textHeightBehavior takes precedence over DefaultTextHeightBehavior ', (WidgetTester tester) async {
const TextHeightBehavior behavior1 = TextHeightBehavior( const TextHeightBehavior behavior1 = TextHeightBehavior(
applyHeightToLastDescent: false, applyHeightToLastDescent: false,
applyHeightToFirstAscent: false, applyHeightToFirstAscent: false,
...@@ -77,7 +78,7 @@ void main() { ...@@ -77,7 +78,7 @@ void main() {
expect(text.textHeightBehavior, behavior1); expect(text.textHeightBehavior, behavior1);
}); });
testWidgets('DefaultTextHeightBehavior changes propagate to Text', (WidgetTester tester) async { testWidgetsWithLeakTracking('DefaultTextHeightBehavior changes propagate to Text', (WidgetTester tester) async {
const Text textWidget = Text('Hello', textDirection: TextDirection.ltr); const Text textWidget = Text('Hello', textDirection: TextDirection.ltr);
const TextHeightBehavior behavior1 = TextHeightBehavior( const TextHeightBehavior behavior1 = TextHeightBehavior(
applyHeightToLastDescent: false, applyHeightToLastDescent: false,
...@@ -107,7 +108,7 @@ void main() { ...@@ -107,7 +108,7 @@ void main() {
expect(text.textHeightBehavior, behavior2); expect(text.textHeightBehavior, behavior2);
}); });
testWidgets( testWidgetsWithLeakTracking(
'DefaultTextHeightBehavior.of(context) returns null if no ' 'DefaultTextHeightBehavior.of(context) returns null if no '
'DefaultTextHeightBehavior widget in tree', 'DefaultTextHeightBehavior widget in tree',
(WidgetTester tester) async { (WidgetTester tester) async {
......
...@@ -6,9 +6,10 @@ import 'dart:ui' as ui show TextHeightBehavior; ...@@ -6,9 +6,10 @@ import 'dart:ui' as ui show TextHeightBehavior;
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';
void main() { void main() {
testWidgets('DefaultTextStyle changes propagate to Text', (WidgetTester tester) async { testWidgetsWithLeakTracking('DefaultTextStyle changes propagate to Text', (WidgetTester tester) async {
const Text textWidget = Text('Hello', textDirection: TextDirection.ltr); const Text textWidget = Text('Hello', textDirection: TextDirection.ltr);
const TextStyle s1 = TextStyle( const TextStyle s1 = TextStyle(
fontSize: 10.0, fontSize: 10.0,
...@@ -43,7 +44,7 @@ void main() { ...@@ -43,7 +44,7 @@ void main() {
expect(text.maxLines, 3); expect(text.maxLines, 3);
}); });
testWidgets('AnimatedDefaultTextStyle changes propagate to Text', (WidgetTester tester) async { testWidgetsWithLeakTracking('AnimatedDefaultTextStyle changes propagate to Text', (WidgetTester tester) async {
const Text textWidget = Text('Hello', textDirection: TextDirection.ltr); const Text textWidget = Text('Hello', textDirection: TextDirection.ltr);
const TextStyle s1 = TextStyle( const TextStyle s1 = TextStyle(
fontSize: 10.0, fontSize: 10.0,
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
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';
void main() { void main() {
testWidgets('Can call setState from didUpdateWidget', (WidgetTester tester) async { testWidgetsWithLeakTracking('Can call setState from didUpdateWidget', (WidgetTester tester) async {
await tester.pumpWidget(const Directionality( await tester.pumpWidget(const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: WidgetUnderTest(text: 'hello'), child: WidgetUnderTest(text: 'hello'),
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
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';
void main() { void main() {
testWidgets('Directionality', (WidgetTester tester) async { testWidgetsWithLeakTracking('Directionality', (WidgetTester tester) async {
final List<TextDirection> log = <TextDirection>[]; final List<TextDirection> log = <TextDirection>[];
final Widget inner = Builder( final Widget inner = Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
...@@ -51,7 +52,7 @@ void main() { ...@@ -51,7 +52,7 @@ void main() {
expect(log, <TextDirection>[TextDirection.ltr, TextDirection.rtl, TextDirection.ltr]); expect(log, <TextDirection>[TextDirection.ltr, TextDirection.rtl, TextDirection.ltr]);
}); });
testWidgets('Directionality default', (WidgetTester tester) async { testWidgetsWithLeakTracking('Directionality default', (WidgetTester tester) async {
bool good = false; bool good = false;
await tester.pumpWidget(Builder( await tester.pumpWidget(Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
...@@ -63,7 +64,7 @@ void main() { ...@@ -63,7 +64,7 @@ void main() {
expect(good, isTrue); expect(good, isTrue);
}); });
testWidgets('Directionality.maybeOf', (WidgetTester tester) async { testWidgetsWithLeakTracking('Directionality.maybeOf', (WidgetTester tester) async {
final GlobalKey hasDirectionality = GlobalKey(); final GlobalKey hasDirectionality = GlobalKey();
final GlobalKey noDirectionality = GlobalKey(); final GlobalKey noDirectionality = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -81,7 +82,7 @@ void main() { ...@@ -81,7 +82,7 @@ void main() {
expect(Directionality.maybeOf(hasDirectionality.currentContext!), TextDirection.rtl); expect(Directionality.maybeOf(hasDirectionality.currentContext!), TextDirection.rtl);
}); });
testWidgets('Directionality.of', (WidgetTester tester) async { testWidgetsWithLeakTracking('Directionality.of', (WidgetTester tester) async {
final GlobalKey hasDirectionality = GlobalKey(); final GlobalKey hasDirectionality = GlobalKey();
final GlobalKey noDirectionality = GlobalKey(); final GlobalKey noDirectionality = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
......
...@@ -6,10 +6,11 @@ import 'dart:ui'; ...@@ -6,10 +6,11 @@ import 'dart:ui';
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';
void main() { void main() {
group('DisplayFeatureSubScreen', () { group('DisplayFeatureSubScreen', () {
testWidgets('without Directionality or anchor', (WidgetTester tester) async { testWidgetsWithLeakTracking('without Directionality or anchor', (WidgetTester tester) async {
const Key childKey = Key('childKey'); const Key childKey = Key('childKey');
final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith( final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith(
displayFeatures: <DisplayFeature>[ displayFeatures: <DisplayFeature>[
...@@ -37,7 +38,7 @@ void main() { ...@@ -37,7 +38,7 @@ void main() {
expect(message, contains('Directionality')); expect(message, contains('Directionality'));
}); });
testWidgets('with anchorPoint', (WidgetTester tester) async { testWidgetsWithLeakTracking('with anchorPoint', (WidgetTester tester) async {
const Key childKey = Key('childKey'); const Key childKey = Key('childKey');
final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith( final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith(
displayFeatures: <DisplayFeature>[ displayFeatures: <DisplayFeature>[
...@@ -68,7 +69,7 @@ void main() { ...@@ -68,7 +69,7 @@ void main() {
expect(renderBox.localToGlobal(Offset.zero), equals(const Offset(410,0))); expect(renderBox.localToGlobal(Offset.zero), equals(const Offset(410,0)));
}); });
testWidgets('with infinity anchorpoint', (WidgetTester tester) async { testWidgetsWithLeakTracking('with infinity anchorpoint', (WidgetTester tester) async {
const Key childKey = Key('childKey'); const Key childKey = Key('childKey');
final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith( final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith(
displayFeatures: <DisplayFeature>[ displayFeatures: <DisplayFeature>[
...@@ -99,7 +100,7 @@ void main() { ...@@ -99,7 +100,7 @@ void main() {
expect(renderBox.localToGlobal(Offset.zero), equals(const Offset(410,0))); expect(renderBox.localToGlobal(Offset.zero), equals(const Offset(410,0)));
}); });
testWidgets('with horizontal hinge and anchorPoint', (WidgetTester tester) async { testWidgetsWithLeakTracking('with horizontal hinge and anchorPoint', (WidgetTester tester) async {
const Key childKey = Key('childKey'); const Key childKey = Key('childKey');
final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith( final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith(
displayFeatures: <DisplayFeature>[ displayFeatures: <DisplayFeature>[
...@@ -129,7 +130,7 @@ void main() { ...@@ -129,7 +130,7 @@ void main() {
expect(renderBox.localToGlobal(Offset.zero), equals(const Offset(0,310))); expect(renderBox.localToGlobal(Offset.zero), equals(const Offset(0,310)));
}); });
testWidgets('with multiple display features and anchorPoint', (WidgetTester tester) async { testWidgetsWithLeakTracking('with multiple display features and anchorPoint', (WidgetTester tester) async {
const Key childKey = Key('childKey'); const Key childKey = Key('childKey');
final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith( final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith(
displayFeatures: <DisplayFeature>[ displayFeatures: <DisplayFeature>[
...@@ -164,7 +165,7 @@ void main() { ...@@ -164,7 +165,7 @@ void main() {
expect(renderBox.localToGlobal(Offset.zero), equals(const Offset(410,310))); expect(renderBox.localToGlobal(Offset.zero), equals(const Offset(410,310)));
}); });
testWidgets('with non-splitting display features and anchorPoint', (WidgetTester tester) async { testWidgetsWithLeakTracking('with non-splitting display features and anchorPoint', (WidgetTester tester) async {
const Key childKey = Key('childKey'); const Key childKey = Key('childKey');
final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith( final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith(
displayFeatures: <DisplayFeature>[ displayFeatures: <DisplayFeature>[
...@@ -209,7 +210,7 @@ void main() { ...@@ -209,7 +210,7 @@ void main() {
expect(renderBox.localToGlobal(Offset.zero), equals(Offset.zero)); expect(renderBox.localToGlobal(Offset.zero), equals(Offset.zero));
}); });
testWidgets('with size 0 display feature in half-opened posture and anchorPoint', (WidgetTester tester) async { testWidgetsWithLeakTracking('with size 0 display feature in half-opened posture and anchorPoint', (WidgetTester tester) async {
const Key childKey = Key('childKey'); const Key childKey = Key('childKey');
final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith( final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith(
displayFeatures: <DisplayFeature>[ displayFeatures: <DisplayFeature>[
......
...@@ -4,10 +4,11 @@ ...@@ -4,10 +4,11 @@
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';
void main() { void main() {
testWidgets('DisposableBuildContext asserts on disposed state', (WidgetTester tester) async { testWidgetsWithLeakTracking('DisposableBuildContext asserts on disposed state', (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));
......
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