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() {
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 TextEditingController controller = TextEditingController();
final FocusNode focusNode = FocusNode();
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
......@@ -120,9 +122,9 @@ void main() {
child: SizedBox(
width: 400,
child: EditableText(
controller: TextEditingController(),
controller: controller,
backgroundCursorColor: const Color(0xff00ffff),
focusNode: FocusNode(),
focusNode: focusNode,
style: const TextStyle(),
cursorColor: const Color(0xff00ffff),
selectionControls: materialTextSelectionHandleControls,
......@@ -170,6 +172,8 @@ void main() {
case TargetPlatform.macOS:
expect(find.byType(CupertinoDesktopTextSelectionToolbarButton), findsOneWidget);
}
controller.dispose();
focusNode.dispose();
},
skip: kIsWeb, // [intended] on web the browser handles the context menu.
variant: TargetPlatformVariant.all(),
......@@ -233,13 +237,14 @@ void main() {
);
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
// selection menu.
await Clipboard.setData(const ClipboardData(text: 'Clipboard data'));
Set<ContextMenuButtonType> buttonTypes = <ContextMenuButtonType>{};
final TextEditingController controller = TextEditingController();
final FocusNode focusNode = FocusNode();
await tester.pumpWidget(
MaterialApp(
......@@ -248,7 +253,7 @@ void main() {
child: EditableText(
controller: controller,
backgroundCursorColor: Colors.grey,
focusNode: FocusNode(),
focusNode: focusNode,
style: const TextStyle(),
cursorColor: Colors.red,
selectionControls: materialTextSelectionHandleControls,
......@@ -323,12 +328,15 @@ void main() {
case TargetPlatform.macOS:
expect(buttonTypes, isNot(contains(ContextMenuButtonType.selectAll)));
}
focusNode.dispose();
controller.dispose();
},
variant: TargetPlatformVariant.all(),
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';
await tester.pumpWidget(
......
......@@ -3360,7 +3360,7 @@ void main() {
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(
home: Scaffold(
appBar: AppBar(),
......
......@@ -47,7 +47,6 @@ void main() {
];
testWidgetsWithLeakTracking('can filter and select a list of string options', (WidgetTester tester) async {
late String lastSelection;
await tester.pumpWidget(
MaterialApp(
......@@ -107,7 +106,7 @@ void main() {
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(
MaterialApp(
home: Scaffold(
......@@ -161,7 +160,7 @@ void main() {
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(
MaterialApp(
home: Scaffold(
......@@ -204,7 +203,7 @@ void main() {
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();
await tester.pumpWidget(
MaterialApp(
......@@ -228,7 +227,7 @@ void main() {
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();
await tester.pumpWidget(
MaterialApp(
......@@ -257,7 +256,7 @@ void main() {
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(
body: Autocomplete<String>(
optionsBuilder: (TextEditingValue textEditingValue) {
......@@ -278,7 +277,7 @@ void main() {
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;
await tester.pumpWidget(MaterialApp(
home: Scaffold(
......@@ -307,7 +306,7 @@ void main() {
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
// after the provided text had been entered into the [Autocomplete] field.
Future<double> getDefaultOptionsHeight(
......@@ -355,7 +354,7 @@ void main() {
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;
await tester.pumpWidget(
MaterialApp(
......@@ -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);
await tester.pumpWidget(
MaterialApp(
......@@ -455,7 +454,7 @@ void main() {
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);
await tester.pumpWidget(
MaterialApp(
......@@ -519,7 +518,7 @@ void main() {
});
group('optionsViewOpenDirection', () {
testWidgets('default (down)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('default (down)', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
......@@ -534,7 +533,7 @@ void main() {
expect(actual, equals(OptionsViewOpenDirection.down));
});
testWidgets('down', (WidgetTester tester) async {
testWidgetsWithLeakTracking('down', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
......@@ -550,7 +549,7 @@ void main() {
expect(actual, equals(OptionsViewOpenDirection.down));
});
testWidgets('up', (WidgetTester tester) async {
testWidgetsWithLeakTracking('up', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
......
......@@ -340,7 +340,7 @@ void main() {
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(
const SingleChildScrollView(
child: ListBody(
......@@ -363,7 +363,7 @@ void main() {
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(
const SingleChildScrollView(
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