@@ -41,6 +41,8 @@ const makeFakeWindow = (options: NativeWindowOptions): FakeWindow => {
4141 let bounds : Rect = { x : 0 , y : 0 , width : options . width , height : options . height } ;
4242 let maximized = false ;
4343 let minimized = false ;
44+ let fullscreen = false ;
45+ let focused = false ;
4446 let onClosed : ( ( ) => void ) | undefined ;
4547 let onClose : ( ( ) => boolean ) | undefined ;
4648 let teardowns = 0 ;
@@ -88,6 +90,7 @@ const makeFakeWindow = (options: NativeWindowOptions): FakeWindow => {
8890 isVisible : ( ) => visible ,
8991 focus : ( ) => {
9092 visible = true ;
93+ focused = true ;
9194 } ,
9295 minimize : ( ) => {
9396 minimized = true ;
@@ -100,6 +103,15 @@ const makeFakeWindow = (options: NativeWindowOptions): FakeWindow => {
100103 } ,
101104 isMaximized : ( ) => maximized ,
102105 isMinimized : ( ) => minimized ,
106+ restore : ( ) => {
107+ minimized = false ;
108+ } ,
109+ isFocused : ( ) => focused ,
110+ setFullScreen : ( flag ) => {
111+ fullscreen = flag ;
112+ } ,
113+ isFullScreen : ( ) => fullscreen ,
114+ setAlwaysOnTop : ( ) => undefined ,
103115 close : ( ) => {
104116 // A real backend routes programmatic close through the same delegate path:
105117 // consult the veto, and only on a non-veto run teardown + fire closed.
@@ -109,6 +121,10 @@ const makeFakeWindow = (options: NativeWindowOptions): FakeWindow => {
109121 teardown ( ) ;
110122 onClosed ?.( ) ;
111123 } ,
124+ destroy : ( ) => {
125+ teardown ( ) ;
126+ onClosed ?.( ) ;
127+ } ,
112128 onClosed : ( cb ) => {
113129 onClosed = cb ;
114130 } ,
@@ -470,3 +486,42 @@ describe('App-level window events', () => {
470486 expect ( appExitCodes ( ) ) . toEqual ( [ ] ) ;
471487 } ) ;
472488} ) ;
489+
490+ describe ( 'BrowserWindow window controls' , ( ) => {
491+ test ( 'restore clears the minimized state' , ( ) => {
492+ const win = new BrowserWindow ( ) ;
493+ win . minimize ( ) ;
494+ expect ( win . isMinimized ( ) ) . toBe ( true ) ;
495+ win . restore ( ) ;
496+ expect ( win . isMinimized ( ) ) . toBe ( false ) ;
497+ } ) ;
498+
499+ test ( 'isFocused reflects the native state' , ( ) => {
500+ const win = new BrowserWindow ( ) ;
501+ expect ( win . isFocused ( ) ) . toBe ( false ) ;
502+ win . focus ( ) ;
503+ expect ( win . isFocused ( ) ) . toBe ( true ) ;
504+ } ) ;
505+
506+ test ( 'setFullScreen toggles isFullScreen' , ( ) => {
507+ const win = new BrowserWindow ( ) ;
508+ expect ( win . isFullScreen ( ) ) . toBe ( false ) ;
509+ win . setFullScreen ( true ) ;
510+ expect ( win . isFullScreen ( ) ) . toBe ( true ) ;
511+ win . setFullScreen ( false ) ;
512+ expect ( win . isFullScreen ( ) ) . toBe ( false ) ;
513+ } ) ;
514+
515+ test ( 'setAlwaysOnTop does not throw' , ( ) => {
516+ const win = new BrowserWindow ( ) ;
517+ expect ( ( ) => win . setAlwaysOnTop ( true ) ) . not . toThrow ( ) ;
518+ } ) ;
519+
520+ test ( 'destroy force-closes even when a close listener vetoes' , ( ) => {
521+ const win = new BrowserWindow ( ) ;
522+ win . on ( 'close' , ( event ) => event . preventDefault ( ) ) ;
523+ win . destroy ( ) ;
524+ expect ( win . isDestroyed ( ) ) . toBe ( true ) ;
525+ expect ( BrowserWindow . fromId ( win . id ) ) . toBeUndefined ( ) ;
526+ } ) ;
527+ } ) ;
0 commit comments