Unverified Commit a7dbec31 authored by Polina Cherkasova's avatar Polina Cherkasova Committed by GitHub

Cover more tests with leak tracking. (#133958)

parent 7625c10f
......@@ -2206,6 +2206,15 @@ class _TimePickerDialogState extends State<TimePickerDialog> with RestorationMix
static const Size _kTimePickerMinLandscapeSize = Size(416, 248);
static const Size _kTimePickerMinInputSize = Size(312, 196);
@override
void dispose() {
_selectedTime.dispose();
_entryMode.dispose();
_autovalidateMode.dispose();
_orientation.dispose();
super.dispose();
}
@override
String? get restorationId => widget.restorationId;
......@@ -2586,6 +2595,13 @@ class _TimePickerState extends State<_TimePicker> with RestorationMixin {
void dispose() {
_vibrateTimer?.cancel();
_vibrateTimer = null;
_orientation.dispose();
_selectedTime.dispose();
_hourMinuteMode.dispose();
_lastModeAnnounced.dispose();
_autofocusHour.dispose();
_autofocusMinute.dispose();
_announcedInitialTime.dispose();
super.dispose();
}
......
......@@ -644,7 +644,7 @@ void main() {
testWidgetsWithLeakTracking('Material2 - Checkbox is focusable and has correct focus color', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
addTearDown(() => focusNode.dispose());
addTearDown(focusNode.dispose);
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
bool? value = true;
Widget buildApp({bool enabled = true}) {
......@@ -715,7 +715,7 @@ void main() {
testWidgetsWithLeakTracking('Material3 - Checkbox is focusable and has correct focus color', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
addTearDown(() => focusNode.dispose());
addTearDown(focusNode.dispose);
final ThemeData theme = ThemeData(useMaterial3: true);
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
bool? value = true;
......@@ -1244,7 +1244,7 @@ void main() {
testWidgetsWithLeakTracking('Checkbox fill color resolves in hovered/focused states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'checkbox');
addTearDown(() => focusNode.dispose());
addTearDown(focusNode.dispose);
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
const Color hoveredFillColor = Color(0xFF000001);
......@@ -1345,7 +1345,7 @@ void main() {
testWidgetsWithLeakTracking('Material2 - Checkbox default overlay color in active/pressed/focused/hovered states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
addTearDown(() => focusNode.dispose());
addTearDown(focusNode.dispose);
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
final ThemeData theme = ThemeData(useMaterial3: false);
......@@ -1413,7 +1413,7 @@ void main() {
testWidgetsWithLeakTracking('Material3 - Checkbox default overlay color in active/pressed/focused/hovered states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
addTearDown(() => focusNode.dispose());
addTearDown(focusNode.dispose);
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
final ThemeData theme = ThemeData(useMaterial3: true);
......@@ -1479,7 +1479,7 @@ void main() {
testWidgetsWithLeakTracking('Checkbox overlay color resolves in active/pressed/focused/hovered states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
addTearDown(() => focusNode.dispose());
addTearDown(focusNode.dispose);
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
const Color fillColor = Color(0xFF000000);
......@@ -1973,7 +1973,7 @@ void main() {
testWidgetsWithLeakTracking('Material3 - Checkbox has default error color when isError is set to true', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
addTearDown(() => focusNode.dispose());
addTearDown(focusNode.dispose);
final ThemeData themeData = ThemeData(useMaterial3: true);
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
bool? value = true;
......@@ -2046,7 +2046,7 @@ void main() {
testWidgetsWithLeakTracking('Material3 - Checkbox MaterialStateBorderSide applies in error states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
addTearDown(() => focusNode.dispose());
addTearDown(focusNode.dispose);
final ThemeData themeData = ThemeData(useMaterial3: true);
const Color borderColor = Color(0xffffeb3b);
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
......
......@@ -111,7 +111,7 @@ void main() {
expect(materialWidget.color, customColor);
});
testWidgets('Dialog Defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Dialog Defaults', (WidgetTester tester) async {
const AlertDialog dialog = AlertDialog(
title: Text('Title'),
content: Text('Y'),
......@@ -146,7 +146,7 @@ void main() {
expect(material3Widget.elevation, 6.0);
});
testWidgets('Dialog.fullscreen Defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Dialog.fullscreen Defaults', (WidgetTester tester) async {
const String dialogTextM2 = 'Fullscreen Dialog - M2';
const String dialogTextM3 = 'Fullscreen Dialog - M3';
......@@ -447,7 +447,7 @@ void main() {
expect(textRect.bottom, dialogRect.bottom - customPadding.bottom);
});
testWidgets('Barrier dismissible', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Barrier dismissible', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Material(
......@@ -644,7 +644,7 @@ void main() {
expect(actionsSize.width, dialogSize.width - (30.0 * 2));
});
testWidgets('AlertDialog.buttonPadding defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('AlertDialog.buttonPadding defaults', (WidgetTester tester) async {
final GlobalKey key1 = GlobalKey();
final GlobalKey key2 = GlobalKey();
......@@ -1904,7 +1904,7 @@ void main() {
semantics.dispose();
});
testWidgets('Dismissible.confirmDismiss defers to an AlertDialog', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Dismissible.confirmDismiss defers to an AlertDialog', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
final List<int> dismissedItems = <int>[];
......@@ -2035,7 +2035,7 @@ void main() {
});
// Regression test for https://github.com/flutter/flutter/issues/28505.
testWidgets('showDialog only gets Theme from context on the first call', (WidgetTester tester) async {
testWidgetsWithLeakTracking('showDialog only gets Theme from context on the first call', (WidgetTester tester) async {
Widget buildFrame(Key builderKey) {
return MaterialApp(
home: Center(
......@@ -2072,7 +2072,7 @@ void main() {
await tester.pump();
});
testWidgets('showDialog safe area', (WidgetTester tester) async {
testWidgetsWithLeakTracking('showDialog safe area', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
builder: (BuildContext context, Widget? child) {
......@@ -2337,7 +2337,7 @@ void main() {
});
group('AlertDialog.scrollable: ', () {
testWidgets('Title is scrollable', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Title is scrollable', (WidgetTester tester) async {
final Key titleKey = UniqueKey();
final AlertDialog dialog = AlertDialog(
title: Container(
......@@ -2377,7 +2377,7 @@ void main() {
expect(box.localToGlobal(Offset.zero), equals(originalOffset.translate(0.0, -200.0)));
});
testWidgets('Title and content are scrollable', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Title and content are scrollable', (WidgetTester tester) async {
final Key titleKey = UniqueKey();
final Key contentKey = UniqueKey();
final AlertDialog dialog = AlertDialog(
......@@ -2416,7 +2416,7 @@ void main() {
});
});
testWidgets('Dialog with RouteSettings', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Dialog with RouteSettings', (WidgetTester tester) async {
late RouteSettings currentRouteSetting;
await tester.pumpWidget(
......@@ -2510,7 +2510,7 @@ void main() {
semantics.dispose();
});
testWidgets('DialogRoute is state restorable', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DialogRoute is state restorable', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
restorationScopeId: 'app',
......@@ -2706,7 +2706,7 @@ void main() {
}
});
testWidgets('showAdaptiveDialog should not allow dismiss on barrier on iOS by default', (WidgetTester tester) async {
testWidgetsWithLeakTracking('showAdaptiveDialog should not allow dismiss on barrier on iOS by default', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS),
......@@ -2766,9 +2766,11 @@ void main() {
expect(find.text('Dialog2'), findsOneWidget);
});
testWidgets('Uses open focus traversal when overridden', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Uses open focus traversal when overridden', (WidgetTester tester) async {
final FocusNode okNode = FocusNode();
addTearDown(okNode.dispose);
final FocusNode cancelNode = FocusNode();
addTearDown(cancelNode.dispose);
Future<bool> nextFocus() async {
final bool result = Actions.invoke(
......
......@@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('DrawerButton control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DrawerButton control test', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
......@@ -170,7 +170,7 @@ void main() {
handle.dispose();
}, variant: TargetPlatformVariant.all());
testWidgets('EndDrawerButton control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('EndDrawerButton control test', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
......
......@@ -5,11 +5,12 @@
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 '../widgets/semantics_tester.dart';
void main() {
testWidgets('Drawer control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer control test', (WidgetTester tester) async {
const Key containerKey = Key('container');
await tester.pumpWidget(
......@@ -57,7 +58,7 @@ void main() {
expect(find.text('header'), findsOneWidget);
});
testWidgets('Drawer dismiss barrier has label', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer dismiss barrier has label', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(
const MaterialApp(
......@@ -81,7 +82,7 @@ void main() {
semantics.dispose();
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('Drawer dismiss barrier has no label', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer dismiss barrier has no label', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(
const MaterialApp(
......@@ -105,7 +106,7 @@ void main() {
semantics.dispose();
}, variant: TargetPlatformVariant.only(TargetPlatform.android));
testWidgets('Scaffold drawerScrimColor', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Scaffold drawerScrimColor', (WidgetTester tester) async {
// The scrim is a Container within a Semantics node labeled "Dismiss",
// within a DrawerController. Sorry.
Container getScrim() {
......@@ -167,7 +168,7 @@ void main() {
expect(find.byType(Drawer), findsNothing);
});
testWidgets('Open/close drawers by flinging', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Open/close drawers by flinging', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
......@@ -381,7 +382,7 @@ void main() {
expect(find.text('endDrawer'), findsOneWidget);
});
testWidgets('ScaffoldState close drawer', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ScaffoldState close drawer', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
await tester.pumpWidget(
MaterialApp(
......@@ -404,7 +405,7 @@ void main() {
expect(find.text('Drawer'), findsNothing);
});
testWidgets('ScaffoldState close drawer do not crash if drawer is already closed', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ScaffoldState close drawer do not crash if drawer is already closed', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
await tester.pumpWidget(
MaterialApp(
......@@ -423,7 +424,7 @@ void main() {
expect(find.text('Drawer'), findsNothing);
});
testWidgets('Disposing drawer does not crash if drawer is open and framework is locked', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Disposing drawer does not crash if drawer is open and framework is locked', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/34978
addTearDown(tester.view.reset);
tester.view.physicalSize = const Size(1800.0, 2400.0);
......@@ -464,7 +465,7 @@ void main() {
expect(find.byType(BackButton), findsNothing);
});
testWidgets('Disposing endDrawer does not crash if endDrawer is open and framework is locked', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Disposing endDrawer does not crash if endDrawer is open and framework is locked', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/34978
addTearDown(tester.view.reset);
tester.view.physicalSize = const Size(1800.0, 2400.0);
......@@ -505,7 +506,7 @@ void main() {
expect(find.byType(BackButton), findsNothing);
});
testWidgets('ScaffoldState close end drawer', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ScaffoldState close end drawer', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
await tester.pumpWidget(
MaterialApp(
......@@ -528,7 +529,7 @@ void main() {
expect(find.text('endDrawer'), findsNothing);
});
testWidgets('Drawer width defaults to Material spec', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer width defaults to Material spec', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
......@@ -547,7 +548,7 @@ void main() {
expect(box.size.width, equals(304.0));
});
testWidgets('Drawer width can be customized by parameter', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer width can be customized by parameter', (WidgetTester tester) async {
const double smallWidth = 200;
await tester.pumpWidget(
......@@ -569,7 +570,7 @@ void main() {
expect(box.size.width, equals(smallWidth));
});
testWidgets('Drawer default shape (ltr)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer default shape (ltr)', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: true),
......@@ -629,7 +630,7 @@ void main() {
);
});
testWidgets('Drawer default shape (rtl)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer default shape (rtl)', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: true),
......@@ -689,7 +690,7 @@ void main() {
);
});
testWidgets('Drawer clip behavior', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer clip behavior', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: true),
......@@ -745,7 +746,7 @@ void main() {
// support is deprecated and the APIs are removed, these tests
// can be deleted.
testWidgets('Drawer default shape', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer default shape', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: false),
......@@ -786,7 +787,7 @@ void main() {
expect(material.shape, null);
});
testWidgets('Drawer clip behavior', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer clip behavior', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: false),
......
......@@ -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 main() {
test('copyWith, ==, hashCode basics', () {
......@@ -18,7 +19,7 @@ void main() {
expect(identical(DrawerThemeData.lerp(data, data, 0.5), data), true);
});
testWidgets('Default debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Default debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const DrawerThemeData().debugFillProperties(builder);
......@@ -30,7 +31,7 @@ void main() {
expect(description, <String>[]);
});
testWidgets('Custom debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Custom debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const DrawerThemeData(
backgroundColor: Color(0x00000099),
......@@ -58,7 +59,7 @@ void main() {
]);
});
testWidgets('Material2 - Default values are used when no Drawer or DrawerThemeData properties are specified', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material2 - Default values are used when no Drawer or DrawerThemeData properties are specified', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
final ThemeData theme = ThemeData(useMaterial3: false);
await tester.pumpWidget(
......@@ -82,7 +83,7 @@ void main() {
expect(_drawerRenderBox(tester).size.width, 304.0);
});
testWidgets('Material3 - Default values are used when no Drawer or DrawerThemeData properties are specified', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material3 - Default values are used when no Drawer or DrawerThemeData properties are specified', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(
......@@ -109,7 +110,7 @@ void main() {
expect(_drawerRenderBox(tester).size.width, 304.0);
});
testWidgets('Material2 - Default values are used when no Drawer or DrawerThemeData properties are specified in end drawer', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material2 - Default values are used when no Drawer or DrawerThemeData properties are specified in end drawer', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
final ThemeData theme = ThemeData(useMaterial3: false);
await tester.pumpWidget(
......@@ -133,7 +134,7 @@ void main() {
expect(_drawerRenderBox(tester).size.width, 304.0);
});
testWidgets('Material3 - Default values are used when no Drawer or DrawerThemeData properties are specified in end drawer', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material3 - Default values are used when no Drawer or DrawerThemeData properties are specified in end drawer', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(
......@@ -160,7 +161,7 @@ void main() {
expect(_drawerRenderBox(tester).size.width, 304.0);
});
testWidgets('DrawerThemeData values are used when no Drawer properties are specified', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DrawerThemeData values are used when no Drawer properties are specified', (WidgetTester tester) async {
const Color backgroundColor = Color(0x00000001);
const Color scrimColor = Color(0x00000002);
const double elevation = 7.0;
......@@ -201,7 +202,7 @@ void main() {
expect(_drawerRenderBox(tester).size.width, width);
});
testWidgets('Drawer values take priority over DrawerThemeData values when both properties are specified', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer values take priority over DrawerThemeData values when both properties are specified', (WidgetTester tester) async {
const Color backgroundColor = Color(0x00000001);
const Color scrimColor = Color(0x00000002);
const double elevation = 7.0;
......@@ -248,7 +249,7 @@ void main() {
expect(_drawerRenderBox(tester).size.width, width);
});
testWidgets('DrawerTheme values take priority over ThemeData.drawerTheme values when both properties are specified', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DrawerTheme values take priority over ThemeData.drawerTheme values when both properties are specified', (WidgetTester tester) async {
const Color backgroundColor = Color(0x00000001);
const Color scrimColor = Color(0x00000002);
const double elevation = 7.0;
......
......@@ -875,7 +875,7 @@ void main() {
},
);
testWidgets('No duplicate global keys at layout/build time', (WidgetTester tester) async {
testWidgetsWithLeakTracking('No duplicate global keys at layout/build time', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/13780
await tester.pumpWidget(
StatefulBuilder(
......@@ -1586,7 +1586,7 @@ void main() {
expect(expandIcon.color, expandIconColor);
});
testWidgets('elevation is propagated properly to MergeableMaterial', (WidgetTester tester) async {
testWidgetsWithLeakTracking('elevation is propagated properly to MergeableMaterial', (WidgetTester tester) async {
const double elevation = 8;
// Test for ExpansionPanelList.
......
......@@ -11,7 +11,7 @@ import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart';
void main() {
testWidgets('FilledButton, FilledButton.icon defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FilledButton, FilledButton.icon defaults', (WidgetTester tester) async {
const ColorScheme colorScheme = ColorScheme.light();
final ThemeData theme = ThemeData.from(useMaterial3: false, colorScheme: colorScheme);
......@@ -124,7 +124,7 @@ void main() {
expect(material.type, MaterialType.button);
});
testWidgets('FilledButton.tonal, FilledButton.tonalIcon defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FilledButton.tonal, FilledButton.tonalIcon defaults', (WidgetTester tester) async {
const ColorScheme colorScheme = ColorScheme.light();
final ThemeData theme = ThemeData.from(colorScheme: colorScheme);
......@@ -239,6 +239,7 @@ void main() {
testWidgets('Default FilledButton meets a11y contrast guidelines', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose);
await tester.pumpWidget(
MaterialApp(
......@@ -1845,6 +1846,7 @@ void main() {
count += 1;
}
final MaterialStatesController controller = MaterialStatesController();
addTearDown(controller.dispose);
controller.addListener(valueChanged);
await tester.pumpWidget(
......@@ -1945,20 +1947,21 @@ void main() {
await gesture.removePointer();
}
testWidgets('FilledButton statesController', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FilledButton statesController', (WidgetTester tester) async {
testStatesController(null, tester);
});
testWidgets('FilledButton.icon statesController', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FilledButton.icon statesController', (WidgetTester tester) async {
testStatesController(const Icon(Icons.add), tester);
});
testWidgets('Disabled FilledButton statesController', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Disabled FilledButton statesController', (WidgetTester tester) async {
int count = 0;
void valueChanged() {
count += 1;
}
final MaterialStatesController controller = MaterialStatesController();
addTearDown(controller.dispose);
controller.addListener(valueChanged);
await tester.pumpWidget(
MaterialApp(
......@@ -1973,7 +1976,9 @@ void main() {
);
expect(controller.value, <MaterialState>{MaterialState.disabled});
expect(count, 1);
});
},
leakTrackingTestConfig: LeakTrackingTestConfig.debugNotDisposed(),
);
}
......
......@@ -50,7 +50,7 @@ void main() {
expect(topAfterScroll.dy, equals(0.0));
}, variant: TargetPlatformVariant.all(excluding: <TargetPlatform>{ TargetPlatform.fuchsia }));
testWidgets('FlexibleSpaceBar collapse mode pin', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FlexibleSpaceBar collapse mode pin', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(platform: debugDefaultTargetPlatformOverride),
......@@ -88,7 +88,7 @@ void main() {
expect(topAfterScroll.dy, equals(-100.0));
}, variant: TargetPlatformVariant.all(excluding: <TargetPlatform>{ TargetPlatform.fuchsia }));
testWidgets('FlexibleSpaceBar collapse mode parallax', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FlexibleSpaceBar collapse mode parallax', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(platform: debugDefaultTargetPlatformOverride),
......
......@@ -91,7 +91,7 @@ void main() {
);
});
testWidgets('FlexibleSpaceBar stretch mode fadeTitle', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FlexibleSpaceBar stretch mode fadeTitle', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
......@@ -135,7 +135,7 @@ void main() {
expect(opacityWidget.opacity, equals(0.0));
});
testWidgets('FlexibleSpaceBar stretch mode ignored for non-overscroll physics', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FlexibleSpaceBar stretch mode ignored for non-overscroll physics', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
......
......@@ -121,7 +121,7 @@ void main() {
focusNode.dispose();
});
testWidgets('when null, iconSize is overridden by closest IconTheme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('when null, iconSize is overridden by closest IconTheme', (WidgetTester tester) async {
RenderBox icon;
final bool material3 = theme.useMaterial3;
......@@ -331,7 +331,7 @@ void main() {
expect(box.size, const Size(80.0, 80.0));
});
testWidgets('test default icon buttons can be stretched if specified', (WidgetTester tester) async {
testWidgetsWithLeakTracking('test default icon buttons can be stretched if specified', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
......@@ -407,7 +407,7 @@ void main() {
expect(align.alignment, Alignment.center);
});
testWidgets('test tooltip', (WidgetTester tester) async {
testWidgetsWithLeakTracking('test tooltip', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: theme,
......@@ -2588,7 +2588,7 @@ void main() {
});
group('IconTheme tests in Material 3', () {
testWidgets('IconTheme overrides default values in M3', (WidgetTester tester) async {
testWidgetsWithLeakTracking('IconTheme overrides default values in M3', (WidgetTester tester) async {
// Theme's IconTheme
await tester.pumpWidget(
MaterialApp(
......
......@@ -4,9 +4,10 @@
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('Theme.wrap()', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Theme.wrap()', (WidgetTester tester) async {
const Color primaryColor = Color(0xFF00FF00);
final Key primaryContainerKey = UniqueKey();
......@@ -91,7 +92,7 @@ void main() {
expect(containerColor(), isNot(primaryColor));
});
testWidgets('PopupMenuTheme.wrap()', (WidgetTester tester) async {
testWidgetsWithLeakTracking('PopupMenuTheme.wrap()', (WidgetTester tester) async {
const double menuFontSize = 24;
const Color menuTextColor = Color(0xFF0000FF);
......@@ -145,7 +146,7 @@ void main() {
await tester.pumpAndSettle(); // menu route animation
});
testWidgets('BannerTheme.wrap()', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BannerTheme.wrap()', (WidgetTester tester) async {
const Color bannerBackgroundColor = Color(0xFF0000FF);
const double bannerFontSize = 48;
const Color bannerTextColor = Color(0xFF00FF00);
......@@ -243,7 +244,7 @@ void main() {
expect(getTextStyle('hello').color, isNot(bannerTextColor));
});
testWidgets('DividerTheme.wrap()', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DividerTheme.wrap()', (WidgetTester tester) async {
const Color dividerColor = Color(0xFF0000FF);
const double dividerSpace = 13;
const double dividerThickness = 7;
......@@ -325,7 +326,7 @@ void main() {
expect(dividerBorder().width, isNot(dividerThickness));
});
testWidgets('ListTileTheme.wrap()', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ListTileTheme.wrap()', (WidgetTester tester) async {
const Color tileSelectedColor = Color(0xFF00FF00);
const Color tileIconColor = Color(0xFF0000FF);
const Color tileTextColor = Color(0xFFFF0000);
......@@ -436,7 +437,7 @@ void main() {
expect(getIconStyle(unselectedIconKey).color, isNot(tileIconColor));
});
testWidgets('SliderTheme.wrap()', (WidgetTester tester) async {
testWidgetsWithLeakTracking('SliderTheme.wrap()', (WidgetTester tester) async {
const Color activeTrackColor = Color(0xFF00FF00);
const Color inactiveTrackColor = Color(0xFF0000FF);
const Color thumbColor = Color(0xFFFF0000);
......@@ -519,7 +520,7 @@ void main() {
expect(sliderBox, isNot(paints..circle(color: thumbColor)));
});
testWidgets('ToggleButtonsTheme.wrap()', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ToggleButtonsTheme.wrap()', (WidgetTester tester) async {
const Color buttonColor = Color(0xFF00FF00);
const Color selectedButtonColor = Color(0xFFFF0000);
......
......@@ -270,12 +270,13 @@ void main() {
await gesture.up();
});
testWidgets('The InkWell widget renders an SelectAction or ActivateAction-induced ink ripple', (WidgetTester tester) async {
testWidgetsWithLeakTracking('The InkWell widget renders an SelectAction or ActivateAction-induced ink ripple', (WidgetTester tester) async {
const Color highlightColor = Color(0xAAFF0000);
const Color splashColor = Color(0xB40000FF);
const BorderRadius borderRadius = BorderRadius.all(Radius.circular(6.0));
final FocusNode focusNode = FocusNode(debugLabel: 'Test Node');
addTearDown(focusNode.dispose);
Future<void> buildTest(Intent intent) async {
return tester.pumpWidget(
Shortcuts(
......@@ -453,9 +454,13 @@ void main() {
}));
});
testWidgets('The InkWell widget on OverlayPortal does not throw', (WidgetTester tester) async {
testWidgetsWithLeakTracking('The InkWell widget on OverlayPortal does not throw', (WidgetTester tester) async {
final OverlayPortalController controller = OverlayPortalController();
controller.show();
late OverlayEntry overlayEntry;
addTearDown(() => overlayEntry..remove()..dispose());
await tester.pumpWidget(
Center(
child: RepaintBoundary(
......@@ -465,7 +470,7 @@ void main() {
textDirection: TextDirection.ltr,
child: Overlay(
initialEntries: <OverlayEntry>[
OverlayEntry(
overlayEntry = OverlayEntry(
builder: (BuildContext context) {
return Center(
child: SizedBox.square(
......
......@@ -2086,7 +2086,7 @@ testWidgetsWithLeakTracking('InkResponse radius can be updated', (WidgetTester t
expect(inkFeatures, paintsExactlyCountTimes(#drawCircle, 0));
});
testWidgets('InkWell disposes statesController', (WidgetTester tester) async {
testWidgetsWithLeakTracking('InkWell disposes statesController', (WidgetTester tester) async {
int tapCount = 0;
Widget buildFrame(MaterialStatesController? statesController) {
return MaterialApp(
......@@ -2103,6 +2103,7 @@ testWidgetsWithLeakTracking('InkResponse radius can be updated', (WidgetTester t
}
final MaterialStatesController controller = MaterialStatesController();
addTearDown(controller.dispose);
int pressedCount = 0;
controller.addListener(() {
if (controller.value.contains(MaterialState.pressed)) {
......
......@@ -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 '../widgets/clipboard_utils.dart';
......@@ -97,7 +98,7 @@ void main() {
group('InputDatePickerFormField', () {
testWidgets('Initial date is the default', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Initial date is the default', (WidgetTester tester) async {
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
final DateTime initialDate = DateTime(2016, DateTime.february, 21);
DateTime? inputDate;
......@@ -111,7 +112,7 @@ void main() {
expect(inputDate, equals(initialDate));
});
testWidgets('Changing initial date is reflected in text value', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Changing initial date is reflected in text value', (WidgetTester tester) async {
final DateTime initialDate = DateTime(2016, DateTime.february, 21);
final DateTime updatedInitialDate = DateTime(2016, DateTime.february, 23);
await tester.pumpWidget(inputDatePickerField(
......@@ -126,7 +127,7 @@ void main() {
expect(textFieldController(tester).value.text, equals('02/23/2016'));
});
testWidgets('Valid date entry', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Valid date entry', (WidgetTester tester) async {
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
DateTime? inputDate;
await tester.pumpWidget(inputDatePickerField(
......@@ -139,7 +140,7 @@ void main() {
expect(inputDate, equals(DateTime(2016, DateTime.february, 21)));
});
testWidgets('Invalid text entry shows errorFormat text', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Invalid text entry shows errorFormat text', (WidgetTester tester) async {
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
DateTime? inputDate;
await tester.pumpWidget(inputDatePickerField(
......@@ -166,7 +167,7 @@ void main() {
expect(find.text('That is not a date.'), findsOneWidget);
});
testWidgets('Valid text entry, but date outside first or last date shows bounds shows errorInvalid text', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Valid text entry, but date outside first or last date shows bounds shows errorInvalid text', (WidgetTester tester) async {
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
DateTime? inputDate;
await tester.pumpWidget(inputDatePickerField(
......@@ -201,7 +202,7 @@ void main() {
expect(find.text('Not in given range.'), findsOneWidget);
});
testWidgets('selectableDatePredicate will be used to show errorInvalid if date is not selectable', (WidgetTester tester) async {
testWidgetsWithLeakTracking('selectableDatePredicate will be used to show errorInvalid if date is not selectable', (WidgetTester tester) async {
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
DateTime? inputDate;
await tester.pumpWidget(inputDatePickerField(
......@@ -227,7 +228,7 @@ void main() {
expect(find.text('Out of range.'), findsNothing);
});
testWidgets('Empty field shows hint text when focused', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Empty field shows hint text when focused', (WidgetTester tester) async {
await tester.pumpWidget(inputDatePickerField());
// Focus on it
await tester.tap(find.byType(TextField));
......@@ -250,7 +251,7 @@ void main() {
expect(textOpacity(tester, 'Enter some date'), equals(0.0));
});
testWidgets('Label text', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Label text', (WidgetTester tester) async {
await tester.pumpWidget(inputDatePickerField());
// Default label
expect(find.text('Enter Date'), findsOneWidget);
......@@ -262,7 +263,7 @@ void main() {
expect(find.text('Give me a date!'), findsOneWidget);
});
testWidgets('Semantics', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Semantics', (WidgetTester tester) async {
final SemanticsHandle semantics = tester.ensureSemantics();
// Fill the clipboard so that the Paste option is available in the text
......@@ -291,7 +292,7 @@ void main() {
semantics.dispose();
});
testWidgets('InputDecorationTheme is honored', (WidgetTester tester) async {
testWidgetsWithLeakTracking('InputDecorationTheme is honored', (WidgetTester tester) async {
const InputBorder border = InputBorder.none;
await tester.pumpWidget(inputDatePickerField(
theme: ThemeData.from(colorScheme: const ColorScheme.light()).copyWith(
......@@ -325,7 +326,7 @@ void main() {
expect(containerColor, equals(Colors.transparent));
});
testWidgets('Date text localization', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Date text localization', (WidgetTester tester) async {
final Iterable<LocalizationsDelegate<dynamic>> delegates = <LocalizationsDelegate<dynamic>>[
TestMaterialLocalizationsDelegate(),
DefaultWidgetsLocalizations.delegate,
......@@ -348,7 +349,7 @@ void main() {
);
});
testWidgets('when an empty date is entered and acceptEmptyDate is true, then errorFormatText is not shown', (WidgetTester tester) async {
testWidgetsWithLeakTracking('when an empty date is entered and acceptEmptyDate is true, then errorFormatText is not shown', (WidgetTester tester) async {
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
const String errorFormatText = 'That is not a date.';
await tester.pumpWidget(inputDatePickerField(
......@@ -363,7 +364,7 @@ void main() {
expect(find.text(errorFormatText), findsNothing);
});
testWidgets('when an empty date is entered and acceptEmptyDate is false, then errorFormatText is shown', (WidgetTester tester) async {
testWidgetsWithLeakTracking('when an empty date is entered and acceptEmptyDate is false, then errorFormatText is shown', (WidgetTester tester) async {
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
const String errorFormatText = 'That is not a date.';
await tester.pumpWidget(inputDatePickerField(
......
......@@ -53,7 +53,7 @@ void main() {
expect(identical(MenuBarThemeData.lerp(data, data, 0.5), data), true);
});
testWidgets('theme is honored', (WidgetTester tester) async {
testWidgetsWithLeakTracking('theme is honored', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: false),
......
......@@ -5,6 +5,7 @@
import 'package:flutter/foundation.dart';
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() {
......@@ -43,7 +44,7 @@ void main() {
expect(identical(MenuStyle.lerp(data, data, 0.5), data), true);
});
testWidgets('fixedSize affects geometry', (WidgetTester tester) async {
testWidgetsWithLeakTracking('fixedSize affects geometry', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Material(
......@@ -88,7 +89,7 @@ void main() {
}
});
testWidgets('maximumSize affects geometry', (WidgetTester tester) async {
testWidgetsWithLeakTracking('maximumSize affects geometry', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Material(
......@@ -131,7 +132,7 @@ void main() {
expect(tester.getRect(findMenuPanels().at(1)).size, equals(const Size(100.0, 100.0)));
});
testWidgets('minimumSize affects geometry', (WidgetTester tester) async {
testWidgetsWithLeakTracking('minimumSize affects geometry', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Material(
......@@ -174,7 +175,7 @@ void main() {
expect(tester.getRect(findMenuPanels().at(1)).size, equals(const Size(300.0, 300.0)));
});
testWidgets('Material parameters are honored', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material parameters are honored', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Material(
......@@ -240,7 +241,7 @@ void main() {
expect(panelPadding.padding, equals(const EdgeInsets.all(20)));
});
testWidgets('visual density', (WidgetTester tester) async {
testWidgetsWithLeakTracking('visual density', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: false),
......
......@@ -54,7 +54,7 @@ void main() {
expect(identical(MenuThemeData.lerp(data, data, 0.5), data), true);
});
testWidgets('theme is honored', (WidgetTester tester) async {
testWidgetsWithLeakTracking('theme is honored', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: false),
......
......@@ -79,7 +79,7 @@ void main() {
expect(box.size.height, equals(0));
});
testWidgets('MergeableMaterial update slice', (WidgetTester tester) async {
testWidgetsWithLeakTracking('MergeableMaterial update slice', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
......@@ -233,7 +233,7 @@ void main() {
debugDisableShadows = true;
});
testWidgets('MergeableMaterial skips shadow for zero elevation', (WidgetTester tester) async {
testWidgetsWithLeakTracking('MergeableMaterial skips shadow for zero elevation', (WidgetTester tester) async {
debugDisableShadows = false;
await tester.pumpWidget(
const MaterialApp(
......@@ -1167,7 +1167,7 @@ void main() {
);
}
testWidgets('MergeableMaterial dividers', (WidgetTester tester) async {
testWidgetsWithLeakTracking('MergeableMaterial dividers', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: false),
......@@ -1329,7 +1329,7 @@ void main() {
expect(decoration.border!.top.color, dividerColor);
});
testWidgets('MergeableMaterial respects MaterialSlice.color', (WidgetTester tester) async {
testWidgetsWithLeakTracking('MergeableMaterial respects MaterialSlice.color', (WidgetTester tester) async {
const Color themeCardColor = Colors.red;
const Color materialSliceColor = Colors.green;
......
......@@ -4,9 +4,10 @@
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('Navigation drawer updates destinations when tapped',
testWidgetsWithLeakTracking('Navigation drawer updates destinations when tapped',
(WidgetTester tester) async {
int mutatedIndex = -1;
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
......@@ -49,7 +50,7 @@ void main() {
expect(mutatedIndex, 0);
});
testWidgets('NavigationDrawer can update background color',
testWidgetsWithLeakTracking('NavigationDrawer can update background color',
(WidgetTester tester) async {
const Color color = Colors.yellow;
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
......@@ -82,7 +83,7 @@ void main() {
expect(_getMaterial(tester).color, equals(color));
});
testWidgets('NavigationDrawer can update elevation',
testWidgetsWithLeakTracking('NavigationDrawer can update elevation',
(WidgetTester tester) async {
const double elevation = 42.0;
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
......@@ -114,7 +115,7 @@ void main() {
expect(_getMaterial(tester).elevation, equals(elevation));
});
testWidgets(
testWidgetsWithLeakTracking(
'NavigationDrawer uses proper defaults when no parameters are given',
(WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
......@@ -163,7 +164,7 @@ void main() {
expect(iconBox.size, const Size(24.0, 24.0));
});
testWidgets('Navigation drawer is scrollable', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Navigation drawer is scrollable', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
widgetSetup(tester, 500, viewHeight: 300);
await tester.pumpWidget(
......@@ -210,7 +211,7 @@ void main() {
expect(find.text('Label10'), findsNothing);
});
testWidgets('Safe Area test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Safe Area test', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
const double viewHeight = 300;
widgetSetup(tester, 500, viewHeight: viewHeight);
......@@ -251,7 +252,7 @@ void main() {
expect(tester.getBottomRight(find.widgetWithText(NavigationDrawerDestination,'Label4')).dy, viewHeight);
});
testWidgets('Navigation drawer semantics', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Navigation drawer semantics', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
final ThemeData theme= ThemeData.from(colorScheme: const ColorScheme.light());
Widget widget({int selectedIndex = 0}) {
......@@ -321,7 +322,7 @@ void main() {
);
});
testWidgets('Navigation destination updates indicator color and shape', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Navigation destination updates indicator color and shape', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
final ThemeData theme = ThemeData(useMaterial3: true);
const Color color = Color(0xff0000ff);
......@@ -372,7 +373,7 @@ void main() {
expect(_getInkWell(tester)?.customBorder, shape);
});
testWidgets('NavigationDrawer.tilePadding defaults to EdgeInsets.symmetric(horizontal: 12.0)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('NavigationDrawer.tilePadding defaults to EdgeInsets.symmetric(horizontal: 12.0)', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
widgetSetup(tester, 3000, viewHeight: 3000);
final Widget widget = _buildWidget(
......
......@@ -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 main() {
test('NavigationDrawerThemeData copyWith, ==, hashCode, basics', () {
......@@ -18,7 +19,7 @@ void main() {
expect(identical(NavigationDrawerThemeData.lerp(data, data, 0.5), data), true);
});
testWidgets('Default debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Default debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const NavigationDrawerThemeData().debugFillProperties(builder);
......@@ -30,7 +31,7 @@ void main() {
expect(description, <String>[]);
});
testWidgets('NavigationDrawerThemeData implements debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('NavigationDrawerThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const NavigationDrawerThemeData(
tileHeight: 50,
......@@ -66,7 +67,7 @@ void main() {
));
});
testWidgets(
testWidgetsWithLeakTracking(
'NavigationDrawerThemeData values are used when no NavigationDrawer properties are specified',
(WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
......@@ -134,7 +135,7 @@ void main() {
);
});
testWidgets(
testWidgetsWithLeakTracking(
'NavigationDrawer values take priority over NavigationDrawerThemeData values when both properties are specified',
(WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
......@@ -196,7 +197,7 @@ void main() {
expect(_getIndicatorDecoration(tester)?.shape, indicatorShape);
});
testWidgets('Local NavigationDrawerTheme takes priority over ThemeData.navigationDrawerTheme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Local NavigationDrawerTheme takes priority over ThemeData.navigationDrawerTheme', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
const Color backgroundColor = Color(0x00000009);
const double elevation = 7.0;
......
......@@ -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 main() {
test('copyWith, ==, hashCode basics', () {
......@@ -12,7 +13,7 @@ void main() {
expect(const NavigationRailThemeData().hashCode, const NavigationRailThemeData().copyWith().hashCode);
});
testWidgets('Material3 - Default values are used when no NavigationRail or NavigationRailThemeData properties are specified', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material3 - Default values are used when no NavigationRail or NavigationRailThemeData properties are specified', (WidgetTester tester) async {
final ThemeData theme = ThemeData.light(useMaterial3: true);
// Material 3 defaults
await tester.pumpWidget(
......@@ -47,7 +48,7 @@ void main() {
expect(inkResponse.customBorder, const StadiumBorder());
});
testWidgets('Material2 - Default values are used when no NavigationRail or NavigationRailThemeData properties are specified', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material2 - Default values are used when no NavigationRail or NavigationRailThemeData properties are specified', (WidgetTester tester) async {
// This test can be removed when `useMaterial3` is deprecated.
await tester.pumpWidget(
MaterialApp(
......@@ -77,7 +78,7 @@ void main() {
expect(find.byType(NavigationIndicator), findsNothing);
});
testWidgets('NavigationRailThemeData values are used when no NavigationRail properties are specified', (WidgetTester tester) async {
testWidgetsWithLeakTracking('NavigationRailThemeData values are used when no NavigationRail properties are specified', (WidgetTester tester) async {
const Color backgroundColor = Color(0x00000001);
const double elevation = 7.0;
const double selectedIconSize = 25.0;
......@@ -145,7 +146,7 @@ void main() {
expect(_indicatorDecoration(tester)?.shape, indicatorShape);
});
testWidgets('NavigationRail values take priority over NavigationRailThemeData values when both properties are specified', (WidgetTester tester) async {
testWidgetsWithLeakTracking('NavigationRail values take priority over NavigationRailThemeData values when both properties are specified', (WidgetTester tester) async {
const Color backgroundColor = Color(0x00000001);
const double elevation = 7.0;
const double selectedIconSize = 25.0;
......@@ -229,14 +230,14 @@ void main() {
});
// Regression test for https://github.com/flutter/flutter/issues/118618.
testWidgets('NavigationRailThemeData lerps correctly with null iconThemes', (WidgetTester tester) async {
testWidgetsWithLeakTracking('NavigationRailThemeData lerps correctly with null iconThemes', (WidgetTester tester) async {
final NavigationRailThemeData lerp = NavigationRailThemeData.lerp(const NavigationRailThemeData(), const NavigationRailThemeData(), 0.5)!;
expect(lerp.selectedIconTheme, isNull);
expect(lerp.unselectedIconTheme, isNull);
});
testWidgets('Default debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Default debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const NavigationRailThemeData().debugFillProperties(builder);
......@@ -248,7 +249,7 @@ void main() {
expect(description, <String>[]);
});
testWidgets('Custom debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Custom debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const NavigationRailThemeData(
backgroundColor: Color(0x00000099),
......
......@@ -1890,6 +1890,7 @@ void main() {
count += 1;
}
final MaterialStatesController controller = MaterialStatesController();
addTearDown(controller.dispose);
controller.addListener(valueChanged);
await tester.pumpWidget(
......@@ -1990,20 +1991,21 @@ void main() {
await gesture.removePointer();
}
testWidgets('OutlinedButton statesController', (WidgetTester tester) async {
testWidgetsWithLeakTracking('OutlinedButton statesController', (WidgetTester tester) async {
testStatesController(null, tester);
});
testWidgets('OutlinedButton.icon statesController', (WidgetTester tester) async {
testWidgetsWithLeakTracking('OutlinedButton.icon statesController', (WidgetTester tester) async {
testStatesController(const Icon(Icons.add), tester);
});
testWidgets('Disabled OutlinedButton statesController', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Disabled OutlinedButton statesController', (WidgetTester tester) async {
int count = 0;
void valueChanged() {
count += 1;
}
final MaterialStatesController controller = MaterialStatesController();
addTearDown(controller.dispose);
controller.addListener(valueChanged);
await tester.pumpWidget(
......
......@@ -306,7 +306,7 @@ void main() {
await tester.pumpAndSettle();
}, variant: TargetPlatformVariant.only(TargetPlatform.android), skip: kIsWeb); // [intended] rasterization is not used on the web.
testWidgets('_ZoomPageTransition only causes child widget built once', (WidgetTester tester) async {
testWidgetsWithLeakTracking('_ZoomPageTransition only causes child widget built once', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/58345
int builtCount = 0;
......
......@@ -68,6 +68,7 @@ void main() {
testWidgets('PaginatedDataTable paging', (WidgetTester tester) async {
final TestDataSource source = TestDataSource();
addTearDown(source.dispose);
final List<String> log = <String>[];
......@@ -1218,7 +1219,9 @@ void main() {
testWidgets('PaginatedDataTable can be scrolled using ScrollController', (WidgetTester tester) async {
final TestDataSource source = TestDataSource();
addTearDown(source.dispose);
final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose);
Widget buildTable(TestDataSource source) {
return Align(
......@@ -1267,7 +1270,9 @@ void main() {
testWidgets('PaginatedDataTable uses PrimaryScrollController when primary ', (WidgetTester tester) async {
final ScrollController primaryScrollController = ScrollController();
addTearDown(primaryScrollController.dispose);
final TestDataSource source = TestDataSource();
addTearDown(source.dispose);
await tester.pumpWidget(
MaterialApp(
......
......@@ -795,8 +795,10 @@ void main() {
expect(tileNode.hasPrimaryFocus, isTrue);
});
testWidgets('RadioListTile onFocusChange callback', (WidgetTester tester) async {
testWidgetsWithLeakTracking('RadioListTile onFocusChange callback', (WidgetTester tester) async {
final FocusNode node = FocusNode(debugLabel: 'RadioListTile onFocusChange');
addTearDown(node.dispose);
bool gotFocus = false;
await tester.pumpWidget(
MaterialApp(
......
......@@ -1311,7 +1311,7 @@ void main() {
focusNode.dispose();
});
testWidgets('Radio overlay color resolves in active/pressed/focused/hovered states', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Radio overlay color resolves in active/pressed/focused/hovered states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Radio');
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
......@@ -1634,7 +1634,7 @@ void main() {
);
});
testWidgets('Material2 - Radio button default overlay colors in hover/focus/press states', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material2 - Radio button default overlay colors in hover/focus/press states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Radio');
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
......@@ -1723,7 +1723,7 @@ void main() {
focusNode.dispose();
});
testWidgets('Material3 - Radio button default overlay colors in hover/focus/press states', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material3 - Radio button default overlay colors in hover/focus/press states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Radio');
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
......
......@@ -791,7 +791,7 @@ void main() {
scrollController.dispose();
});
testWidgets('Scrollbar never goes away until finger lift', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Scrollbar never goes away until finger lift', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scrollbar(
......
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