Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!doctype html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <title>Test Constructor: DynamicsCompressor</title> | |
| 5 <script src="../../resources/testharness.js"></script> | |
| 6 <script src="../../resources/testharnessreport.js"></script> | |
| 7 <script src="../resources/audio-testing.js"></script> | |
| 8 <script src="audionodeoptions.js"></script> | |
| 9 </head> | |
| 10 | |
| 11 <body> | |
| 12 <script> | |
| 13 var context; | |
| 14 | |
| 15 var audit = Audit.createTaskRunner(); | |
| 16 | |
| 17 audit.defineTask("initialize", function (taskDone) { | |
| 18 Should("context = new OfflineAudioContext(...)", function () { | |
| 19 context = new OfflineAudioContext(1, 1, 48000); | |
| 20 }).notThrow(); | |
| 21 taskDone(); | |
| 22 }); | |
| 23 | |
| 24 audit.defineTask("invalid constructor", function (taskDone) { | |
| 25 var node; | |
| 26 var success = true; | |
| 27 | |
| 28 success = Should("new DynamicsCompressorNode()", function () { | |
| 29 node = new DynamicsCompressorNode(); | |
| 30 }).throw("TypeError"); | |
| 31 success = Should("new DynamicsCompressorNode(1)", function () { | |
| 32 node = new DynamicsCompressorNode(1); | |
| 33 }).throw("TypeError") && success; | |
| 34 success = Should("new DynamicsCompressorNode(context, 42)", function () { | |
| 35 node = new DynamicsCompressorNode(context, 42); | |
| 36 }).throw("TypeError") && success; | |
| 37 | |
| 38 Should("Invalid constructors", success) | |
| 39 .summarize( | |
| 40 "correctly threw errors", | |
| 41 "did not throw errors in all cases"); | |
| 42 | |
| 43 taskDone(); | |
| 44 }); | |
| 45 | |
| 46 audit.defineTask("default constructor", function (taskDone) { | |
| 47 var node; | |
| 48 var success = true; | |
| 49 | |
| 50 success = success = Should("node = new DynamicsCompressorNode(context)", function () { | |
| 51 node = new DynamicsCompressorNode(context); | |
| 52 }).notThrow(); | |
| 53 success = success = Should("node instanceof DynamicsCompressorNode", | |
| 54 node instanceof DynamicsCompressorNode) | |
| 55 .beEqualTo(true) && success; | |
| 56 | |
| 57 success = Should("node.threshold.value", node.threshold.value) | |
| 58 .beEqualTo(-24) && success; | |
| 59 success = success = Should("node.knee.value", node.knee.value) | |
| 60 .beEqualTo(30) && success; | |
| 61 success = success = Should("node.ratio.value", node.ratio.value) | |
| 62 .beEqualTo(12) && success; | |
| 63 success = success = Should("node.reduction", node.reduction) | |
| 64 .beEqualTo(0) && success; | |
| 65 success = success = Should("node.attack.value", node.attack.value) | |
| 66 .beEqualTo(Math.fround(0.003)) && success; | |
| 67 success = success = Should("node.release.value", node.release.value) | |
| 68 .beEqualTo(0.25) && success; | |
| 69 | |
| 70 success = success = Should("node.channelCount", node.channelCount) | |
| 71 .beEqualTo(2) && success; | |
| 72 success = success = Should("node.channelCountMode", node.channelCountMod e) | |
| 73 .beEqualTo("max") && success; | |
| 74 success = success = Should("node.channelInterpretation", node.channelInt erpretation) | |
| 75 .beEqualTo("speakers") && success; | |
| 76 | |
| 77 Should("new DynamicsCompressorNode(context)", success) | |
| 78 .summarize( | |
| 79 "constructed node with correct attributes", | |
| 80 "did not construct correct node correctly") | |
| 81 | |
| 82 taskDone(); | |
| 83 }); | |
| 84 | |
| 85 audit.defineTask("test AudioNodeOptions", function (taskDone) { | |
| 86 testAudioNodeOptions(context, "DynamicsCompressorNode"); | |
| 87 taskDone(); | |
| 88 }); | |
| 89 | |
| 90 audit.defineTask("constructor with options", function (taskDone) { | |
| 91 var node; | |
| 92 var success = true; | |
| 93 var options = { | |
| 94 threshold: -33, | |
| 95 knee: 15, | |
| 96 ratio: 7, | |
| 97 attack: 0.625, | |
| 98 release: 0.125 | |
| 99 }; | |
| 100 | |
| 101 success = Should("node = new DynamicsCompressorNode(c, " + JSON.stringif y(options) + | |
| 102 ")", | |
| 103 function () { | |
| 104 node = new DynamicsCompressorNode(context, options); | |
| 105 }).notThrow(); | |
| 106 success = success = Should("node instanceof DynamicsCompressorNode", | |
|
hongchan
2016/09/14 17:40:07
We still have duplicated |success|s.
Raymond Toy
2016/09/14 18:02:24
Found and fixed them all, everywhere.
| |
| 107 node instanceof DynamicsCompressorNode) | |
| 108 .beEqualTo(true) && success; | |
| 109 | |
| 110 success = success = Should("node.threshold.value", node.threshold.value) | |
| 111 .beEqualTo(options.threshold) && success; | |
| 112 success = success = Should("node.knee.value", node.knee.value) | |
| 113 .beEqualTo(options.knee) && success; | |
| 114 success = success = Should("node.ratio.value", node.ratio.value) | |
| 115 .beEqualTo(options.ratio) && success; | |
| 116 success = success = Should("node.attack.value", node.attack.value) | |
| 117 .beEqualTo(options.attack) && success; | |
| 118 success = success = Should("node.release.value", node.release.value) | |
| 119 .beEqualTo(options.release) && success; | |
| 120 | |
| 121 success = success = Should("node.channelCount", node.channelCount) | |
| 122 .beEqualTo(2) && success; | |
| 123 success = success = Should("node.channelCountMode", node.channelCountMod e) | |
| 124 .beEqualTo("max") && success; | |
| 125 success = success = Should("node.channelInterpretation", node.channelInt erpretation) | |
| 126 .beEqualTo("speakers") && success; | |
| 127 | |
| 128 success = Should("DynamicsCompressorNode(context) constructed with corre ct values", | |
| 129 success) | |
| 130 .beEqualTo(true); | |
| 131 | |
| 132 taskDone(); | |
| 133 }); | |
| 134 | |
| 135 | |
| 136 audit.runTasks(); | |
| 137 </script> | |
| 138 </body> | |
| 139 </html> | |
| OLD | NEW |