fix: desktopCapturer and screen display ids should match (#42883)

* fix: `desktopCapturer` and `screen` display IDs should match

* simplify wide-to-utf8 conversion

* remove unnecessary include
This commit is contained in:
Calvin 2024-07-14 00:51:57 -07:00 committed by GitHub
parent 3a6a201534
commit 493bc3ac9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 16 deletions

View file

@ -1,6 +1,5 @@
import { expect } from 'chai';
import { Display, screen, desktopCapturer } from 'electron/main';
import { ifit } from './lib/spec-helpers';
describe('screen module', () => {
describe('methods reassignment', () => {
@ -24,14 +23,14 @@ describe('screen module', () => {
}
});
// desktopCapturer.getSources does not work as expected in Windows CI.
ifit(process.platform !== 'win32')('returns displays with IDs matching desktopCapturer source display IDs', async () => {
it('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);
expect(displayIds).to.have.length(sources.length);
expect(displayIds).to.have.same.members(sourceIds);
});
});