Unverified Commit 127b90e1 authored by Polina Cherkasova's avatar Polina Cherkasova Committed by GitHub

Test cover more tests with leak tracking. (#133712)

parent c1256d53
...@@ -111,8 +111,10 @@ void main() { ...@@ -111,8 +111,10 @@ void main() {
expect(find.byKey(key), findsOneWidget); expect(find.byKey(key), findsOneWidget);
}); });
testWidgets('Can build from EditableTextState', (WidgetTester tester) async { testWidgetsWithLeakTracking('Can build from EditableTextState', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
final TextEditingController controller = TextEditingController();
final FocusNode focusNode = FocusNode();
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
...@@ -120,9 +122,9 @@ void main() { ...@@ -120,9 +122,9 @@ void main() {
child: SizedBox( child: SizedBox(
width: 400, width: 400,
child: EditableText( child: EditableText(
controller: TextEditingController(), controller: controller,
backgroundCursorColor: const Color(0xff00ffff), backgroundCursorColor: const Color(0xff00ffff),
focusNode: FocusNode(), focusNode: focusNode,
style: const TextStyle(), style: const TextStyle(),
cursorColor: const Color(0xff00ffff), cursorColor: const Color(0xff00ffff),
selectionControls: materialTextSelectionHandleControls, selectionControls: materialTextSelectionHandleControls,
...@@ -170,6 +172,8 @@ void main() { ...@@ -170,6 +172,8 @@ void main() {
case TargetPlatform.macOS: case TargetPlatform.macOS:
expect(find.byType(CupertinoDesktopTextSelectionToolbarButton), findsOneWidget); expect(find.byType(CupertinoDesktopTextSelectionToolbarButton), findsOneWidget);
} }
controller.dispose();
focusNode.dispose();
}, },
skip: kIsWeb, // [intended] on web the browser handles the context menu. skip: kIsWeb, // [intended] on web the browser handles the context menu.
variant: TargetPlatformVariant.all(), variant: TargetPlatformVariant.all(),
...@@ -233,13 +237,14 @@ void main() { ...@@ -233,13 +237,14 @@ void main() {
); );
group('buttonItems', () { group('buttonItems', () {
testWidgets('getEditableTextButtonItems builds the correct button items per-platform', (WidgetTester tester) async { testWidgetsWithLeakTracking('getEditableTextButtonItems builds the correct button items per-platform', (WidgetTester tester) async {
// Fill the clipboard so that the Paste option is available in the text // Fill the clipboard so that the Paste option is available in the text
// selection menu. // selection menu.
await Clipboard.setData(const ClipboardData(text: 'Clipboard data')); await Clipboard.setData(const ClipboardData(text: 'Clipboard data'));
Set<ContextMenuButtonType> buttonTypes = <ContextMenuButtonType>{}; Set<ContextMenuButtonType> buttonTypes = <ContextMenuButtonType>{};
final TextEditingController controller = TextEditingController(); final TextEditingController controller = TextEditingController();
final FocusNode focusNode = FocusNode();
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -248,7 +253,7 @@ void main() { ...@@ -248,7 +253,7 @@ void main() {
child: EditableText( child: EditableText(
controller: controller, controller: controller,
backgroundCursorColor: Colors.grey, backgroundCursorColor: Colors.grey,
focusNode: FocusNode(), focusNode: focusNode,
style: const TextStyle(), style: const TextStyle(),
cursorColor: Colors.red, cursorColor: Colors.red,
selectionControls: materialTextSelectionHandleControls, selectionControls: materialTextSelectionHandleControls,
...@@ -323,12 +328,15 @@ void main() { ...@@ -323,12 +328,15 @@ void main() {
case TargetPlatform.macOS: case TargetPlatform.macOS:
expect(buttonTypes, isNot(contains(ContextMenuButtonType.selectAll))); expect(buttonTypes, isNot(contains(ContextMenuButtonType.selectAll)));
} }
focusNode.dispose();
controller.dispose();
}, },
variant: TargetPlatformVariant.all(), variant: TargetPlatformVariant.all(),
skip: kIsWeb, // [intended] skip: kIsWeb, // [intended]
); );
testWidgets('getAdaptiveButtons builds the correct button widgets per-platform', (WidgetTester tester) async { testWidgetsWithLeakTracking('getAdaptiveButtons builds the correct button widgets per-platform', (WidgetTester tester) async {
const String buttonText = 'Click me'; const String buttonText = 'Click me';
await tester.pumpWidget( await tester.pumpWidget(
......
...@@ -3360,7 +3360,7 @@ void main() { ...@@ -3360,7 +3360,7 @@ void main() {
expect(tester.getRect(find.byKey(key)), const Rect.fromLTRB(0, 0, 100, 56)); expect(tester.getRect(find.byKey(key)), const Rect.fromLTRB(0, 0, 100, 56));
}); });
testWidgets("AppBar with EndDrawer doesn't have leading", (WidgetTester tester) async { testWidgetsWithLeakTracking("AppBar with EndDrawer doesn't have leading", (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Scaffold( home: Scaffold(
appBar: AppBar(), appBar: AppBar(),
......
...@@ -47,7 +47,6 @@ void main() { ...@@ -47,7 +47,6 @@ void main() {
]; ];
testWidgetsWithLeakTracking('can filter and select a list of string options', (WidgetTester tester) async { testWidgetsWithLeakTracking('can filter and select a list of string options', (WidgetTester tester) async {
late String lastSelection; late String lastSelection;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -107,7 +106,7 @@ void main() { ...@@ -107,7 +106,7 @@ void main() {
expect(list.semanticChildCount, 6); expect(list.semanticChildCount, 6);
}); });
testWidgets('can filter and select a list of custom User options', (WidgetTester tester) async { testWidgetsWithLeakTracking('can filter and select a list of custom User options', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
...@@ -161,7 +160,7 @@ void main() { ...@@ -161,7 +160,7 @@ void main() {
expect(list.semanticChildCount, 1); expect(list.semanticChildCount, 1);
}); });
testWidgets('displayStringForOption is displayed in the options', (WidgetTester tester) async { testWidgetsWithLeakTracking('displayStringForOption is displayed in the options', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
...@@ -204,7 +203,7 @@ void main() { ...@@ -204,7 +203,7 @@ void main() {
expect(field.controller!.text, kOptionsUsers.first.name); expect(field.controller!.text, kOptionsUsers.first.name);
}); });
testWidgets('can build a custom field', (WidgetTester tester) async { testWidgetsWithLeakTracking('can build a custom field', (WidgetTester tester) async {
final GlobalKey fieldKey = GlobalKey(); final GlobalKey fieldKey = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -228,7 +227,7 @@ void main() { ...@@ -228,7 +227,7 @@ void main() {
expect(find.byType(TextFormField), findsNothing); expect(find.byType(TextFormField), findsNothing);
}); });
testWidgets('can build custom options', (WidgetTester tester) async { testWidgetsWithLeakTracking('can build custom options', (WidgetTester tester) async {
final GlobalKey optionsKey = GlobalKey(); final GlobalKey optionsKey = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -257,7 +256,7 @@ void main() { ...@@ -257,7 +256,7 @@ void main() {
expect(find.byKey(optionsKey), findsOneWidget); expect(find.byKey(optionsKey), findsOneWidget);
}); });
testWidgets('the default Autocomplete options widget has a maximum height of 200', (WidgetTester tester) async { testWidgetsWithLeakTracking('the default Autocomplete options widget has a maximum height of 200', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: Scaffold( await tester.pumpWidget(MaterialApp(home: Scaffold(
body: Autocomplete<String>( body: Autocomplete<String>(
optionsBuilder: (TextEditingValue textEditingValue) { optionsBuilder: (TextEditingValue textEditingValue) {
...@@ -278,7 +277,7 @@ void main() { ...@@ -278,7 +277,7 @@ void main() {
expect(resultingHeight, equals(200)); expect(resultingHeight, equals(200));
}); });
testWidgets('the options height restricts to max desired height', (WidgetTester tester) async { testWidgetsWithLeakTracking('the options height restricts to max desired height', (WidgetTester tester) async {
const double desiredHeight = 150.0; const double desiredHeight = 150.0;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Scaffold( home: Scaffold(
...@@ -307,7 +306,7 @@ void main() { ...@@ -307,7 +306,7 @@ void main() {
expect(resultingHeight, equals(desiredHeight)); expect(resultingHeight, equals(desiredHeight));
}); });
testWidgets('The height of options shrinks to height of resulting items, if less than maxHeight', (WidgetTester tester) async { testWidgetsWithLeakTracking('The height of options shrinks to height of resulting items, if less than maxHeight', (WidgetTester tester) async {
// Returns a Future with the height of the default [Autocomplete] options widget // Returns a Future with the height of the default [Autocomplete] options widget
// after the provided text had been entered into the [Autocomplete] field. // after the provided text had been entered into the [Autocomplete] field.
Future<double> getDefaultOptionsHeight( Future<double> getDefaultOptionsHeight(
...@@ -355,7 +354,7 @@ void main() { ...@@ -355,7 +354,7 @@ void main() {
expect(oneItemsHeight, lessThan(twoItemsHeight)); expect(oneItemsHeight, lessThan(twoItemsHeight));
}); });
testWidgets('initialValue sets initial text field value', (WidgetTester tester) async { testWidgetsWithLeakTracking('initialValue sets initial text field value', (WidgetTester tester) async {
late String lastSelection; late String lastSelection;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -416,7 +415,7 @@ void main() { ...@@ -416,7 +415,7 @@ void main() {
} }
} }
testWidgets('keyboard navigation of the options properly highlights the option', (WidgetTester tester) async { testWidgetsWithLeakTracking('keyboard navigation of the options properly highlights the option', (WidgetTester tester) async {
const Color highlightColor = Color(0xFF112233); const Color highlightColor = Color(0xFF112233);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -455,7 +454,7 @@ void main() { ...@@ -455,7 +454,7 @@ void main() {
checkOptionHighlight(tester, 'elephant', highlightColor); checkOptionHighlight(tester, 'elephant', highlightColor);
}); });
testWidgets('keyboard navigation keeps the highlighted option scrolled into view', (WidgetTester tester) async { testWidgetsWithLeakTracking('keyboard navigation keeps the highlighted option scrolled into view', (WidgetTester tester) async {
const Color highlightColor = Color(0xFF112233); const Color highlightColor = Color(0xFF112233);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -519,7 +518,7 @@ void main() { ...@@ -519,7 +518,7 @@ void main() {
}); });
group('optionsViewOpenDirection', () { group('optionsViewOpenDirection', () {
testWidgets('default (down)', (WidgetTester tester) async { testWidgetsWithLeakTracking('default (down)', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
...@@ -534,7 +533,7 @@ void main() { ...@@ -534,7 +533,7 @@ void main() {
expect(actual, equals(OptionsViewOpenDirection.down)); expect(actual, equals(OptionsViewOpenDirection.down));
}); });
testWidgets('down', (WidgetTester tester) async { testWidgetsWithLeakTracking('down', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
...@@ -550,7 +549,7 @@ void main() { ...@@ -550,7 +549,7 @@ void main() {
expect(actual, equals(OptionsViewOpenDirection.down)); expect(actual, equals(OptionsViewOpenDirection.down));
}); });
testWidgets('up', (WidgetTester tester) async { testWidgetsWithLeakTracking('up', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
......
...@@ -340,7 +340,7 @@ void main() { ...@@ -340,7 +340,7 @@ void main() {
group('layoutBehavior', () { group('layoutBehavior', () {
testWidgets('ButtonBar has a min height of 52 when using ButtonBarLayoutBehavior.constrained', (WidgetTester tester) async { testWidgetsWithLeakTracking('ButtonBar has a min height of 52 when using ButtonBarLayoutBehavior.constrained', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const SingleChildScrollView( const SingleChildScrollView(
child: ListBody( child: ListBody(
...@@ -363,7 +363,7 @@ void main() { ...@@ -363,7 +363,7 @@ void main() {
expect(tester.getBottomRight(buttonBar).dy - tester.getTopRight(buttonBar).dy, 52.0); expect(tester.getBottomRight(buttonBar).dy - tester.getTopRight(buttonBar).dy, 52.0);
}); });
testWidgets('ButtonBar has padding applied when using ButtonBarLayoutBehavior.padded', (WidgetTester tester) async { testWidgetsWithLeakTracking('ButtonBar has padding applied when using ButtonBarLayoutBehavior.padded', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const SingleChildScrollView( const SingleChildScrollView(
child: ListBody( child: ListBody(
......
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