|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+import FeatureFlags from '../flags/FeatureFlags';
|
|
|
2
|
+import Listenable from '../util/Listenable';
|
|
|
3
|
+
|
|
|
4
|
+import { ReceiveVideoController } from './ReceiveVideoController';
|
|
|
5
|
+
|
|
|
6
|
+// JSDocs disabled for Mock classes to avoid duplication - check on the original classes for info.
|
|
|
7
|
+/* eslint-disable require-jsdoc */
|
|
|
8
|
+/**
|
|
|
9
|
+ * Mock conference for the purpose of this test file.
|
|
|
10
|
+ */
|
|
|
11
|
+class MockConference extends Listenable {
|
|
|
12
|
+ /**
|
|
|
13
|
+ * A constructor...
|
|
|
14
|
+ */
|
|
|
15
|
+ constructor() {
|
|
|
16
|
+ super();
|
|
|
17
|
+ this.options = {
|
|
|
18
|
+ config: {}
|
|
|
19
|
+ };
|
|
|
20
|
+
|
|
|
21
|
+ this.activeMediaSession = undefined;
|
|
|
22
|
+ this.mediaSessions = [];
|
|
|
23
|
+ }
|
|
|
24
|
+
|
|
|
25
|
+ _getMediaSessions() {
|
|
|
26
|
+ return this.mediaSessions;
|
|
|
27
|
+ }
|
|
|
28
|
+}
|
|
|
29
|
+
|
|
|
30
|
+/**
|
|
|
31
|
+ * Mock {@link RTC} - add things as needed, but only things useful for all tests.
|
|
|
32
|
+ */
|
|
|
33
|
+export class MockRTC extends Listenable {
|
|
|
34
|
+ /**
|
|
|
35
|
+ * constructor
|
|
|
36
|
+ */
|
|
|
37
|
+ /* eslint-disable no-useless-constructor */
|
|
|
38
|
+ constructor() {
|
|
|
39
|
+ super();
|
|
|
40
|
+ }
|
|
|
41
|
+
|
|
|
42
|
+ // eslint-disable-next-line no-empty-function
|
|
|
43
|
+ setNewReceiverVideoConstraints() {
|
|
|
44
|
+
|
|
|
45
|
+ }
|
|
|
46
|
+}
|
|
|
47
|
+
|
|
|
48
|
+/* eslint-enable require-jsdoc */
|
|
|
49
|
+describe('ReceiveVideoController', () => {
|
|
|
50
|
+ let conference;
|
|
|
51
|
+ let rtc;
|
|
|
52
|
+ let receiveVideoController;
|
|
|
53
|
+
|
|
|
54
|
+ beforeEach(() => {
|
|
|
55
|
+ conference = new MockConference();
|
|
|
56
|
+ rtc = new MockRTC();
|
|
|
57
|
+ receiveVideoController = new ReceiveVideoController(conference, rtc);
|
|
|
58
|
+ });
|
|
|
59
|
+
|
|
|
60
|
+ describe('when sourceNameSignaling is enabled', () => {
|
|
|
61
|
+ beforeEach(() => {
|
|
|
62
|
+ FeatureFlags.init({ sourceNameSignaling: true });
|
|
|
63
|
+ });
|
|
|
64
|
+
|
|
|
65
|
+ it('should call setNewReceiverVideoConstraints with the source names format.', () => {
|
|
|
66
|
+ const rtcSpy = spyOn(rtc, 'setNewReceiverVideoConstraints');
|
|
|
67
|
+ const constraints = {
|
|
|
68
|
+ onStageSources: [ 'A_camera_1', 'B_screen_2', 'C_camera_1' ],
|
|
|
69
|
+ selectedSources: [ 'A_camera_1' ]
|
|
|
70
|
+ };
|
|
|
71
|
+
|
|
|
72
|
+ receiveVideoController.setReceiverConstraints(constraints);
|
|
|
73
|
+ expect(rtcSpy).toHaveBeenCalledWith(constraints);
|
|
|
74
|
+ });
|
|
|
75
|
+
|
|
|
76
|
+ it('should not allow the endpoints format.', () => {
|
|
|
77
|
+ const constraints = {
|
|
|
78
|
+ onStageEndpoints: [ 'A', 'B', 'C' ],
|
|
|
79
|
+ selectedEndpoints: [ 'A' ]
|
|
|
80
|
+ };
|
|
|
81
|
+
|
|
|
82
|
+ try {
|
|
|
83
|
+ receiveVideoController.setReceiverConstraints(constraints);
|
|
|
84
|
+ fail();
|
|
|
85
|
+ } catch (error) {
|
|
|
86
|
+ expect(error).toEqual(new Error(
|
|
|
87
|
+ '"onStageEndpoints" and "selectedEndpoints" are not supported when sourceNameSignaling is enabled.'
|
|
|
88
|
+ ));
|
|
|
89
|
+ }
|
|
|
90
|
+ });
|
|
|
91
|
+ });
|
|
|
92
|
+
|
|
|
93
|
+ describe('when sourceNameSignaling is disabled', () => {
|
|
|
94
|
+ beforeEach(() => {
|
|
|
95
|
+ FeatureFlags.init({ sourceNameSignaling: false });
|
|
|
96
|
+ });
|
|
|
97
|
+
|
|
|
98
|
+ it('should call setNewReceiverVideoConstraints with the endpoints format.', () => {
|
|
|
99
|
+ const rtcSpy = spyOn(rtc, 'setNewReceiverVideoConstraints');
|
|
|
100
|
+ const constraints = {
|
|
|
101
|
+ onStageEndpoints: [ 'A', 'B', 'C' ],
|
|
|
102
|
+ selectedEndpoints: [ 'A' ]
|
|
|
103
|
+ };
|
|
|
104
|
+
|
|
|
105
|
+ receiveVideoController.setReceiverConstraints(constraints);
|
|
|
106
|
+ expect(rtcSpy).toHaveBeenCalledWith(constraints);
|
|
|
107
|
+ });
|
|
|
108
|
+
|
|
|
109
|
+ it('should not allow the source names format.', () => {
|
|
|
110
|
+ const constraints = {
|
|
|
111
|
+ onStageSources: [ 'A_camera_1', 'B_screen_2', 'C_camera_1' ],
|
|
|
112
|
+ selectedSources: [ 'A_camera_1' ]
|
|
|
113
|
+ };
|
|
|
114
|
+
|
|
|
115
|
+ try {
|
|
|
116
|
+ receiveVideoController.setReceiverConstraints(constraints);
|
|
|
117
|
+ fail();
|
|
|
118
|
+ } catch (error) {
|
|
|
119
|
+ expect(error).toEqual(new Error(
|
|
|
120
|
+ '"onStageSources" and "selectedSources" are not supported when sourceNameSignaling is disabled.'
|
|
|
121
|
+ ));
|
|
|
122
|
+ }
|
|
|
123
|
+ });
|
|
|
124
|
+ });
|
|
|
125
|
+});
|