OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <title>Test Constructor: StereoPanner</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 StereoPannerNode()", function () { |
| 30 node = new StereoPannerNode(); |
| 31 }).throw("TypeError"); |
| 32 success = Should("new StereoPannerNode(1)", function () { |
| 33 node = new StereoPannerNode(1) && success; |
| 34 }).throw("TypeError"); |
| 35 success = Should("new StereoPannerNode(context, 42)", function () { |
| 36 node = new StereoPannerNode(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 StereoPannerNode(context)", function () { |
| 52 node = new StereoPannerNode(context); |
| 53 }).notThrow(); |
| 54 success = Should("node instanceof StereoPannerNode", node instanceof Ste
reoPannerNode) |
| 55 .beEqualTo(true) && success; |
| 56 |
| 57 success = Should("node.pan.value", node.pan.value) |
| 58 .beEqualTo(0) && success; |
| 59 |
| 60 Should("new StereoPannerNode(context)", success) |
| 61 .summarize( |
| 62 "constructed node with correct attributes", |
| 63 "did not construct correct node correctly") |
| 64 |
| 65 taskDone(); |
| 66 }); |
| 67 |
| 68 audit.defineTask("test AudioNodeOptions", function (taskDone) { |
| 69 // Can't use testAudioNodeOptions because the constraints for this node |
| 70 // are not supported there. |
| 71 var node; |
| 72 var success = true; |
| 73 |
| 74 // Test that we can set the channel count to 1 or 2. |
| 75 var options = { |
| 76 channelCount: 1 |
| 77 }; |
| 78 success = Should("new StereoPannerNode(c, " + JSON.stringify(options) +
")", |
| 79 function () { |
| 80 node = new StereoPannerNode(context, options); |
| 81 }).notThrow() && success; |
| 82 success = Should("node.channelCount", node.channelCount) |
| 83 .beEqualTo(1) && success; |
| 84 |
| 85 options = { |
| 86 channelCount: 2 |
| 87 }; |
| 88 success = Should("new StereoPannerNode(c, " + JSON.stringify(options) +
")", |
| 89 function () { |
| 90 node = new StereoPannerNode(context, options); |
| 91 }).notThrow() && success; |
| 92 success = Should("node.channelCount", node.channelCount) |
| 93 .beEqualTo(2) && success; |
| 94 |
| 95 // Test that other channel counts throw an error |
| 96 options = { |
| 97 channelCount: 0 |
| 98 }; |
| 99 success = Should("new StereoPannerNode(c, " + JSON.stringify(options) +
")", |
| 100 function () { |
| 101 node = new StereoPannerNode(context, options); |
| 102 }).throw("NotSupportedError") && success; |
| 103 |
| 104 options = { |
| 105 channelCount: 3 |
| 106 }; |
| 107 success = Should("new StereoPannerNode(c, " + JSON.stringify(options) +
")", |
| 108 function () { |
| 109 node = new StereoPannerNode(context, options); |
| 110 }).throw("NotSupportedError") && success; |
| 111 |
| 112 options = { |
| 113 channelCount: 99 |
| 114 }; |
| 115 success = Should("new StereoPannerNode(c, " + JSON.stringify(options) +
")", |
| 116 function () { |
| 117 node = new StereoPannerNode(context, options); |
| 118 }).throw("NotSupportedError") && success; |
| 119 |
| 120 // Test channelCountMode. A mode of "max" is illegal, but others are |
| 121 // ok. |
| 122 options = { |
| 123 channelCountMode: "clamped-max" |
| 124 }; |
| 125 success = Should("new StereoPannerNode(c, " + JSON.stringify(options) +
")", |
| 126 function () { |
| 127 node = new StereoPannerNode(context, options); |
| 128 }).notThrow() && success; |
| 129 success = Should("node.channelCountMode", node.channelCountMode) |
| 130 .beEqualTo(options.channelCountMode) && success; |
| 131 |
| 132 options = { |
| 133 channelCountMode: "explicit" |
| 134 }; |
| 135 success = Should("new StereoPannerNode(c, " + JSON.stringify(options) +
")", |
| 136 function () { |
| 137 node = new StereoPannerNode(context, options); |
| 138 }).notThrow() && success; |
| 139 success = Should("node.channelCountMode", node.channelCountMode) |
| 140 .beEqualTo(options.channelCountMode) && success; |
| 141 |
| 142 options = { |
| 143 channelCountMode: "max" |
| 144 }; |
| 145 success = Should("new StereoPannerNode(c, " + JSON.stringify(options) +
")", |
| 146 function () { |
| 147 node = new StereoPannerNode(context, options); |
| 148 }).throw("NotSupportedError") && success; |
| 149 |
| 150 options = { |
| 151 channelCountMode: "foobar" |
| 152 }; |
| 153 success = Should("new StereoPannerNode(c, " + JSON.stringify(options) +
")", |
| 154 function () { |
| 155 node = new StereoPannerNode(context, options); |
| 156 }).throw("TypeError") && success; |
| 157 |
| 158 // Test channelInterpretation. |
| 159 options = { |
| 160 channelInterpretation: "speakers" |
| 161 }; |
| 162 success = Should("new StereoPannerNode(c, " + JSON.stringify(options) +
")", |
| 163 function () { |
| 164 node = new StereoPannerNode(context, options); |
| 165 }).notThrow() && success; |
| 166 success = Should("node.channelInterpretation", node.channelInterpretatio
n) |
| 167 .beEqualTo(options.channelInterpretation) && success; |
| 168 |
| 169 options = { |
| 170 channelInterpretation: "discrete" |
| 171 }; |
| 172 success = Should("new StereoPannerNode(c, " + JSON.stringify(options) +
")", |
| 173 function () { |
| 174 node = new StereoPannerNode(context, options); |
| 175 }).notThrow() && success; |
| 176 success = Should("node.channelInterpretation", node.channelInterpretatio
n) |
| 177 .beEqualTo(options.channelInterpretation) && success; |
| 178 |
| 179 options = { |
| 180 channelInterpretation: "foobar" |
| 181 }; |
| 182 success = Should("new StereoPannerNode(c, " + JSON.stringify(options) +
")", |
| 183 function () { |
| 184 node = new StereoPannerNode(context, options); |
| 185 }).throw("TypeError") && success; |
| 186 |
| 187 Should("AudioNodeOptions for StereoPannerNode", success) |
| 188 .summarize( |
| 189 "were correctly handled", |
| 190 "were not correctly handled"); |
| 191 |
| 192 taskDone(); |
| 193 }); |
| 194 |
| 195 audit.defineTask("constructor with options", function (taskDone) { |
| 196 var node; |
| 197 var success = true; |
| 198 var options = { |
| 199 pan: 0.75, |
| 200 }; |
| 201 |
| 202 success = Should("node = new StereoPannerNode(, " + JSON.stringify(optio
ns) + ")", |
| 203 function () { |
| 204 node = new StereoPannerNode(context, options); |
| 205 }).notThrow(); |
| 206 success = Should("node instanceof StereoPannerNode", node instanceof Ste
reoPannerNode) |
| 207 .beEqualTo(true) && success; |
| 208 |
| 209 success = Should("node.pan.value", node.pan.value) |
| 210 .beEqualTo(options.pan) && success; |
| 211 |
| 212 Should("new StereoPannerNode() with options", success) |
| 213 .summarize( |
| 214 "constructed with correct attributes", |
| 215 "was not constructed correctly"); |
| 216 |
| 217 taskDone(); |
| 218 }); |
| 219 |
| 220 audit.runTasks(); |
| 221 </script> |
| 222 </body> |
| 223 </html> |
OLD | NEW |