diff --git a/lib/widgets/contact_sync_shortfall_banner.dart b/lib/widgets/contact_sync_shortfall_banner.dart index 708cdb88..5deb5958 100644 --- a/lib/widgets/contact_sync_shortfall_banner.dart +++ b/lib/widgets/contact_sync_shortfall_banner.dart @@ -92,9 +92,14 @@ class ContactSyncShortfallBanner extends StatelessWidget { ], ), ), + // No tooltip: this sits above the Navigator, where there is no + // Overlay, and a Tooltip without one blanks the window (#713). IconButton( - tooltip: l10n.common_close, - icon: Icon(Icons.close, color: scheme.onErrorContainer), + icon: Icon( + Icons.close, + color: scheme.onErrorContainer, + semanticLabel: l10n.common_close, + ), onPressed: onDismiss, ), ], diff --git a/test/widgets/contact_sync_shortfall_banner_test.dart b/test/widgets/contact_sync_shortfall_banner_test.dart index 3717fd65..ddf747b6 100644 --- a/test/widgets/contact_sync_shortfall_banner_test.dart +++ b/test/widgets/contact_sync_shortfall_banner_test.dart @@ -1,3 +1,4 @@ +import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -80,6 +81,50 @@ void main() { expect(calls, ['dismiss']); }); + // #713: the app mounts the banner in MaterialApp.builder, above the + // Navigator, where there is no Overlay. The tests above mount it under + // `home:`, which has one, so they could not see this. + group('mounted where the app mounts it (MaterialApp.builder)', () { + Widget inBuilder({bool decisionPending = false}) => MaterialApp( + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + builder: (context, child) => ContactSyncShortfallBanner( + shortfall: short, + decisionPending: decisionPending, + undeliveredCount: 244, + onDismiss: () => calls.add('dismiss'), + onKeep: () => calls.add('keep'), + onUseRadio: () => calls.add('useRadio'), + child: child ?? const SizedBox.shrink(), + ), + home: const Scaffold(body: Text('APP')), + ); + + testWidgets('hovering the close button does not break the app', ( + tester, + ) async { + await tester.pumpWidget(inBuilder()); + final gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); + await gesture.addPointer(location: Offset.zero); + addTearDown(gesture.removePointer); + await gesture.moveTo(tester.getCenter(find.byIcon(Icons.close))); + await tester.pumpAndSettle(const Duration(seconds: 2)); + + expect(tester.takeException(), isNull); + expect(find.text('Contact sync incomplete'), findsOneWidget); + expect(find.text('APP'), findsOneWidget); + }); + + testWidgets('the decision dialog works there too', (tester) async { + await tester.pumpWidget(inBuilder(decisionPending: true)); + await tester.pump(); + await tester.tap(find.text('Keep my contacts')); + + expect(tester.takeException(), isNull); + expect(calls, ['keep']); + }); + }); + group('decision pending', () { testWidgets('asks, says how many would be removed, defaults to Keep', ( tester,