Unverified Commit 56cbf3e1 authored by Kostia Sokolovskyi's avatar Kostia Sokolovskyi Committed by GitHub

Cover more test/widgets tests with leak tracking #5 (#134869)

parent abf8361a
...@@ -1976,9 +1976,7 @@ void main() { ...@@ -1976,9 +1976,7 @@ void main() {
); );
expect(controller.value, <MaterialState>{MaterialState.disabled}); expect(controller.value, <MaterialState>{MaterialState.disabled});
expect(count, 1); expect(count, 1);
}, });
leakTrackingTestConfig: LeakTrackingTestConfig.debugNotDisposed(),
);
} }
......
...@@ -2544,7 +2544,6 @@ void main() { ...@@ -2544,7 +2544,6 @@ void main() {
}); });
testWidgetsWithLeakTracking('Should have only one SnackBar during back swipe navigation', testWidgetsWithLeakTracking('Should have only one SnackBar during back swipe navigation',
leakTrackingTestConfig: LeakTrackingTestConfig.debugNotDisposed(),
(WidgetTester tester) async { (WidgetTester tester) async {
const String snackBarText = 'hello snackbar'; const String snackBarText = 'hello snackbar';
const Key snackTarget = Key('snack-target'); const Key snackTarget = Key('snack-target');
......
...@@ -8,11 +8,12 @@ import 'package:flutter/gestures.dart'; ...@@ -8,11 +8,12 @@ import 'package:flutter/gestures.dart';
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 'gesture_utils.dart'; import 'gesture_utils.dart';
void main() { void main() {
testWidgets('Events bubble up the tree', (WidgetTester tester) async { testWidgetsWithLeakTracking('Events bubble up the tree', (WidgetTester tester) async {
final List<String> log = <String>[]; final List<String> log = <String>[];
await tester.pumpWidget( await tester.pumpWidget(
...@@ -46,7 +47,7 @@ void main() { ...@@ -46,7 +47,7 @@ void main() {
])); ]));
}); });
testWidgets('Detects hover events from touch devices', (WidgetTester tester) async { testWidgetsWithLeakTracking('Detects hover events from touch devices', (WidgetTester tester) async {
final List<String> log = <String>[]; final List<String> log = <String>[];
await tester.pumpWidget( await tester.pumpWidget(
...@@ -74,7 +75,7 @@ void main() { ...@@ -74,7 +75,7 @@ void main() {
}); });
group('transformed events', () { group('transformed events', () {
testWidgets('simple offset for touch/signal', (WidgetTester tester) async { testWidgetsWithLeakTracking('simple offset for touch/signal', (WidgetTester tester) async {
final List<PointerEvent> events = <PointerEvent>[]; final List<PointerEvent> events = <PointerEvent>[];
final Key key = UniqueKey(); final Key key = UniqueKey();
...@@ -145,7 +146,7 @@ void main() { ...@@ -145,7 +146,7 @@ void main() {
expect(events.single.transform, expectedTransform); expect(events.single.transform, expectedTransform);
}); });
testWidgets('scaled for touch/signal', (WidgetTester tester) async { testWidgetsWithLeakTracking('scaled for touch/signal', (WidgetTester tester) async {
final List<PointerEvent> events = <PointerEvent>[]; final List<PointerEvent> events = <PointerEvent>[];
final Key key = UniqueKey(); final Key key = UniqueKey();
...@@ -222,7 +223,7 @@ void main() { ...@@ -222,7 +223,7 @@ void main() {
expect(events.single.transform, expectedTransform); expect(events.single.transform, expectedTransform);
}); });
testWidgets('scaled and offset for touch/signal', (WidgetTester tester) async { testWidgetsWithLeakTracking('scaled and offset for touch/signal', (WidgetTester tester) async {
final List<PointerEvent> events = <PointerEvent>[]; final List<PointerEvent> events = <PointerEvent>[];
final Key key = UniqueKey(); final Key key = UniqueKey();
...@@ -300,7 +301,7 @@ void main() { ...@@ -300,7 +301,7 @@ void main() {
expect(events.single.transform, expectedTransform); expect(events.single.transform, expectedTransform);
}); });
testWidgets('rotated for touch/signal', (WidgetTester tester) async { testWidgetsWithLeakTracking('rotated for touch/signal', (WidgetTester tester) async {
final List<PointerEvent> events = <PointerEvent>[]; final List<PointerEvent> events = <PointerEvent>[];
final Key key = UniqueKey(); final Key key = UniqueKey();
...@@ -378,9 +379,12 @@ void main() { ...@@ -378,9 +379,12 @@ void main() {
}); });
}); });
testWidgets("RenderPointerListener's debugFillProperties when default", (WidgetTester tester) async { testWidgetsWithLeakTracking("RenderPointerListener's debugFillProperties when default", (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
RenderPointerListener().debugFillProperties(builder); final RenderPointerListener renderListener = RenderPointerListener();
addTearDown(renderListener.dispose);
renderListener.debugFillProperties(builder);
final List<String> description = builder.properties final List<String> description = builder.properties
.where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info)) .where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
...@@ -396,9 +400,13 @@ void main() { ...@@ -396,9 +400,13 @@ void main() {
]); ]);
}); });
testWidgets("RenderPointerListener's debugFillProperties when full", (WidgetTester tester) async { testWidgetsWithLeakTracking("RenderPointerListener's debugFillProperties when full", (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
RenderPointerListener(
final RenderErrorBox renderErrorBox = RenderErrorBox();
addTearDown(() => renderErrorBox.dispose());
final RenderPointerListener renderListener = RenderPointerListener(
onPointerDown: (PointerDownEvent event) {}, onPointerDown: (PointerDownEvent event) {},
onPointerUp: (PointerUpEvent event) {}, onPointerUp: (PointerUpEvent event) {},
onPointerMove: (PointerMoveEvent event) {}, onPointerMove: (PointerMoveEvent event) {},
...@@ -406,8 +414,11 @@ void main() { ...@@ -406,8 +414,11 @@ void main() {
onPointerCancel: (PointerCancelEvent event) {}, onPointerCancel: (PointerCancelEvent event) {},
onPointerSignal: (PointerSignalEvent event) {}, onPointerSignal: (PointerSignalEvent event) {},
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
child: RenderErrorBox(), child: renderErrorBox,
).debugFillProperties(builder); );
addTearDown(renderListener.dispose);
renderListener.debugFillProperties(builder);
final List<String> description = builder.properties final List<String> description = builder.properties
.where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info)) .where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
......
...@@ -5,9 +5,10 @@ ...@@ -5,9 +5,10 @@
import 'package:flutter/gestures.dart' show DragStartBehavior; import 'package:flutter/gestures.dart' show DragStartBehavior;
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('ListView.builder() fixed itemExtent, scroll to end, append, scroll', (WidgetTester tester) async { testWidgetsWithLeakTracking('ListView.builder() fixed itemExtent, scroll to end, append, scroll', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/9506 // Regression test for https://github.com/flutter/flutter/issues/9506
Widget buildFrame(int itemCount) { Widget buildFrame(int itemCount) {
...@@ -35,7 +36,7 @@ void main() { ...@@ -35,7 +36,7 @@ void main() {
expect(find.text('item 3'), findsOneWidget); expect(find.text('item 3'), findsOneWidget);
}); });
testWidgets('ListView.builder() fixed itemExtent, scroll to end, append, scroll', (WidgetTester tester) async { testWidgetsWithLeakTracking('ListView.builder() fixed itemExtent, scroll to end, append, scroll', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/9506 // Regression test for https://github.com/flutter/flutter/issues/9506
Widget buildFrame(int itemCount) { Widget buildFrame(int itemCount) {
......
...@@ -6,11 +6,12 @@ import 'dart:async'; ...@@ -6,11 +6,12 @@ import 'dart:async';
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 TestAutomatedTestWidgetsFlutterBinding binding = TestAutomatedTestWidgetsFlutterBinding(); final TestAutomatedTestWidgetsFlutterBinding binding = TestAutomatedTestWidgetsFlutterBinding();
testWidgets('Locale is available when Localizations widget stops deferring frames', (WidgetTester tester) async { testWidgetsWithLeakTracking('Locale is available when Localizations widget stops deferring frames', (WidgetTester tester) async {
final FakeLocalizationsDelegate delegate = FakeLocalizationsDelegate(); final FakeLocalizationsDelegate delegate = FakeLocalizationsDelegate();
await tester.pumpWidget(Localizations( await tester.pumpWidget(Localizations(
locale: const Locale('fo'), locale: const Locale('fo'),
...@@ -37,7 +38,7 @@ void main() { ...@@ -37,7 +38,7 @@ void main() {
expect(find.text('loaded'), findsOneWidget); expect(find.text('loaded'), findsOneWidget);
}); });
testWidgets('Localizations.localeOf throws when no localizations exist', (WidgetTester tester) async { testWidgetsWithLeakTracking('Localizations.localeOf throws when no localizations exist', (WidgetTester tester) async {
final GlobalKey contextKey = GlobalKey(debugLabel: 'Test Key'); final GlobalKey contextKey = GlobalKey(debugLabel: 'Test Key');
await tester.pumpWidget(Container(key: contextKey)); await tester.pumpWidget(Container(key: contextKey));
...@@ -48,7 +49,7 @@ void main() { ...@@ -48,7 +49,7 @@ void main() {
))); )));
}); });
testWidgets('Localizations.maybeLocaleOf returns null when no localizations exist', (WidgetTester tester) async { testWidgetsWithLeakTracking('Localizations.maybeLocaleOf returns null when no localizations exist', (WidgetTester tester) async {
final GlobalKey contextKey = GlobalKey(debugLabel: 'Test Key'); final GlobalKey contextKey = GlobalKey(debugLabel: 'Test Key');
await tester.pumpWidget(Container(key: contextKey)); await tester.pumpWidget(Container(key: contextKey));
......
...@@ -9,6 +9,7 @@ import 'package:fake_async/fake_async.dart'; ...@@ -9,6 +9,7 @@ import 'package:fake_async/fake_async.dart';
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';
class _MockAnimationController extends AnimationController { class _MockAnimationController extends AnimationController {
_MockAnimationController() _MockAnimationController()
...@@ -42,7 +43,7 @@ void main() { ...@@ -42,7 +43,7 @@ void main() {
} }
group('Raw Magnifier', () { group('Raw Magnifier', () {
testWidgets('should render with correct focal point and decoration', testWidgetsWithLeakTracking('should render with correct focal point and decoration',
(WidgetTester tester) async { (WidgetTester tester) async {
final Key appKey = UniqueKey(); final Key appKey = UniqueKey();
const Size magnifierSize = Size(100, 100); const Size magnifierSize = Size(100, 100);
...@@ -116,7 +117,7 @@ void main() { ...@@ -116,7 +117,7 @@ void main() {
magnifierController.removeFromOverlay(); magnifierController.removeFromOverlay();
}); });
testWidgets( testWidgetsWithLeakTracking(
'should immediately remove from overlay on no animation controller', 'should immediately remove from overlay on no animation controller',
(WidgetTester tester) async { (WidgetTester tester) async {
await runFakeAsync((FakeAsync async) async { await runFakeAsync((FakeAsync async) async {
...@@ -149,7 +150,7 @@ void main() { ...@@ -149,7 +150,7 @@ void main() {
}); });
}); });
testWidgets('should update shown based on animation status', testWidgetsWithLeakTracking('should update shown based on animation status',
(WidgetTester tester) async { (WidgetTester tester) async {
await runFakeAsync((FakeAsync async) async { await runFakeAsync((FakeAsync async) async {
final MagnifierController magnifierController = final MagnifierController magnifierController =
...@@ -214,7 +215,7 @@ void main() { ...@@ -214,7 +215,7 @@ void main() {
}); });
group('show', () { group('show', () {
testWidgets('should insert below below widget', (WidgetTester tester) async { testWidgetsWithLeakTracking('should insert below below widget', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp( await tester.pumpWidget(const MaterialApp(
home: Text('text'), home: Text('text'),
)); ));
...@@ -226,6 +227,7 @@ void main() { ...@@ -226,6 +227,7 @@ void main() {
final OverlayEntry fakeBeforeOverlayEntry = final OverlayEntry fakeBeforeOverlayEntry =
OverlayEntry(builder: (_) => fakeBefore); OverlayEntry(builder: (_) => fakeBefore);
addTearDown(() => fakeBeforeOverlayEntry..remove()..dispose());
Overlay.of(context).insert(fakeBeforeOverlayEntry); Overlay.of(context).insert(fakeBeforeOverlayEntry);
magnifierController.show( magnifierController.show(
...@@ -247,7 +249,7 @@ void main() { ...@@ -247,7 +249,7 @@ void main() {
expect(allOverlayChildren.first.widget.key, fakeMagnifier.key); expect(allOverlayChildren.first.widget.key, fakeMagnifier.key);
}); });
testWidgets('should insert newly built widget without animating out if overlay != null', testWidgetsWithLeakTracking('should insert newly built widget without animating out if overlay != null',
(WidgetTester tester) async { (WidgetTester tester) async {
await runFakeAsync((FakeAsync async) async { await runFakeAsync((FakeAsync async) async {
final _MockAnimationController animationController = final _MockAnimationController animationController =
......
...@@ -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('setState can be called from build, initState, didChangeDependencies, and didUpdateWidget', (WidgetTester tester) async { testWidgetsWithLeakTracking('setState can be called from build, initState, didChangeDependencies, and didUpdateWidget', (WidgetTester tester) async {
// Initial build. // Initial build.
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
......
...@@ -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('runApp uses deprecated pipelineOwner and renderView', (WidgetTester tester) async { testWidgetsWithLeakTracking('runApp uses deprecated pipelineOwner and renderView', (WidgetTester tester) async {
runApp(const SizedBox()); runApp(const SizedBox());
final RenderObject renderObject = tester.renderObject(find.byType(SizedBox)); final RenderObject renderObject = tester.renderObject(find.byType(SizedBox));
...@@ -21,7 +22,7 @@ void main() { ...@@ -21,7 +22,7 @@ void main() {
expect(renderObject.owner, equals(tester.binding.pipelineOwner)); expect(renderObject.owner, equals(tester.binding.pipelineOwner));
}); });
testWidgets('can manually attach RootWidget to build owner', (WidgetTester tester) async { testWidgetsWithLeakTracking('can manually attach RootWidget to build owner', (WidgetTester tester) async {
expect(find.byType(ColoredBox), findsNothing); expect(find.byType(ColoredBox), findsNothing);
final RootWidget rootWidget = RootWidget( final RootWidget rootWidget = RootWidget(
......
...@@ -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('Widgets in view update as expected', (WidgetTester tester) async { testWidgetsWithLeakTracking('Widgets in view update as expected', (WidgetTester tester) async {
final Widget widget = View( final Widget widget = View(
view: tester.view, view: tester.view,
child: const TestWidget(), child: const TestWidget(),
...@@ -49,7 +50,7 @@ void main() { ...@@ -49,7 +50,7 @@ void main() {
expect(tester.renderObject<RenderParagraph>(find.byType(Text)).text.toPlainText(), 'FooBar'); expect(tester.renderObject<RenderParagraph>(find.byType(Text)).text.toPlainText(), 'FooBar');
}); });
testWidgets('Views in ViewCollection update as expected', (WidgetTester tester) async { testWidgetsWithLeakTracking('Views in ViewCollection update as expected', (WidgetTester tester) async {
Iterable<String> renderParagraphTexts() { Iterable<String> renderParagraphTexts() {
return tester.renderObjectList<RenderParagraph>(find.byType(Text)).map((RenderParagraph r) => r.text.toPlainText()); return tester.renderObjectList<RenderParagraph>(find.byType(Text)).map((RenderParagraph r) => r.text.toPlainText());
} }
...@@ -103,7 +104,7 @@ void main() { ...@@ -103,7 +104,7 @@ void main() {
expect(renderParagraphTexts(), <String>['Guten', 'Morgen']); expect(renderParagraphTexts(), <String>['Guten', 'Morgen']);
}); });
testWidgets('Views in ViewAnchor update as expected', (WidgetTester tester) async { testWidgetsWithLeakTracking('Views in ViewAnchor update as expected', (WidgetTester tester) async {
Iterable<String> renderParagraphTexts() { Iterable<String> renderParagraphTexts() {
return tester.renderObjectList<RenderParagraph>(find.byType(Text)).map((RenderParagraph r) => r.text.toPlainText()); return tester.renderObjectList<RenderParagraph>(find.byType(Text)).map((RenderParagraph r) => r.text.toPlainText());
} }
......
...@@ -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 'test_widgets.dart'; import 'test_widgets.dart';
...@@ -32,7 +33,7 @@ void checkTree(WidgetTester tester, List<BoxDecoration> expectedDecorations) { ...@@ -32,7 +33,7 @@ void checkTree(WidgetTester tester, List<BoxDecoration> expectedDecorations) {
} }
void main() { void main() {
testWidgets('MultiChildRenderObjectElement control test', (WidgetTester tester) async { testWidgetsWithLeakTracking('MultiChildRenderObjectElement control test', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Stack( const Stack(
...@@ -117,7 +118,7 @@ void main() { ...@@ -117,7 +118,7 @@ void main() {
}); });
testWidgets('MultiChildRenderObjectElement with stateless widgets', (WidgetTester tester) async { testWidgetsWithLeakTracking('MultiChildRenderObjectElement with stateless widgets', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Stack( const Stack(
...@@ -243,7 +244,7 @@ void main() { ...@@ -243,7 +244,7 @@ void main() {
checkTree(tester, <BoxDecoration>[]); checkTree(tester, <BoxDecoration>[]);
}); });
testWidgets('MultiChildRenderObjectElement with stateful widgets', (WidgetTester tester) async { testWidgetsWithLeakTracking('MultiChildRenderObjectElement with stateful widgets', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Stack( const Stack(
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('Render and element tree stay in sync when keyed children move around', (WidgetTester tester) async { testWidgetsWithLeakTracking('Render and element tree stay in sync when keyed children move around', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/48855. // Regression test for https://github.com/flutter/flutter/issues/48855.
await tester.pumpWidget( await tester.pumpWidget(
...@@ -59,7 +60,7 @@ void main() { ...@@ -59,7 +60,7 @@ void main() {
); );
}); });
testWidgets('Building a new MultiChildRenderObjectElement with children having duplicated keys throws', (WidgetTester tester) async { testWidgetsWithLeakTracking('Building a new MultiChildRenderObjectElement with children having duplicated keys throws', (WidgetTester tester) async {
const ValueKey<int> duplicatedKey = ValueKey<int>(1); const ValueKey<int> duplicatedKey = ValueKey<int>(1);
await tester.pumpWidget(const Column( await tester.pumpWidget(const Column(
...@@ -79,7 +80,7 @@ void main() { ...@@ -79,7 +80,7 @@ void main() {
); );
}); });
testWidgets('Updating a MultiChildRenderObjectElement to have children with duplicated keys throws', (WidgetTester tester) async { testWidgetsWithLeakTracking('Updating a MultiChildRenderObjectElement to have children with duplicated keys throws', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/81541 // Regression test for https://github.com/flutter/flutter/issues/81541
const ValueKey<int> key1 = ValueKey<int>(1); const ValueKey<int> key1 = ValueKey<int>(1);
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
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 'test_widgets.dart'; import 'test_widgets.dart';
...@@ -26,7 +27,7 @@ class TestCustomPainter extends CustomPainter { ...@@ -26,7 +27,7 @@ class TestCustomPainter extends CustomPainter {
} }
void main() { void main() {
testWidgets('Do we paint when coming back from a navigation', (WidgetTester tester) async { testWidgetsWithLeakTracking('Do we paint when coming back from a navigation', (WidgetTester tester) async {
final List<String> log = <String>[]; final List<String> log = <String>[];
log.add('0'); log.add('0');
await tester.pumpWidget( await tester.pumpWidget(
......
...@@ -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 'observer_tester.dart'; import 'observer_tester.dart';
void main() { void main() {
testWidgets('Back during pushReplacement', (WidgetTester tester) async { testWidgetsWithLeakTracking('Back during pushReplacement', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: const Material(child: Text('home')), home: const Material(child: Text('home')),
routes: <String, WidgetBuilder>{ routes: <String, WidgetBuilder>{
...@@ -42,7 +43,7 @@ void main() { ...@@ -42,7 +43,7 @@ void main() {
}); });
group('pushAndRemoveUntil', () { group('pushAndRemoveUntil', () {
testWidgets('notifies appropriately', (WidgetTester tester) async { testWidgetsWithLeakTracking('notifies appropriately', (WidgetTester tester) async {
final TestObserver observer = TestObserver(); final TestObserver observer = TestObserver();
final Widget myApp = MaterialApp( final Widget myApp = MaterialApp(
home: const Material(child: Text('home')), home: const Material(child: Text('home')),
...@@ -110,7 +111,7 @@ void main() { ...@@ -110,7 +111,7 @@ void main() {
])); ]));
}); });
testWidgets('triggers page transition animation for pushed route', (WidgetTester tester) async { testWidgetsWithLeakTracking('triggers page transition animation for pushed route', (WidgetTester tester) async {
final Widget myApp = MaterialApp( final Widget myApp = MaterialApp(
home: const Material(child: Text('home')), home: const Material(child: Text('home')),
routes: <String, WidgetBuilder>{ routes: <String, WidgetBuilder>{
...@@ -139,7 +140,7 @@ void main() { ...@@ -139,7 +140,7 @@ void main() {
expect(find.text('b'), findsOneWidget); expect(find.text('b'), findsOneWidget);
}); });
testWidgets('Hero transition triggers when preceding route contains hero, and predicate route does not', (WidgetTester tester) async { testWidgetsWithLeakTracking('Hero transition triggers when preceding route contains hero, and predicate route does not', (WidgetTester tester) async {
const String kHeroTag = 'hero'; const String kHeroTag = 'hero';
final Widget myApp = MaterialApp( final Widget myApp = MaterialApp(
initialRoute: '/', initialRoute: '/',
...@@ -184,7 +185,7 @@ void main() { ...@@ -184,7 +185,7 @@ void main() {
expect(find.text('b'), isOnstage); expect(find.text('b'), isOnstage);
}); });
testWidgets('Hero transition does not trigger when preceding route does not contain hero, but predicate route does', (WidgetTester tester) async { testWidgetsWithLeakTracking('Hero transition does not trigger when preceding route does not contain hero, but predicate route does', (WidgetTester tester) async {
const String kHeroTag = 'hero'; const String kHeroTag = 'hero';
final Widget myApp = MaterialApp( final Widget myApp = MaterialApp(
theme: ThemeData( theme: ThemeData(
......
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