| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 | 2 |
| 3 <html> | 3 <html> |
| 4 <head> | 4 <head> |
| 5 <script src="../../resources/js-test.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
| 6 <script src="../../resources/testharnessreport.js"></script> |
| 6 <script src="../resources/audit-util.js"></script> | 7 <script src="../resources/audit-util.js"></script> |
| 7 <script src="../resources/audio-testing.js"></script> | 8 <script src="../resources/audit.js"></script> |
| 8 </head> | 9 </head> |
| 9 | 10 |
| 10 <body> | 11 <body> |
| 11 <div id="description"></div> | |
| 12 <div id="console"></div> | |
| 13 | |
| 14 <script> | 12 <script> |
| 15 description("Basic tests for DynamicsCompressorNode API."); | 13 var audit = Audit.createTaskRunner(); |
| 16 | |
| 17 var context; | 14 var context; |
| 18 var compressor; | 15 var compressor; |
| 19 | 16 |
| 20 function runTest() { | 17 audit.define("test", function (task, should) { |
| 21 if (window.testRunner) { | 18 task.describe("Basic tests for DynamicsCompressorNode API"); |
| 22 testRunner.dumpAsText(); | |
| 23 testRunner.waitUntilDone(); | |
| 24 } | |
| 25 | |
| 26 window.jsTestIsAsync = true; | |
| 27 | 19 |
| 28 context = new AudioContext(); | 20 context = new AudioContext(); |
| 29 compressor = context.createDynamicsCompressor(); | 21 compressor = context.createDynamicsCompressor(); |
| 30 | 22 |
| 31 try { | 23 should(compressor.threshold.value, "compressor.threshold.value") |
| 32 if (compressor.threshold.value == -24) | 24 .beEqualTo(-24); |
| 33 testPassed("threshold attribute has correct default value."); | 25 should(compressor.knee.value, "compressor.knee.value") |
| 34 else | 26 .beEqualTo(30); |
| 35 testFailed("threshold attribute has incorrect default value."); | 27 should(compressor.ratio.value, "compressor.ratio.value") |
| 28 .beEqualTo(12); |
| 29 should(compressor.attack.value, "compressor.attack.value") |
| 30 .beEqualTo(Math.fround(0.003)); |
| 31 should(compressor.release.value, "compressor.release.value") |
| 32 .beEqualTo(0.25); |
| 33 should(typeof compressor.reduction, "typeof compressor.reduction") |
| 34 .beEqualTo("number"); |
| 35 should(compressor.reduction, "compressor.reduction") |
| 36 .beEqualTo(0); |
| 36 | 37 |
| 37 if (compressor.knee.value == 30) | 38 done(); |
| 38 testPassed("knee attribute has correct default value."); | 39 }); |
| 39 else | |
| 40 testFailed("knee attribute has incorrect default value."); | |
| 41 | |
| 42 if (compressor.ratio.value == 12) | |
| 43 testPassed("ratio attribute has correct default value."); | |
| 44 else | |
| 45 testFailed("ratio attribute has incorrect default value."); | |
| 46 | |
| 47 if (compressor.attack.value === Math.fround(0.003)) | |
| 48 testPassed("attack attribute has correct default value."); | |
| 49 else | |
| 50 testFailed("attack attribute has incorrect default value."); | |
| 51 | 40 |
| 52 if (compressor.release.value === 0.25) | 41 audit.run(); |
| 53 testPassed("release attribute has correct default value."); | |
| 54 else | |
| 55 testFailed("release attribute has incorrect default value."); | |
| 56 | |
| 57 if (typeof compressor.reduction === "number") { | |
| 58 testPassed("reduction attribute is a number.") | |
| 59 if (compressor.reduction == 0) | |
| 60 testPassed("reduction attribute has correct default value.") | |
| 61 } else { | |
| 62 testFailed("reduction attribute is an " + compressor.reduction.const
ructor.name + " not a number."); | |
| 63 } | |
| 64 | |
| 65 } catch(e) { | |
| 66 testFailed("Exception thrown when accessing DynamicsCompressorNode attri
butes."); | |
| 67 } | |
| 68 | |
| 69 finishJSTest(); | |
| 70 } | |
| 71 | |
| 72 runTest(); | |
| 73 | 42 |
| 74 </script> | 43 </script> |
| 75 | 44 |
| 76 </body> | 45 </body> |
| 77 </html> | 46 </html> |
| OLD | NEW |