fix: desktopCapturer
and screen
source ids should match screen ids (#42860)
* fix: desktopCapturer screen source ids should match screen ids Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * test: add a regression test Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
parent
6631dd16ec
commit
b1bf730793
2 changed files with 48 additions and 6 deletions
|
@ -1,5 +1,6 @@
|
|||
import { expect } from 'chai';
|
||||
import { Display, screen } from 'electron/main';
|
||||
import { Display, screen, desktopCapturer } from 'electron/main';
|
||||
import { ifit } from './lib/spec-helpers';
|
||||
|
||||
describe('screen module', () => {
|
||||
describe('methods reassignment', () => {
|
||||
|
@ -14,6 +15,26 @@ describe('screen module', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('screen.getAllDisplays', () => {
|
||||
it('returns an array of displays', () => {
|
||||
const displays = screen.getAllDisplays();
|
||||
expect(displays).to.be.an('array').with.lengthOf.at.least(1);
|
||||
for (const display of displays) {
|
||||
expect(display).to.be.an('object');
|
||||
}
|
||||
});
|
||||
|
||||
// desktopCapturer.getSources does not work as expected in Windows CI.
|
||||
ifit(process.platform !== 'win32')('returns displays with IDs matching desktopCapturer source display IDs', async () => {
|
||||
const displayIds = screen.getAllDisplays().map(d => `${d.id}`);
|
||||
|
||||
const sources = await desktopCapturer.getSources({ types: ['screen'] });
|
||||
const sourceIds = sources.map(s => s.display_id);
|
||||
|
||||
expect(displayIds).to.have.members(sourceIds);
|
||||
});
|
||||
});
|
||||
|
||||
describe('screen.getCursorScreenPoint()', () => {
|
||||
it('returns a point object', () => {
|
||||
const point = screen.getCursorScreenPoint();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue