Dispose FocusNode in tests. (#146161)

This commit is contained in:
Polina Cherkasova 2024-04-02 16:51:16 -07:00 committed by GitHub
parent 972725332f
commit 96a491ceef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -890,10 +890,13 @@ void main() {
'This will be the start of a new line. When triple clicking this block ' 'This will be the start of a new line. When triple clicking this block '
'of text all of it should be selected.'; 'of text all of it should be selected.';
final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: SelectableRegion( home: SelectableRegion(
focusNode: FocusNode(), focusNode: focusNode,
selectionControls: materialTextSelectionControls, selectionControls: materialTextSelectionControls,
child: const Center( child: const Center(
child: Text(longText), child: Text(longText),
@ -962,10 +965,13 @@ void main() {
}, skip: kIsWeb); // https://github.com/flutter/flutter/issues/125582. }, skip: kIsWeb); // https://github.com/flutter/flutter/issues/125582.
testWidgets('mouse can select multiple widgets on triple click drag when selecting inside a WidgetSpan', (WidgetTester tester) async { testWidgets('mouse can select multiple widgets on triple click drag when selecting inside a WidgetSpan', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: SelectableRegion( home: SelectableRegion(
focusNode: FocusNode(), focusNode: focusNode,
selectionControls: materialTextSelectionControls, selectionControls: materialTextSelectionControls,
child: const Text.rich( child: const Text.rich(
WidgetSpan( WidgetSpan(
@ -1015,10 +1021,13 @@ void main() {
}, skip: kIsWeb); // https://github.com/flutter/flutter/issues/125582. }, skip: kIsWeb); // https://github.com/flutter/flutter/issues/125582.
testWidgets('mouse can select multiple widgets on triple click drag', (WidgetTester tester) async { testWidgets('mouse can select multiple widgets on triple click drag', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: SelectableRegion( home: SelectableRegion(
focusNode: FocusNode(), focusNode: focusNode,
selectionControls: materialTextSelectionControls, selectionControls: materialTextSelectionControls,
child: const Column( child: const Column(
children: <Widget>[ children: <Widget>[
@ -1078,10 +1087,13 @@ void main() {
}, skip: kIsWeb); // https://github.com/flutter/flutter/issues/125582. }, skip: kIsWeb); // https://github.com/flutter/flutter/issues/125582.
testWidgets('mouse can select multiple widgets on triple click drag and return to origin paragraph', (WidgetTester tester) async { testWidgets('mouse can select multiple widgets on triple click drag and return to origin paragraph', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: SelectableRegion( home: SelectableRegion(
focusNode: FocusNode(), focusNode: focusNode,
selectionControls: materialTextSelectionControls, selectionControls: materialTextSelectionControls,
child: const Column( child: const Column(
children: <Widget>[ children: <Widget>[
@ -1151,10 +1163,13 @@ void main() {
}, skip: kIsWeb); // https://github.com/flutter/flutter/issues/125582. }, skip: kIsWeb); // https://github.com/flutter/flutter/issues/125582.
testWidgets('mouse can reverse selection across multiple widgets on triple click drag', (WidgetTester tester) async { testWidgets('mouse can reverse selection across multiple widgets on triple click drag', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: SelectableRegion( home: SelectableRegion(
focusNode: FocusNode(), focusNode: focusNode,
selectionControls: materialTextSelectionControls, selectionControls: materialTextSelectionControls,
child: const Column( child: const Column(
children: <Widget>[ children: <Widget>[