| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../fast/js/resources/js-test-pre.js"></script> |
| <script src="resources/audio-testing.js"></script> |
| </head> |
| |
| <body> |
| <div id="description"></div> |
| <div id="console"></div> |
| |
| <script> |
| description("Basic tests for BiquadFilterNode."); |
| |
| var context = 0; |
| |
| function runTest() { |
| if (window.testRunner) { |
| testRunner.dumpAsText(); |
| testRunner.waitUntilDone(); |
| } |
| |
| window.jsTestIsAsync = true; |
| |
| context = new webkitAudioContext(); |
| var filter = context.createBiquadFilter(); |
| |
| if (filter.numberOfInputs === 1) |
| testPassed("BiquadFilterNode has one iutput."); |
| else |
| testFailed("BiquadFilterNode should have one iutput."); |
| |
| if (filter.numberOfOutputs === 1) |
| testPassed("BiquadFilterNode has one output."); |
| else |
| testFailed("BiquadFilterNode should have one output."); |
| |
| if (filter.type === filter.LOWPASS) |
| testPassed("Biquad filter defaults to low-pass filter."); |
| else |
| testFailed("Biquad filter should default to low-pass filter."); |
| |
| // Check that all legal filter types can be set. |
| var filterTypeArray = [filter.LOWPASS, |
| filter.HIGHPASS, |
| filter.BANDPASS, |
| filter.LOWSHELF, |
| filter.HIGHSHELF, |
| filter.PEAKING, |
| filter.NOTCH, |
| filter.ALLPASS]; |
| |
| for (var i = 0; i < filterTypeArray.length; ++i) { |
| try { |
| filter.type = filterTypeArray[i]; |
| if (filter.type === filterTypeArray[i] && filterTypeArray[i] === i) { |
| var message = "Biquad filter type " + i + " is settable."; |
| testPassed(message); |
| } else { |
| var message = "Biquad filter type " + i + " was not correctly set."; |
| testFailed(message); |
| } |
| } catch(e) { |
| var message = "Biquad filter type " + i + " should not throw exception."; |
| testFailed(message); |
| } |
| } |
| |
| // Check that illegal filter type throws. |
| try { |
| filter.type = filter.ALLPASS + 1; |
| testFailed("Illegal filter type should throw exception."); |
| } catch(e) { |
| testPassed("Illegal filter type correctly throws exception."); |
| } |
| |
| finishJSTest(); |
| } |
| |
| runTest(); |
| |
| </script> |
| |
| <script src="../fast/js/resources/js-test-post.js"></script> |
| </body> |
| </html> |