Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: re-enable and fix some BrowserWindow tests on Linux #32575

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 18 additions & 13 deletions spec-main/api-browser-window-spec.ts
Expand Up @@ -1238,8 +1238,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() is 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();
Expand Down Expand Up @@ -1292,7 +1294,7 @@ describe('BrowserWindow module', () => {
await close;
});

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();
Expand Down Expand Up @@ -1354,7 +1356,7 @@ describe('BrowserWindow module', () => {

w.setAspectRatio(16 / 11);

const maximize = emittedOnce(w, 'resize');
const maximize = emittedOnce(w, 'maximize');
w.show();
w.maximize();
await maximize;
Expand All @@ -1365,8 +1367,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() is 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();
Expand Down Expand Up @@ -1409,7 +1413,7 @@ describe('BrowserWindow module', () => {
expectBoundsEqual(normal, w.getBounds());
});

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();
Expand Down Expand Up @@ -3773,7 +3777,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 });
Expand All @@ -3796,20 +3800,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;
});
Expand Down Expand Up @@ -4067,9 +4074,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();
Expand All @@ -4081,7 +4086,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();
Expand Down