Skip to content

Commit

Permalink
test: "zoom-changed" event emission from webContents when user zooms …
Browse files Browse the repository at this point in the history
…with the mouse wheel.

Should only go in when Electron has webContents.sendInputContent fixed so that it properly creates
a WebMouseWheelEvent.
  • Loading branch information
ppontes committed Apr 12, 2019
1 parent 87f170d commit 280bdad
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions spec/api-web-contents-spec.js
Expand Up @@ -347,6 +347,54 @@ describe('webContents module', () => {
})
})

describe('zoom-changed', () => {
before(function () {
// On Mac, zooming isn't done with the mouse wheel.
if (process.platform === 'darwin') {
this.skip()
}
})

it('is emitted with the correct zooming info', (done) => {
w.loadFile(path.join(fixtures, 'pages', 'base-page.html'))
w.webContents.once('did-finish-load', () => {
const testZoomChanged = (opts) => {
return new Promise((resolve, reject) => {
w.webContents.once('zoom-changed', (event, zoomingIn) => {
assert.strictEqual(zoomingIn, opts.zoomingIn)
resolve()
})

const modifiers = ['control', 'meta']
const inputEvent = {
type: 'mousewheel',
x: 300,
y: 300,
deltaX: 0,
deltaY: opts.zoomingIn ? 1 : -1,
wheelTicksX: 0,
wheelTicksY: opts.zoomingIn ? 1 : -1,
phase: 'began',
modifiers
}

w.webContents.sendInputEvent(inputEvent)
})
}

Promise.resolve().then(() => {
return testZoomChanged({
zoomingIn: true
})
}).then(() => {
return testZoomChanged({
zoomingIn: false
})
}).then(done).catch(done)
})
})
})

describe('devtools window', () => {
let testFn = it
if (process.platform === 'darwin' && isCi) {
Expand Down

0 comments on commit 280bdad

Please sign in to comment.