|
1 | 1 | import 'dart:ui' show ImageFilter; |
2 | 2 |
|
3 | 3 | import 'package:flutter/material.dart'; |
| 4 | +import 'package:flutter/services.dart'; |
4 | 5 | import 'package:flutter_test/flutter_test.dart'; |
5 | 6 | import 'package:querya_desktop/core/motion/querya_motion.dart'; |
6 | 7 | import 'package:querya_desktop/core/motion/querya_motion_scope.dart'; |
@@ -70,6 +71,47 @@ void main() { |
70 | 71 | await future; |
71 | 72 | }); |
72 | 73 |
|
| 74 | + testWidgets('barrierDismissible true closes dialog on Escape', (tester) async { |
| 75 | + final ctx = await pumpHost(tester); |
| 76 | + var completed = false; |
| 77 | + |
| 78 | + final future = showAppDialog<void>( |
| 79 | + context: ctx, |
| 80 | + barrierDismissible: true, |
| 81 | + builder: (c) => const AlertDialog(title: Text('Escapable')), |
| 82 | + ).whenComplete(() => completed = true); |
| 83 | + |
| 84 | + await tester.pumpAndSettle(); |
| 85 | + expect(find.text('Escapable'), findsOneWidget); |
| 86 | + |
| 87 | + await tester.sendKeyEvent(LogicalKeyboardKey.escape); |
| 88 | + await tester.pumpAndSettle(); |
| 89 | + |
| 90 | + expect(find.text('Escapable'), findsNothing); |
| 91 | + expect(completed, isTrue); |
| 92 | + await future; |
| 93 | + }); |
| 94 | + |
| 95 | + testWidgets('barrierDismissible false ignores Escape', (tester) async { |
| 96 | + final ctx = await pumpHost(tester); |
| 97 | + |
| 98 | + final future = showAppDialog<void>( |
| 99 | + context: ctx, |
| 100 | + barrierDismissible: false, |
| 101 | + builder: (c) => const AlertDialog(title: Text('No escape')), |
| 102 | + ); |
| 103 | + |
| 104 | + await tester.pumpAndSettle(); |
| 105 | + await tester.sendKeyEvent(LogicalKeyboardKey.escape); |
| 106 | + await tester.pumpAndSettle(); |
| 107 | + |
| 108 | + expect(find.text('No escape'), findsOneWidget); |
| 109 | + |
| 110 | + Navigator.of(ctx, rootNavigator: true).pop(); |
| 111 | + await tester.pumpAndSettle(); |
| 112 | + await future; |
| 113 | + }); |
| 114 | + |
73 | 115 | testWidgets('showAppDialog uses fade-slide (not scale) with BackdropFilter', |
74 | 116 | (tester) async { |
75 | 117 | final ctx = await pumpHost(tester); |
|
0 commit comments