@@ -83,6 +83,31 @@ class _DisappearingDeleteConnection extends RecordingConnection {
8383 }
8484}
8585
86+ /// Holds exactly one requested listing while leaving the previous rows visible.
87+ class _HeldListConnection extends RecordingConnection {
88+ _HeldListConnection () : super (initial: ConnState .ready);
89+
90+ Completer <void > listStarted = Completer <void >();
91+ Completer <void > releaseList = Completer <void >();
92+ bool _holdNext = false ;
93+
94+ void holdNextList () {
95+ listStarted = Completer <void >();
96+ releaseList = Completer <void >();
97+ _holdNext = true ;
98+ }
99+
100+ @override
101+ Future <List <RemoteEntry >> listDir (String path) async {
102+ if (_holdNext) {
103+ _holdNext = false ;
104+ listStarted.complete ();
105+ await releaseList.future;
106+ }
107+ return super .listDir (path);
108+ }
109+ }
110+
86111void main () {
87112 Uint8List b (String s) => Uint8List .fromList (utf8.encode (s));
88113 Key entryKey (String n) => ValueKey <String >('fileEntry_$n ' );
@@ -493,6 +518,73 @@ void main() {
493518 expect (rec.getFileCalls, isEmpty);
494519 });
495520
521+ testWidgets ('Space toggles the keyboard-focused file checkbox' , (
522+ WidgetTester tester,
523+ ) async {
524+ final RecordingConnection rec = RecordingConnection (
525+ initial: ConnState .ready,
526+ );
527+ addTearDown (rec.dispose);
528+ await rec.putFile ('/alpha.py' , b ('print("alpha")\n ' ));
529+ await pumpSurface (tester, const FilesView (), connection: rec);
530+ await tester.pumpAndSettle ();
531+
532+ await enterSelection (tester);
533+ final Finder checkbox = find.byKey (selectKey ('alpha.py' ));
534+ for (
535+ int step = 0 ;
536+ step < 8 && ! primaryFocusIsWithin (tester, checkbox);
537+ step += 1
538+ ) {
539+ await tester.sendKeyEvent (LogicalKeyboardKey .tab);
540+ await tester.pump ();
541+ }
542+ expect (
543+ primaryFocusIsWithin (tester, checkbox),
544+ isTrue,
545+ reason: 'the selected-file checkbox participates in focus traversal' ,
546+ );
547+
548+ await tester.sendKeyEvent (LogicalKeyboardKey .space);
549+ await tester.pump ();
550+
551+ expect (tester.widget <Checkbox >(checkbox).value, isTrue);
552+ expect (rec.getFileCalls, isEmpty);
553+ });
554+
555+ testWidgets (
556+ 'long press cannot enter selection while refresh is in flight' ,
557+ (WidgetTester tester) async {
558+ final _HeldListConnection rec = _HeldListConnection ();
559+ addTearDown (() {
560+ if (! rec.releaseList.isCompleted) rec.releaseList.complete ();
561+ rec.dispose ();
562+ });
563+ await rec.putFile ('/alpha.py' , b ('alpha\n ' ));
564+ await pumpSurface (tester, const FilesView (), connection: rec);
565+ await tester.pumpAndSettle ();
566+
567+ rec.holdNextList ();
568+ final Future <void > pending = containerOf (
569+ tester,
570+ ).read (fileExplorerProvider.notifier).refresh ();
571+ await rec.listStarted.future;
572+ await tester.pump ();
573+
574+ final TextButton selectAction = tester.widget <TextButton >(
575+ find.byKey (kFilesSelectActionKey),
576+ );
577+ expect (selectAction.onPressed, isNull);
578+ await tester.longPress (find.byKey (entryKey ('alpha.py' )));
579+ await tester.pump ();
580+ expect (find.byKey (kFilesSelectionBarKey), findsNothing);
581+
582+ rec.releaseList.complete ();
583+ await pending;
584+ await tester.pumpAndSettle ();
585+ },
586+ );
587+
496588 testWidgets (
497589 'folders and protected root or scratch entries stay locked and excluded' ,
498590 (WidgetTester tester) async {
@@ -1041,6 +1133,112 @@ void main() {
10411133 },
10421134 );
10431135
1136+ testWidgets ('a running delete locks progress, selection, and mutations' , (
1137+ WidgetTester tester,
1138+ ) async {
1139+ final _HeldDeleteConnection rec = _HeldDeleteConnection ();
1140+ addTearDown (() {
1141+ if (! rec.release.isCompleted) rec.release.complete ();
1142+ rec.dispose ();
1143+ });
1144+ await rec.putFile ('/alpha.py' , b ('alpha\n ' ));
1145+ await rec.putFile ('/beta.py' , b ('beta\n ' ));
1146+ await pumpSurface (tester, const FilesView (), connection: rec);
1147+ await tester.pumpAndSettle ();
1148+ final AppLocalizations l10n = l10nOf (tester);
1149+
1150+ await enterSelection (tester);
1151+ await selectAllShown (tester);
1152+ await tester.tap (find.byKey (kFilesBulkDeleteActionKey));
1153+ await tester.pumpAndSettle ();
1154+ await tester.tap (
1155+ find.descendant (
1156+ of: find.byType (AlertDialog ),
1157+ matching: find.widgetWithText (FilledButton , l10n.commonDelete),
1158+ ),
1159+ );
1160+ await tester.pump ();
1161+ expect (rec.started.isCompleted, isTrue);
1162+
1163+ final String progress = l10n.filesDeleteSelectedProgress (
1164+ 'alpha.py' ,
1165+ 0 ,
1166+ 2 ,
1167+ );
1168+ final Finder progressText = find.text (progress);
1169+ expect (progressText, findsOneWidget);
1170+ final Finder liveProgress = find.ancestor (
1171+ of: progressText,
1172+ matching: find.byWidgetPredicate (
1173+ (Widget widget) =>
1174+ widget is Semantics && widget.properties.liveRegion == true ,
1175+ ),
1176+ );
1177+ expect (liveProgress, findsOneWidget);
1178+ expect (tester.widget <Semantics >(liveProgress).properties.label, progress);
1179+
1180+ final Finder cancel = find.ancestor (
1181+ of: find.byTooltip (l10n.filesSelectionCancel),
1182+ matching: find.byType (IconButton ),
1183+ );
1184+ expect (tester.widget <IconButton >(cancel).onPressed, isNull);
1185+ expect (
1186+ tester
1187+ .widget <IconButton >(find.byKey (kFilesSelectAllShownKey))
1188+ .onPressed,
1189+ isNull,
1190+ );
1191+ expect (
1192+ tester
1193+ .widget <IconButton >(find.byKey (kFilesBulkDeleteActionKey))
1194+ .onPressed,
1195+ isNull,
1196+ );
1197+ for (final String name in < String > ['alpha.py' , 'beta.py' ]) {
1198+ expect (
1199+ tester.widget <Checkbox >(find.byKey (selectKey (name))).onChanged,
1200+ isNull,
1201+ );
1202+ expect (
1203+ tester.widget <ListTile >(find.byKey (entryKey (name))).onTap,
1204+ isNull,
1205+ );
1206+ }
1207+ expect (find.byType (RefreshIndicator ), findsNothing);
1208+ expect (find.text (l10n.filesSelectionSelectedCount (2 )), findsOneWidget);
1209+
1210+ rec.release.complete ();
1211+ await tester.pumpAndSettle ();
1212+ });
1213+
1214+ testWidgets (
1215+ 'disconnect dismisses an open exact confirmation with zero I/O' ,
1216+ (WidgetTester tester) async {
1217+ final RecordingConnection rec = RecordingConnection (
1218+ initial: ConnState .ready,
1219+ );
1220+ addTearDown (rec.dispose);
1221+ await rec.putFile ('/alpha.py' , b ('alpha\n ' ));
1222+ await pumpSurface (tester, const FilesView (), connection: rec);
1223+ await tester.pumpAndSettle ();
1224+ final AppLocalizations l10n = l10nOf (tester);
1225+
1226+ await enterSelection (tester);
1227+ await tester.tap (find.byKey (entryKey ('alpha.py' )));
1228+ await tester.pump ();
1229+ await tester.tap (find.byKey (kFilesBulkDeleteActionKey));
1230+ await tester.pumpAndSettle ();
1231+ expect (find.byType (AlertDialog ), findsOneWidget);
1232+
1233+ rec.emit (ConnState .disconnected);
1234+ await tester.pumpAndSettle ();
1235+
1236+ expect (find.byType (AlertDialog ), findsNothing);
1237+ expect (find.text (l10n.filesDisconnectedTitle), findsOneWidget);
1238+ expect (rec.deleteCalls, isEmpty);
1239+ },
1240+ );
1241+
10441242 testWidgets ('a replaced listing dismisses a stale confirmation safely' , (
10451243 WidgetTester tester,
10461244 ) async {
0 commit comments