@@ -565,6 +565,109 @@ suite('WorkingCopyBackupTracker (native)', function () {
565
565
} ) ;
566
566
} ) ;
567
567
568
+ suite ( '"onExit" setting - scratchpad' , ( ) => {
569
+ test ( 'should hot exit (reason: CLOSE, windows: single, workspace)' , function ( ) {
570
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT , ShutdownReason . CLOSE , false , true , false ) ;
571
+ } ) ;
572
+ test ( 'should hot exit (reason: CLOSE, windows: single, empty workspace)' , function ( ) {
573
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT , ShutdownReason . CLOSE , false , false , false ) ;
574
+ } ) ;
575
+ test ( 'should hot exit (reason: CLOSE, windows: multiple, workspace)' , function ( ) {
576
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT , ShutdownReason . CLOSE , true , true , false ) ;
577
+ } ) ;
578
+ test ( 'should NOT hot exit (reason: CLOSE, windows: multiple, empty workspace)' , function ( ) {
579
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT , ShutdownReason . CLOSE , true , false , true ) ;
580
+ } ) ;
581
+ test ( 'should hot exit (reason: QUIT, windows: single, workspace)' , function ( ) {
582
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT , ShutdownReason . QUIT , false , true , false ) ;
583
+ } ) ;
584
+ test ( 'should hot exit (reason: QUIT, windows: single, empty workspace)' , function ( ) {
585
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT , ShutdownReason . QUIT , false , false , false ) ;
586
+ } ) ;
587
+ test ( 'should hot exit (reason: QUIT, windows: multiple, workspace)' , function ( ) {
588
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT , ShutdownReason . QUIT , true , true , false ) ;
589
+ } ) ;
590
+ test ( 'should hot exit (reason: QUIT, windows: multiple, empty workspace)' , function ( ) {
591
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT , ShutdownReason . QUIT , true , false , false ) ;
592
+ } ) ;
593
+ test ( 'should hot exit (reason: RELOAD, windows: single, workspace)' , function ( ) {
594
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT , ShutdownReason . RELOAD , false , true , false ) ;
595
+ } ) ;
596
+ test ( 'should hot exit (reason: RELOAD, windows: single, empty workspace)' , function ( ) {
597
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT , ShutdownReason . RELOAD , false , false , false ) ;
598
+ } ) ;
599
+ test ( 'should hot exit (reason: RELOAD, windows: multiple, workspace)' , function ( ) {
600
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT , ShutdownReason . RELOAD , true , true , false ) ;
601
+ } ) ;
602
+ test ( 'should hot exit (reason: RELOAD, windows: multiple, empty workspace)' , function ( ) {
603
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT , ShutdownReason . RELOAD , true , false , false ) ;
604
+ } ) ;
605
+ test ( 'should hot exit (reason: LOAD, windows: single, workspace)' , function ( ) {
606
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT , ShutdownReason . LOAD , false , true , false ) ;
607
+ } ) ;
608
+ test ( 'should NOT hot exit (reason: LOAD, windows: single, empty workspace)' , function ( ) {
609
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT , ShutdownReason . LOAD , false , false , true ) ;
610
+ } ) ;
611
+ test ( 'should hot exit (reason: LOAD, windows: multiple, workspace)' , function ( ) {
612
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT , ShutdownReason . LOAD , true , true , false ) ;
613
+ } ) ;
614
+ test ( 'should NOT hot exit (reason: LOAD, windows: multiple, empty workspace)' , function ( ) {
615
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT , ShutdownReason . LOAD , true , false , true ) ;
616
+ } ) ;
617
+ } ) ;
618
+
619
+ suite ( '"onExitAndWindowClose" setting - scratchpad' , ( ) => {
620
+ test ( 'should hot exit (reason: CLOSE, windows: single, workspace)' , function ( ) {
621
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT_AND_WINDOW_CLOSE , ShutdownReason . CLOSE , false , true , false ) ;
622
+ } ) ;
623
+ test ( 'should hot exit (reason: CLOSE, windows: single, empty workspace)' , function ( ) {
624
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT_AND_WINDOW_CLOSE , ShutdownReason . CLOSE , false , false , ! ! isMacintosh ) ;
625
+ } ) ;
626
+ test ( 'should hot exit (reason: CLOSE, windows: multiple, workspace)' , function ( ) {
627
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT_AND_WINDOW_CLOSE , ShutdownReason . CLOSE , true , true , false ) ;
628
+ } ) ;
629
+ test ( 'should NOT hot exit (reason: CLOSE, windows: multiple, empty workspace)' , function ( ) {
630
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT_AND_WINDOW_CLOSE , ShutdownReason . CLOSE , true , false , true ) ;
631
+ } ) ;
632
+ test ( 'should hot exit (reason: QUIT, windows: single, workspace)' , function ( ) {
633
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT_AND_WINDOW_CLOSE , ShutdownReason . QUIT , false , true , false ) ;
634
+ } ) ;
635
+ test ( 'should hot exit (reason: QUIT, windows: single, empty workspace)' , function ( ) {
636
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT_AND_WINDOW_CLOSE , ShutdownReason . QUIT , false , false , false ) ;
637
+ } ) ;
638
+ test ( 'should hot exit (reason: QUIT, windows: multiple, workspace)' , function ( ) {
639
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT_AND_WINDOW_CLOSE , ShutdownReason . QUIT , true , true , false ) ;
640
+ } ) ;
641
+ test ( 'should hot exit (reason: QUIT, windows: multiple, empty workspace)' , function ( ) {
642
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT_AND_WINDOW_CLOSE , ShutdownReason . QUIT , true , false , false ) ;
643
+ } ) ;
644
+ test ( 'should hot exit (reason: RELOAD, windows: single, workspace)' , function ( ) {
645
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT_AND_WINDOW_CLOSE , ShutdownReason . RELOAD , false , true , false ) ;
646
+ } ) ;
647
+ test ( 'should hot exit (reason: RELOAD, windows: single, empty workspace)' , function ( ) {
648
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT_AND_WINDOW_CLOSE , ShutdownReason . RELOAD , false , false , false ) ;
649
+ } ) ;
650
+ test ( 'should hot exit (reason: RELOAD, windows: multiple, workspace)' , function ( ) {
651
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT_AND_WINDOW_CLOSE , ShutdownReason . RELOAD , true , true , false ) ;
652
+ } ) ;
653
+ test ( 'should hot exit (reason: RELOAD, windows: multiple, empty workspace)' , function ( ) {
654
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT_AND_WINDOW_CLOSE , ShutdownReason . RELOAD , true , false , false ) ;
655
+ } ) ;
656
+ test ( 'should hot exit (reason: LOAD, windows: single, workspace)' , function ( ) {
657
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT_AND_WINDOW_CLOSE , ShutdownReason . LOAD , false , true , false ) ;
658
+ } ) ;
659
+ test ( 'should NOT hot exit (reason: LOAD, windows: single, empty workspace)' , function ( ) {
660
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT_AND_WINDOW_CLOSE , ShutdownReason . LOAD , false , false , true ) ;
661
+ } ) ;
662
+ test ( 'should hot exit (reason: LOAD, windows: multiple, workspace)' , function ( ) {
663
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT_AND_WINDOW_CLOSE , ShutdownReason . LOAD , true , true , false ) ;
664
+ } ) ;
665
+ test ( 'should NOT hot exit (reason: LOAD, windows: multiple, empty workspace)' , function ( ) {
666
+ return scratchpadHotExitTest . call ( this , HotExitConfiguration . ON_EXIT_AND_WINDOW_CLOSE , ShutdownReason . LOAD , true , false , true ) ;
667
+ } ) ;
668
+ } ) ;
669
+
670
+
568
671
async function hotExitTest ( this : any , setting : string , shutdownReason : ShutdownReason , multipleWindows : boolean , workspace : boolean , shouldVeto : boolean ) : Promise < void > {
569
672
const { accessor, cleanup } = await createTracker ( ) ;
570
673
@@ -604,5 +707,60 @@ suite('WorkingCopyBackupTracker (native)', function () {
604
707
605
708
await cleanup ( ) ;
606
709
}
710
+
711
+ async function scratchpadHotExitTest ( this : any , setting : string , shutdownReason : ShutdownReason , multipleWindows : boolean , workspace : boolean , shouldVeto : boolean ) : Promise < void > {
712
+ const { accessor, cleanup } = await createTracker ( ) ;
713
+
714
+ class TestBackupWorkingCopy extends TestWorkingCopy {
715
+
716
+ constructor ( resource : URI ) {
717
+ super ( resource ) ;
718
+
719
+ accessor . workingCopyService . registerWorkingCopy ( this ) ;
720
+ }
721
+
722
+ override capabilities = WorkingCopyCapabilities . Untitled | WorkingCopyCapabilities . Scratchpad ;
723
+
724
+ override isDirty ( ) : boolean {
725
+ return false ;
726
+ }
727
+
728
+ override isModified ( ) : boolean {
729
+ return true ;
730
+ }
731
+ }
732
+
733
+ // Set hot exit config
734
+ accessor . filesConfigurationService . testOnFilesConfigurationChange ( { files : { hotExit : setting } } ) ;
735
+
736
+ // Set empty workspace if required
737
+ if ( ! workspace ) {
738
+ accessor . contextService . setWorkspace ( new Workspace ( 'empty:1508317022751' ) ) ;
739
+ }
740
+
741
+ // Set multiple windows if required
742
+ if ( multipleWindows ) {
743
+ accessor . nativeHostService . windowCount = Promise . resolve ( 2 ) ;
744
+ }
745
+
746
+ // Set cancel to force a veto if hot exit does not trigger
747
+ accessor . fileDialogService . setConfirmResult ( ConfirmResult . CANCEL ) ;
748
+
749
+ const resource = toResource . call ( this , '/path/custom.txt' ) ;
750
+ new TestBackupWorkingCopy ( resource ) ;
751
+
752
+ const event = new TestBeforeShutdownEvent ( ) ;
753
+ event . reason = shutdownReason ;
754
+ accessor . lifecycleService . fireBeforeShutdown ( event ) ;
755
+
756
+ const veto = await event . value ;
757
+ assert . ok ( typeof event . finalValue === 'function' ) ; // assert the tracker uses the internal finalVeto API
758
+ assert . strictEqual ( accessor . workingCopyBackupService . discardedBackups . length , 0 ) ; // When hot exit is set, backups should never be cleaned since the confirm result is cancel
759
+ assert . strictEqual ( veto , shouldVeto ) ;
760
+
761
+ await cleanup ( ) ;
762
+
763
+ await cleanup ( ) ;
764
+ }
607
765
} ) ;
608
766
} ) ;
0 commit comments