OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <title>Test Constructor: ChannelSplitter</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 |
| 22 taskDone(); |
| 23 }); |
| 24 |
| 25 audit.defineTask("invalid constructor", function (taskDone) { |
| 26 var node; |
| 27 var success = true; |
| 28 |
| 29 success = Should("new ChannelSplitterNode()", function () { |
| 30 node = new ChannelSplitterNode(); |
| 31 }).throw("TypeError"); |
| 32 success = Should("new ChannelSplitterNode(1)", function () { |
| 33 node = new ChannelSplitterNode(1) && success; |
| 34 }).throw("TypeError"); |
| 35 success = Should("new ChannelSplitterNode(context, 42)", function () { |
| 36 node = new ChannelSplitterNode(context, 42) && success; |
| 37 }).throw("TypeError"); |
| 38 |
| 39 Should("Invalid constructors", success) |
| 40 .summarize( |
| 41 "correctly threw errors", |
| 42 "did not throw errors in all cases"); |
| 43 |
| 44 taskDone(); |
| 45 }); |
| 46 |
| 47 audit.defineTask("default constructor", function (taskDone) { |
| 48 var node; |
| 49 var success = true; |
| 50 |
| 51 success = Should("node = new ChannelSplitterNode(context)", function ()
{ |
| 52 node = new ChannelSplitterNode(context); |
| 53 }).notThrow(); |
| 54 success = Should("node instanceof ChannelSplitterNode", node instanceof
ChannelSplitterNode) |
| 55 .beEqualTo(true) && success; |
| 56 |
| 57 success = Should("node.numberOfInputs", node.numberOfInputs) |
| 58 .beEqualTo(1) && success; |
| 59 success = Should("node.numberOfOutputs", node.numberOfOutputs) |
| 60 .beEqualTo(6) && success; |
| 61 success = Should("node.channelCount", node.channelCount) |
| 62 .beEqualTo(2) && success; |
| 63 success = Should("node.channelCountMode", node.channelCountMode) |
| 64 .beEqualTo("max") && success; |
| 65 success = Should("node.channelInterpretation", node.channelInterpretatio
n) |
| 66 .beEqualTo("speakers") && success; |
| 67 |
| 68 Should("new ChannelSplitterNode(context)", success) |
| 69 .summarize( |
| 70 "constructed node with correct attributes", |
| 71 "did not construct correct node correctly") |
| 72 |
| 73 taskDone(); |
| 74 }); |
| 75 |
| 76 audit.defineTask("test AudioNodeOptions", function (taskDone) { |
| 77 testAudioNodeOptions(context, "ChannelSplitterNode"); |
| 78 taskDone(); |
| 79 }); |
| 80 |
| 81 audit.defineTask("constructor options", function (taskDone) { |
| 82 var node; |
| 83 var success = true; |
| 84 var options = { |
| 85 numberOfInputs: 3, |
| 86 numberOfOutputs: 9, |
| 87 channelInterpretation: "discrete" |
| 88 }; |
| 89 |
| 90 success = Should("node = new ChannelSplitterNode(context, " + JSON.strin
gify(options) + ")", function () { |
| 91 node = new ChannelSplitterNode(context, options); |
| 92 }).notThrow(); |
| 93 |
| 94 success = Should("node.numberOfInputs", node.numberOfInputs) |
| 95 .beEqualTo(1) && success; |
| 96 success = Should("node.numberOfOutputs", node.numberOfOutputs) |
| 97 .beEqualTo(options.numberOfOutputs) && success; |
| 98 success = Should("node.channelInterpretation", node.channelInterpretatio
n) |
| 99 .beEqualTo(options.channelInterpretation) && success; |
| 100 |
| 101 options = { numberOfOutputs: 99 }; |
| 102 success = Should("new ChannelSplitterNode(c, " + JSON.stringify(options)
+ ")", |
| 103 function () { |
| 104 node = new ChannelSplitterNode(context, options); |
| 105 }) |
| 106 .throw("IndexSizeError") && success; |
| 107 |
| 108 options = { channelCount: 3 }; |
| 109 success = Should("new ChannelSplitterNode(c, " + JSON.stringify(options)
+ ")", |
| 110 function () { |
| 111 node = new ChannelSplitterNode(context, options); |
| 112 }) |
| 113 .notThrow() && success; |
| 114 |
| 115 options = { channelCountMode: "max"}; |
| 116 success = Should("new ChannelSplitterNode(c, " + JSON.stringify(options)
+ ")", |
| 117 function () { |
| 118 node = new ChannelSplitterNode(context, { |
| 119 channelCountMode: "max" |
| 120 }); |
| 121 }) |
| 122 .notThrow() && success; |
| 123 |
| 124 Should("new ChannelSplitterNode() with options", success) |
| 125 .summarize( |
| 126 "constructed with correct attributes", |
| 127 "was not constructed correctly"); |
| 128 |
| 129 taskDone(); |
| 130 }); |
| 131 |
| 132 audit.runTasks(); |
| 133 </script> |
| 134 </body> |
| 135 </html> |
OLD | NEW |