blob: ce528b42f2bce2bfc9df7d19e4ca0d123d39744b [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("Tests RTCDTMFSender.");
var pc = null;
var stream = null;
var dtmfsender = null;
function error() {
testFailed('Error callback called.');
finishJSTest();
}
var lastCall = false;
var callCount = 1;
function ontonechange(e) {
event = e;
testPassed("ontonechange was called " + event.tone);
if (!lastCall) {
callCount++;
if (8 == callCount)
lastCall = true;
} else {
shouldBeEmptyString('event.tone');
finishJSTest();
}
}
function pc_onicechange() {
if (pc.iceConnectionState === "completed") {
testPassed("pc is connected");
track = stream.getAudioTracks()[0];
shouldThrow('dtmfsender = pc.createDTMFSender(track);');
pc.addStream(stream);
shouldNotThrow('dtmfsender = pc.createDTMFSender(track);');
shouldBeTrue('dtmfsender.canInsertDTMF');
dtmfsender.ontonechange = ontonechange;
dtmfsender.insertDTMF("1");
shouldBe('dtmfsender.duration', "100");
shouldBe('dtmfsender.interToneGap', "70");
dtmfsender.insertDTMF("4", "40", "30");
shouldBe('dtmfsender.duration', "40");
shouldBe('dtmfsender.interToneGap', "30");
dtmfsender.insertDTMF("123", "6000");
shouldBe('dtmfsender.duration', "6000");
shouldBe('dtmfsender.interToneGap', "70");
shouldThrow('dtmfsender.insertDTMF("1", "20");');
shouldThrow('dtmfsender.insertDTMF("1", "7000");');
shouldThrow('dtmfsender.insertDTMF("1", "70", "10");');
}
}
function gotStream(s) {
stream = s;
testPassed('Stream generated.');
shouldBe('stream.getAudioTracks().length', '1');
shouldBe('stream.getVideoTracks().length', '0');
pc = new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]});
pc.oniceconnectionstatechange = pc_onicechange;
}
shouldNotThrow("navigator.webkitGetUserMedia({audio:true}, gotStream, error);");
window.jsTestIsAsync = true;
window.successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>