Skip to content

Commit c50f7b0

Browse files
committed
test: updated unit tests
1 parent 15164b1 commit c50f7b0

File tree

1 file changed

+140
-9
lines changed
  • packages/@webex/plugin-meetings/test/unit/spec/media

1 file changed

+140
-9
lines changed

packages/@webex/plugin-meetings/test/unit/spec/media/index.ts

Lines changed: 140 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,12 @@ describe('createMediaConnection', () => {
141141
const roapMediaConnectionConstructorStub = sinon
142142
.stub(InternalMediaCoreModule, 'RoapMediaConnection')
143143
.returns(fakeRoapMediaConnection);
144-
144+
145145
StaticConfig.set({bandwidth: {audio: 123, video: 456, startBitrate: 999}});
146-
146+
147147
const ENABLE_EXTMAP = false;
148148
const ENABLE_RTX = true;
149-
149+
150150
Media.createMediaConnection(false, 'sendonly-debug-id', 'meetingId', {
151151
mediaProperties: {
152152
mediaDirection: {
@@ -168,7 +168,7 @@ describe('createMediaConnection', () => {
168168
turnServerInfo: undefined,
169169
iceCandidatesTimeout: undefined,
170170
});
171-
171+
172172
assert.calledWith(
173173
roapMediaConnectionConstructorStub,
174174
sinon.match.any,
@@ -194,12 +194,12 @@ describe('createMediaConnection', () => {
194194
const roapMediaConnectionConstructorStub = sinon
195195
.stub(InternalMediaCoreModule, 'RoapMediaConnection')
196196
.returns(fakeRoapMediaConnection);
197-
197+
198198
StaticConfig.set({bandwidth: {audio: 123, video: 456, startBitrate: 999}});
199-
199+
200200
const ENABLE_EXTMAP = true;
201201
const ENABLE_RTX = false;
202-
202+
203203
Media.createMediaConnection(false, 'recvonly-debug-id', 'meetingId', {
204204
mediaProperties: {
205205
mediaDirection: {
@@ -221,7 +221,7 @@ describe('createMediaConnection', () => {
221221
turnServerInfo: undefined,
222222
iceCandidatesTimeout: undefined,
223223
});
224-
224+
225225
assert.calledWith(
226226
roapMediaConnectionConstructorStub,
227227
sinon.match.any,
@@ -242,7 +242,6 @@ describe('createMediaConnection', () => {
242242
'recvonly-debug-id'
243243
);
244244
});
245-
246245

247246
it('creates a MultistreamRoapMediaConnection when multistream is enabled', () => {
248247
const multistreamRoapMediaConnectionConstructorStub = sinon
@@ -511,6 +510,138 @@ describe('createMediaConnection', () => {
511510
);
512511
});
513512

513+
const testEnableInboundAudioLevelMonitoring = (
514+
testName: string,
515+
browserStubs: {isChrome?: boolean; isEdge?: boolean; isFirefox?: boolean},
516+
isMultistream: boolean,
517+
expectedConfig: object,
518+
additionalOptions = {}
519+
) => {
520+
it(testName, () => {
521+
const connectionConstructorStub = isMultistream
522+
? sinon.stub(InternalMediaCoreModule, 'MultistreamRoapMediaConnection')
523+
: sinon.stub(InternalMediaCoreModule, 'RoapMediaConnection');
524+
525+
connectionConstructorStub.returns(fakeRoapMediaConnection);
526+
527+
// Set up browser stubs
528+
sinon.stub(BrowserInfo, 'isChrome').returns(browserStubs.isChrome || false);
529+
sinon.stub(BrowserInfo, 'isEdge').returns(browserStubs.isEdge || false);
530+
sinon.stub(BrowserInfo, 'isFirefox').returns(browserStubs.isFirefox || false);
531+
532+
const baseOptions = {
533+
mediaProperties: {
534+
mediaDirection: {
535+
sendAudio: true,
536+
sendVideo: true,
537+
sendShare: false,
538+
receiveAudio: true,
539+
receiveVideo: true,
540+
receiveShare: true,
541+
},
542+
...(isMultistream
543+
? {}
544+
: {
545+
audioStream: fakeAudioStream,
546+
videoStream: fakeVideoStream,
547+
shareVideoTrack: null,
548+
shareAudioTrack: null,
549+
}),
550+
},
551+
...(isMultistream
552+
? {}
553+
: {
554+
remoteQualityLevel: 'HIGH',
555+
enableRtx: true,
556+
enableExtmap: true,
557+
}),
558+
...additionalOptions,
559+
};
560+
561+
if (!isMultistream) {
562+
StaticConfig.set({bandwidth: {audio: 123, video: 456, startBitrate: 999}});
563+
}
564+
565+
Media.createMediaConnection(isMultistream, 'debug string', 'meeting id', baseOptions);
566+
567+
if (isMultistream) {
568+
assert.calledOnceWithExactly(
569+
connectionConstructorStub,
570+
expectedConfig,
571+
'meeting id',
572+
sinon.match.func,
573+
sinon.match.func,
574+
sinon.match.func
575+
);
576+
} else {
577+
assert.calledOnceWithExactly(
578+
connectionConstructorStub,
579+
expectedConfig,
580+
sinon.match.object,
581+
'debug string'
582+
);
583+
}
584+
});
585+
};
586+
587+
testEnableInboundAudioLevelMonitoring(
588+
'enables enableInboundAudioLevelMonitoring for multistream when browser is Chrome',
589+
{isChrome: true, isEdge: false},
590+
true,
591+
{
592+
iceServers: [],
593+
disableAudioTwcc: true,
594+
enableInboundAudioLevelMonitoring: true,
595+
}
596+
);
597+
598+
testEnableInboundAudioLevelMonitoring(
599+
'enables enableInboundAudioLevelMonitoring for multistream when browser is Edge',
600+
{isChrome: false, isEdge: true},
601+
true,
602+
{
603+
iceServers: [],
604+
disableAudioTwcc: true,
605+
enableInboundAudioLevelMonitoring: true,
606+
}
607+
);
608+
609+
testEnableInboundAudioLevelMonitoring(
610+
'does not enable enableInboundAudioLevelMonitoring for multistream when browser is Firefox',
611+
{isChrome: false, isEdge: false, isFirefox: true},
612+
true,
613+
{
614+
iceServers: [],
615+
disableAudioTwcc: true,
616+
doFullIce: true,
617+
stopIceGatheringAfterFirstRelayCandidate: undefined,
618+
}
619+
);
620+
621+
testEnableInboundAudioLevelMonitoring(
622+
'does not enable enableInboundAudioLevelMonitoring for non-multistream connections even when browser is Chrome',
623+
{isChrome: true, isEdge: false},
624+
false,
625+
{
626+
iceServers: [],
627+
iceCandidatesTimeout: undefined,
628+
skipInactiveTransceivers: false,
629+
requireH264: true,
630+
sdpMunging: {
631+
convertPort9to0: false,
632+
addContentSlides: true,
633+
bandwidthLimits: {
634+
audio: 123,
635+
video: 456,
636+
},
637+
startBitrate: 999,
638+
periodicKeyframes: 20,
639+
disableExtmap: false,
640+
disableRtx: false,
641+
},
642+
}
643+
);
644+
514645
[
515646
{testCase: 'turnServerInfo is undefined', turnServerInfo: undefined},
516647
{

0 commit comments

Comments
 (0)