Skip to content

Commit b958b87

Browse files
authored
Fix leaky tests. (flutter#150817)
1 parent 5030724 commit b958b87

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

packages/flutter/test/cupertino/button_test.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,8 @@ void main() {
492492

493493
testWidgets('Button can be focused and has default colors', (WidgetTester tester) async {
494494
final FocusNode focusNode = FocusNode(debugLabel: 'Button');
495+
addTearDown(focusNode.dispose);
496+
495497
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
496498
const Border defaultFocusBorder = Border.fromBorderSide(
497499
BorderSide(
@@ -540,6 +542,8 @@ void main() {
540542

541543
testWidgets('Button configures focus color', (WidgetTester tester) async {
542544
final FocusNode focusNode = FocusNode(debugLabel: 'Button');
545+
addTearDown(focusNode.dispose);
546+
543547
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
544548
const Color focusColor = CupertinoColors.systemGreen;
545549

@@ -576,6 +580,8 @@ void main() {
576580

577581
testWidgets('CupertinoButton.onFocusChange callback', (WidgetTester tester) async {
578582
final FocusNode focusNode = FocusNode(debugLabel: 'CupertinoButton');
583+
addTearDown(focusNode.dispose);
584+
579585
bool focused = false;
580586
await tester.pumpWidget(
581587
CupertinoApp(

packages/flutter/test/widgets/undo_history_test.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ void main() {
3232

3333
testWidgets('UndoHistory widget registers as global undo/redo client', (WidgetTester tester) async {
3434
final FocusNode focusNode = FocusNode(debugLabel: 'UndoHistory Node');
35+
addTearDown(focusNode.dispose);
3536
final GlobalKey undoHistoryGlobalKey = GlobalKey();
3637
final ValueNotifier<int> value = ValueNotifier<int>(0);
3738
addTearDown(value.dispose);
@@ -68,6 +69,7 @@ void main() {
6869
testWidgets('UndoHistory widget deregisters as global undo/redo client when it loses focus',
6970
(WidgetTester tester) async {
7071
final FocusNode focusNode = FocusNode(debugLabel: 'UndoHistory Node');
72+
addTearDown(focusNode.dispose);
7173
final GlobalKey undoHistoryGlobalKey = GlobalKey();
7274
final ValueNotifier<int> value = ValueNotifier<int>(0);
7375
addTearDown(value.dispose);
@@ -105,6 +107,7 @@ void main() {
105107

106108
testWidgets('UndoHistory widget deregisters as global undo/redo client when disposed', (WidgetTester tester) async {
107109
final FocusNode focusNode = FocusNode(debugLabel: 'UndoHistory Node');
110+
addTearDown(focusNode.dispose);
108111
final GlobalKey undoHistoryGlobalKey = GlobalKey();
109112
final ValueNotifier<int> value = ValueNotifier<int>(0);
110113
addTearDown(value.dispose);

0 commit comments

Comments
 (0)