@@ -706,6 +706,94 @@ void main() {
706706 drag.dispose ();
707707 });
708708
709+ for (final waitingForRunner in [true , false ]) {
710+ testWidgets (
711+ waitingForRunner
712+ ? 'פירוק רצועת המקור לפני תשובת ה־runner מבטל את ההעברה'
713+ : 'פירוק רצועת המקור לפני האישור מבטל את ההעברה' ,
714+ (tester) async {
715+ final windows = FakeViewWindows (tester);
716+ final view = windows.registry.open (size: const Size (800 , 600 ))! ;
717+ final drops = makeDrops (windows.registry);
718+ final target = _target (1 );
719+ drops.register (view.id, target.target);
720+ final tab = ToolTab (toolId: 'builtin.calendar' , title: 'לוח שנה' );
721+ final source = _RecordingTabsBloc ([tab]);
722+ addTearDown (source.close);
723+ final release = Completer <void >();
724+ final confirmation = Completer <bool >();
725+ final originalConfirm = CrossWindowTabDrag .confirmTransfer;
726+ addTearDown (
727+ () => CrossWindowTabDrag .confirmTransfer = originalConfirm,
728+ );
729+ final confirmations = < OpenedTab > [];
730+ CrossWindowTabDrag .confirmTransfer = (tab) {
731+ confirmations.add (tab);
732+ return confirmation.future;
733+ };
734+ runner.systemDrag = {'ran' : false , 'hwnd' : view.handle.hwnd};
735+ if (waitingForRunner) runner.systemDragGate = release;
736+ final drag = CrossWindowTabDrag (inProcess: drops);
737+ addTearDown (drag.dispose);
738+ drag.begin (tab, colors, tabsBloc: source);
739+
740+ await tester.pump (const Duration (seconds: 1 ));
741+ expect (runner.named ('dragOutToSystem' ), hasLength (1 ));
742+ expect (confirmations, waitingForRunner ? isEmpty : [same (tab)]);
743+ drag.dispose ();
744+ await tester.pump ();
745+ expect (runner.named ('endTabDrag' ), hasLength (1 ));
746+
747+ release.complete ();
748+ confirmation.complete (true );
749+ await tester.pump ();
750+ expect (runner.named ('endTabDrag' ), hasLength (1 ));
751+ expect (confirmations, waitingForRunner ? isEmpty : [same (tab)]);
752+ expect (target.received, isEmpty);
753+ expect (source.events, isEmpty);
754+ },
755+ );
756+ }
757+
758+ testWidgets ('חלון חדש באותה משבצת אינו מקבל שחרור ישן' , (tester) async {
759+ final windows = FakeViewWindows (tester);
760+ final view = windows.registry.open (size: const Size (800 , 600 ))! ;
761+ final drops = makeDrops (windows.registry);
762+ final target = _target (1 );
763+ drops.register (view.id, target.target);
764+ final tab = ToolTab (toolId: 'builtin.calendar' , title: 'לוח שנה' );
765+ final source = _RecordingTabsBloc ([tab]);
766+ addTearDown (source.close);
767+ final originalConfirm = CrossWindowTabDrag .confirmTransfer;
768+ addTearDown (() => CrossWindowTabDrag .confirmTransfer = originalConfirm);
769+ final confirmation = Completer <bool >();
770+ final confirmations = < OpenedTab > [];
771+ CrossWindowTabDrag .confirmTransfer = (tab) {
772+ confirmations.add (tab);
773+ return confirmation.future;
774+ };
775+ runner.systemDrag = {'ran' : false , 'hwnd' : view.handle.hwnd};
776+ final drag = CrossWindowTabDrag (inProcess: drops);
777+ addTearDown (drag.dispose);
778+ drag.begin (tab, colors, tabsBloc: source);
779+ await tester.pump (const Duration (seconds: 1 ));
780+ expect (confirmations, [same (tab)]);
781+
782+ drops.unregister (view.id, target.target);
783+ view.handle.destroy ();
784+ final replacement = windows.registry.open (size: const Size (800 , 600 ))! ;
785+ expect (replacement.slot, view.slot);
786+ final replacementTarget = _target (1 );
787+ drops.register (replacement.id, replacementTarget.target);
788+ confirmation.complete (true );
789+ await tester.pump ();
790+
791+ expect (screenCalls, isEmpty);
792+ expect (target.received, isEmpty);
793+ expect (replacementTarget.received, isEmpty);
794+ expect (source.events, isEmpty);
795+ });
796+
709797 testWidgets ('גרירה שנמסרה למערכת ושוחררה מעל שורת המשימות מבוטלת' , (
710798 tester,
711799 ) async {
0 commit comments