feat: BrowserWindow.getNormalBounds() (#13290)
* First commit * Add Mac support (1st attempt) * Add Mac support (2nd attempt) * Simplify tests * Restore window state ! * Looking at other tests, seems minimize, maximize, fullscreen are skipped when in CI * Fix Mac tests * Restore tests in CI * Fix typo * widget getRestoredBounds not working on Mac !! * widget getRestoredBounds not working on Mac !! * Add IsNormal function * Add IsNormal * IsNormal => isNormal * Deactivate fullscreen on Mac. Do not receive leave-fullscreen event * Set default original_frame_ * Set default original_frame_ * Fix Mac
This commit is contained in:
parent
872890ea5c
commit
5f6706ac33
10 changed files with 176 additions and 1 deletions
|
@ -558,6 +558,114 @@ describe('BrowserWindow module', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe(`BrowserWindow.getNormalBounds()`, () => {
|
||||
describe(`Normal state`, () => {
|
||||
it(`checks normal bounds after resize`, (done) => {
|
||||
const size = [300, 400]
|
||||
w.once('resize', () => {
|
||||
assertBoundsEqual(w.getNormalBounds(), w.getBounds())
|
||||
done()
|
||||
})
|
||||
w.setSize(size[0], size[1])
|
||||
})
|
||||
it(`checks normal bounds after move`, (done) => {
|
||||
const pos = [10, 10]
|
||||
w.once('move', () => {
|
||||
assertBoundsEqual(w.getNormalBounds(), w.getBounds())
|
||||
done()
|
||||
})
|
||||
w.setPosition(pos[0], pos[1])
|
||||
})
|
||||
})
|
||||
describe(`Maximized state`, () => {
|
||||
before(function () {
|
||||
if (isCI) {
|
||||
this.skip()
|
||||
}
|
||||
})
|
||||
it(`checks normal bounds when maximized`, (done) => {
|
||||
const bounds = w.getBounds()
|
||||
w.once('maximize', () => {
|
||||
assertBoundsEqual(w.getNormalBounds(), bounds)
|
||||
done()
|
||||
})
|
||||
w.show()
|
||||
w.maximize()
|
||||
})
|
||||
it(`checks normal bounds when unmaximized`, (done) => {
|
||||
const bounds = w.getBounds()
|
||||
w.once('maximize', () => {
|
||||
w.unmaximize()
|
||||
})
|
||||
w.once('unmaximize', () => {
|
||||
assertBoundsEqual(w.getNormalBounds(), bounds)
|
||||
done()
|
||||
})
|
||||
w.show()
|
||||
w.maximize()
|
||||
})
|
||||
})
|
||||
describe(`Minimized state`, () => {
|
||||
before(function () {
|
||||
if (isCI) {
|
||||
this.skip()
|
||||
}
|
||||
})
|
||||
it(`checks normal bounds when minimized`, (done) => {
|
||||
const bounds = w.getBounds()
|
||||
w.once('minimize', () => {
|
||||
assertBoundsEqual(w.getNormalBounds(), bounds)
|
||||
done()
|
||||
})
|
||||
w.show()
|
||||
w.minimize()
|
||||
})
|
||||
it(`checks normal bounds when restored`, (done) => {
|
||||
const bounds = w.getBounds()
|
||||
w.once('minimize', () => {
|
||||
w.restore()
|
||||
})
|
||||
w.once('restore', () => {
|
||||
assertBoundsEqual(w.getNormalBounds(), bounds)
|
||||
done()
|
||||
})
|
||||
w.show()
|
||||
w.minimize()
|
||||
})
|
||||
})
|
||||
describe(`Fullscreen state`, () => {
|
||||
before(function () {
|
||||
if (isCI) {
|
||||
this.skip()
|
||||
}
|
||||
if (process.platform === 'darwin') {
|
||||
this.skip()
|
||||
}
|
||||
})
|
||||
it(`checks normal bounds when fullscreen'ed`, (done) => {
|
||||
const bounds = w.getBounds()
|
||||
w.once('enter-full-screen', () => {
|
||||
assertBoundsEqual(w.getNormalBounds(), bounds)
|
||||
done()
|
||||
})
|
||||
w.show()
|
||||
w.setFullScreen(true)
|
||||
})
|
||||
it(`checks normal bounds when unfullscreen'ed`, (done) => {
|
||||
const bounds = w.getBounds()
|
||||
w.once('enter-full-screen', () => {
|
||||
w.setFullScreen(false)
|
||||
})
|
||||
w.once('leave-full-screen', () => {
|
||||
assertBoundsEqual(w.getNormalBounds(), bounds)
|
||||
done()
|
||||
})
|
||||
w.show()
|
||||
w.setFullScreen(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('BrowserWindow.setProgressBar(progress)', () => {
|
||||
it('sets the progress', () => {
|
||||
assert.doesNotThrow(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue