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

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

parent daea6e00
......@@ -31,7 +31,7 @@ void main() {
await tester.tapAt(const Offset(20.0, 20.0));
await tester.pump();
expect(find.text('Action Sheet'), findsNothing);
}, leakTrackingTestConfig: LeakTrackingTestConfig.debugNotDisposed());
});
testWidgetsWithLeakTracking('Verify that a tap on title section (not buttons) does not dismiss an action sheet', (WidgetTester tester) async {
await tester.pumpWidget(
......
......@@ -6,11 +6,12 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'semantics_tester.dart';
void main() {
testWidgets('SemanticsNode ids are stable', (WidgetTester tester) async {
testWidgetsWithLeakTracking('SemanticsNode ids are stable', (WidgetTester tester) async {
// Regression test for b/151732341.
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(Directionality(
......
......@@ -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('Texture with freeze set to true', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Texture with freeze set to true', (WidgetTester tester) async {
await tester.pumpWidget(
const Center(child: Texture(textureId: 1, freeze: true)),
);
......@@ -25,6 +26,7 @@ void main() {
expect(textureBox.freeze, true);
final ContainerLayer containerLayer = ContainerLayer();
addTearDown(containerLayer.dispose);
final PaintingContext paintingContext = PaintingContext(containerLayer, Rect.zero);
textureBox.paint(paintingContext, Offset.zero);
final Layer layer = containerLayer.lastChild!;
......@@ -35,7 +37,7 @@ void main() {
expect(textureLayer.freeze, true);
});
testWidgets('Texture with default FilterQuality', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Texture with default FilterQuality', (WidgetTester tester) async {
await tester.pumpWidget(
const Center(child: Texture(textureId: 1)),
);
......@@ -53,6 +55,7 @@ void main() {
expect(textureBox.filterQuality, FilterQuality.low);
final ContainerLayer containerLayer = ContainerLayer();
addTearDown(containerLayer.dispose);
final PaintingContext paintingContext = PaintingContext(containerLayer, Rect.zero);
textureBox.paint(paintingContext, Offset.zero);
final Layer layer = containerLayer.lastChild!;
......@@ -64,7 +67,7 @@ void main() {
});
testWidgets('Texture with FilterQuality.none', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Texture with FilterQuality.none', (WidgetTester tester) async {
await tester.pumpWidget(
const Center(child: Texture(textureId: 1, filterQuality: FilterQuality.none)),
);
......@@ -82,6 +85,7 @@ void main() {
expect(textureBox.filterQuality, FilterQuality.none);
final ContainerLayer containerLayer = ContainerLayer();
addTearDown(containerLayer.dispose);
final PaintingContext paintingContext = PaintingContext(containerLayer, Rect.zero);
textureBox.paint(paintingContext, Offset.zero);
final Layer layer = containerLayer.lastChild!;
......@@ -92,7 +96,7 @@ void main() {
expect(textureLayer.filterQuality, FilterQuality.none);
});
testWidgets('Texture with FilterQuality.low', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Texture with FilterQuality.low', (WidgetTester tester) async {
await tester.pumpWidget(
const Center(child: Texture(textureId: 1)),
);
......@@ -110,6 +114,7 @@ void main() {
expect(textureBox.filterQuality, FilterQuality.low);
final ContainerLayer containerLayer = ContainerLayer();
addTearDown(containerLayer.dispose);
final PaintingContext paintingContext = PaintingContext(containerLayer, Rect.zero);
textureBox.paint(paintingContext, Offset.zero);
final Layer layer = containerLayer.lastChild!;
......
......@@ -5,9 +5,10 @@
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('Nested TickerMode cannot turn tickers back on', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Nested TickerMode cannot turn tickers back on', (WidgetTester tester) async {
int outerTickCount = 0;
int innerTickCount = 0;
......@@ -99,7 +100,7 @@ void main() {
expect(innerTickCount, 0);
});
testWidgets('Changing TickerMode does not rebuild widgets with SingleTickerProviderStateMixin', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Changing TickerMode does not rebuild widgets with SingleTickerProviderStateMixin', (WidgetTester tester) async {
Widget widgetUnderTest({required bool tickerEnabled}) {
return TickerMode(
enabled: tickerEnabled,
......@@ -121,7 +122,7 @@ void main() {
expect(state().buildCount, 1);
});
testWidgets('Changing TickerMode does not rebuild widgets with TickerProviderStateMixin', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Changing TickerMode does not rebuild widgets with TickerProviderStateMixin', (WidgetTester tester) async {
Widget widgetUnderTest({required bool tickerEnabled}) {
return TickerMode(
enabled: tickerEnabled,
......@@ -143,7 +144,7 @@ void main() {
expect(state().buildCount, 1);
});
testWidgets('Moving widgets with SingleTickerProviderStateMixin to a new TickerMode ancestor works', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Moving widgets with SingleTickerProviderStateMixin to a new TickerMode ancestor works', (WidgetTester tester) async {
final GlobalKey tickingWidgetKey = GlobalKey();
Widget widgetUnderTest({required LocalKey tickerModeKey, required bool tickerEnabled}) {
return TickerMode(
......@@ -164,7 +165,7 @@ void main() {
expect(tickingState.ticker.isTicking, isFalse);
});
testWidgets('Moving widgets with TickerProviderStateMixin to a new TickerMode ancestor works', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Moving widgets with TickerProviderStateMixin to a new TickerMode ancestor works', (WidgetTester tester) async {
final GlobalKey tickingWidgetKey = GlobalKey();
Widget widgetUnderTest({required LocalKey tickerModeKey, required bool tickerEnabled}) {
return TickerMode(
......@@ -185,7 +186,7 @@ void main() {
expect(tickingState.ticker.isTicking, isFalse);
});
testWidgets('Ticking widgets in old route do not rebuild when new route is pushed', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Ticking widgets in old route do not rebuild when new route is pushed', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
routes: <String, WidgetBuilder>{
'/foo' : (BuildContext context) => const Text('New route'),
......
......@@ -6,9 +6,10 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('TickerMode', (WidgetTester tester) async {
testWidgetsWithLeakTracking('TickerMode', (WidgetTester tester) async {
const Widget widget = TickerMode(
enabled: false,
child: CircularProgressIndicator(),
......@@ -34,7 +35,7 @@ void main() {
expect(tester.binding.transientCallbackCount, 0);
});
testWidgets('Navigation with TickerMode', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Navigation with TickerMode', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
home: const LinearProgressIndicator(),
routes: <String, WidgetBuilder>{
......@@ -56,7 +57,7 @@ void main() {
expect(tester.binding.transientCallbackCount, 1);
});
testWidgets('SingleTickerProviderStateMixin can handle not being used', (WidgetTester tester) async {
testWidgetsWithLeakTracking('SingleTickerProviderStateMixin can handle not being used', (WidgetTester tester) async {
const Widget widget = BoringTickerTest();
expect(widget.toString, isNot(throwsException));
......@@ -96,7 +97,7 @@ void main() {
));
});
testWidgets('SingleTickerProviderStateMixin dispose while active', (WidgetTester tester) async {
testWidgetsWithLeakTracking('SingleTickerProviderStateMixin dispose while active', (WidgetTester tester) async {
final GlobalKey<_SingleTickerTestState> key = GlobalKey<_SingleTickerTestState>();
final Widget widget = _SingleTickerTest(key: key);
await tester.pumpWidget(widget);
......@@ -136,7 +137,7 @@ void main() {
}
});
testWidgets('SingleTickerProviderStateMixin dispose while active', (WidgetTester tester) async {
testWidgetsWithLeakTracking('SingleTickerProviderStateMixin dispose while active', (WidgetTester tester) async {
final GlobalKey<_SingleTickerTestState> key = GlobalKey<_SingleTickerTestState>();
final Widget widget = _SingleTickerTest(key: key);
await tester.pumpWidget(widget);
......@@ -176,7 +177,7 @@ void main() {
}
});
testWidgets('TickerProviderStateMixin dispose while any ticker is active', (WidgetTester tester) async {
testWidgetsWithLeakTracking('TickerProviderStateMixin dispose while any ticker is active', (WidgetTester tester) async {
final GlobalKey<_MultipleTickerTestState> key = GlobalKey<_MultipleTickerTestState>();
final Widget widget = _MultipleTickerTest(key: key);
await tester.pumpWidget(widget);
......@@ -216,12 +217,12 @@ void main() {
});
});
testWidgets('SingleTickerProviderStateMixin does not call State.toString', (WidgetTester tester) async {
testWidgetsWithLeakTracking('SingleTickerProviderStateMixin does not call State.toString', (WidgetTester tester) async {
await tester.pumpWidget(const _SingleTickerTest());
expect(tester.state<_SingleTickerTestState>(find.byType(_SingleTickerTest)).toStringCount, 0);
});
testWidgets('TickerProviderStateMixin does not call State.toString', (WidgetTester tester) async {
testWidgetsWithLeakTracking('TickerProviderStateMixin does not call State.toString', (WidgetTester tester) async {
await tester.pumpWidget(const _MultipleTickerTest());
expect(tester.state<_MultipleTickerTestState>(find.byType(_MultipleTickerTest)).toStringCount, 0);
});
......
......@@ -5,9 +5,10 @@
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('toString control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('toString control test', (WidgetTester tester) async {
final Widget widget = Title(
color: const Color(0xFF00FF00),
title: 'Awesome app',
......@@ -16,7 +17,7 @@ void main() {
expect(widget.toString, isNot(throwsException));
});
testWidgets('should handle having no title', (WidgetTester tester) async {
testWidgetsWithLeakTracking('should handle having no title', (WidgetTester tester) async {
final Title widget = Title(
color: const Color(0xFF00FF00),
child: Container(),
......@@ -26,14 +27,14 @@ void main() {
expect(widget.color, equals(const Color(0xFF00FF00)));
});
testWidgets('should not allow non-opaque color', (WidgetTester tester) async {
testWidgetsWithLeakTracking('should not allow non-opaque color', (WidgetTester tester) async {
expect(() => Title(
color: const Color(0x00000000),
child: Container(),
), throwsAssertionError);
});
testWidgets('should not pass "null" to setApplicationSwitcherDescription', (WidgetTester tester) async {
testWidgetsWithLeakTracking('should not pass "null" to setApplicationSwitcherDescription', (WidgetTester tester) async {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
......
......@@ -4,10 +4,12 @@
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('TrackingScrollController saves offset', (WidgetTester tester) async {
testWidgetsWithLeakTracking('TrackingScrollController saves offset', (WidgetTester tester) async {
final TrackingScrollController controller = TrackingScrollController();
addTearDown(controller.dispose);
const double listItemHeight = 100.0;
await tester.pumpWidget(
......
......@@ -6,10 +6,13 @@ import 'dart:math' as math;
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('Scrollable scaled up', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Scrollable scaled up', (WidgetTester tester) async {
final ScrollController controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(
MaterialApp(
home: Transform.scale(
......@@ -52,8 +55,10 @@ void main() {
expect(controller.offset, 42.5); // 85.0 - (85.0 / 2)
});
testWidgets('Scrollable scaled down', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Scrollable scaled down', (WidgetTester tester) async {
final ScrollController controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(
MaterialApp(
home: Transform.scale(
......@@ -96,8 +101,10 @@ void main() {
expect(controller.offset, 0.0); // 340.0 - (170.0 * 2)
});
testWidgets('Scrollable rotated 90 degrees', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Scrollable rotated 90 degrees', (WidgetTester tester) async {
final ScrollController controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(
MaterialApp(
home: Transform.rotate(
......@@ -136,8 +143,10 @@ void main() {
expect(controller.offset, 30.0); // 100.0 - 70.0
});
testWidgets('Perspective transform on scrollable', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Perspective transform on scrollable', (WidgetTester tester) async {
final ScrollController controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(
MaterialApp(
home: Transform(
......
......@@ -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('Animates forward when built', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Animates forward when built', (WidgetTester tester) async {
final List<int> values = <int>[];
int endCount = 0;
await tester.pumpWidget(
......@@ -37,7 +38,7 @@ void main() {
expect(values, <int>[10, 60, 110]);
});
testWidgets('No initial animation when begin=null', (WidgetTester tester) async {
testWidgetsWithLeakTracking('No initial animation when begin=null', (WidgetTester tester) async {
final List<int> values = <int>[];
int endCount = 0;
await tester.pumpWidget(
......@@ -61,7 +62,7 @@ void main() {
});
testWidgets('No initial animation when begin=end', (WidgetTester tester) async {
testWidgetsWithLeakTracking('No initial animation when begin=end', (WidgetTester tester) async {
final List<int> values = <int>[];
int endCount = 0;
await tester.pumpWidget(
......@@ -84,7 +85,7 @@ void main() {
expect(values, <int>[100]);
});
testWidgets('Replace tween animates new tween', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Replace tween animates new tween', (WidgetTester tester) async {
final List<int> values = <int>[];
Widget buildWidget({required IntTween tween}) {
return TweenAnimationBuilder<int>(
......@@ -112,7 +113,7 @@ void main() {
expect(values, <int>[0, 100, 100, 150, 200]);
});
testWidgets('Curve is respected', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Curve is respected', (WidgetTester tester) async {
final List<int> values = <int>[];
Widget buildWidget({required IntTween tween, required Curve curve}) {
return TweenAnimationBuilder<int>(
......@@ -142,7 +143,7 @@ void main() {
expect(values, <int>[100, 150]);
});
testWidgets('Duration is respected', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Duration is respected', (WidgetTester tester) async {
final List<int> values = <int>[];
Widget buildWidget({required IntTween tween, required Duration duration}) {
return TweenAnimationBuilder<int>(
......@@ -170,7 +171,7 @@ void main() {
expect(values, <int>[100, 125]);
});
testWidgets('Child is integrated into tree', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Child is integrated into tree', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
......@@ -189,7 +190,7 @@ void main() {
});
group('Change tween gapless while', () {
testWidgets('running forward', (WidgetTester tester) async {
testWidgetsWithLeakTracking('running forward', (WidgetTester tester) async {
final List<int> values = <int>[];
Widget buildWidget({required IntTween tween}) {
return TweenAnimationBuilder<int>(
......@@ -224,7 +225,7 @@ void main() {
values.clear();
});
testWidgets('running forward and then reverse with same tween instance', (WidgetTester tester) async {
testWidgetsWithLeakTracking('running forward and then reverse with same tween instance', (WidgetTester tester) async {
final List<int> values = <int>[];
Widget buildWidget({required IntTween tween}) {
return TweenAnimationBuilder<int>(
......@@ -254,7 +255,7 @@ void main() {
});
});
testWidgets('Changing tween while gapless tween change is in progress', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Changing tween while gapless tween change is in progress', (WidgetTester tester) async {
final List<int> values = <int>[];
Widget buildWidget({required IntTween tween}) {
return TweenAnimationBuilder<int>(
......@@ -294,7 +295,7 @@ void main() {
expect(values, <int>[175, 338, 501]);
});
testWidgets('Changing curve while no animation is running does not trigger animation', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Changing curve while no animation is running does not trigger animation', (WidgetTester tester) async {
final List<int> values = <int>[];
Widget buildWidget({required Curve curve}) {
return TweenAnimationBuilder<int>(
......@@ -323,7 +324,7 @@ void main() {
expect(values, <int>[100]);
});
testWidgets('Setting same tween and direction does not trigger animation', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Setting same tween and direction does not trigger animation', (WidgetTester tester) async {
final List<int> values = <int>[];
Widget buildWidget({required IntTween tween}) {
return TweenAnimationBuilder<int>(
......@@ -352,7 +353,7 @@ void main() {
expect(values, everyElement(100));
});
testWidgets('Setting same tween and direction while gapless animation is in progress works', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Setting same tween and direction while gapless animation is in progress works', (WidgetTester tester) async {
final List<int> values = <int>[];
Widget buildWidget({required IntTween tween}) {
return TweenAnimationBuilder<int>(
......@@ -388,7 +389,7 @@ void main() {
expect(values, everyElement(300));
});
testWidgets('Works with nullable tweens', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Works with nullable tweens', (WidgetTester tester) async {
final List<Size?> values = <Size?>[];
await tester.pumpWidget(
TweenAnimationBuilder<Size?>(
......
......@@ -6,6 +6,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/gestures/monodrag.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'two_dimensional_utils.dart';
......@@ -19,34 +20,40 @@ Widget? _testChildBuilder(BuildContext context, ChildVicinity vicinity) {
void main() {
group('TwoDimensionalScrollView',() {
testWidgets('asserts the axis directions do not conflict with one another', (WidgetTester tester) async {
testWidgetsWithLeakTracking('asserts the axis directions do not conflict with one another', (WidgetTester tester) async {
final List<Object> exceptions = <Object>[];
final FlutterExceptionHandler? oldHandler = FlutterError.onError;
FlutterError.onError = (FlutterErrorDetails details) {
exceptions.add(details.exception);
};
// Horizontal wrong
late final TwoDimensionalChildBuilderDelegate delegate1;
addTearDown(() => delegate1.dispose());
await tester.pumpWidget(MaterialApp(
home: SimpleBuilderTableView(
delegate: TwoDimensionalChildBuilderDelegate(builder: (_, __) => null),
delegate: delegate1 = TwoDimensionalChildBuilderDelegate(builder: (_, __) => null),
horizontalDetails: const ScrollableDetails.vertical(),
// Horizontal has default const ScrollableDetails.horizontal()
),
));
// Vertical wrong
late final TwoDimensionalChildBuilderDelegate delegate2;
addTearDown(() => delegate2.dispose());
await tester.pumpWidget(MaterialApp(
home: SimpleBuilderTableView(
delegate: TwoDimensionalChildBuilderDelegate(builder: (_, __) => null),
delegate: delegate2 = TwoDimensionalChildBuilderDelegate(builder: (_, __) => null),
verticalDetails: const ScrollableDetails.horizontal(),
// Horizontal has default const ScrollableDetails.horizontal()
),
));
// Both wrong
late final TwoDimensionalChildBuilderDelegate delegate3;
addTearDown(() => delegate3.dispose());
await tester.pumpWidget(MaterialApp(
home: SimpleBuilderTableView(
delegate: TwoDimensionalChildBuilderDelegate(builder: (_, __) => null),
delegate: delegate3 = TwoDimensionalChildBuilderDelegate(builder: (_, __) => null),
verticalDetails: const ScrollableDetails.horizontal(),
horizontalDetails: const ScrollableDetails.vertical(),
),
......@@ -60,15 +67,19 @@ void main() {
}
}, variant: TargetPlatformVariant.all());
testWidgets('ScrollableDetails.controller can set initial scroll positions, modify within bounds', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ScrollableDetails.controller can set initial scroll positions, modify within bounds', (WidgetTester tester) async {
final ScrollController verticalController = ScrollController(initialScrollOffset: 100);
addTearDown(verticalController.dispose);
final ScrollController horizontalController = ScrollController(initialScrollOffset: 50);
addTearDown(horizontalController.dispose);
late final TwoDimensionalChildBuilderDelegate delegate;
addTearDown(() => delegate.dispose());
await tester.pumpWidget(MaterialApp(
home: SimpleBuilderTableView(
verticalDetails: ScrollableDetails.vertical(controller: verticalController),
horizontalDetails: ScrollableDetails.horizontal(controller: horizontalController),
delegate: TwoDimensionalChildBuilderDelegate(
delegate: delegate = TwoDimensionalChildBuilderDelegate(
builder: _testChildBuilder,
maxXIndex: 99,
maxYIndex: 99,
......@@ -99,13 +110,20 @@ void main() {
expect(horizontalController.position.pixels, 19200);
}, variant: TargetPlatformVariant.all());
testWidgets('Properly assigns the PrimaryScrollController to the main axis on the correct platform', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Properly assigns the PrimaryScrollController to the main axis on the correct platform', (WidgetTester tester) async {
late ScrollController controller;
Widget buildForPrimaryScrollController({
bool? explicitPrimary,
Axis mainAxis = Axis.vertical,
bool addControllerConflict = false,
}) {
final ScrollController verticalController = ScrollController();
addTearDown(verticalController.dispose);
final ScrollController horizontalController = ScrollController();
addTearDown(horizontalController.dispose);
late final TwoDimensionalChildBuilderDelegate delegate;
addTearDown(() => delegate.dispose());
return MaterialApp(
home: PrimaryScrollController(
controller: controller,
......@@ -114,15 +132,15 @@ void main() {
primary: explicitPrimary,
verticalDetails: ScrollableDetails.vertical(
controller: addControllerConflict && mainAxis == Axis.vertical
? ScrollController()
? verticalController
: null
),
horizontalDetails: ScrollableDetails.horizontal(
controller: addControllerConflict && mainAxis == Axis.horizontal
? ScrollController()
? horizontalController
: null
),
delegate: TwoDimensionalChildBuilderDelegate(
delegate: delegate = TwoDimensionalChildBuilderDelegate(
builder: _testChildBuilder,
maxXIndex: 99,
maxYIndex: 99,
......@@ -134,6 +152,7 @@ void main() {
// Horizontal default - horizontal never automatically adopts PSC
controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(buildForPrimaryScrollController(
mainAxis: Axis.horizontal,
));
......@@ -151,6 +170,7 @@ void main() {
// Horizontal explicitly true
controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(buildForPrimaryScrollController(
mainAxis: Axis.horizontal,
explicitPrimary: true,
......@@ -171,6 +191,7 @@ void main() {
// Horizontal explicitly false
controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(buildForPrimaryScrollController(
mainAxis: Axis.horizontal,
explicitPrimary: false,
......@@ -190,6 +211,7 @@ void main() {
// Vertical default
controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(buildForPrimaryScrollController());
await tester.pumpAndSettle();
......@@ -209,6 +231,7 @@ void main() {
// Vertical explicitly true
controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(buildForPrimaryScrollController(
explicitPrimary: true,
));
......@@ -228,6 +251,7 @@ void main() {
// Vertical explicitly false
controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(buildForPrimaryScrollController(
explicitPrimary: false,
));
......@@ -253,6 +277,7 @@ void main() {
// Vertical asserts ScrollableDetails.controller has not been provided if
// primary is explicitly set
controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(buildForPrimaryScrollController(
explicitPrimary: true,
addControllerConflict: true,
......@@ -268,6 +293,7 @@ void main() {
// Horizontal asserts ScrollableDetails.controller has not been provided
// if primary is explicitly set true
controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(buildForPrimaryScrollController(
mainAxis: Axis.horizontal,
explicitPrimary: true,
......@@ -282,12 +308,14 @@ void main() {
FlutterError.onError = oldHandler;
}, variant: TargetPlatformVariant.all());
testWidgets('TwoDimensionalScrollable receives the correct details from TwoDimensionalScrollView', (WidgetTester tester) async {
testWidgetsWithLeakTracking('TwoDimensionalScrollable receives the correct details from TwoDimensionalScrollView', (WidgetTester tester) async {
late BuildContext capturedContext;
// Default
late final TwoDimensionalChildBuilderDelegate delegate1;
addTearDown(() => delegate1.dispose());
await tester.pumpWidget(MaterialApp(
home: SimpleBuilderTableView(
delegate: TwoDimensionalChildBuilderDelegate(
delegate: delegate1 = TwoDimensionalChildBuilderDelegate(
builder: (BuildContext context, ChildVicinity vicinity) {
capturedContext = context;
return Text(vicinity.toString());
......@@ -305,13 +333,15 @@ void main() {
expect(scrollable.widget.dragStartBehavior, DragStartBehavior.start);
// Customized
late final TwoDimensionalChildBuilderDelegate delegate2;
addTearDown(() => delegate2.dispose());
await tester.pumpWidget(MaterialApp(
home: SimpleBuilderTableView(
verticalDetails: const ScrollableDetails.vertical(reverse: true),
horizontalDetails: const ScrollableDetails.horizontal(reverse: true),
diagonalDragBehavior: DiagonalDragBehavior.weightedContinuous,
dragStartBehavior: DragStartBehavior.down,
delegate: TwoDimensionalChildBuilderDelegate(
delegate: delegate2 = TwoDimensionalChildBuilderDelegate(
builder: _testChildBuilder,
),
),
......
......@@ -6,6 +6,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'editable_text_utils.dart';
......@@ -30,9 +31,12 @@ void main() {
Future<void> sendUndo(WidgetTester tester) => sendUndoRedo(tester);
Future<void> sendRedo(WidgetTester tester) => sendUndoRedo(tester, true);
testWidgets('allows undo and redo to be called programmatically from the UndoHistoryController', (WidgetTester tester) async {
testWidgetsWithLeakTracking('allows undo and redo to be called programmatically from the UndoHistoryController', (WidgetTester tester) async {
final ValueNotifier<int> value = ValueNotifier<int>(0);
addTearDown(value.dispose);
final UndoHistoryController controller = UndoHistoryController();
addTearDown(controller.dispose);
await tester.pumpWidget(
MaterialApp(
home: UndoHistory<int>(
......@@ -119,9 +123,12 @@ void main() {
expect(controller.value.canRedo, false);
}, variant: TargetPlatformVariant.all());
testWidgets('allows undo and redo to be called using the keyboard', (WidgetTester tester) async {
testWidgetsWithLeakTracking('allows undo and redo to be called using the keyboard', (WidgetTester tester) async {
final ValueNotifier<int> value = ValueNotifier<int>(0);
addTearDown(value.dispose);
final UndoHistoryController controller = UndoHistoryController();
addTearDown(controller.dispose);
await tester.pumpWidget(
MaterialApp(
home: UndoHistory<int>(
......@@ -211,9 +218,12 @@ void main() {
expect(controller.value.canRedo, false);
}, variant: TargetPlatformVariant.all(), skip: kIsWeb); // [intended]
testWidgets('duplicate changes do not affect the undo history', (WidgetTester tester) async {
testWidgetsWithLeakTracking('duplicate changes do not affect the undo history', (WidgetTester tester) async {
final ValueNotifier<int> value = ValueNotifier<int>(0);
addTearDown(value.dispose);
final UndoHistoryController controller = UndoHistoryController();
addTearDown(controller.dispose);
await tester.pumpWidget(
MaterialApp(
home: UndoHistory<int>(
......@@ -261,11 +271,14 @@ void main() {
expect(controller.value.canRedo, true);
}, variant: TargetPlatformVariant.all());
testWidgets('ignores value changes pushed during onTriggered', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ignores value changes pushed during onTriggered', (WidgetTester tester) async {
final ValueNotifier<int> value = ValueNotifier<int>(0);
addTearDown(value.dispose);
final UndoHistoryController controller = UndoHistoryController();
addTearDown(controller.dispose);
int Function(int newValue) valueToUse = (int value) => value;
final GlobalKey<UndoHistoryState<int>> key = GlobalKey<UndoHistoryState<int>>();
await tester.pumpWidget(
MaterialApp(
home: UndoHistory<int>(
......@@ -309,16 +322,20 @@ void main() {
expect(() => key.currentState!.undo(), throwsAssertionError);
}, variant: TargetPlatformVariant.all());
testWidgets('changes should send setUndoState to the UndoManagerConnection on iOS', (WidgetTester tester) async {
testWidgetsWithLeakTracking('changes should send setUndoState to the UndoManagerConnection on iOS', (WidgetTester tester) async {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.undoManager, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose);
final ValueNotifier<int> value = ValueNotifier<int>(0);
addTearDown(value.dispose);
final UndoHistoryController controller = UndoHistoryController();
addTearDown(controller.dispose);
await tester.pumpWidget(
MaterialApp(
home: UndoHistory<int>(
......@@ -378,9 +395,12 @@ void main() {
expect(methodCall.arguments as Map<String, dynamic>, <String, bool>{'canUndo': false, 'canRedo': true});
}, variant: const TargetPlatformVariant(<TargetPlatform>{TargetPlatform.iOS}), skip: kIsWeb); // [intended]
testWidgets('handlePlatformUndo should undo or redo appropriately on iOS', (WidgetTester tester) async {
testWidgetsWithLeakTracking('handlePlatformUndo should undo or redo appropriately on iOS', (WidgetTester tester) async {
final ValueNotifier<int> value = ValueNotifier<int>(0);
addTearDown(value.dispose);
final UndoHistoryController controller = UndoHistoryController();
addTearDown(controller.dispose);
await tester.pumpWidget(
MaterialApp(
home: UndoHistory<int>(
......@@ -465,9 +485,10 @@ void main() {
});
group('UndoHistoryController', () {
testWidgets('UndoHistoryController notifies onUndo listeners onUndo', (WidgetTester tester) async {
testWidgetsWithLeakTracking('UndoHistoryController notifies onUndo listeners onUndo', (WidgetTester tester) async {
int calls = 0;
final UndoHistoryController controller = UndoHistoryController();
addTearDown(controller.dispose);
controller.onUndo.addListener(() {
calls++;
});
......@@ -482,9 +503,10 @@ void main() {
expect(calls, 1);
});
testWidgets('UndoHistoryController notifies onRedo listeners onRedo', (WidgetTester tester) async {
testWidgetsWithLeakTracking('UndoHistoryController notifies onRedo listeners onRedo', (WidgetTester tester) async {
int calls = 0;
final UndoHistoryController controller = UndoHistoryController();
addTearDown(controller.dispose);
controller.onRedo.addListener(() {
calls++;
});
......@@ -499,9 +521,10 @@ void main() {
expect(calls, 1);
});
testWidgets('UndoHistoryController notifies listeners on value change', (WidgetTester tester) async {
testWidgetsWithLeakTracking('UndoHistoryController notifies listeners on value change', (WidgetTester tester) async {
int calls = 0;
final UndoHistoryController controller = UndoHistoryController(value: const UndoHistoryValue(canUndo: true));
addTearDown(controller.dispose);
controller.addListener(() {
calls++;
});
......
......@@ -4,6 +4,7 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
class TestUniqueWidget extends UniqueWidget<TestUniqueWidgetState> {
const TestUniqueWidget({ required super.key });
......@@ -18,7 +19,7 @@ class TestUniqueWidgetState extends State<TestUniqueWidget> {
}
void main() {
testWidgets('Unique widget control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Unique widget control test', (WidgetTester tester) async {
final TestUniqueWidget widget = TestUniqueWidget(key: GlobalKey<TestUniqueWidgetState>());
await tester.pumpWidget(widget);
......
......@@ -5,6 +5,7 @@
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() {
late SpyStringValueNotifier valueListenable;
......@@ -32,21 +33,26 @@ void main() {
textBuilderUnderTest = builderForValueListenable(valueListenable);
});
testWidgets('Null value is ok', (WidgetTester tester) async {
tearDown(() {
valueListenable.dispose();
});
testWidgetsWithLeakTracking('Null value is ok', (WidgetTester tester) async {
await tester.pumpWidget(textBuilderUnderTest);
expect(find.byType(Placeholder), findsOneWidget);
});
testWidgets('Widget builds with initial value', (WidgetTester tester) async {
valueListenable = SpyStringValueNotifier('Bachman');
testWidgetsWithLeakTracking('Widget builds with initial value', (WidgetTester tester) async {
final SpyStringValueNotifier valueListenable = SpyStringValueNotifier('Bachman');
addTearDown(valueListenable.dispose);
await tester.pumpWidget(builderForValueListenable(valueListenable));
expect(find.text('Bachman'), findsOneWidget);
});
testWidgets('Widget updates when value changes', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Widget updates when value changes', (WidgetTester tester) async {
await tester.pumpWidget(textBuilderUnderTest);
valueListenable.value = 'Gilfoyle';
......@@ -59,15 +65,15 @@ void main() {
expect(find.text('Dinesh'), findsOneWidget);
});
testWidgets('Can change listenable', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Can change listenable', (WidgetTester tester) async {
await tester.pumpWidget(textBuilderUnderTest);
valueListenable.value = 'Gilfoyle';
await tester.pump();
expect(find.text('Gilfoyle'), findsOneWidget);
final ValueListenable<String?> differentListenable =
SpyStringValueNotifier('Hendricks');
final SpyStringValueNotifier differentListenable = SpyStringValueNotifier('Hendricks');
addTearDown(differentListenable.dispose);
await tester.pumpWidget(builderForValueListenable(differentListenable));
......@@ -75,15 +81,15 @@ void main() {
expect(find.text('Hendricks'), findsOneWidget);
});
testWidgets('Stops listening to old listenable after changing listenable', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Stops listening to old listenable after changing listenable', (WidgetTester tester) async {
await tester.pumpWidget(textBuilderUnderTest);
valueListenable.value = 'Gilfoyle';
await tester.pump();
expect(find.text('Gilfoyle'), findsOneWidget);
final ValueListenable<String?> differentListenable =
SpyStringValueNotifier('Hendricks');
final SpyStringValueNotifier differentListenable = SpyStringValueNotifier('Hendricks');
addTearDown(differentListenable.dispose);
await tester.pumpWidget(builderForValueListenable(differentListenable));
......@@ -98,7 +104,7 @@ void main() {
expect(find.text('Hendricks'), findsOneWidget);
});
testWidgets('Self-cleans when removed', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Self-cleans when removed', (WidgetTester tester) async {
await tester.pumpWidget(textBuilderUnderTest);
valueListenable.value = 'Gilfoyle';
......
......@@ -7,9 +7,10 @@ import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('Widgets running with runApp can find View', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Widgets running with runApp can find View', (WidgetTester tester) async {
FlutterView? viewOf;
FlutterView? viewMaybeOf;
......@@ -29,7 +30,7 @@ void main() {
expect(viewMaybeOf, isA<FlutterView>());
});
testWidgets('Widgets running with pumpWidget can find View', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Widgets running with pumpWidget can find View', (WidgetTester tester) async {
FlutterView? view;
FlutterView? viewMaybeOf;
......@@ -49,7 +50,7 @@ void main() {
expect(viewMaybeOf, isA<FlutterView>());
});
testWidgets('cannot find View behind a LookupBoundary', (WidgetTester tester) async {
testWidgetsWithLeakTracking('cannot find View behind a LookupBoundary', (WidgetTester tester) async {
await tester.pumpWidget(
LookupBoundary(
child: Container(),
......@@ -69,7 +70,7 @@ void main() {
);
});
testWidgets('child of view finds view, parentPipelineOwner, mediaQuery', (WidgetTester tester) async {
testWidgetsWithLeakTracking('child of view finds view, parentPipelineOwner, mediaQuery', (WidgetTester tester) async {
FlutterView? outsideView;
FlutterView? insideView;
PipelineOwner? outsideParent;
......@@ -111,7 +112,7 @@ void main() {
expect(pipelineOwners.single, equals(insideParent));
});
testWidgets('cannot have multiple views with same FlutterView', (WidgetTester tester) async {
testWidgetsWithLeakTracking('cannot have multiple views with same FlutterView', (WidgetTester tester) async {
await pumpWidgetWithoutViewWrapper(
tester: tester,
widget: ViewCollection(
......@@ -138,11 +139,11 @@ void main() {
);
});
testWidgets('ViewCollection must have one view', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ViewCollection must have one view', (WidgetTester tester) async {
expect(() => ViewCollection(views: const <Widget>[]), throwsAssertionError);
});
testWidgets('ViewAnchor.child does not see surrounding view', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ViewAnchor.child does not see surrounding view', (WidgetTester tester) async {
FlutterView? inside;
FlutterView? outside;
await tester.pumpWidget(
......@@ -165,7 +166,7 @@ void main() {
expect(outside, isNotNull);
});
testWidgets('ViewAnchor layout order', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ViewAnchor layout order', (WidgetTester tester) async {
Finder findSpyWidget(int label) {
return find.byWidgetPredicate((Widget w) => w is SpyRenderWidget && w.label == label);
}
......@@ -192,7 +193,7 @@ void main() {
expect(log, <String>['layout 1', 'layout 3', 'layout 2']);
});
testWidgets('visitChildren of ViewAnchor visits both children', (WidgetTester tester) async {
testWidgetsWithLeakTracking('visitChildren of ViewAnchor visits both children', (WidgetTester tester) async {
await tester.pumpWidget(
ViewAnchor(
view: View(
......@@ -221,7 +222,7 @@ void main() {
expect(children, hasLength(1));
});
testWidgets('visitChildren of ViewCollection visits all children', (WidgetTester tester) async {
testWidgetsWithLeakTracking('visitChildren of ViewCollection visits all children', (WidgetTester tester) async {
await pumpWidgetWithoutViewWrapper(
tester: tester,
widget: ViewCollection(
......@@ -267,7 +268,7 @@ void main() {
});
group('renderObject getter', () {
testWidgets('ancestors of view see RenderView as renderObject', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ancestors of view see RenderView as renderObject', (WidgetTester tester) async {
late BuildContext builderContext;
await pumpWidgetWithoutViewWrapper(
tester: tester,
......@@ -289,7 +290,7 @@ void main() {
expect(tester.element(find.byType(Builder)).renderObject, renderObject);
});
testWidgets('ancestors of ViewCollection get null for renderObject', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ancestors of ViewCollection get null for renderObject', (WidgetTester tester) async {
late BuildContext builderContext;
await pumpWidgetWithoutViewWrapper(
tester: tester,
......@@ -317,7 +318,7 @@ void main() {
expect(tester.element(find.byType(Builder)).renderObject, isNull);
});
testWidgets('ancestors of a ViewAnchor see the right RenderObject', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ancestors of a ViewAnchor see the right RenderObject', (WidgetTester tester) async {
late BuildContext builderContext;
await tester.pumpWidget(
Builder(
......@@ -342,7 +343,7 @@ void main() {
});
});
testWidgets('correctly switches between view configurations', (WidgetTester tester) async {
testWidgetsWithLeakTracking('correctly switches between view configurations', (WidgetTester tester) async {
await pumpWidgetWithoutViewWrapper(
tester: tester,
widget: View(
......@@ -401,7 +402,7 @@ void main() {
), throwsAssertionError);
});
testWidgets('attaches itself correctly', (WidgetTester tester) async {
testWidgetsWithLeakTracking('attaches itself correctly', (WidgetTester tester) async {
final Key viewKey = UniqueKey();
late final PipelineOwner parentPipelineOwner;
await tester.pumpWidget(
......
......@@ -5,6 +5,7 @@
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'semantics_tester.dart';
......@@ -29,7 +30,7 @@ class _TestStateState extends State<TestState> {
}
void main() {
testWidgets('Visibility', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Visibility', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
final List<String> log = <String>[];
......@@ -439,7 +440,7 @@ void main() {
semantics.dispose();
});
testWidgets('Visibility does not force compositing when visible and maintain*', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Visibility does not force compositing when visible and maintain*', (WidgetTester tester) async {
await tester.pumpWidget(
const Visibility(
maintainSize: true,
......@@ -455,7 +456,7 @@ void main() {
expect(tester.layers.last, isA<PictureLayer>());
});
testWidgets('SliverVisibility does not force compositing when visible and maintain*', (WidgetTester tester) async {
testWidgetsWithLeakTracking('SliverVisibility does not force compositing when visible and maintain*', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -485,7 +486,7 @@ void main() {
expect(tester.layers.last, isA<PictureLayer>());
});
testWidgets('Visibility.of returns correct value', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Visibility.of returns correct value', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -518,7 +519,7 @@ void main() {
expect(find.text('is visible ? false', skipOffstage: false), findsOneWidget);
});
testWidgets('Visibility.of works when multiple Visibility widgets are in hierarchy', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Visibility.of works when multiple Visibility widgets are in hierarchy', (WidgetTester tester) async {
bool didChangeDependencies = false;
void handleDidChangeDependencies() {
didChangeDependencies = true;
......
......@@ -5,6 +5,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void verify(WidgetTester tester, List<Offset> answerKey) {
final List<Offset> testAnswers = tester.renderObjectList<RenderBox>(find.byType(SizedBox)).map<Offset>(
......@@ -14,7 +15,7 @@ void verify(WidgetTester tester, List<Offset> answerKey) {
}
void main() {
testWidgets('Basic Wrap test (LTR)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Basic Wrap test (LTR)', (WidgetTester tester) async {
await tester.pumpWidget(
const Wrap(
textDirection: TextDirection.ltr,
......@@ -129,7 +130,7 @@ void main() {
});
testWidgets('Basic Wrap test (RTL)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Basic Wrap test (RTL)', (WidgetTester tester) async {
await tester.pumpWidget(
const Wrap(
textDirection: TextDirection.rtl,
......@@ -247,12 +248,12 @@ void main() {
});
testWidgets('Empty wrap', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Empty wrap', (WidgetTester tester) async {
await tester.pumpWidget(const Center(child: Wrap(alignment: WrapAlignment.center)));
expect(tester.renderObject<RenderBox>(find.byType(Wrap)).size, equals(Size.zero));
});
testWidgets('Wrap alignment (LTR)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Wrap alignment (LTR)', (WidgetTester tester) async {
await tester.pumpWidget(const Wrap(
alignment: WrapAlignment.center,
spacing: 5.0,
......@@ -322,7 +323,7 @@ void main() {
]);
});
testWidgets('Wrap alignment (RTL)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Wrap alignment (RTL)', (WidgetTester tester) async {
await tester.pumpWidget(const Wrap(
alignment: WrapAlignment.center,
spacing: 5.0,
......@@ -392,7 +393,7 @@ void main() {
]);
});
testWidgets('Wrap runAlignment (DOWN)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Wrap runAlignment (DOWN)', (WidgetTester tester) async {
await tester.pumpWidget(const Wrap(
runAlignment: WrapAlignment.center,
runSpacing: 5.0,
......@@ -479,7 +480,7 @@ void main() {
});
testWidgets('Wrap runAlignment (UP)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Wrap runAlignment (UP)', (WidgetTester tester) async {
await tester.pumpWidget(const Wrap(
runAlignment: WrapAlignment.center,
runSpacing: 5.0,
......@@ -570,7 +571,7 @@ void main() {
});
testWidgets('Shrink-wrapping Wrap test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Shrink-wrapping Wrap test', (WidgetTester tester) async {
await tester.pumpWidget(
const Align(
alignment: Alignment.topLeft,
......@@ -620,7 +621,7 @@ void main() {
]);
});
testWidgets('Wrap spacing test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Wrap spacing test', (WidgetTester tester) async {
await tester.pumpWidget(
const Align(
alignment: Alignment.topLeft,
......@@ -645,7 +646,7 @@ void main() {
]);
});
testWidgets('Vertical Wrap test with spacing', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Vertical Wrap test with spacing', (WidgetTester tester) async {
await tester.pumpWidget(
const Align(
alignment: Alignment.topLeft,
......@@ -704,7 +705,7 @@ void main() {
]);
});
testWidgets('Visual overflow generates a clip', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Visual overflow generates a clip', (WidgetTester tester) async {
await tester.pumpWidget(const Wrap(
textDirection: TextDirection.ltr,
children: <Widget>[
......@@ -726,7 +727,7 @@ void main() {
expect(tester.renderObject<RenderBox>(find.byType(Wrap)), paints..clipRect());
});
testWidgets('Hit test children in wrap', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Hit test children in wrap', (WidgetTester tester) async {
final List<String> log = <String>[];
await tester.pumpWidget(Wrap(
......@@ -762,14 +763,14 @@ void main() {
expect(log, equals(<String>['hit']));
});
testWidgets('RenderWrap toStringShallow control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('RenderWrap toStringShallow control test', (WidgetTester tester) async {
await tester.pumpWidget(const Wrap(alignment: WrapAlignment.center));
final RenderBox wrap = tester.renderObject(find.byType(Wrap));
expect(wrap.toStringShallow(), hasOneLineDescription);
});
testWidgets('RenderWrap toString control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('RenderWrap toString control test', (WidgetTester tester) async {
await tester.pumpWidget(const Wrap(
direction: Axis.vertical,
runSpacing: 7.0,
......@@ -787,7 +788,7 @@ void main() {
expect(width, equals(2021));
});
testWidgets('Wrap baseline control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Wrap baseline control test', (WidgetTester tester) async {
await tester.pumpWidget(
const Center(
child: Baseline(
......@@ -815,7 +816,7 @@ void main() {
);
});
testWidgets('Spacing with slight overflow', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Spacing with slight overflow', (WidgetTester tester) async {
await tester.pumpWidget(const Wrap(
textDirection: TextDirection.ltr,
spacing: 10.0,
......@@ -837,7 +838,7 @@ void main() {
]);
});
testWidgets('Object exactly matches container width', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Object exactly matches container width', (WidgetTester tester) async {
await tester.pumpWidget(
const Column(
children: <Widget>[
......@@ -879,7 +880,7 @@ void main() {
]);
});
testWidgets('Wrap can set and update clipBehavior', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Wrap can set and update clipBehavior', (WidgetTester tester) async {
await tester.pumpWidget(const Wrap(textDirection: TextDirection.ltr));
final RenderWrap renderObject = tester.allRenderObjects.whereType<RenderWrap>().first;
expect(renderObject.clipBehavior, equals(Clip.none));
......@@ -888,7 +889,7 @@ void main() {
expect(renderObject.clipBehavior, equals(Clip.antiAlias));
});
testWidgets('Horizontal wrap - IntrinsicsHeight', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Horizontal wrap - IntrinsicsHeight', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/48679.
await tester.pumpWidget(
const Directionality(
......@@ -920,7 +921,7 @@ void main() {
expect(tester.getSize(find.byType(IntrinsicHeight)).height, 2 * 16 + 40);
});
testWidgets('Vertical wrap - IntrinsicsWidth', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Vertical wrap - IntrinsicsWidth', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/48679.
await tester.pumpWidget(
const Directionality(
......
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