| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> |
| 5 <script src="../resources/audit-util.js"></script> | 6 <script src="../resources/audit-util.js"></script> |
| 6 <script src="../resources/audio-testing.js"></script> | 7 <script src="../resources/audit.js"></script> |
| 7 </head> | 8 </head> |
| 8 | 9 |
| 9 <body> | 10 <body> |
| 10 <div id="description"></div> | |
| 11 <div id="console"></div> | |
| 12 | 11 |
| 13 <script> | 12 <script> |
| 14 description("Basic tests for AnalyserNode."); | |
| 15 | 13 |
| 16 var context = 0; | 14 var context = 0; |
| 17 | 15 |
| 18 function runTest() { | 16 var audit = Audit.createTaskRunner(); |
| 19 if (window.testRunner) { | |
| 20 testRunner.dumpAsText(); | |
| 21 testRunner.waitUntilDone(); | |
| 22 } | |
| 23 | 17 |
| 24 window.jsTestIsAsync = true; | 18 audit.define("Basic AnalyserNode test", function (task, should) { |
| 25 | |
| 26 context = new AudioContext(); | 19 context = new AudioContext(); |
| 27 var analyser = context.createAnalyser(); | 20 var analyser = context.createAnalyser(); |
| 28 | 21 |
| 29 if (analyser.numberOfInputs === 1) | 22 should(analyser.numberOfInputs, "Number of inputs for AnalyserNode") |
| 30 testPassed("AnalyserNode has one input."); | 23 .beEqualTo(1); |
| 31 else | |
| 32 testFailed("AnalyserNode should have one input, not " + analyser.numberO
fInputs + "."); | |
| 33 | 24 |
| 34 if (analyser.numberOfOutputs === 1) | 25 should(analyser.numberOfOutputs, "Number of outputs for AnalyserNode") |
| 35 testPassed("AnalyserNode has one output."); | 26 .beEqualTo(1); |
| 36 else | |
| 37 testFailed("AnalyserNode should have one output."); | |
| 38 | 27 |
| 39 if (analyser.minDecibels === -100) | 28 should(analyser.minDecibels, "Default minDecibels value") |
| 40 testPassed("minDecibels default value is -100."); | 29 .beEqualTo(-100); |
| 41 else | |
| 42 testFailed("minDecibels default value should be -100."); | |
| 43 | 30 |
| 44 if (analyser.maxDecibels === -30) | 31 should(analyser.maxDecibels, "Default maxDecibels value") |
| 45 testPassed("maxDecibels default value is -30."); | 32 .beEqualTo(-30); |
| 46 else | |
| 47 testFailed("maxDecibels default value should be -30."); | |
| 48 | 33 |
| 49 if (analyser.smoothingTimeConstant === 0.8) | 34 should(analyser.smoothingTimeConstant, "Default smoothingTimeConstant value"
) |
| 50 testPassed("smoothingTimeConstant default value is 0.8."); | 35 .beEqualTo(0.8); |
| 51 else | 36 |
| 52 testFailed("smoothingTimeConstant default value should be 0.8."); | |
| 53 | |
| 54 var expectedValue = -50 - (1/3); | 37 var expectedValue = -50 - (1/3); |
| 55 analyser.minDecibels = expectedValue; | 38 analyser.minDecibels = expectedValue; |
| 56 if (analyser.minDecibels === expectedValue) | 39 |
| 57 testPassed("minDecibels value is set to " + expectedValue + ".") | 40 should(analyser.minDecibels, "node.minDecibels = " + expectedValue) |
| 58 else | 41 .beEqualTo(expectedValue); |
| 59 testFailed("minDecibels value should be set to " + expectedValue + ", no
t " + analyser.minDecibels + "."); | |
| 60 | 42 |
| 61 expectedValue = -40 - (1/3); | 43 expectedValue = -40 - (1/3); |
| 62 analyser.maxDecibels = expectedValue; | 44 analyser.maxDecibels = expectedValue; |
| 63 if (analyser.maxDecibels === expectedValue) | |
| 64 testPassed("maxDecibels value is set to " + expectedValue + ".") | |
| 65 else | |
| 66 testFailed("maxDecibels value should be set to " + expectedValue + ", no
t " + analyser.maxDecibels + "."); | |
| 67 | 45 |
| 68 finishJSTest(); | 46 should(analyser.maxDecibels, "node.maxDecibels = " + expectedValue) |
| 69 } | 47 .beEqualTo(expectedValue); |
| 70 | 48 |
| 71 runTest(); | 49 task.done(); |
| 50 }); |
| 72 | 51 |
| 52 audit.run(); |
| 73 </script> | 53 </script> |
| 74 | 54 |
| 75 </body> | 55 </body> |
| 76 </html> | 56 </html> |
| OLD | NEW |