diff --git a/spec-main/api-browser-window-spec.ts b/spec-main/api-browser-window-spec.ts index 345400b50de13..cd2e82622f225 100644 --- a/spec-main/api-browser-window-spec.ts +++ b/spec-main/api-browser-window-spec.ts @@ -1079,8 +1079,10 @@ describe('BrowserWindow module', () => { }); }); - ifdescribe(process.platform !== 'linux')('Maximized state', () => { - it('checks normal bounds when maximized', async () => { + describe('Maximized state', () => { + // TODO(dsanders11): Enable these once BrowserWindow.getBounds() accurate on Linux. + // See https://github.com/electron/electron/issues/10388 + ifit(process.platform !== 'linux')('checks normal bounds when maximized', async () => { const bounds = w.getBounds(); const maximize = emittedOnce(w, 'maximize'); w.show(); @@ -1088,7 +1090,7 @@ describe('BrowserWindow module', () => { await maximize; expectBoundsEqual(w.getNormalBounds(), bounds); }); - it('checks normal bounds when unmaximized', async () => { + ifit(process.platform !== 'linux')('checks normal bounds when unmaximized', async () => { const bounds = w.getBounds(); w.once('maximize', () => { w.unmaximize(); @@ -1119,6 +1121,9 @@ describe('BrowserWindow module', () => { await unmaximize; expectBoundsEqual(w.getNormalBounds(), bounds); }); + // TODO(dsanders11): Remove the usage of "resize" events on Windows once the + // "maximize"/"unmaximize" events fire on transparent windows. + // See https://github.com/electron/electron/issues/32633 it('can check transparent window maximization', async () => { w.destroy(); w = new BrowserWindow({ @@ -1128,12 +1133,12 @@ describe('BrowserWindow module', () => { transparent: true }); - const maximize = emittedOnce(w, 'resize'); + const maximize = emittedOnce(w, process.platform === 'win32' ? 'resize' : 'maximize'); w.show(); w.maximize(); await maximize; expect(w.isMaximized()).to.equal(true); - const unmaximize = emittedOnce(w, 'resize'); + const unmaximize = emittedOnce(w, process.platform === 'win32' ? 'resize' : 'unmaximize'); w.unmaximize(); await unmaximize; expect(w.isMaximized()).to.equal(false); @@ -1147,7 +1152,7 @@ describe('BrowserWindow module', () => { w.setAspectRatio(16 / 11); - const maximize = emittedOnce(w, 'resize'); + const maximize = emittedOnce(w, 'maximize'); w.show(); w.maximize(); await maximize; @@ -1158,8 +1163,10 @@ describe('BrowserWindow module', () => { }); }); - ifdescribe(process.platform !== 'linux')('Minimized state', () => { - it('checks normal bounds when minimized', async () => { + describe('Minimized state', () => { + // TODO(dsanders11): Enable these once BrowserWindow.getBounds() accurate on Linux. + // See https://github.com/electron/electron/issues/10388 + ifit(process.platform !== 'linux')('checks normal bounds when minimized', async () => { const bounds = w.getBounds(); const minimize = emittedOnce(w, 'minimize'); w.show(); @@ -1167,7 +1174,7 @@ describe('BrowserWindow module', () => { await minimize; expectBoundsEqual(w.getNormalBounds(), bounds); }); - it('checks normal bounds when restored', async () => { + ifit(process.platform !== 'linux')('checks normal bounds when restored', async () => { const bounds = w.getBounds(); w.once('minimize', () => { w.restore(); @@ -3239,7 +3246,7 @@ describe('BrowserWindow module', () => { }); }); - ifdescribe(process.platform !== 'linux')('max/minimize events', () => { + describe('max/minimize events', () => { afterEach(closeAllWindows); it('emits an event when window is maximized', async () => { const w = new BrowserWindow({ show: false }); @@ -3249,20 +3256,23 @@ describe('BrowserWindow module', () => { await maximize; }); - it('emits only one event when frameless window is maximized', () => { + it('emits only one event when frameless window is maximized', async () => { const w = new BrowserWindow({ show: false, frame: false }); let emitted = 0; w.on('maximize', () => emitted++); w.show(); w.maximize(); + await delay(1000); expect(emitted).to.equal(1); }); it('emits an event when window is unmaximized', async () => { const w = new BrowserWindow({ show: false }); + const maximize = emittedOnce(w, 'maximize'); const unmaximize = emittedOnce(w, 'unmaximize'); w.show(); w.maximize(); + await maximize; w.unmaximize(); await unmaximize; }); @@ -3438,9 +3448,7 @@ describe('BrowserWindow module', () => { expectBoundsEqual(w.getPosition(), initialPosition); }); - // TODO(dsanders11): Enable once minimize event works on Linux again. - // See https://github.com/electron/electron/issues/28699 - ifit(process.platform !== 'linux')('should not restore a minimized window', async () => { + it('should not restore a minimized window', async () => { const w = new BrowserWindow(); const minimize = emittedOnce(w, 'minimize'); w.minimize(); @@ -3452,7 +3460,7 @@ describe('BrowserWindow module', () => { it('should not change the size or position of a normal window', async () => { const w = new BrowserWindow(); - + await delay(1000); const initialSize = w.getSize(); const initialPosition = w.getPosition(); w.unmaximize();