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
Add test for updateLocalUsermediaStream (#2596)
This commit is contained in:
@ -148,6 +148,7 @@ export class MockMediaStream {
|
||||
) {}
|
||||
|
||||
listeners: [string, (...args: any[]) => any][] = [];
|
||||
public isStopped = false;
|
||||
|
||||
dispatchEvent(eventType: string) {
|
||||
this.listeners.forEach(([t, c]) => {
|
||||
@ -196,7 +197,9 @@ export class MockMediaHandler {
|
||||
this.userMediaStreams.push(stream);
|
||||
return stream;
|
||||
}
|
||||
stopUserMediaStream() { }
|
||||
stopUserMediaStream(stream: MockMediaStream) {
|
||||
stream.isStopped = true;
|
||||
}
|
||||
hasAudioDevice() { return true; }
|
||||
hasVideoDevice() { return true; }
|
||||
stopAllStreams() {}
|
||||
|
@ -263,6 +263,33 @@ describe('Group Call', function() {
|
||||
groupCall.leave();
|
||||
}
|
||||
});
|
||||
|
||||
it("retains state of local user media stream when updated", async () => {
|
||||
try {
|
||||
await groupCall.create();
|
||||
|
||||
await groupCall.initLocalCallFeed();
|
||||
|
||||
const oldStream = groupCall.localCallFeed.stream as unknown as MockMediaStream;
|
||||
|
||||
// arbitrary values, important part is that they're the same afterwards
|
||||
await groupCall.setLocalVideoMuted(true);
|
||||
await groupCall.setMicrophoneMuted(false);
|
||||
|
||||
const newStream = await mockClient.getMediaHandler().getUserMediaStream(true, true);
|
||||
|
||||
groupCall.updateLocalUsermediaStream(newStream);
|
||||
|
||||
expect(groupCall.localCallFeed.stream).toBe(newStream);
|
||||
|
||||
expect(groupCall.isLocalVideoMuted()).toEqual(true);
|
||||
expect(groupCall.isMicrophoneMuted()).toEqual(false);
|
||||
|
||||
expect(oldStream.isStopped).toEqual(true);
|
||||
} finally {
|
||||
groupCall.leave();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('Placing calls', function() {
|
||||
|
Reference in New Issue
Block a user