Fix a couple of CupertinoTextField tests to avoid leak-tracking test failures. (#135851)

This commit is contained in:
Kostia Sokolovskyi 2023-10-02 23:29:37 +02:00 committed by GitHub
parent 0eb2cb50a5
commit ff68b62599
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2485,13 +2485,11 @@ void main() {
await gesture.up(); await gesture.up();
await tester.pump(); await tester.pump();
expect(find.byType(CupertinoButton), isContextMenuProvidedByPlatform ? findsNothing : findsNWidgets(4)); expect(find.byType(CupertinoButton), isContextMenuProvidedByPlatform ? findsNothing : findsNWidgets(4));
// Skip the magnifier hide animation, so it can release resources.
await tester.pump(const Duration(milliseconds: 150));
}, },
// TODO(derdilla): remove after fixing and leak track other failing tests in
// this file. https://github.com/flutter/flutter/issues/135803
leakTrackingTestConfig: const LeakTrackingTestConfig(notDisposedAllowList:
<String, int?>{'ValueNotifier<_OverlayEntryWidgetState?>': 1})
); );
//
testWidgetsWithLeakTracking('Readonly text field does not have tap action', (WidgetTester tester) async { testWidgetsWithLeakTracking('Readonly text field does not have tap action', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
@ -5816,7 +5814,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }),
); );
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(); final TextEditingController controller = TextEditingController();
addTearDown(controller.dispose); addTearDown(controller.dispose);
@ -5860,11 +5858,17 @@ void main() {
expect(controller.selection.isCollapsed, true); expect(controller.selection.isCollapsed, true);
expect(controller.selection.baseOffset, testValue.indexOf('i')); 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.pump();
await tester.pump(const Duration(milliseconds: 150));
}, },
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }), 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(); final TextEditingController controller = TextEditingController();
addTearDown(controller.dispose); addTearDown(controller.dispose);
@ -5909,6 +5913,12 @@ void main() {
expect(controller.selection.isCollapsed, true); expect(controller.selection.isCollapsed, true);
expect(controller.selection.baseOffset, testValue.indexOf('i')); 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.pump();
await tester.pump(const Duration(milliseconds: 150));
}, },
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }),
); );
@ -5990,7 +6000,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }),
); );
testWidgets('Can move cursor when dragging (Android)', (WidgetTester tester) async { testWidgetsWithLeakTracking('Can move cursor when dragging (Android)', (WidgetTester tester) async {
final TextEditingController controller = TextEditingController(); final TextEditingController controller = TextEditingController();
addTearDown(controller.dispose); addTearDown(controller.dispose);
@ -6031,6 +6041,12 @@ void main() {
expect(controller.selection.isCollapsed, true); expect(controller.selection.isCollapsed, true);
expect(controller.selection.baseOffset, testValue.indexOf('g')); expect(controller.selection.baseOffset, testValue.indexOf('g'));
// End gesture and skip the magnifier hide animation, so it can release
// resources.
await gesture.up();
await tester.pump();
await tester.pump(const Duration(milliseconds: 150));
}, },
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia }),
); );