You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MockClasses.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* eslint-disable no-empty-function */
  2. /**
  3. * Mock {@link TraceablePeerConnection} - add things as needed, but only things useful for all tests.
  4. */
  5. export class MockPeerConnection {
  6. /**
  7. * Constructor.
  8. *
  9. * @param {string} id RTC id
  10. * @param {boolean} usesUnifiedPlan
  11. */
  12. constructor(id, usesUnifiedPlan) {
  13. this.id = id;
  14. this._usesUnifiedPlan = usesUnifiedPlan;
  15. }
  16. /**
  17. * {@link TraceablePeerConnection.localDescription}.
  18. *
  19. * @returns {Object}
  20. */
  21. get localDescription() {
  22. return {
  23. sdp: ''
  24. };
  25. }
  26. /**
  27. * {@link TraceablePeerConnection.remoteDescription}.
  28. *
  29. * @returns {Object}
  30. */
  31. get remoteDescription() {
  32. return {
  33. sdp: ''
  34. };
  35. }
  36. /**
  37. * {@link TraceablePeerConnection.createAnswer}.
  38. *
  39. * @returns {Promise<Object>}
  40. */
  41. createAnswer() {
  42. return Promise.resolve(/* answer */{});
  43. }
  44. /**
  45. * {@link TraceablePeerConnection.processLocalSdpForTransceiverInfo}.
  46. *
  47. * @returns {void}
  48. */
  49. processLocalSdpForTransceiverInfo() {
  50. }
  51. /**
  52. * {@link TraceablePeerConnection.setLocalDescription}.
  53. *
  54. * @returns {Promise<void>}
  55. */
  56. setLocalDescription() {
  57. return Promise.resolve();
  58. }
  59. /**
  60. * {@link TraceablePeerConnection.setRemoteDescription}.
  61. *
  62. * @returns {Promise<void>}
  63. */
  64. setRemoteDescription() {
  65. return Promise.resolve();
  66. }
  67. /**
  68. * {@link TraceablePeerConnection.setSenderVideoConstraints}.
  69. */
  70. setSenderVideoConstraints() {
  71. }
  72. /**
  73. * {@link TraceablePeerConnection.setVideoTransferActive}.
  74. */
  75. setVideoTransferActive() {
  76. return false;
  77. }
  78. /**
  79. * {@link TraceablePeerConnection.usesUnifiedPlan}.
  80. */
  81. usesUnifiedPlan() {
  82. return this._usesUnifiedPlan;
  83. }
  84. /**
  85. * {@link TraceablePeerConnection.getLocalVideoTracks}.
  86. */
  87. getLocalVideoTracks() {
  88. return [];
  89. }
  90. }
  91. /**
  92. * Mock {@link RTC} - add things as needed, but only things useful for all tests.
  93. */
  94. export class MockRTC {
  95. /**
  96. * {@link RTC.createPeerConnection}.
  97. *
  98. * @returns {MockPeerConnection}
  99. */
  100. createPeerConnection() {
  101. this.pc = new MockPeerConnection();
  102. return this.pc;
  103. }
  104. }
  105. /* eslint-enable no-empty-function */