diff options
Diffstat (limited to 'testing/web-platform/tests/webaudio/resources/merger-testing.js')
-rw-r--r-- | testing/web-platform/tests/webaudio/resources/merger-testing.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webaudio/resources/merger-testing.js b/testing/web-platform/tests/webaudio/resources/merger-testing.js new file mode 100644 index 0000000000..4477ec0a1f --- /dev/null +++ b/testing/web-platform/tests/webaudio/resources/merger-testing.js @@ -0,0 +1,24 @@ +// This file is for the audiochannelmerger-* layout tests. +// Requires |audio-testing.js| to work properly. + +function testMergerInput(should, config) { + let context = new OfflineAudioContext(config.numberOfChannels, 128, 44100); + let merger = context.createChannelMerger(config.numberOfChannels); + let source = context.createBufferSource(); + source.buffer = createConstantBuffer(context, 128, config.testBufferContent); + + // Connect the output of source into the specified input of merger. + if (config.mergerInputIndex) + source.connect(merger, 0, config.mergerInputIndex); + else + source.connect(merger); + merger.connect(context.destination); + source.start(); + + return context.startRendering().then(function(buffer) { + let prefix = config.testBufferContent.length + '-channel source: '; + for (let i = 0; i < config.numberOfChannels; i++) + should(buffer.getChannelData(i), prefix + 'Channel #' + i) + .beConstantValueOf(config.expected[i]); + }); +} |