ctor-channelmerger.html (2916B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title> 5 Test Constructor: ChannelMerger 6 </title> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="/webaudio/resources/audit-util.js"></script> 10 <script src="/webaudio/resources/audionodeoptions.js"></script> 11 </head> 12 <body> 13 <script> 14 let context; 15 16 test(() => { 17 context = new OfflineAudioContext(1, 1, 48000); 18 }, 'Initialize AudioContext for ChannelMergerNode tests'); 19 20 test(() => { 21 testInvalidConstructor_W3CTH('ChannelMergerNode', context); 22 }, 'Invalid constructor behavior for ChannelMergerNode'); 23 24 test(() => { 25 const prefix = 'node0'; 26 const node = 27 testDefaultConstructor_W3CTH('ChannelMergerNode', context, { 28 prefix: prefix, 29 numberOfInputs: 6, 30 numberOfOutputs: 1, 31 channelCount: 1, 32 channelCountMode: 'explicit', 33 channelInterpretation: 'speakers', 34 }); 35 }, 'Default constructor behavior for ChannelMergerNode'); 36 37 test(() => { 38 testAudioNodeOptions_W3CTH(context, 'ChannelMergerNode', { 39 channelCount: { 40 value: 1, 41 isFixed: true, 42 exceptionType: 'InvalidStateError', 43 }, 44 channelCountMode: { 45 value: 'explicit', 46 isFixed: true, 47 exceptionType: 'InvalidStateError', 48 }, 49 }); 50 }, 'AudioNodeOptions behavior for ChannelMergerNode'); 51 52 test(() => { 53 let node; 54 let options = { 55 numberOfInputs: 3, 56 numberOfOutputs: 9, 57 channelInterpretation: 'discrete', 58 }; 59 60 node = new ChannelMergerNode(context, options); 61 62 assert_equals( 63 node.numberOfInputs, options.numberOfInputs, 64 'node1.numberOfInputs'); 65 assert_equals(node.numberOfOutputs, 1, 'node1.numberOfOutputs'); 66 assert_equals( 67 node.channelInterpretation, options.channelInterpretation, 68 'node1.channelInterpretation'); 69 70 options = {numberOfInputs: 99}; 71 assert_throws_dom('IndexSizeError', () => { 72 node = new ChannelMergerNode(context, options); 73 }, 'new ChannelMergerNode(c, ' + JSON.stringify(options) + ')'); 74 75 options = {channelCount: 3}; 76 assert_throws_dom('InvalidStateError', () => { 77 node = new ChannelMergerNode(context, options); 78 }, 'new ChannelMergerNode(c, ' + JSON.stringify(options) + ')'); 79 80 options = {channelCountMode: 'max'}; 81 assert_throws_dom('InvalidStateError', () => { 82 node = new ChannelMergerNode(context, options); 83 }, 'new ChannelMergerNode(c, ' + JSON.stringify(options) + ')'); 84 }, 'Constructor options validation for ChannelMergerNode'); 85 </script> 86 </body> 87 </html>