fix: save normal window bounds when maximizing (#25051)

* fix: save normal window bounds when maximizing

* fix: prevent maximize being emitted twice
This commit is contained in:
Cheng Zhao 2020-08-25 05:32:08 +09:00 committed by GitHub
parent 5ed3460751
commit cd3fadc2fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 9 deletions

View file

@ -1021,6 +1021,26 @@ describe('BrowserWindow module', () => {
await unmaximize;
expectBoundsEqual(w.getNormalBounds(), bounds);
});
it('does not change size for a frameless window with min size', async () => {
w.destroy();
w = new BrowserWindow({
show: false,
frame: false,
width: 300,
height: 300,
minWidth: 300,
minHeight: 300
});
const bounds = w.getBounds();
w.once('maximize', () => {
w.unmaximize();
});
const unmaximize = emittedOnce(w, 'unmaximize');
w.show();
w.maximize();
await unmaximize;
expectBoundsEqual(w.getNormalBounds(), bounds);
});
});
ifdescribe(process.platform !== 'linux')('Minimized state', () => {
@ -2993,6 +3013,15 @@ describe('BrowserWindow module', () => {
await maximize;
});
it('emits only one event when frameless window is maximized', () => {
const w = new BrowserWindow({ show: false, frame: false });
let emitted = 0;
w.on('maximize', () => emitted++);
w.show();
w.maximize();
expect(emitted).to.equal(1);
});
it('emits an event when window is unmaximized', async () => {
const w = new BrowserWindow({ show: false });
const unmaximize = emittedOnce(w, 'unmaximize');