blob: b06d79378a74e414b413ac8de1ea6f176525dea3 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="resources/audio-testing.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Basic tests for PannerNode.");
var context = 0;
function runTest() {
window.jsTestIsAsync = true;
context = new webkitAudioContext();
var panner = context.createPanner();
if (panner.numberOfInputs === 1)
testPassed("PannerNode has one input.");
else
testFailed("PannerNode should have one input.");
if (panner.numberOfOutputs === 1)
testPassed("PannerNode has one output.");
else
testFailed("PannerNode should have one output.");
if (panner.refDistance === 1)
testPassed("refDistance default value is 1.");
else
testFailed("refDistance default value should be 1.");
panner.refDistance = 270.52
if (panner.refDistance === 270.52)
testPassed("refDistance value is set to 270.52.");
else
testFailed("refDistance value should be set to 270.52.");
if (panner.maxDistance === 10000)
testPassed("maxDistance default value is 10000.");
else
testFailed("maxDistance default value should be 10000.");
panner.maxDistance = 100.55
if (panner.maxDistance === 100.55)
testPassed("maxDistance value is set to 100.55.");
else
testFailed("maxDistance value should be set to 100.55.");
if (panner.rolloffFactor === 1)
testPassed("rolloffFactor default value is 1.");
else
testFailed("rolloffFactor default value should be 1.");
panner.rolloffFactor = 0.83
if (panner.rolloffFactor === 0.83)
testPassed("rolloffFactor value is set to 0.83.");
else
testFailed("rolloffFactor value should be set to 0.83.");
if (panner.coneInnerAngle === 360)
testPassed("coneInnerAngle default value is 360.");
else
testFailed("coneInnerAngle default value should be 360.");
panner.coneInnerAngle = 240.45
if (panner.coneInnerAngle === 240.45)
testPassed("coneInnerAngle value is set to 240.45.");
else
testFailed("coneInnerAngle value should be set to 240.45.");
if (panner.coneOuterAngle === 360)
testPassed("coneOuterAngle default value is 360.");
else
testFailed("coneOuterAngle default value should be 360.");
panner.coneOuterAngle = 166.66
if (panner.coneOuterAngle === 166.66)
testPassed("coneOuterAngle value is set to 166.66.");
else
testFailed("coneOuterAngle value should be set to 166.66.");
if (panner.coneOuterGain === 0)
testPassed("coneOuterGain default value is 0.");
else
testFailed("coneOuterGain default value should be 0.");
panner.coneOuterGain = 0.35
if (panner.coneOuterGain === 0.35)
testPassed("coneOuterGain value is set to 0.35.");
else
testFailed("coneOuterGain value should be set to 0.35.");
if (panner.panningModel === "HRTF")
testPassed("PannerNode defaults to 'HRTF' panningModel.");
else
testFailed("PannerNode should default to 'HRTF' panningModel.");
if (panner.distanceModel === "inverse")
testPassed("PannerNode defaults to 'inverse' distanceModel.");
else
testFailed("PannerNode should default to 'inverse' distanceModel.");
// Check that the .panningModel attribute can be set to all legal values.
var panningModels = [{value: "equalpower"},
{value: "HRTF"},
];
for (var i = 0; i < panningModels.length; ++i) {
try {
panner.panningModel = panningModels[i].value;
if (panner.panningModel === panningModels[i].value) {
var message = "panningModel: '" + panningModels[i].value + "' is settable.";
testPassed(message);
} else {
var message = "panningModel: '" + panningModels[i].value + "' was not correctly set.";
testFailed(message);
}
} catch(e) {
var message = "Setting panningModel to '" + panningModels[i].value + "' should not throw exception.";
testFailed(message);
}
}
// Check that the .distanceModel attribute can be set to all legal values.
var distanceModels = [{value: "linear"},
{value: "inverse"},
{value: "exponential"}];
for (var i = 0; i < distanceModels.length; ++i) {
try {
panner.distanceModel = distanceModels[i].value;
if (panner.distanceModel === distanceModels[i].value) {
var message = "distanceModel: '" + distanceModels[i].value + "' is settable.";
testPassed(message);
} else {
var message = "distanceModel: '" + distanceModels[i].value + "' was not correctly set.";
testFailed(message);
}
} catch(e) {
var message = "Setting distanceModel to '" + distanceModels[i].value + "' should not throw exception.";
testFailed(message);
}
}
// Check that we don't throw an exception for illegal .distanceModel values as per WebIDL.
shouldNotThrowException(function() { panner.distanceModel = "xyz12349jfksd"; }, "Setting .distanceModel to illegal string value");
shouldNotThrowException(function() { panner.distanceModel = new Float32Array(1); }, "Setting .distanceModel to illegal type");
finishJSTest();
}
runTest();
</script>
</body>
</html>