| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Test Constructor: ChannelMerger</title> | 4 <title>Test Constructor: ChannelMerger</title> |
| 5 <script src="../../resources/testharness.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
| 6 <script src="../../resources/testharnessreport.js"></script> | 6 <script src="../../resources/testharnessreport.js"></script> |
| 7 <script src="../resources/audit-util.js"></script> | 7 <script src="../resources/audit-util.js"></script> |
| 8 <script src="../resources/audio-testing.js"></script> | 8 <script src="../resources/audit.js"></script> |
| 9 <script src="audionodeoptions.js"></script> | 9 <script src="new-audionodeoptions.js"></script> |
| 10 </head> | 10 </head> |
| 11 | 11 |
| 12 <body> | 12 <body> |
| 13 <script> | 13 <script> |
| 14 var context; | 14 let context; |
| 15 | 15 |
| 16 var audit = Audit.createTaskRunner(); | 16 let audit = Audit.createTaskRunner(); |
| 17 | 17 |
| 18 audit.defineTask("initialize", function (taskDone) { | 18 audit.define('initialize', (task, should) => { |
| 19 Should("context = new OfflineAudioContext(...)", function () { | 19 context = initializeContext(should); |
| 20 context = new OfflineAudioContext(1, 1, 48000); | 20 task.done(); |
| 21 }).notThrow(); | |
| 22 | |
| 23 taskDone(); | |
| 24 }); | 21 }); |
| 25 | 22 |
| 26 audit.defineTask("invalid constructor", function (taskDone) { | 23 audit.define('invalid constructor', (task, should) => { |
| 27 var node; | 24 testInvalidConstructor(should, 'ChannelMergerNode', context); |
| 28 var success = true; | 25 task.done(); |
| 29 | |
| 30 success = Should("new ChannelMergerNode()", function () { | |
| 31 node = new ChannelMergerNode(); | |
| 32 }).throw("TypeError"); | |
| 33 success = Should("new ChannelMergerNode(1)", function () { | |
| 34 node = new ChannelMergerNode(1) && success; | |
| 35 }).throw("TypeError"); | |
| 36 success = Should("new ChannelMergerNode(context, 42)", function () { | |
| 37 node = new ChannelMergerNode(context, 42) && success; | |
| 38 }).throw("TypeError"); | |
| 39 | |
| 40 Should("Invalid constructors", success) | |
| 41 .summarize( | |
| 42 "correctly threw errors", | |
| 43 "did not throw errors in all cases"); | |
| 44 | |
| 45 taskDone(); | |
| 46 }); | 26 }); |
| 47 | 27 |
| 48 audit.defineTask("default constructor", function (taskDone) { | 28 audit.define('default constructor', (task, should) => { |
| 49 var node; | 29 let prefix = 'node0'; |
| 50 var success = true; | 30 let node = |
| 31 testDefaultConstructor(should, 'ChannelMergerNode', context, { |
| 32 prefix: prefix, |
| 33 numberOfInputs: 6, |
| 34 numberOfOutputs: 1, |
| 35 channelCount: 1, |
| 36 channelCountMode: 'explicit', |
| 37 channelInterpretation: 'speakers' |
| 38 }); |
| 51 | 39 |
| 52 success = Should("node0 = new ChannelMergerNode(context)", function () { | 40 task.done(); |
| 53 node = new ChannelMergerNode(context); | |
| 54 }).notThrow(); | |
| 55 success = Should("node0 instanceof ChannelMergerNode", node instanceof C
hannelMergerNode) | |
| 56 .beEqualTo(true) && success; | |
| 57 | |
| 58 success = Should("node0.numberOfInputs", node.numberOfInputs) | |
| 59 .beEqualTo(6) && success; | |
| 60 success = Should("node0.numberOfOutputs", node.numberOfOutputs) | |
| 61 .beEqualTo(1) && success; | |
| 62 success = Should("node0.channelCount", node.channelCount) | |
| 63 .beEqualTo(1) && success; | |
| 64 success = Should("node0.channelCountMode", node.channelCountMode) | |
| 65 .beEqualTo("explicit") && success; | |
| 66 success = Should("node0.channelInterpretation", node.channelInterpretati
on) | |
| 67 .beEqualTo("speakers") && success; | |
| 68 | |
| 69 Should("new ChannelMergerNode(context)", success) | |
| 70 .summarize( | |
| 71 "constructed node with correct attributes", | |
| 72 "did not construct correct node correctly") | |
| 73 | |
| 74 taskDone(); | |
| 75 }); | 41 }); |
| 76 | 42 |
| 77 audit.defineTask("test AudioNodeOptions", function (taskDone) { | 43 audit.define('test AudioNodeOptions', (task, should) => { |
| 78 testAudioNodeOptions(context, "ChannelMergerNode", { | 44 testAudioNodeOptions(should, context, 'ChannelMergerNode', { |
| 79 expectedChannelCount: { | 45 channelCount: |
| 80 value: 1, | 46 {value: 1, isFixed: true, errorType: 'InvalidStateError'}, |
| 47 channelCountMode: { |
| 48 value: 'explicit', |
| 81 isFixed: true, | 49 isFixed: true, |
| 82 errorType: "InvalidStateError" | 50 errorType: 'InvalidStateError' |
| 83 }, | |
| 84 expectedChannelCountMode: { | |
| 85 value: "explicit", | |
| 86 isFixed: true, | |
| 87 errorType: "InvalidStateError" | |
| 88 } | 51 } |
| 89 }); | 52 }); |
| 90 taskDone(); | 53 task.done(); |
| 91 }); | 54 }); |
| 92 | 55 |
| 93 audit.defineTask("constructor options", function (taskDone) { | 56 audit.define('constructor options', (task, should) => { |
| 94 var node; | 57 let node; |
| 95 var success = true; | 58 let options = { |
| 96 var options = { | |
| 97 numberOfInputs: 3, | 59 numberOfInputs: 3, |
| 98 numberOfOutputs: 9, | 60 numberOfOutputs: 9, |
| 99 channelInterpretation: "discrete" | 61 channelInterpretation: 'discrete' |
| 100 }; | 62 }; |
| 101 | 63 |
| 102 success = Should("node1 = new ChannelMergerNode(context, " + JSON.string
ify(options) + | 64 should( |
| 103 ")", | 65 () => { |
| 104 function () { | 66 node = new ChannelMergerNode(context, options); |
| 105 node = new ChannelMergerNode(context, options); | 67 }, |
| 106 }).notThrow(); | 68 'node1 = new ChannelMergerNode(context, ' + |
| 69 JSON.stringify(options) + ')') |
| 70 .notThrow(); |
| 107 | 71 |
| 108 success = Should("node1.numberOfInputs", node.numberOfInputs) | 72 should(node.numberOfInputs, 'node1.numberOfInputs') |
| 109 .beEqualTo(options.numberOfInputs) && success; | 73 .beEqualTo(options.numberOfInputs); |
| 110 success = Should("node1.numberOfOutputs", node.numberOfOutputs) | 74 should(node.numberOfOutputs, 'node1.numberOfOutputs').beEqualTo(1); |
| 111 .beEqualTo(1) && success; | 75 should(node.channelInterpretation, 'node1.channelInterpretation') |
| 112 success = Should("node1.channelInterpretation", node.channelInterpretati
on) | 76 .beEqualTo(options.channelInterpretation); |
| 113 .beEqualTo(options.channelInterpretation) && success; | |
| 114 | 77 |
| 115 options = { | 78 options = {numberOfInputs: 99}; |
| 116 numberOfInputs: 99 | 79 should( |
| 117 }; | 80 () => { |
| 118 success = Should("new ChannelMergerNode(c, " + JSON.stringify(options) +
")", | |
| 119 function () { | |
| 120 node = new ChannelMergerNode(context, options); | 81 node = new ChannelMergerNode(context, options); |
| 121 }) | 82 }, |
| 122 .throw("IndexSizeError") && success; | 83 'new ChannelMergerNode(c, ' + JSON.stringify(options) + ')') |
| 84 .throw('IndexSizeError'); |
| 123 | 85 |
| 124 options = { | 86 options = {channelCount: 3}; |
| 125 channelCount: 3 | 87 should( |
| 126 }; | 88 () => { |
| 127 success = Should("new ChannelMergerNode(c, " + JSON.stringify(options) +
")", | |
| 128 function () { | |
| 129 node = new ChannelMergerNode(context, options); | 89 node = new ChannelMergerNode(context, options); |
| 130 }) | 90 }, |
| 131 .throw("InvalidStateError") && success; | 91 'new ChannelMergerNode(c, ' + JSON.stringify(options) + ')') |
| 92 .throw('InvalidStateError'); |
| 132 | 93 |
| 133 options = { | 94 options = {channelCountMode: 'max'}; |
| 134 channelCountMode: "max" | 95 should( |
| 135 }; | 96 () => { |
| 136 success = Should("new ChannelMergerNode(c, " + JSON.stringify(options) +
")", | |
| 137 function () { | |
| 138 node = new ChannelMergerNode(context, options); | 97 node = new ChannelMergerNode(context, options); |
| 139 }) | 98 }, |
| 140 .throw("InvalidStateError") && success; | 99 'new ChannelMergerNode(c, ' + JSON.stringify(options) + ')') |
| 100 .throw('InvalidStateError'); |
| 141 | 101 |
| 142 Should("new ChannelMergerNode() with options", success) | 102 task.done(); |
| 143 .summarize( | |
| 144 "constructed with correct attributes", | |
| 145 "was not constructed correctly"); | |
| 146 | |
| 147 taskDone(); | |
| 148 }); | 103 }); |
| 149 | 104 |
| 150 audit.runTasks(); | 105 audit.run(); |
| 151 </script> | 106 </script> |
| 152 </body> | 107 </body> |
| 153 </html> | 108 </html> |
| OLD | NEW |