OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <title>Test Constructor: Convolver</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 succes = Should("new ConvolverNode()", function () { |
| 29 node = new ConvolverNode(); |
| 30 }).throw("TypeError"); |
| 31 success = Should("new ConvolverNode(1)", function () { |
| 32 node = new ConvolverNode(1); |
| 33 }).throw("TypeError") && success; |
| 34 success = Should("new ConvolverNode(context, 42)", function () { |
| 35 node = new ConvolverNode(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 taskDone(); |
| 43 }); |
| 44 |
| 45 audit.defineTask("default constructor", function (taskDone) { |
| 46 var node; |
| 47 var success = true; |
| 48 |
| 49 success = Should("node = new ConvolverNode(context)", function () { |
| 50 node = new ConvolverNode(context); |
| 51 }).notThrow(); |
| 52 success = Should("node instanceOf ConvolverNode", node instanceof Convol
verNode) |
| 53 .beEqualTo(true) && success; |
| 54 success = Should("node.normalize", node.normalize) |
| 55 .beEqualTo(true) && success; |
| 56 |
| 57 success = Should("node.channelCount", node.channelCount) |
| 58 .beEqualTo(2) && success; |
| 59 success = Should("node.channelCountMode", node.channelCountMode) |
| 60 .beEqualTo("clamped-max") && success; |
| 61 success = Should("node.channelInterpretation", node.channelInterpretatio
n) |
| 62 .beEqualTo("speakers") && success; |
| 63 |
| 64 success = Should("new AnalyserNode(context)", success) |
| 65 .summarize( |
| 66 "constructed node with correct attributes", |
| 67 "did not construct correct node correctly") |
| 68 |
| 69 taskDone(); |
| 70 }); |
| 71 |
| 72 audit.defineTask("test AudioNodeOptions", function (taskDone) { |
| 73 testAudioNodeOptions(context, "ConvolverNode"); |
| 74 taskDone(); |
| 75 }); |
| 76 |
| 77 audit.defineTask("construct with options", function (taskDone) { |
| 78 var buf = context.createBuffer(1, 1, context.sampleRate); |
| 79 var options = { |
| 80 buffer: buf, |
| 81 disableNormalization: false |
| 82 }; |
| 83 |
| 84 var message = "node = new ConvolverNode(context, "; |
| 85 message += "{ buffer: <buf>, " + "disableNormalization: "; |
| 86 message += options.disableNormalization + "}"; |
| 87 |
| 88 var node; |
| 89 success = Should(message, function () { |
| 90 node = new ConvolverNode(context, options); |
| 91 }).notThrow(); |
| 92 |
| 93 success = Should("node instanceOf ConvolverNode", node instanceof Convol
verNode) |
| 94 .beEqualTo(true) && success; |
| 95 success = Should("node.buffer === <buf>", node.buffer === |
| 96 options.buffer) |
| 97 .beEqualTo(true) && success; |
| 98 success = Should("node.normalize", node.normalize) |
| 99 .beEqualTo(!options.disableNormalization) && success; |
| 100 |
| 101 options.buffer = null; |
| 102 options.disableNormalization = true; |
| 103 var message = "node = new ConvolverNode(context, "; |
| 104 message += "{ buffer: " + options.buffer + ", " + "disableNormalization:
"; |
| 105 message += options.disableNormalization + "}"; |
| 106 |
| 107 success = Should(message, function () { |
| 108 node = new ConvolverNode(context, options); |
| 109 }).notThrow() && success; |
| 110 success = Should("node.buffer", node.buffer).beEqualTo(null) && success; |
| 111 success = Should("node.normalize", node.normalize) |
| 112 .beEqualTo(!options.disableNormalization) && success; |
| 113 |
| 114 var message = "node = new ConvolverNode(context, "; |
| 115 message += "{ " + "disableNormalization: "; |
| 116 message += options.disableNormalization + "}"; |
| 117 |
| 118 success = Should(message, function () { |
| 119 node = new ConvolverNode(context, options); |
| 120 }).notThrow() && success; |
| 121 success = Should("node.buffer", node.buffer).beEqualTo(null) && success; |
| 122 success = Should("node.normalize", node.normalize) |
| 123 .beEqualTo(!options.disableNormalization) && success; |
| 124 |
| 125 Should("new ConvolverNode() with options", success) |
| 126 .summarize( |
| 127 "constructed with correct attributes", |
| 128 "was not constructed correctly"); |
| 129 |
| 130 taskDone(); |
| 131 }); |
| 132 |
| 133 audit.runTasks(); |
| 134 </script> |
| 135 </body> |
| 136 </html> |
OLD | NEW |