Unverified Commit 7d0c9b72 authored by Kostia Sokolovskyi's avatar Kostia Sokolovskyi Committed by GitHub

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

parent 083ac65c
......@@ -306,7 +306,7 @@ void main() {
expect(find.text('popped'), findsOneWidget);
},
leakTrackingTestConfig: const LeakTrackingTestConfig(
// TODO(someone): remove after fixing
// TODO(ksokolovskyi): remove after fixing
// https://github.com/flutter/flutter/issues/134205
notDisposedAllowList: <String, int?> {'_RestorableRouteInformation': 1},
));
......@@ -338,7 +338,7 @@ void main() {
expect(find.text('popped'), findsOneWidget);
},
leakTrackingTestConfig: const LeakTrackingTestConfig(
// TODO(someone): remove after fixing
// TODO(ksokolovskyi): remove after fixing
// https://github.com/flutter/flutter/issues/134205
notDisposedAllowList: <String, int?> {'_RestorableRouteInformation': 1},
));
......@@ -434,7 +434,7 @@ void main() {
expect(find.text('popped'), findsOneWidget);
},
leakTrackingTestConfig: const LeakTrackingTestConfig(
// TODO(someone): remove after fixing
// TODO(ksokolovskyi): remove after fixing
// https://github.com/flutter/flutter/issues/134205
notDisposedAllowList: <String, int?> {'_RestorableRouteInformation': 1},
));
......@@ -455,7 +455,7 @@ void main() {
expect(find.text('/'), findsOneWidget);
},
leakTrackingTestConfig: const LeakTrackingTestConfig(
// TODO(someone): remove after fixing
// TODO(ksokolovskyi): remove after fixing
// https://github.com/flutter/flutter/issues/134205
notDisposedAllowList: <String, int?> {'_RestorableRouteInformation': 1},
));
......
......@@ -8,12 +8,13 @@ import 'package:flutter/gestures.dart' show DragStartBehavior;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'semantics_tester.dart';
void main() {
testWidgets('Drawer control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer control test', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
late BuildContext savedContext;
await tester.pumpWidget(
......@@ -44,7 +45,7 @@ void main() {
expect(find.text('drawer'), findsNothing);
});
testWidgets('Drawer tap test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer tap test', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
await tester.pumpWidget(
MaterialApp(
......@@ -76,7 +77,7 @@ void main() {
expect(find.text('drawer'), findsNothing);
});
testWidgets('Drawer hover test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer hover test', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
final List<String> logs = <String>[];
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
......@@ -146,7 +147,7 @@ void main() {
logs.clear();
});
testWidgets('Drawer drag cancel resume (LTR)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer drag cancel resume (LTR)', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
await tester.pumpWidget(
MaterialApp(
......@@ -197,7 +198,7 @@ void main() {
await gesture.up();
});
testWidgets('Drawer drag cancel resume (RTL)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer drag cancel resume (RTL)', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
await tester.pumpWidget(
MaterialApp(
......@@ -251,7 +252,7 @@ void main() {
await gesture.up();
});
testWidgets('Drawer navigator back button', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer navigator back button', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
bool buttonPressed = false;
......@@ -299,7 +300,7 @@ void main() {
expect(buttonPressed, equals(true));
});
testWidgets('Dismissible ModalBarrier includes button in semantic tree', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Dismissible ModalBarrier includes button in semantic tree', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
......@@ -326,7 +327,7 @@ void main() {
semantics.dispose();
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('Dismissible ModalBarrier is hidden on Android (back button is used to dismiss)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Dismissible ModalBarrier is hidden on Android (back button is used to dismiss)', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
......@@ -354,7 +355,7 @@ void main() {
semantics.dispose();
}, variant: TargetPlatformVariant.only(TargetPlatform.android));
testWidgets('Drawer contains route semantics flags', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer contains route semantics flags', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
......
......@@ -4,13 +4,15 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('runs animations', (WidgetTester tester) async {
testWidgetsWithLeakTracking('runs animations', (WidgetTester tester) async {
final AnimationController controller = AnimationController(
vsync: const TestVSync(),
duration: const Duration(milliseconds: 300),
);
addTearDown(controller.dispose);
await tester.pumpWidget(Center(
child: DualTransitionBuilder(
......@@ -74,11 +76,12 @@ void main() {
expect(_getOpacity(tester), 1.0);
});
testWidgets('keeps state', (WidgetTester tester) async {
testWidgetsWithLeakTracking('keeps state', (WidgetTester tester) async {
final AnimationController controller = AnimationController(
vsync: const TestVSync(),
duration: const Duration(milliseconds: 300),
);
addTearDown(controller.dispose);
await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr,
......@@ -138,11 +141,13 @@ void main() {
expect(state, same(tester.state(find.byType(_StatefulTestWidget))));
});
testWidgets('does not jump when interrupted - forward', (WidgetTester tester) async {
testWidgetsWithLeakTracking('does not jump when interrupted - forward', (WidgetTester tester) async {
final AnimationController controller = AnimationController(
vsync: const TestVSync(),
duration: const Duration(milliseconds: 300),
);
addTearDown(controller.dispose);
await tester.pumpWidget(Center(
child: DualTransitionBuilder(
animation: controller,
......@@ -202,12 +207,14 @@ void main() {
expect(_getOpacity(tester), 1.0);
});
testWidgets('does not jump when interrupted - reverse', (WidgetTester tester) async {
testWidgetsWithLeakTracking('does not jump when interrupted - reverse', (WidgetTester tester) async {
final AnimationController controller = AnimationController(
value: 1.0,
vsync: const TestVSync(),
duration: const Duration(milliseconds: 300),
);
addTearDown(controller.dispose);
await tester.pumpWidget(Center(
child: DualTransitionBuilder(
animation: controller,
......
......@@ -7,6 +7,7 @@ import 'dart:math' as math;
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
Finder findKey(int i) => find.byKey(ValueKey<int>(i), skipOffstage: false);
......@@ -68,7 +69,7 @@ Widget buildListView(Axis scrollDirection, { bool reverse = false, bool shrinkWr
void main() {
group('SingleChildScrollView', () {
testWidgets('SingleChildScrollView ensureVisible Axis.vertical', (WidgetTester tester) async {
testWidgetsWithLeakTracking('SingleChildScrollView ensureVisible Axis.vertical', (WidgetTester tester) async {
BuildContext findContext(int i) => tester.element(findKey(i));
await tester.pumpWidget(buildSingleChildScrollView(Axis.vertical));
......@@ -95,7 +96,7 @@ void main() {
expect(tester.getTopLeft(findKey(3)).dy, equals(100.0));
});
testWidgets('SingleChildScrollView ensureVisible Axis.horizontal', (WidgetTester tester) async {
testWidgetsWithLeakTracking('SingleChildScrollView ensureVisible Axis.horizontal', (WidgetTester tester) async {
BuildContext findContext(int i) => tester.element(findKey(i));
await tester.pumpWidget(buildSingleChildScrollView(Axis.horizontal));
......@@ -122,7 +123,7 @@ void main() {
expect(tester.getTopLeft(findKey(3)).dx, equals(100.0));
});
testWidgets('SingleChildScrollView ensureVisible Axis.vertical reverse', (WidgetTester tester) async {
testWidgetsWithLeakTracking('SingleChildScrollView ensureVisible Axis.vertical reverse', (WidgetTester tester) async {
BuildContext findContext(int i) => tester.element(findKey(i));
await tester.pumpWidget(buildSingleChildScrollView(Axis.vertical, reverse: true));
......@@ -190,7 +191,7 @@ void main() {
expect(tester.getBottomLeft(findKey(6)).dy, equals(500.0));
});
testWidgets('SingleChildScrollView ensureVisible Axis.horizontal reverse', (WidgetTester tester) async {
testWidgetsWithLeakTracking('SingleChildScrollView ensureVisible Axis.horizontal reverse', (WidgetTester tester) async {
BuildContext findContext(int i) => tester.element(findKey(i));
await tester.pumpWidget(buildSingleChildScrollView(Axis.horizontal, reverse: true));
......@@ -263,7 +264,7 @@ void main() {
expect(tester.getBottomLeft(findKey(6)).dx, equals(500.0));
});
testWidgets('SingleChildScrollView ensureVisible rotated child', (WidgetTester tester) async {
testWidgetsWithLeakTracking('SingleChildScrollView ensureVisible rotated child', (WidgetTester tester) async {
BuildContext findContext(int i) => tester.element(findKey(i));
await tester.pumpWidget(
......@@ -310,7 +311,7 @@ void main() {
expect(tester.getTopLeft(findKey(0)).dy, moreOrLessEquals(500.0, epsilon: 0.1));
});
testWidgets('Nested SingleChildScrollView ensureVisible behavior test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Nested SingleChildScrollView ensureVisible behavior test', (WidgetTester tester) async {
// Regressing test for https://github.com/flutter/flutter/issues/65100
Finder findKey(String coordinate) => find.byKey(ValueKey<String>(coordinate));
BuildContext findContext(String coordinate) => tester.element(findKey(coordinate));
......@@ -388,7 +389,7 @@ void main() {
});
group('ListView', () {
testWidgets('ListView ensureVisible Axis.vertical', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ListView ensureVisible Axis.vertical', (WidgetTester tester) async {
BuildContext findContext(int i) => tester.element(findKey(i));
Future<void> prepare(double offset) async {
tester.state<ScrollableState>(find.byType(Scrollable)).position.jumpTo(offset);
......@@ -424,7 +425,7 @@ void main() {
expect(tester.getTopLeft(findKey(3)).dy, equals(100.0));
});
testWidgets('ListView ensureVisible Axis.horizontal', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ListView ensureVisible Axis.horizontal', (WidgetTester tester) async {
BuildContext findContext(int i) => tester.element(findKey(i));
Future<void> prepare(double offset) async {
tester.state<ScrollableState>(find.byType(Scrollable)).position.jumpTo(offset);
......@@ -460,7 +461,7 @@ void main() {
expect(tester.getTopLeft(findKey(3)).dx, equals(100.0));
});
testWidgets('ListView ensureVisible Axis.vertical reverse', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ListView ensureVisible Axis.vertical reverse', (WidgetTester tester) async {
BuildContext findContext(int i) => tester.element(findKey(i));
Future<void> prepare(double offset) async {
tester.state<ScrollableState>(find.byType(Scrollable)).position.jumpTo(offset);
......@@ -536,7 +537,7 @@ void main() {
expect(tester.getBottomLeft(findKey(0)).dy, equals(500.0));
});
testWidgets('ListView ensureVisible Axis.horizontal reverse', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ListView ensureVisible Axis.horizontal reverse', (WidgetTester tester) async {
BuildContext findContext(int i) => tester.element(findKey(i));
Future<void> prepare(double offset) async {
tester.state<ScrollableState>(find.byType(Scrollable)).position.jumpTo(offset);
......@@ -617,7 +618,7 @@ void main() {
expect(tester.getBottomLeft(findKey(0)).dx, equals(500.0));
});
testWidgets('ListView ensureVisible negative child', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ListView ensureVisible negative child', (WidgetTester tester) async {
BuildContext findContext(int i) => tester.element(findKey(i));
Future<void> prepare(double offset) async {
tester.state<ScrollableState>(find.byType(Scrollable)).position.jumpTo(offset);
......@@ -675,7 +676,7 @@ void main() {
expect(getOffset(), equals(-400.0));
});
testWidgets('ListView ensureVisible rotated child', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ListView ensureVisible rotated child', (WidgetTester tester) async {
BuildContext findContext(int i) => tester.element(findKey(i));
Future<void> prepare(double offset) async {
tester.state<ScrollableState>(find.byType(Scrollable)).position.jumpTo(offset);
......@@ -728,7 +729,7 @@ void main() {
});
group('ListView shrinkWrap', () {
testWidgets('ListView ensureVisible Axis.vertical', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ListView ensureVisible Axis.vertical', (WidgetTester tester) async {
BuildContext findContext(int i) => tester.element(findKey(i));
Future<void> prepare(double offset) async {
tester.state<ScrollableState>(find.byType(Scrollable)).position.jumpTo(offset);
......@@ -764,7 +765,7 @@ void main() {
expect(tester.getTopLeft(findKey(3)).dy, equals(100.0));
});
testWidgets('ListView ensureVisible Axis.horizontal', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ListView ensureVisible Axis.horizontal', (WidgetTester tester) async {
BuildContext findContext(int i) => tester.element(findKey(i));
Future<void> prepare(double offset) async {
tester.state<ScrollableState>(find.byType(Scrollable)).position.jumpTo(offset);
......@@ -800,7 +801,7 @@ void main() {
expect(tester.getTopLeft(findKey(3)).dx, equals(100.0));
});
testWidgets('ListView ensureVisible Axis.vertical reverse', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ListView ensureVisible Axis.vertical reverse', (WidgetTester tester) async {
BuildContext findContext(int i) => tester.element(findKey(i));
Future<void> prepare(double offset) async {
tester.state<ScrollableState>(find.byType(Scrollable)).position.jumpTo(offset);
......@@ -876,7 +877,7 @@ void main() {
expect(tester.getBottomLeft(findKey(0)).dy, equals(500.0));
});
testWidgets('ListView ensureVisible Axis.horizontal reverse', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ListView ensureVisible Axis.horizontal reverse', (WidgetTester tester) async {
BuildContext findContext(int i) => tester.element(findKey(i));
Future<void> prepare(double offset) async {
tester.state<ScrollableState>(find.byType(Scrollable)).position.jumpTo(offset);
......@@ -959,7 +960,7 @@ void main() {
});
group('Scrollable with center', () {
testWidgets('ensureVisible', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ensureVisible', (WidgetTester tester) async {
BuildContext findContext(int i) => tester.element(findKey(i));
Future<void> prepare(double offset) async {
tester.state<ScrollableState>(find.byType(Scrollable)).position.jumpTo(offset);
......
......@@ -4,9 +4,10 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('ErrorWidget.builder', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ErrorWidget.builder', (WidgetTester tester) async {
final ErrorWidgetBuilder oldBuilder = ErrorWidget.builder;
ErrorWidget.builder = (FlutterErrorDetails details) {
return const Text('oopsie!', textDirection: TextDirection.ltr);
......@@ -25,7 +26,7 @@ void main() {
ErrorWidget.builder = oldBuilder;
});
testWidgets('ErrorWidget.builder', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ErrorWidget.builder', (WidgetTester tester) async {
final ErrorWidgetBuilder oldBuilder = ErrorWidget.builder;
ErrorWidget.builder = (FlutterErrorDetails details) {
return ErrorWidget('');
......
......@@ -8,6 +8,7 @@ import 'dart:ui' as ui;
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../image_data.dart';
import '../painting/image_test_utils.dart';
......@@ -90,14 +91,26 @@ FadeInImageParts findFadeInImage(WidgetTester tester) {
}
}
Future<void> main() async {
void main() {
// These must run outside test zone to complete
final ui.Image targetImage = await createTestImage();
final ui.Image placeholderImage = await createTestImage();
final ui.Image replacementImage = await createTestImage();
late final ui.Image targetImage;
late final ui.Image placeholderImage;
late final ui.Image replacementImage;
setUpAll(() async {
targetImage = await createTestImage();
placeholderImage = await createTestImage();
replacementImage = await createTestImage();
});
tearDownAll(() {
targetImage.dispose();
placeholderImage.dispose();
replacementImage.dispose();
});
group('FadeInImage', () {
testWidgets('animates an uncached image', (WidgetTester tester) async {
testWidgetsWithLeakTracking('animates an uncached image', (WidgetTester tester) async {
final TestImageProvider placeholderProvider = TestImageProvider(placeholderImage);
final TestImageProvider imageProvider = TestImageProvider(targetImage);
......@@ -147,7 +160,7 @@ Future<void> main() async {
expect(findFadeInImage(tester).target.opacity, 1);
});
testWidgets("FadeInImage's image obeys gapless playback", (WidgetTester tester) async {
testWidgetsWithLeakTracking("FadeInImage's image obeys gapless playback", (WidgetTester tester) async {
final TestImageProvider placeholderProvider = TestImageProvider(placeholderImage);
final TestImageProvider imageProvider = TestImageProvider(targetImage);
final TestImageProvider secondImageProvider = TestImageProvider(replacementImage);
......@@ -188,7 +201,7 @@ Future<void> main() async {
});
// Regression test for https://github.com/flutter/flutter/issues/111011
testWidgets("FadeInImage's image obeys gapless playback when first image is cached but second isn't",
testWidgetsWithLeakTracking("FadeInImage's image obeys gapless playback when first image is cached but second isn't",
(WidgetTester tester) async {
final TestImageProvider placeholderProvider = TestImageProvider(placeholderImage);
final TestImageProvider imageProvider = TestImageProvider(targetImage);
......@@ -225,7 +238,7 @@ Future<void> main() async {
expect(parts.target.opacity, 1);
});
testWidgets("FadeInImage's placeholder obeys gapless playback", (WidgetTester tester) async {
testWidgetsWithLeakTracking("FadeInImage's placeholder obeys gapless playback", (WidgetTester tester) async {
final TestImageProvider placeholderProvider = TestImageProvider(placeholderImage);
final TestImageProvider secondPlaceholderProvider = TestImageProvider(replacementImage);
final TestImageProvider imageProvider = TestImageProvider(targetImage);
......@@ -261,7 +274,7 @@ Future<void> main() async {
expect(parts.placeholder!.opacity, 1);
});
testWidgets('shows a cached image immediately when skipFadeOnSynchronousLoad=true', (WidgetTester tester) async {
testWidgetsWithLeakTracking('shows a cached image immediately when skipFadeOnSynchronousLoad=true', (WidgetTester tester) async {
final TestImageProvider placeholderProvider = TestImageProvider(placeholderImage);
final TestImageProvider imageProvider = TestImageProvider(targetImage);
imageProvider.resolve(ImageConfiguration.empty);
......@@ -277,7 +290,7 @@ Future<void> main() async {
expect(findFadeInImage(tester).target.opacity, 1);
});
testWidgets('handles updating the placeholder image', (WidgetTester tester) async {
testWidgetsWithLeakTracking('handles updating the placeholder image', (WidgetTester tester) async {
final TestImageProvider placeholderProvider = TestImageProvider(placeholderImage);
final TestImageProvider secondPlaceholderProvider = TestImageProvider(replacementImage);
final TestImageProvider imageProvider = TestImageProvider(targetImage);
......@@ -309,7 +322,7 @@ Future<void> main() async {
expect(findFadeInImage(tester).state, same(state));
});
testWidgets('does not keep the placeholder in the tree if it is invisible', (WidgetTester tester) async {
testWidgetsWithLeakTracking('does not keep the placeholder in the tree if it is invisible', (WidgetTester tester) async {
final TestImageProvider placeholderProvider = TestImageProvider(placeholderImage);
final TestImageProvider imageProvider = TestImageProvider(targetImage);
......@@ -331,7 +344,7 @@ Future<void> main() async {
expect(find.byType(Image), findsOneWidget);
});
testWidgets("doesn't interrupt in-progress animation when animation values are updated", (WidgetTester tester) async {
testWidgetsWithLeakTracking("doesn't interrupt in-progress animation when animation values are updated", (WidgetTester tester) async {
final TestImageProvider placeholderProvider = TestImageProvider(placeholderImage);
final TestImageProvider imageProvider = TestImageProvider(targetImage);
......@@ -434,7 +447,7 @@ Future<void> main() async {
});
group('semantics', () {
testWidgets('only one Semantics node appears within FadeInImage', (WidgetTester tester) async {
testWidgetsWithLeakTracking('only one Semantics node appears within FadeInImage', (WidgetTester tester) async {
final TestImageProvider placeholderProvider = TestImageProvider(placeholderImage);
final TestImageProvider imageProvider = TestImageProvider(targetImage);
......@@ -446,7 +459,7 @@ Future<void> main() async {
expect(find.byType(Semantics), findsOneWidget);
});
testWidgets('is excluded if excludeFromSemantics is true', (WidgetTester tester) async {
testWidgetsWithLeakTracking('is excluded if excludeFromSemantics is true', (WidgetTester tester) async {
final TestImageProvider placeholderProvider = TestImageProvider(placeholderImage);
final TestImageProvider imageProvider = TestImageProvider(targetImage);
......@@ -462,7 +475,7 @@ Future<void> main() async {
group('label', () {
const String imageSemanticText = 'Test image semantic label';
testWidgets('defaults to image label if placeholder label is unspecified', (WidgetTester tester) async {
testWidgetsWithLeakTracking('defaults to image label if placeholder label is unspecified', (WidgetTester tester) async {
Semantics semanticsWidget() => tester.widget(find.byType(Semantics));
final TestImageProvider placeholderProvider = TestImageProvider(placeholderImage);
......@@ -489,7 +502,7 @@ Future<void> main() async {
expect(semanticsWidget().properties.label, imageSemanticText);
});
testWidgets('is empty without any specified semantics labels', (WidgetTester tester) async {
testWidgetsWithLeakTracking('is empty without any specified semantics labels', (WidgetTester tester) async {
Semantics semanticsWidget() => tester.widget(find.byType(Semantics));
final TestImageProvider placeholderProvider = TestImageProvider(placeholderImage);
......@@ -515,7 +528,7 @@ Future<void> main() async {
});
group("placeholder's BoxFit", () {
testWidgets("should be the image's BoxFit when not set", (WidgetTester tester) async {
testWidgetsWithLeakTracking("should be the image's BoxFit when not set", (WidgetTester tester) async {
final TestImageProvider placeholderProvider = TestImageProvider(placeholderImage);
final TestImageProvider imageProvider = TestImageProvider(targetImage);
......@@ -529,7 +542,7 @@ Future<void> main() async {
expect(findFadeInImage(tester).placeholder!.fit, equals(BoxFit.cover));
});
testWidgets('should be the given value when set', (WidgetTester tester) async {
testWidgetsWithLeakTracking('should be the given value when set', (WidgetTester tester) async {
final TestImageProvider placeholderProvider = TestImageProvider(placeholderImage);
final TestImageProvider imageProvider = TestImageProvider(targetImage);
......@@ -546,7 +559,7 @@ Future<void> main() async {
});
group("placeholder's FilterQuality", () {
testWidgets("should be the image's FilterQuality when not set", (WidgetTester tester) async {
testWidgetsWithLeakTracking("should be the image's FilterQuality when not set", (WidgetTester tester) async {
final TestImageProvider placeholderProvider = TestImageProvider(placeholderImage);
final TestImageProvider imageProvider = TestImageProvider(targetImage);
......@@ -560,7 +573,7 @@ Future<void> main() async {
expect(findFadeInImage(tester).placeholder!.filterQuality, equals(FilterQuality.medium));
});
testWidgets('should be the given value when set', (WidgetTester tester) async {
testWidgetsWithLeakTracking('should be the given value when set', (WidgetTester tester) async {
final TestImageProvider placeholderProvider = TestImageProvider(placeholderImage);
final TestImageProvider imageProvider = TestImageProvider(targetImage);
......
......@@ -5,9 +5,10 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('FadeTransition', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FadeTransition', (WidgetTester tester) async {
final DebugPrintCallback oldPrint = debugPrint;
final List<String> log = <String>[];
debugPrint = (String? message, { int? wrapWidth }) {
......
......@@ -5,9 +5,10 @@
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('Can size according to aspect ratio', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Can size according to aspect ratio', (WidgetTester tester) async {
final Key outside = UniqueKey();
final Key inside = UniqueKey();
......@@ -42,7 +43,7 @@ void main() {
expect(insidePoint, equals(outsidePoint));
});
testWidgets('Can contain child', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Can contain child', (WidgetTester tester) async {
final Key outside = UniqueKey();
final Key inside = UniqueKey();
......@@ -77,7 +78,7 @@ void main() {
expect(insidePoint, equals(outsidePoint));
});
testWidgets('Child can cover', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Child can cover', (WidgetTester tester) async {
final Key outside = UniqueKey();
final Key inside = UniqueKey();
......@@ -113,7 +114,7 @@ void main() {
expect(insidePoint, equals(outsidePoint));
});
testWidgets('FittedBox with no child', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FittedBox with no child', (WidgetTester tester) async {
final Key key = UniqueKey();
await tester.pumpWidget(
Center(
......@@ -129,7 +130,7 @@ void main() {
expect(box.size.height, 0.0);
});
testWidgets('Child can be aligned multiple ways in a row', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Child can be aligned multiple ways in a row', (WidgetTester tester) async {
final Key outside = UniqueKey();
final Key inside = UniqueKey();
......@@ -339,7 +340,7 @@ void main() {
}
});
testWidgets('FittedBox layers - contain', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FittedBox layers - contain', (WidgetTester tester) async {
await tester.pumpWidget(
const Center(
child: SizedBox(
......@@ -360,7 +361,7 @@ void main() {
expect(getLayers(), <Type>[TransformLayer, TransformLayer, OffsetLayer]);
});
testWidgets('FittedBox layers - cover - horizontal', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FittedBox layers - cover - horizontal', (WidgetTester tester) async {
await tester.pumpWidget(
const Center(
child: SizedBox(
......@@ -383,7 +384,7 @@ void main() {
expect(getLayers(), <Type>[TransformLayer, ClipRectLayer, TransformLayer, OffsetLayer]);
});
testWidgets('FittedBox layers - cover - vertical', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FittedBox layers - cover - vertical', (WidgetTester tester) async {
await tester.pumpWidget(
const Center(
child: SizedBox(
......@@ -406,7 +407,7 @@ void main() {
expect(getLayers(), <Type>[TransformLayer, ClipRectLayer, TransformLayer, OffsetLayer]);
});
testWidgets('FittedBox layers - none - clip', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FittedBox layers - none - clip', (WidgetTester tester) async {
final List<double> values = <double>[10.0, 50.0, 100.0];
for (final double a in values) {
for (final double b in values) {
......@@ -442,7 +443,7 @@ void main() {
}
});
testWidgets('Big child into small fitted box - hit testing', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Big child into small fitted box - hit testing', (WidgetTester tester) async {
final GlobalKey key1 = GlobalKey();
bool pointerDown = false;
await tester.pumpWidget(
......@@ -474,7 +475,7 @@ void main() {
expect(pointerDown, isTrue);
});
testWidgets('Can set and update clipBehavior', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Can set and update clipBehavior', (WidgetTester tester) async {
await tester.pumpWidget(FittedBox(fit: BoxFit.none, child: Container()));
final RenderFittedBox renderObject = tester.allRenderObjects.whereType<RenderFittedBox>().first;
expect(renderObject.clipBehavior, equals(Clip.none));
......@@ -483,7 +484,7 @@ void main() {
expect(renderObject.clipBehavior, equals(Clip.antiAlias));
});
testWidgets('BoxFit.scaleDown matches size of child', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BoxFit.scaleDown matches size of child', (WidgetTester tester) async {
final Key outside = UniqueKey();
final Key inside = UniqueKey();
......@@ -544,7 +545,7 @@ void main() {
expect(insidePoint - outsidePoint, equals(Offset.zero));
});
testWidgets('Switching to and from BoxFit.scaleDown causes relayout', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Switching to and from BoxFit.scaleDown causes relayout', (WidgetTester tester) async {
final Key outside = UniqueKey();
final Widget scaleDownWidget = Center(
......@@ -588,7 +589,7 @@ void main() {
expect(outsideBox.size.height, 50.0);
});
testWidgets('FittedBox without child does not throw', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FittedBox without child does not throw', (WidgetTester tester) async {
await tester.pumpWidget(
const Center(
child: SizedBox(
......
......@@ -5,9 +5,10 @@
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('Can hit test flex children of stacks', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Can hit test flex children of stacks', (WidgetTester tester) async {
bool didReceiveTap = false;
await tester.pumpWidget(
Directionality(
......@@ -47,7 +48,7 @@ void main() {
expect(didReceiveTap, isTrue);
});
testWidgets('Flexible defaults to loose', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Flexible defaults to loose', (WidgetTester tester) async {
await tester.pumpWidget(
const Row(
textDirection: TextDirection.ltr,
......@@ -61,7 +62,7 @@ void main() {
expect(box.size.width, 100.0);
});
testWidgets("Doesn't overflow because of floating point accumulated error", (WidgetTester tester) async {
testWidgetsWithLeakTracking("Doesn't overflow because of floating point accumulated error", (WidgetTester tester) async {
// both of these cases have failed in the past due to floating point issues
await tester.pumpWidget(
const Center(
......@@ -99,7 +100,7 @@ void main() {
);
});
testWidgets('Error information is printed correctly', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Error information is printed correctly', (WidgetTester tester) async {
// We run this twice, the first time without an error, so that the second time
// we only get a single exception. Otherwise we'd get two, the one we want and
// an extra one when we discover we never computed a size.
......@@ -133,7 +134,7 @@ void main() {
expect(message, contains('\nSee also:'));
});
testWidgets('Can set and update clipBehavior', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Can set and update clipBehavior', (WidgetTester tester) async {
await tester.pumpWidget(const Flex(direction: Axis.vertical));
final RenderFlex renderObject = tester.allRenderObjects.whereType<RenderFlex>().first;
expect(renderObject.clipBehavior, equals(Clip.none));
......
......@@ -5,6 +5,7 @@
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
class TestFlowDelegate extends FlowDelegate {
TestFlowDelegate({required this.startOffset}) : super(repaint: startOffset);
......@@ -61,7 +62,7 @@ class DuplicatePainterOpacityFlowDelegate extends OpacityFlowDelegate {
}
void main() {
testWidgets('Flow control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Flow control test', (WidgetTester tester) async {
final AnimationController startOffset = AnimationController.unbounded(
vsync: tester,
);
......@@ -115,7 +116,7 @@ void main() {
expect(log, equals(<int>[0]));
});
testWidgets('paintChild gets called twice', (WidgetTester tester) async {
testWidgetsWithLeakTracking('paintChild gets called twice', (WidgetTester tester) async {
await tester.pumpWidget(
Flow(
delegate: DuplicatePainterOpacityFlowDelegate(1.0),
......@@ -137,7 +138,7 @@ void main() {
));
});
testWidgets('Flow opacity layer', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Flow opacity layer', (WidgetTester tester) async {
const double opacity = 0.2;
await tester.pumpWidget(
Flow(
......@@ -157,7 +158,7 @@ void main() {
expect(layer!.firstChild, isA<TransformLayer>());
});
testWidgets('Flow can set and update clipBehavior', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Flow can set and update clipBehavior', (WidgetTester tester) async {
const double opacity = 0.2;
await tester.pumpWidget(
Flow(
......@@ -186,7 +187,7 @@ void main() {
}
});
testWidgets('Flow.unwrapped can set and update clipBehavior', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Flow.unwrapped can set and update clipBehavior', (WidgetTester tester) async {
const double opacity = 0.2;
await tester.pumpWidget(
Flow.unwrapped(
......
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