Exemplo n.º 1
0
  it('does not throw an error when called more than once (regression)', async () => {
    const sources1 = await desktopCapturer.getSources({ types: ['window', 'screen'] })
    expect(sources1).to.be.an('array').that.is.not.empty()

    const sources2 = await desktopCapturer.getSources({ types: ['window', 'screen'] })
    expect(sources2).to.be.an('array').that.is.not.empty()
  })
Exemplo n.º 2
0
  it('responds to subsequent calls of different options', async () => {
    const promise1 = desktopCapturer.getSources({ types: ['window'] })
    expect(promise1).to.not.eventually.be.rejected()

    const promise2 = desktopCapturer.getSources({ types: ['screen'] })
    expect(promise2).to.not.eventually.be.rejected()
  })
  it('responds to subsequent calls of different options', (done) => {
    let callCount = 0
    const callback = (error, sources) => {
      callCount++
      assert.equal(error, null)
      if (callCount === 2) done()
    }

    desktopCapturer.getSources({types: ['window']}, callback)
    desktopCapturer.getSources({types: ['screen']}, callback)
  })
Exemplo n.º 4
0
  it('responds to subsequent calls of different options', done => {
    let callCount = 0
    const callback = (error, sources) => {
      callCount++
      expect(error).to.be.null()
      if (callCount === 2) done()
    }

    desktopCapturer.getSources({ types: ['window'] }, callback)
    desktopCapturer.getSources({ types: ['screen'] }, callback)
  })
Exemplo n.º 5
0
  it('responds to subsequest calls of different options', function (done) {
    var callCount = 0
    var callback = function (error, sources) {
      callCount++
      assert.equal(error, null)
      if (callCount === 2) done()
    }

    desktopCapturer.getSources({types: ['window']}, callback)
    desktopCapturer.getSources({types: ['screen']}, callback)
  })
Exemplo n.º 6
0
  it('does not throw an error when called more than once (regression)', function (done) {
    var callCount = 0
    var callback = function (error, sources) {
      callCount++
      assert.equal(error, null)
      assert.notEqual(sources.length, 0)
      if (callCount === 2) done()
    }

    desktopCapturer.getSources({types: ['window', 'screen']}, callback)
    desktopCapturer.getSources({types: ['window', 'screen']}, callback)
  })
Exemplo n.º 7
0
  it('does not throw an error when called more than once (regression)', (done) => {
    let callCount = 0
    const callback = (error, sources) => {
      callCount++
      expect(error).to.be.null()
      expect(sources).to.be.an('array').that.is.not.empty()
      if (callCount === 2) done()
    }

    desktopCapturer.getSources({ types: ['window', 'screen'] }, callback)
    desktopCapturer.getSources({ types: ['window', 'screen'] }, callback)
  })
Exemplo n.º 8
0
 it('should return a non-empty array of sources (callback)', (done) => {
   desktopCapturer.getSources({ types: ['window', 'screen'] }, (err, sources) => {
     expect(sources).to.be.an('array').that.is.not.empty()
     expect(err).to.be.null()
     done()
   })
 })
Exemplo n.º 9
0
 it('should return a non-empty array of sources', function (done) {
   desktopCapturer.getSources({
     types: ['window', 'screen']
   }, function (error, sources) {
     assert.equal(error, null)
     assert.notEqual(sources.length, 0)
     done()
   })
 })
Exemplo n.º 10
0
 //Show all video sources
 function showSources() {
   desktopCapturer.getSources({ types:['window', 'screen'] }, function(error, sources) {
     for (let source of sources) {
       $('thumbnail').append( " <p> Electron <p>"  );
       console.log("Name: " + source.name);
       addSource(source);
     }     
   });
 }
Exemplo n.º 11
0
function getSources(types, callback) {
  var options = {
    types: types || ['window', 'screen']
  };
  electron.desktopCapturer.getSources(options, function (err, sources) {
    if (err) throw err;
    callback(null, sources);
  });
}
 it('returns an empty display_id for window sources on Windows and Mac', (done) => {
   // Linux doesn't return any window sources.
   if (process.platform !== 'win32' && process.platform !== 'darwin') {
     return done()
   }
   desktopCapturer.getSources({types: ['window']}, (error, sources) => {
     assert.equal(error, null)
     assert.notEqual(sources.length, 0)
     sources.forEach((source) => { assert.equal(source.display_id.length, 0) })
     done()
   })
 })
