You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-07-31 15:24:23 +03:00
Test fallback screensharing (#2659)
* Test fallback screensharing * Test replacetrack is called * Unused import * Return type * Fix other test after new track IDs
This commit is contained in:
@ -104,13 +104,18 @@ export class MockRTCPeerConnection {
|
||||
private onReadyToNegotiate: () => void;
|
||||
localDescription: RTCSessionDescription;
|
||||
signalingState: RTCSignalingState = "stable";
|
||||
public senders: MockRTCRtpSender[] = [];
|
||||
|
||||
public static triggerAllNegotiations() {
|
||||
public static triggerAllNegotiations(): void {
|
||||
for (const inst of this.instances) {
|
||||
inst.doNegotiation();
|
||||
}
|
||||
}
|
||||
|
||||
public static hasAnyPendingNegotiations(): boolean {
|
||||
return this.instances.some(i => i.needsNegotiation);
|
||||
}
|
||||
|
||||
public static resetInstances() {
|
||||
this.instances = [];
|
||||
}
|
||||
@ -153,10 +158,12 @@ export class MockRTCPeerConnection {
|
||||
}
|
||||
close() { }
|
||||
getStats() { return []; }
|
||||
addTrack(track: MockMediaStreamTrack) {
|
||||
addTrack(track: MockMediaStreamTrack): MockRTCRtpSender {
|
||||
this.needsNegotiation = true;
|
||||
this.onReadyToNegotiate();
|
||||
return new MockRTCRtpSender(track);
|
||||
const newSender = new MockRTCRtpSender(track);
|
||||
this.senders.push(newSender);
|
||||
return newSender;
|
||||
}
|
||||
|
||||
removeTrack() {
|
||||
@ -164,6 +171,8 @@ export class MockRTCPeerConnection {
|
||||
this.onReadyToNegotiate();
|
||||
}
|
||||
|
||||
getSenders(): MockRTCRtpSender[] { return this.senders; }
|
||||
|
||||
doNegotiation() {
|
||||
if (this.needsNegotiation && this.negotiationNeededListener) {
|
||||
this.needsNegotiation = false;
|
||||
@ -271,8 +280,8 @@ export class MockMediaHandler {
|
||||
|
||||
getUserMediaStream(audio: boolean, video: boolean) {
|
||||
const tracks = [];
|
||||
if (audio) tracks.push(new MockMediaStreamTrack("audio_track", "audio"));
|
||||
if (video) tracks.push(new MockMediaStreamTrack("video_track", "video"));
|
||||
if (audio) tracks.push(new MockMediaStreamTrack("usermedia_audio_track", "audio"));
|
||||
if (video) tracks.push(new MockMediaStreamTrack("usermedia_video_track", "video"));
|
||||
|
||||
const stream = new MockMediaStream(USERMEDIA_STREAM_ID, tracks);
|
||||
this.userMediaStreams.push(stream);
|
||||
@ -282,8 +291,8 @@ export class MockMediaHandler {
|
||||
stream.isStopped = true;
|
||||
}
|
||||
getScreensharingStream = jest.fn((opts?: IScreensharingOpts) => {
|
||||
const tracks = [new MockMediaStreamTrack("video_track", "video")];
|
||||
if (opts?.audio) tracks.push(new MockMediaStreamTrack("audio_track", "audio"));
|
||||
const tracks = [new MockMediaStreamTrack("screenshare_video_track", "video")];
|
||||
if (opts?.audio) tracks.push(new MockMediaStreamTrack("screenshare_audio_track", "audio"));
|
||||
|
||||
const stream = new MockMediaStream(SCREENSHARE_STREAM_ID, tracks);
|
||||
this.screensharingStreams.push(stream);
|
||||
|
Reference in New Issue
Block a user