Skip to content

Commit

Permalink
Adding support for Windows to use navigator.mediaDevices.getDisplayMe…
Browse files Browse the repository at this point in the history
…dia (#2270)
  • Loading branch information
axeleriksson147 authored Jan 31, 2025
1 parent 9959873 commit 47caf65
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 93 deletions.
118 changes: 76 additions & 42 deletions spec/screenPicker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ jest.mock('../src/common/env', () => {
};
});

const mockThumbnail = {
toDataURL: () => {},
};

describe('screen picker', () => {
const keyCode = {
pageDown: { keyCode: 34 },
Expand Down Expand Up @@ -40,26 +44,26 @@ describe('screen picker', () => {
display_id: '0',
id: '0',
name: 'Application screen 0',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
{
display_id: '1',
id: '1',
name: 'Application screen 1',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
{
display_id: '2',
id: '2',
name: 'Application screen 2',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
],
selectedSource: {
display_id: '1',
id: '1',
name: 'Application screen 1',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
};

Expand All @@ -85,7 +89,7 @@ describe('screen picker', () => {
display_id: '1',
id: '1',
name: 'Entire screen',
thumbnail: undefined,
thumbnail: mockThumbnail,
};
const customSelector = 'button.ScreenPicker-share-button';
wrapper.setState({ selectedSource });
Expand All @@ -101,7 +105,7 @@ describe('screen picker', () => {
display_id: '0',
id: '0',
name: 'Entire screen',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
],
selectedSource: undefined,
Expand All @@ -119,14 +123,14 @@ describe('screen picker', () => {
display_id: '0',
id: '0',
name: 'Entire screen',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
],
selectedSource: {
display_id: '0',
id: '0',
name: 'Entire screen',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
};
const applicationScreenStateMock = {
Expand All @@ -135,14 +139,14 @@ describe('screen picker', () => {
display_id: '',
id: '1',
name: 'Application 1',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
],
selectedSource: {
display_id: '',
id: '1',
name: 'Application 1',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
};

Expand Down Expand Up @@ -175,7 +179,7 @@ describe('screen picker', () => {
fileName: 'fullscreen',
id: '0',
name: 'Entire screen',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
};
const customSelector = '.ScreenPicker-item-container';
Expand All @@ -185,27 +189,27 @@ describe('screen picker', () => {
display_id: '0',
id: '0',
name: 'Entire screen',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
{
display_id: '1',
id: '1',
name: 'Application screen 1',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
{
display_id: '2',
id: '2',
name: 'Application screen 2',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
],
selectedSource: {
display_id: '1',
fileName: 'fullscreen',
id: '1',
name: 'Application screen 1',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
};
wrapper.setState(applicationScreenStateMock);
Expand All @@ -222,7 +226,7 @@ describe('screen picker', () => {
fileName: 'fullscreen',
id: '2',
name: 'Application screen 2',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
};
const customSelector = '.ScreenPicker-item-container';
Expand All @@ -232,27 +236,27 @@ describe('screen picker', () => {
display_id: '0',
id: '0',
name: 'Entire screen',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
{
display_id: '1',
id: '1',
name: 'Application screen 1',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
{
display_id: '2',
id: '2',
name: 'Application screen 2',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
],
selectedSource: {
display_id: '1',
fileName: 'fullscreen',
id: '1',
name: 'Application screen 1',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
};
wrapper.setState(applicationScreenStateMock);
Expand Down Expand Up @@ -289,7 +293,7 @@ describe('screen picker', () => {
fileName: 'fullscreen',
id: '2',
name: 'Application screen 2',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
};
const wrapper = shallow(React.createElement(ScreenPicker));
Expand All @@ -306,7 +310,7 @@ describe('screen picker', () => {
fileName: 'fullscreen',
id: '2',
name: 'Application screen 2',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
};
const wrapper = shallow(React.createElement(ScreenPicker));
Expand All @@ -323,7 +327,7 @@ describe('screen picker', () => {
fileName: 'fullscreen',
id: '0',
name: 'Application screen 0',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
};
const wrapper = shallow(React.createElement(ScreenPicker));
Expand All @@ -340,7 +344,7 @@ describe('screen picker', () => {
fileName: 'fullscreen',
id: '0',
name: 'Application screen 0',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
};
const wrapper = shallow(React.createElement(ScreenPicker));
Expand All @@ -357,7 +361,7 @@ describe('screen picker', () => {
fileName: 'fullscreen',
id: '0',
name: 'Application screen 0',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
};
const wrapper = shallow(React.createElement(ScreenPicker));
Expand All @@ -374,7 +378,7 @@ describe('screen picker', () => {
fileName: 'fullscreen',
id: '2',
name: 'Application screen 2',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
};
const wrapper = shallow(React.createElement(ScreenPicker));
Expand All @@ -389,7 +393,7 @@ describe('screen picker', () => {
display_id: '1',
id: '1',
name: 'Application screen 1',
thumbnail: undefined,
thumbnail: mockThumbnail,
};
const wrapper = shallow(React.createElement(ScreenPicker));
wrapper.setState(stateMock);
Expand Down Expand Up @@ -418,7 +422,7 @@ describe('screen picker', () => {
fileName: 'fullscreen',
id: '0',
name: 'Application screen 0',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
};
const wrapper = shallow(React.createElement(ScreenPicker));
Expand All @@ -437,19 +441,19 @@ describe('screen picker', () => {
display_id: '',
id: '1',
name: 'Application Screen',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
{
display_id: '',
id: '2',
name: 'Application Screen 2',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
{
display_id: '',
id: '3',
name: 'Application Screen 3',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
],
};
Expand All @@ -466,10 +470,20 @@ describe('screen picker', () => {
display_id: '1',
id: '1',
name: 'Entire screen',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
{
display_id: '2',
id: '2',
name: 'Screen 2',
thumbnail: mockThumbnail,
},
{
display_id: '3',
id: '3',
name: 'screen 3',
thumbnail: mockThumbnail,
},
{ display_id: '2', id: '2', name: 'Screen 2', thumbnail: undefined },
{ display_id: '3', id: '3', name: 'screen 3', thumbnail: undefined },
],
};
wrapper.setState(entireScreenStateMock);
Expand All @@ -486,10 +500,20 @@ describe('screen picker', () => {
display_id: '',
id: '1',
name: 'Entire screen',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
{
display_id: '',
id: '2',
name: 'Screen 2',
thumbnail: mockThumbnail,
},
{
display_id: '',
id: '3',
name: 'screen 3',
thumbnail: mockThumbnail,
},
{ display_id: '', id: '2', name: 'Screen 2', thumbnail: undefined },
{ display_id: '', id: '3', name: 'screen 3', thumbnail: undefined },
],
};
env.isWindowsOS = true;
Expand All @@ -509,10 +533,20 @@ describe('screen picker', () => {
display_id: '',
id: '1',
name: 'Entire screen',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
{
display_id: '',
id: '2',
name: 'Screen 2',
thumbnail: mockThumbnail,
},
{
display_id: '',
id: '3',
name: 'screen 3',
thumbnail: mockThumbnail,
},
{ display_id: '', id: '2', name: 'Screen 2', thumbnail: undefined },
{ display_id: '', id: '3', name: 'screen 3', thumbnail: undefined },
],
};
env.isWindowsOS = false;
Expand All @@ -531,13 +565,13 @@ describe('screen picker', () => {
display_id: '1',
id: '1',
name: 'Entire screen',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
{
display_id: '',
id: '1',
name: 'Application screen',
thumbnail: undefined,
thumbnail: mockThumbnail,
},
],
};
Expand Down
Loading

0 comments on commit 47caf65

Please sign in to comment.