Exemplo n.º 13
0
  it('returns an empty display_id for window sources on Windows and Mac', async () => {
    // Linux doesn't return any window sources.
    if (process.platform !== 'win32' && process.platform !== 'darwin') return

    const { BrowserWindow } = remote
    const w = new BrowserWindow({ width: 200, height: 200 })

    const sources = await desktopCapturer.getSources({ types: ['window'] })
    w.destroy()
    expect(sources).to.be.an('array').that.is.not.empty()
    for (const { display_id: displayId } of sources) {
      expect(displayId).to.be.a('string').and.be.empty()
    }
  })
Exemplo n.º 14
0
  it('disabling thumbnail should return empty images', async () => {
    const { BrowserWindow } = remote
    const w = new BrowserWindow({ show: false, width: 200, height: 200 })
    const wShown = emittedOnce(w, 'show')
    w.show()
    await wShown

    const sources = await desktopCapturer.getSources({ types: ['window', 'screen'], thumbnailSize: { width: 0, height: 0 } })
    w.destroy()
    expect(sources).to.be.an('array').that.is.not.empty()
    for (const { thumbnail: thumbnailImage } of sources) {
      expect(thumbnailImage).to.be.a('NativeImage')
      expect(thumbnailImage.isEmpty()).to.be.true()
    }
  })
 it('returns display_ids matching the Screen API on Windows and Mac', (done) => {
   if (process.platform !== 'win32' && process.platform !== 'darwin') {
     return done()
   }
   const displays = screen.getAllDisplays()
   desktopCapturer.getSources({types: ['screen']}, (error, sources) => {
     assert.equal(error, null)
     assert.notEqual(sources.length, 0)
     assert.equal(sources.length, displays.length)
     for (let i = 0; i < sources.length; i++) {
       assert.equal(sources[i].display_id, displays[i].id)
     }
     done()
   })
 })
Exemplo n.º 16
0
  it('returns display_ids matching the Screen API on Windows and Mac', done => {
    if (process.platform !== 'win32' && process.platform !== 'darwin') {
      return done()
    }

    const displays = screen.getAllDisplays()
    desktopCapturer.getSources({ types: ['screen'] }, (error, sources) => {
      expect(error).to.be.null()
      expect(sources).to.be.an('array').of.length(displays.length)

      for (let i = 0; i < sources.length; i++) {
        expect(sources[i].display_id).to.equal(displays[i].id.toString())
      }
      done()
    })
  })
Exemplo n.º 17
0
  it('returns display_ids matching the Screen API on Windows and Mac', async () => {
    if (process.platform !== 'win32' && process.platform !== 'darwin') return

    const displays = screen.getAllDisplays()
    const sources = await desktopCapturer.getSources({ types: ['screen'] })
    expect(sources).to.be.an('array').of.length(displays.length)

    for (let i = 0; i < sources.length; i++) {
      expect(sources[i].display_id).to.equal(displays[i].id.toString())
    }

    it('returns empty sources when blocked', async () => {
      ipcRenderer.send('handle-next-desktop-capturer-get-sources')
      const sources = await desktopCapturer.getSources({ types: ['screen'] })
      expect(sources).to.be.empty()
    })
  })
Exemplo n.º 18
0
 it('returns empty sources when blocked', async () => {
   ipcRenderer.send('handle-next-desktop-capturer-get-sources')
   const sources = await desktopCapturer.getSources({ types: ['screen'] })
   expect(sources).to.be.empty()
 })
Exemplo n.º 19
0
 it('should return a non-empty array of sources', async () => {
   const sources = await desktopCapturer.getSources({ types: ['window', 'screen'] })
   expect(sources).to.be.an('array').that.is.not.empty()
 })
Exemplo n.º 20
0
 it('throws an error for invalid options', async () => {
   const promise = desktopCapturer.getSources(['window', 'screen'])
   expect(promise).to.be.eventually.rejectedWith(Error, 'Invalid options')
 })
Exemplo n.º 21
0
 it('throws an error for invalid options', done => {
   desktopCapturer.getSources(['window', 'screen'], error => {
     expect(error.message).to.equal('Invalid options')
     done()
   })
 })
 it('throws an error for invalid options', (done) => {
   desktopCapturer.getSources(['window', 'screen'], (error) => {
     assert.equal(error.message, 'Invalid options')
     done()
   })
 })
Exemplo n.º 23
0
const getMediaSources = types => new Promise((ok, nope) => {
  desktopCapturer.getSources({ types }, (err, sources) => {
    if (err) nope(err)
    ok(sources)
  })
})