Bug 1291715 - Add mochitest for DTMF; r=jib
☠☠ backed out by 23abc8c21f75 ☠ ☠
authorDan Minor <dminor@mozilla.com>
Thu, 29 Sep 2016 15:05:33 -0400
changeset 316538 044172cb2dd83db60358793ee4e59063b0e96943
parent 316537 91c0b78bb4dd5032bef67519c41268623fdac301
child 316539 078248a9fdbc3c28e09c57b65d4024f5b5c39c57
push id32865
push userdminor@mozilla.com
push dateWed, 05 Oct 2016 14:36:22 +0000
treeherderautoland@078248a9fdbc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1291715
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1291715 - Add mochitest for DTMF; r=jib MozReview-Commit-ID: 4acq5uMLxe9
dom/media/tests/mochitest/mochitest.ini
dom/media/tests/mochitest/test_peerConnection_insertDTMF.html
--- a/dom/media/tests/mochitest/mochitest.ini
+++ b/dom/media/tests/mochitest/mochitest.ini
@@ -134,16 +134,17 @@ skip-if = (android_version == '18' && de
 # [test_peerConnection_certificates.html] # bug 1180968
 [test_peerConnection_close.html]
 [test_peerConnection_closeDuringIce.html]
 [test_peerConnection_constructedStream.html]
 skip-if = android_version == '18' # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_peerConnection_errorCallbacks.html]
 [test_peerConnection_iceFailure.html]
 skip-if = os == 'linux' || os == 'mac' || os == 'win' || android_version == '18' # (Bug 1180388 for win, mac and linux), android(Bug 1189784, timeouts on 4.3 emulator)
+[test_peerConnection_insertDTMF.html]
 [test_peerConnection_forwarding_basicAudioVideoCombined.html]
 skip-if = android_version == '18' # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_peerConnection_noTrickleAnswer.html]
 [test_peerConnection_noTrickleOffer.html]
 [test_peerConnection_noTrickleOfferAnswer.html]
 [test_peerConnection_offerRequiresReceiveAudio.html]
 [test_peerConnection_offerRequiresReceiveVideo.html]
 [test_peerConnection_offerRequiresReceiveVideoAudio.html]
new file mode 100644
--- /dev/null
+++ b/dom/media/tests/mochitest/test_peerConnection_insertDTMF.html
@@ -0,0 +1,82 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <script type="application/javascript" src="pc.js"></script>
+</head>
+<body>
+<pre id="test">
+<script type="application/javascript;version=1.8">
+createHTML({
+  bug: "1291715",
+  title: "Test insertDTMF on sender",
+  visible: true
+});
+
+function insertdtmftest(pc) {
+  ok(pc.getSenders().length > 0, "have senders");
+  var sender = pc.getSenders()[0];
+  ok(sender.dtmf, "sender has dtmf object");
+
+  ok(sender.dtmf.toneBuffer === "", "sender should start with empty tonebuffer");
+
+  sender.dtmf.insertDTMF("A", 10);
+  is(sender.dtmf.duration, 40, "minimum duration is 40");
+  sender.dtmf.insertDTMF("A", 10000);
+  is(sender.dtmf.duration, 6000, "maximum duration is 6000");
+  sender.dtmf.insertDTMF("A", 70, 10);
+  is(sender.dtmf.duration, 70, "default duration is 70");
+  is(sender.dtmf.interToneGap, 30, "minimum interToneGap is 30");
+  sender.dtmf.insertDTMF("", 100, 40);
+  is(sender.dtmf.duration, 100, "duration is 70");
+  is(sender.dtmf.interToneGap, 40, "interToneGap is 40");
+
+  var threw = false;
+  try {
+    sender.dtmf.insertDTMF("bad tones");
+  } catch (ex) {
+    threw = true;
+    is(ex.code, DOMException.INVALID_CHARACTER_ERR, "Expected InvalidCharacterError");
+  }
+  ok(threw, "Expected exception");
+
+  sender.dtmf.insertDTMF("A");
+  sender.dtmf.insertDTMF("B");
+  ok(sender.dtmf.toneBuffer.indexOf("A") == -1, "calling insertDTMF should replace current characters");
+
+  sender.dtmf.insertDTMF("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
+  ok(sender.dtmf.toneBuffer.indexOf("A") != -1, "lowercase characters should be normalized");
+
+  pc.removeTrack(sender);
+  threw = false;
+  try {
+    sender.dtmf.insertDTMF("AAA");
+  } catch (ex) {
+    threw = true;
+    is(ex.code, DOMException.INVALID_STATE_ERR, "Expected InvalidStateError");
+  }
+  ok(threw, "Expected exception");
+}
+
+runNetworkTest(() => {
+
+  test = new PeerConnectionTest();
+  test.setMediaConstraints([{audio: true}], [{audio: true}]);
+  test.chain.removeAfter("PC_REMOTE_WAIT_FOR_MEDIA_FLOW");
+
+  // Test sender dtmf.
+  test.chain.append([
+    function PC_LOCAL_INSERT_DTMF(test) {
+      // We want to call removeTrack
+      test.pcLocal.expectNegotiationNeeded();
+      return insertdtmftest(test.pcLocal._pc);
+    }
+  ]);
+
+  return test.run()
+    .catch(e => ok(false, "unexpected failure: " + e));
+});
+
+</script>
+</pre>
+</body>
+</html>