Bug 1439736 - AudioLevel RTP header ext. send/recv mochitest draft
authorNico Grunbaum
Tue, 20 Feb 2018 12:46:38 -0800
changeset 757958 321190a0db7ac88b575a4553e1a74e155201086f
parent 757856 dd6caba141428343fb26f3ec23a3ee1844a4b241
push id99898
push userna-g@nostrum.com
push dateWed, 21 Feb 2018 17:23:04 +0000
bugs1439736
milestone60.0a1
Bug 1439736 - AudioLevel RTP header ext. send/recv mochitest MozReview-Commit-ID: 2ybzJSSS7Jb
dom/media/tests/mochitest/mochitest.ini
dom/media/tests/mochitest/test_peerConnection_audioSynchronizationSourcesUnidirectional.html
--- a/dom/media/tests/mochitest/mochitest.ini
+++ b/dom/media/tests/mochitest/mochitest.ini
@@ -101,16 +101,18 @@ skip-if = android_version == '18' # andr
 [test_peerConnection_audioCodecs.html]
 skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_peerConnection_transceivers.html]
 skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_peerConnection_basicAudio.html]
 skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_peerConnection_audioSynchronizationSources.html]
 skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
+[test_peerConnection_audioSynchronizationSourcesUnidirectional.html]
+skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_peerConnection_audioContributingSources.html]
 skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_peerConnection_checkPacketDumpHook.html]
 skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_peerConnection_basicAudioNATSrflx.html]
 skip-if = toolkit == 'android' || (os == 'linux' && (debug || asan)) # websockets don't work on android (bug 1266217), linux hang (bug 1339568)
 [test_peerConnection_basicAudioNATRelay.html]
 skip-if = toolkit == 'android' || (os == 'linux' && (debug || asan)) # websockets don't work on android (bug 1266217), linux hang (bug 1339568)
new file mode 100644
--- /dev/null
+++ b/dom/media/tests/mochitest/test_peerConnection_audioSynchronizationSourcesUnidirectional.html
@@ -0,0 +1,54 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <script type="application/javascript" src="pc.js"></script>
+</head>
+<body>
+<pre id="test">
+<script type="application/javascript">
+  createHTML({
+    bug: "1439001",
+    title: "Test audio unidirectional getSynchronizationSources"
+  });
+
+  var waitForSyncSources = async (test) => {
+    let receiver = test.pcRemote.getReceivers()[0];
+    ok(receiver, "Remote has a receiver");
+    // Wait for remote sync source
+    while (receiver.getSynchronizationSources().length == 0) {
+      await wait(250);
+    }
+    is(receiver.getSynchronizationSources().length, 1,
+       "Remote receiver has a synchronization source");
+    // Make sure local has no sync source
+    is(test.pcLocal.getReceivers()[0].getSynchronizationSources().length, 0,
+       "Local receiver has no synchronization source");
+  };
+  /*
+   * Test to make sure that in unidirectional calls, the receiving end has
+   * synchronization sources with audio levels, and the sending end has none.
+   */
+  var testGetSynchronizationSourcesUnidirectional = async (test) => {
+    await waitForSyncSources(test);
+    let receiver = test.pcRemote.getReceivers()[0];
+    let syncSources = receiver.getSynchronizationSources();
+    ok(syncSources.length > 0,
+       "Receiver has Synchronization sources " + JSON.stringify(syncSources));
+    is(syncSources.length, 1, "Receiver has only a single sync source");
+    let syncSource = syncSources[0];
+    ok(syncSource.audioLevel !== undefined, "SynchronizationSource has audioLevel");
+  };
+
+  var test;
+  runNetworkTest(function(options) {
+    test = new PeerConnectionTest(options);
+    test.chain.insertAfter("PC_REMOTE_WAIT_FOR_MEDIA_FLOW",
+      [testGetSynchronizationSourcesUnidirectional]);
+    test.setMediaConstraints([{audio: true}], []);
+    test.pcLocal.audioElementsOnly = true;
+    test.run();
+  });
+</script>
+</pre>
+</body>
+</html>