Unverified Commit 5064f782 authored by Kostia Sokolovskyi's avatar Kostia Sokolovskyi Committed by GitHub

Cover more test/material tests with leak tracking. (#136093)

parent 83134ac7
......@@ -876,7 +876,7 @@ void main() {
expect(tester.getSize(find.byKey(keyA)), equals(const Size(20.0, 20.0)));
});
testWidgets('Chip padding - LTR', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Chip padding - LTR', (WidgetTester tester) async {
final GlobalKey keyA = GlobalKey();
final GlobalKey keyB = GlobalKey();
......@@ -915,7 +915,7 @@ void main() {
expect(tester.getBottomRight(find.byType(Icon)), const Offset(457.0, 309.0));
});
testWidgets('Chip padding - RTL', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Chip padding - RTL', (WidgetTester tester) async {
final GlobalKey keyA = GlobalKey();
final GlobalKey keyB = GlobalKey();
......@@ -1849,7 +1849,7 @@ void main() {
expect(tester.getSize(find.byKey(key2)), const Size(80.0, 32.0));
});
testWidgets('Chip uses the right theme colors for the right components', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Chip uses the right theme colors for the right components', (WidgetTester tester) async {
final ThemeData themeData = ThemeData(
platform: TargetPlatform.android,
primarySwatch: Colors.blue,
......@@ -2596,7 +2596,7 @@ void main() {
checkChipMaterialClipBehavior(tester, Clip.antiAlias);
});
testWidgets('selected chip and avatar draw darkened layer within avatar circle', (WidgetTester tester) async {
testWidgetsWithLeakTracking('selected chip and avatar draw darkened layer within avatar circle', (WidgetTester tester) async {
await tester.pumpWidget(
wrapForChip(
useMaterial3: false,
......@@ -2639,8 +2639,9 @@ void main() {
expect(find.byType(InkWell), findsOneWidget);
});
testWidgets('Chip uses stateful color for text color in different states', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Chip uses stateful color for text color in different states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose);
const Color pressedColor = Color(0x00000001);
const Color hoverColor = Color(0x00000002);
......@@ -2727,8 +2728,9 @@ void main() {
expect(textColor(), disabledColor);
});
testWidgets('Chip uses stateful border side color in different states', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Chip uses stateful border side color in different states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose);
const Color pressedColor = Color(0x00000001);
const Color hoverColor = Color(0x00000002);
......@@ -2807,8 +2809,9 @@ void main() {
expect(find.byType(RawChip), paints..rrect()..rrect(color: disabledColor));
});
testWidgets('Chip uses stateful border side color from resolveWith', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Chip uses stateful border side color from resolveWith', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose);
const Color pressedColor = Color(0x00000001);
const Color hoverColor = Color(0x00000002);
......@@ -2888,8 +2891,9 @@ void main() {
});
testWidgets('Chip uses stateful nullable border side color from resolveWith', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Chip uses stateful nullable border side color from resolveWith', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose);
const Color pressedColor = Color(0x00000001);
const Color hoverColor = Color(0x00000002);
......@@ -2977,8 +2981,9 @@ void main() {
expect(find.byType(RawChip), paints..rrect()..rrect(color: disabledColor));
});
testWidgets('Chip uses stateful shape in different states', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Chip uses stateful shape in different states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose);
OutlinedBorder? getShape(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
......@@ -3320,8 +3325,9 @@ void main() {
expect(decoration.shape, shape);
});
testWidgets('Chip highlight color is drawn on top of the backgroundColor', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Chip highlight color is drawn on top of the backgroundColor', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'RawChip');
addTearDown(focusNode.dispose);
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
const Color backgroundColor = Color(0xff00ff00);
......@@ -3443,7 +3449,7 @@ void main() {
expect(getMaterialBox(tester), paints..rrect(color: selectedColor));
});
testWidgets('Delete button tap target area does not include label', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Delete button tap target area does not include label', (WidgetTester tester) async {
bool calledDelete = false;
await tester.pumpWidget(
wrapForChip(
......@@ -3486,7 +3492,7 @@ void main() {
});
// This is a regression test for https://github.com/flutter/flutter/pull/133615.
testWidgets('Material3 - Custom shape without provided side uses default side', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material3 - Custom shape without provided side uses default side', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(
MaterialApp(
......@@ -3510,7 +3516,7 @@ void main() {
);
});
testWidgets("Material3 - RawChip.shape's side is used when provided", (WidgetTester tester) async {
testWidgetsWithLeakTracking("Material3 - RawChip.shape's side is used when provided", (WidgetTester tester) async {
Widget buildChip({ OutlinedBorder? shape, BorderSide? side }) {
return MaterialApp(
theme: ThemeData(useMaterial3: true),
......@@ -3569,7 +3575,7 @@ void main() {
// support is deprecated and the APIs are removed, these tests
// can be deleted.
testWidgets('M2 Chip defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('M2 Chip defaults', (WidgetTester tester) async {
late TextTheme textTheme;
Widget buildFrame(Brightness brightness) {
......@@ -3646,7 +3652,7 @@ void main() {
expect(labelStyle.wordSpacing, textTheme.bodyLarge?.wordSpacing);
});
testWidgets('Chip uses the right theme colors for the right components', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Chip uses the right theme colors for the right components', (WidgetTester tester) async {
final ThemeData themeData = ThemeData(
platform: TargetPlatform.android,
primarySwatch: Colors.blue,
......
......@@ -929,7 +929,7 @@ void main() {
);
});
testWidgets("Material3 - RawChip.shape's side is used when provided", (WidgetTester tester) async {
testWidgetsWithLeakTracking("Material3 - RawChip.shape's side is used when provided", (WidgetTester tester) async {
Widget buildChip({ OutlinedBorder? shape, BorderSide? side }) {
return MaterialApp(
theme: ThemeData(
......
......@@ -698,7 +698,7 @@ void main() {
expect(find.text('disabled'), findsOneWidget);
});
testWidgets(
testWidgetsWithLeakTracking(
'DropdownButtonFormField - hint displays when the items list is '
'empty, items is null, and disabledHint is null',
(WidgetTester tester) async {
......@@ -1232,7 +1232,7 @@ void main() {
expect(inkWell.borderRadius, errorBorderRadius);
});
testWidgets('DropdownButtonFormField onChanged is called when the form is reset', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DropdownButtonFormField onChanged is called when the form is reset', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/123009.
final GlobalKey<FormFieldState<String>> stateKey = GlobalKey<FormFieldState<String>>();
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
......
......@@ -1782,6 +1782,7 @@ void main() {
count += 1;
}
final MaterialStatesController controller = MaterialStatesController();
addTearDown(controller.dispose);
controller.addListener(valueChanged);
await tester.pumpWidget(
......@@ -1882,21 +1883,23 @@ void main() {
await gesture.removePointer();
}
testWidgets('ElevatedButton statesController', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ElevatedButton statesController', (WidgetTester tester) async {
testStatesController(null, tester);
});
testWidgets('ElevatedButton.icon statesController', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ElevatedButton.icon statesController', (WidgetTester tester) async {
testStatesController(const Icon(Icons.add), tester);
});
testWidgets('Disabled ElevatedButton statesController', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Disabled ElevatedButton 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(
home: Center(
......
......@@ -589,7 +589,7 @@ void main() {
});
// Regression test for https://github.com/flutter/flutter/issues/71435
testWidgets(
testWidgetsWithLeakTracking(
'Scaffold.bottomSheet should be updated without creating a new RO'
' when the new widget has the same key and type.',
(WidgetTester tester) async {
......
......@@ -1134,7 +1134,7 @@ void main() {
expect(snackBarBottomRight.dy - actionTextBottomRight.dy, 14.0 + 40.0); // margin + bottom padding
});
testWidgets(
testWidgetsWithLeakTracking(
'Material2 - Custom padding between SnackBar and its contents when set to SnackBarBehavior.fixed',
(WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
......@@ -1191,7 +1191,7 @@ void main() {
},
);
testWidgets(
testWidgetsWithLeakTracking(
'Material3 - Custom padding between SnackBar and its contents when set to SnackBarBehavior.fixed',
(WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
......@@ -1405,7 +1405,7 @@ void main() {
expect(snackBarBottomRight.dy - actionTextBottomRight.dy, 24.0); // margin (with no bottom padding)
});
testWidgets(
testWidgetsWithLeakTracking(
'Material2 - Custom padding between SnackBar and its contents when set to SnackBarBehavior.floating',
(WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
......@@ -1465,7 +1465,7 @@ void main() {
},
);
testWidgets(
testWidgetsWithLeakTracking(
'Material3 - Custom padding between SnackBar and its contents when set to SnackBarBehavior.floating',
(WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
......@@ -1873,7 +1873,7 @@ void main() {
behavior: behavior,
);
testWidgets(
testWidgetsWithLeakTracking(
'$behavior should align SnackBar with the bottom of Scaffold '
'when Scaffold has no other elements',
(WidgetTester tester) async {
......@@ -1902,7 +1902,7 @@ void main() {
},
);
testWidgets(
testWidgetsWithLeakTracking(
'$behavior should align SnackBar with the top of BottomNavigationBar '
'when Scaffold has no FloatingActionButton',
(WidgetTester tester) async {
......@@ -1934,7 +1934,7 @@ void main() {
);
}
testWidgets(
testWidgetsWithLeakTracking(
'Padding of ${SnackBarBehavior.fixed} is not consumed by viewInsets',
(WidgetTester tester) async {
final Widget child = MaterialApp(
......@@ -1997,7 +1997,7 @@ void main() {
},
);
testWidgets(
testWidgetsWithLeakTracking(
'${SnackBarBehavior.fixed} should align SnackBar with the bottom of Scaffold '
'when Scaffold has a FloatingActionButton',
(WidgetTester tester) async {
......@@ -2032,7 +2032,7 @@ void main() {
},
);
testWidgets(
testWidgetsWithLeakTracking(
'${SnackBarBehavior.floating} should align SnackBar with the top of FloatingActionButton when Scaffold has a FloatingActionButton',
(WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
......@@ -2072,7 +2072,7 @@ void main() {
},
);
testWidgets(
testWidgetsWithLeakTracking(
'${SnackBarBehavior.floating} should not align SnackBar with the top of FloatingActionButton '
'when Scaffold has a FloatingActionButton and floatingActionButtonLocation is set to a top position',
(WidgetTester tester) async {
......@@ -2125,7 +2125,7 @@ void main() {
},
);
testWidgets(
testWidgetsWithLeakTracking(
'${SnackBarBehavior.floating} should align SnackBar with the top of FloatingActionButton '
'when Scaffold has a FloatingActionButton and floatingActionButtonLocation is not set to a top position',
(WidgetTester tester) async {
......@@ -2193,7 +2193,7 @@ void main() {
},
);
testWidgets(
testWidgetsWithLeakTracking(
'${SnackBarBehavior.fixed} should align SnackBar with the top of BottomNavigationBar '
'when Scaffold has a BottomNavigationBar and FloatingActionButton',
(WidgetTester tester) async {
......@@ -2230,7 +2230,7 @@ void main() {
},
);
testWidgets(
testWidgetsWithLeakTracking(
'${SnackBarBehavior.floating} should align SnackBar with the top of FloatingActionButton '
'when Scaffold has BottomNavigationBar and FloatingActionButton',
(WidgetTester tester) async {
......@@ -2400,7 +2400,7 @@ void main() {
expect(errorMessages.contains(offScreenMessage), isTrue);
});
testWidgets(
testWidgetsWithLeakTracking(
'SnackBar has correct end padding when it contains an action with fixed behavior',
(WidgetTester tester) async {
await tester.pumpWidget(
......@@ -2437,7 +2437,7 @@ void main() {
},
);
testWidgets(
testWidgetsWithLeakTracking(
'SnackBar has correct end padding when it contains an action with floating behavior',
(WidgetTester tester) async {
await tester.pumpWidget(
......@@ -3337,7 +3337,7 @@ void main() {
);
});
testWidgets(
testWidgetsWithLeakTracking(
'ScaffoldMessenger will alert for snackbars that cannot be presented', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/103004
await tester.pumpWidget(const MaterialApp(
......@@ -3723,7 +3723,7 @@ testWidgetsWithLeakTracking('SnackBarAction backgroundColor works as a Color', (
expect(completer.isCompleted, true);
});
testWidgets("Can't tap on button behind snack bar defined by margin and HitTestBehavior.opaque", (WidgetTester tester) async {
testWidgetsWithLeakTracking("Can't tap on button behind snack bar defined by margin and HitTestBehavior.opaque", (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/78537.
tester.view.physicalSize = const Size.square(200);
tester.view.devicePixelRatio = 1;
......
......@@ -787,7 +787,7 @@ void main() {
expect(state.widget.cursorColor, cursorColor);
});
testWidgets('Use error cursor color when an InputDecoration with an errorText or error widget is provided', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Use error cursor color when an InputDecoration with an errorText or error widget is provided', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Material(
......@@ -2484,7 +2484,7 @@ void main() {
expect(controller.selection.extentOffset, testValue.indexOf('g'));
});
testWidgets('Can move cursor when dragging, when tap is on collapsed selection (iOS)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Can move cursor when dragging, when tap is on collapsed selection (iOS)', (WidgetTester tester) async {
final TextEditingController controller = _textEditingController();
await tester.pumpWidget(
......@@ -2527,6 +2527,11 @@ void main() {
expect(controller.selection.isCollapsed, true);
expect(controller.selection.baseOffset, testValue.indexOf('i'));
// End gesture and skip the magnifier hide animation, so it can release
// resources.
await gesture.up();
await tester.pumpAndSettle();
},
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }),
);
......@@ -2576,7 +2581,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }),
);
testWidgets('Can move cursor when dragging, when tap is on collapsed selection (iOS) - multiline', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Can move cursor when dragging, when tap is on collapsed selection (iOS) - multiline', (WidgetTester tester) async {
final TextEditingController controller = _textEditingController();
await tester.pumpWidget(
......@@ -2620,11 +2625,16 @@ void main() {
expect(controller.selection.isCollapsed, true);
expect(controller.selection.baseOffset, testValue.indexOf('i'));
// End gesture and skip the magnifier hide animation, so it can release
// resources.
await gesture.up();
await tester.pumpAndSettle();
},
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }),
);
testWidgets('Can move cursor when dragging, when tap is on collapsed selection (iOS) - ListView', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Can move cursor when dragging, when tap is on collapsed selection (iOS) - ListView', (WidgetTester tester) async {
// This is a regression test for
// https://github.com/flutter/flutter/issues/122519
final TextEditingController controller = _textEditingController();
......@@ -2697,6 +2707,11 @@ void main() {
expect(controller.selection.isCollapsed, true);
expect(controller.selection.baseOffset, testValue.indexOf('i'));
// End gesture and skip the magnifier hide animation, so it can release
// resources.
await gesture.up();
await tester.pumpAndSettle();
},
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }),
);
......@@ -12361,7 +12376,7 @@ void main() {
skip: isBrowser, // [intended] Browser handles arrow keys differently.
);
testWidgets('long press drag can edge scroll vertically', (WidgetTester tester) async {
testWidgetsWithLeakTracking('long press drag can edge scroll vertically', (WidgetTester tester) async {
final TextEditingController controller = _textEditingController(
text: 'Atwater Peel Sherbrooke Bonaventure Angrignon Peel Côte-des-Neigse Atwater Peel Sherbrooke Bonaventure Angrignon Peel Côte-des-Neiges',
);
......@@ -12438,6 +12453,11 @@ void main() {
textOffsetToPosition(tester, 0).dy,
moreOrLessEquals(firstCharY - lineHeight, epsilon: 1),
);
// End gesture and skip the magnifier hide animation, so it can release
// resources.
await gesture.up();
await tester.pumpAndSettle();
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgetsWithLeakTracking('keyboard selection change scrolls the field vertically', (WidgetTester tester) async {
......@@ -14283,7 +14303,7 @@ void main() {
});
});
});
testWidgets("Arrow keys don't move input focus", (WidgetTester tester) async {
testWidgetsWithLeakTracking("Arrow keys don't move input focus", (WidgetTester tester) async {
final TextEditingController controller1 = _textEditingController();
final TextEditingController controller2 = _textEditingController();
final TextEditingController controller3 = _textEditingController();
......@@ -14446,7 +14466,7 @@ void main() {
expect(textFieldSize1, equals(textFieldSize2));
});
testWidgets(
testWidgetsWithLeakTracking(
'The selection menu displays in an Overlay without error',
(WidgetTester tester) async {
// This is a regression test for
......@@ -14455,6 +14475,9 @@ void main() {
text: 'This is a test that shows some odd behavior with Text Selection!',
);
late final OverlayEntry overlayEntry;
addTearDown(() => overlayEntry..remove()..dispose());
await tester.pumpWidget(MaterialApp(
home: Scaffold(
body: ColoredBox(
......@@ -14466,7 +14489,7 @@ void main() {
height: 600,
child: Overlay(
initialEntries: <OverlayEntry>[
OverlayEntry(
overlayEntry = OverlayEntry(
builder: (BuildContext context) => Center(
child: TextField(
controller: controller,
......@@ -16271,7 +16294,7 @@ void main() {
});
group('magnifier builder', () {
testWidgets('should build custom magnifier if given',
testWidgetsWithLeakTracking('should build custom magnifier if given',
(WidgetTester tester) async {
final Widget customMagnifier = Container(
key: UniqueKey(),
......@@ -16286,14 +16309,15 @@ void main() {
home: Placeholder(),
));
final BuildContext context =
tester.firstElement(find.byType(Placeholder));
final BuildContext context = tester.firstElement(find.byType(Placeholder));
final ValueNotifier<MagnifierInfo> magnifierInfo = ValueNotifier<MagnifierInfo>(MagnifierInfo.empty);
addTearDown(magnifierInfo.dispose);
expect(
textField.magnifierConfiguration!.magnifierBuilder(
context,
MagnifierController(),
ValueNotifier<MagnifierInfo>(MagnifierInfo.empty),
magnifierInfo,
),
isA<Widget>().having(
(Widget widget) => widget.key,
......@@ -16302,24 +16326,26 @@ void main() {
});
group('defaults', () {
testWidgets('should build Magnifier on Android', (WidgetTester tester) async {
testWidgetsWithLeakTracking('should build Magnifier on Android', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp(
home: Scaffold(body: TextField()))
);
final BuildContext context = tester.firstElement(find.byType(TextField));
final EditableText editableText = tester.widget(find.byType(EditableText));
final ValueNotifier<MagnifierInfo> magnifierInfo = ValueNotifier<MagnifierInfo>(MagnifierInfo.empty);
addTearDown(magnifierInfo.dispose);
expect(
editableText.magnifierConfiguration.magnifierBuilder(
context,
MagnifierController(),
ValueNotifier<MagnifierInfo>(MagnifierInfo.empty),
magnifierInfo,
),
isA<TextMagnifier>());
}, variant: TargetPlatformVariant.only(TargetPlatform.android));
testWidgets('should build CupertinoMagnifier on iOS',
testWidgetsWithLeakTracking('should build CupertinoMagnifier on iOS',
(WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp(
home: Scaffold(body: TextField()))
......@@ -16327,17 +16353,19 @@ void main() {
final BuildContext context = tester.firstElement(find.byType(TextField));
final EditableText editableText = tester.widget(find.byType(EditableText));
final ValueNotifier<MagnifierInfo> magnifierInfo = ValueNotifier<MagnifierInfo>(MagnifierInfo.empty);
addTearDown(magnifierInfo.dispose);
expect(
editableText.magnifierConfiguration.magnifierBuilder(
context,
MagnifierController(),
ValueNotifier<MagnifierInfo>(MagnifierInfo.empty),
magnifierInfo,
),
isA<CupertinoTextMagnifier>());
}, variant: TargetPlatformVariant.only(TargetPlatform.iOS));
testWidgets('should build nothing on Android and iOS',
testWidgetsWithLeakTracking('should build nothing on Android and iOS',
(WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp(
home: Scaffold(body: TextField()))
......@@ -16345,12 +16373,14 @@ void main() {
final BuildContext context = tester.firstElement(find.byType(TextField));
final EditableText editableText = tester.widget(find.byType(EditableText));
final ValueNotifier<MagnifierInfo> magnifierInfo = ValueNotifier<MagnifierInfo>(MagnifierInfo.empty);
addTearDown(magnifierInfo.dispose);
expect(
editableText.magnifierConfiguration.magnifierBuilder(
context,
MagnifierController(),
ValueNotifier<MagnifierInfo>(MagnifierInfo.empty),
magnifierInfo,
),
isNull);
},
......
......@@ -694,7 +694,7 @@ void main() {
expect(find.text('5 of 10'), findsOneWidget);
});
testWidgets('readonly text form field will hide cursor by default', (WidgetTester tester) async {
testWidgetsWithLeakTracking('readonly text form field will hide cursor by default', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Material(
......
......@@ -864,12 +864,15 @@ void main() {
expect(tooltipContainer.padding, const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0));
}, variant: const TargetPlatformVariant(<TargetPlatform>{TargetPlatform.macOS, TargetPlatform.linux, TargetPlatform.windows}));
testWidgets('Can tooltip decoration be customized', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Can tooltip decoration be customized', (WidgetTester tester) async {
final GlobalKey<TooltipState> tooltipKey = GlobalKey<TooltipState>();
const Decoration customDecoration = ShapeDecoration(
shape: StadiumBorder(),
color: Color(0x80800000),
);
late final OverlayEntry entry;
addTearDown(() => entry..remove()..dispose());
await tester.pumpWidget(
Theme(
data: ThemeData(useMaterial3: false),
......@@ -877,7 +880,7 @@ void main() {
textDirection: TextDirection.ltr,
child: Overlay(
initialEntries: <OverlayEntry>[
OverlayEntry(
entry = OverlayEntry(
builder: (BuildContext context) {
return Tooltip(
key: tooltipKey,
......@@ -1422,16 +1425,18 @@ void main() {
await tester.pump(waitDuration);
});
testWidgets('Does tooltip contribute semantics', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Does tooltip contribute semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
final GlobalKey<TooltipState> tooltipKey = GlobalKey<TooltipState>();
late final OverlayEntry entry;
addTearDown(() => entry..remove()..dispose());
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: Overlay(
initialEntries: <OverlayEntry>[
OverlayEntry(
entry = OverlayEntry(
builder: (BuildContext context) {
return Stack(
children: <Widget>[
......@@ -2349,7 +2354,7 @@ void main() {
expect(tester.takeException(), isNull);
});
testWidgets('Tooltip is not selectable', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Tooltip is not selectable', (WidgetTester tester) async {
const String tooltipText = 'AAAAAAAAAAAAAAAAAAAAAAA';
String? selectedText;
await tester.pumpWidget(
......
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