2016-03-25 13:03:49 -07:00
|
|
|
const assert = require('assert')
|
2017-10-26 20:44:06 -04:00
|
|
|
const {desktopCapturer, remote} = require('electron')
|
2016-01-11 18:40:23 -08:00
|
|
|
|
2017-10-26 20:44:06 -04:00
|
|
|
const isCI = remote.getGlobal('isCi')
|
2016-04-30 20:51:09 +09:00
|
|
|
|
2017-10-26 20:44:06 -04:00
|
|
|
describe('desktopCapturer', () => {
|
|
|
|
if (isCI && process.platform === 'win32') return
|
2016-04-30 20:51:09 +09:00
|
|
|
|
2017-10-26 20:44:06 -04:00
|
|
|
it('should return a non-empty array of sources', (done) => {
|
2016-01-19 10:54:12 -08:00
|
|
|
desktopCapturer.getSources({
|
2016-01-11 18:40:23 -08:00
|
|
|
types: ['window', 'screen']
|
2017-10-26 20:44:06 -04:00
|
|
|
}, (error, sources) => {
|
2016-03-25 13:03:49 -07:00
|
|
|
assert.equal(error, null)
|
|
|
|
assert.notEqual(sources.length, 0)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
2016-01-19 10:57:18 -08:00
|
|
|
|
2017-10-26 20:44:06 -04:00
|
|
|
it('throws an error for invalid options', (done) => {
|
|
|
|
desktopCapturer.getSources(['window', 'screen'], (error) => {
|
2016-08-09 15:31:24 -07:00
|
|
|
assert.equal(error.message, 'Invalid options')
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2017-10-26 20:44:06 -04:00
|
|
|
it('does not throw an error when called more than once (regression)', (done) => {
|
|
|
|
let callCount = 0
|
|
|
|
const callback = (error, sources) => {
|
2016-03-25 13:03:49 -07:00
|
|
|
callCount++
|
|
|
|
assert.equal(error, null)
|
|
|
|
assert.notEqual(sources.length, 0)
|
|
|
|
if (callCount === 2) done()
|
|
|
|
}
|
2016-01-19 10:57:18 -08:00
|
|
|
|
2016-03-25 13:03:49 -07:00
|
|
|
desktopCapturer.getSources({types: ['window', 'screen']}, callback)
|
|
|
|
desktopCapturer.getSources({types: ['window', 'screen']}, callback)
|
|
|
|
})
|
2016-04-28 02:02:14 +05:30
|
|
|
|
2017-10-26 20:44:06 -04:00
|
|
|
it('responds to subsequest calls of different options', (done) => {
|
|
|
|
let callCount = 0
|
|
|
|
const callback = (error, sources) => {
|
2016-04-28 02:02:14 +05:30
|
|
|
callCount++
|
|
|
|
assert.equal(error, null)
|
|
|
|
if (callCount === 2) done()
|
|
|
|
}
|
|
|
|
|
|
|
|
desktopCapturer.getSources({types: ['window']}, callback)
|
|
|
|
desktopCapturer.getSources({types: ['screen']}, callback)
|
|
|
|
})
|
2016-03-25 13:03:49 -07:00
|
|
|
})
|