diff options
Diffstat (limited to 'testing/web-platform/tests/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.html')
-rw-r--r-- | testing/web-platform/tests/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.html | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.html b/testing/web-platform/tests/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.html new file mode 100644 index 0000000000..a2c4581c4e --- /dev/null +++ b/testing/web-platform/tests/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.html @@ -0,0 +1,71 @@ +<!DOCTYPE html> +<html> + <head> + <title> + audiobuffer.html + </title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/webaudio/resources/audit-util.js"></script> + <script src="/webaudio/resources/audit.js"></script> + </head> + <body> + <script id="layout-test-code"> + let sampleRate = 44100.0 + let lengthInSeconds = 2; + let numberOfChannels = 4; + + let audit = Audit.createTaskRunner(); + + audit.define('Basic tests for AudioBuffer', function(task, should) { + let context = new AudioContext(); + let buffer = context.createBuffer( + numberOfChannels, sampleRate * lengthInSeconds, sampleRate); + + // Just for printing out a message describing what "buffer" is in the + // following tests. + should( + true, + 'buffer = context.createBuffer(' + numberOfChannels + ', ' + + (sampleRate * lengthInSeconds) + ', ' + sampleRate + ')') + .beTrue(); + + should(buffer.sampleRate, 'buffer.sampleRate').beEqualTo(sampleRate); + + should(buffer.length, 'buffer.length') + .beEqualTo(sampleRate * lengthInSeconds); + + should(buffer.duration, 'buffer.duration').beEqualTo(lengthInSeconds); + + should(buffer.numberOfChannels, 'buffer.numberOfChannels') + .beEqualTo(numberOfChannels); + + for (let index = 0; index < buffer.numberOfChannels; ++index) { + should( + buffer.getChannelData(index) instanceof window.Float32Array, + 'buffer.getChannelData(' + index + + ') instanceof window.Float32Array') + .beTrue(); + } + + should( + function() { + buffer.getChannelData(buffer.numberOfChannels); + }, + 'buffer.getChannelData(' + buffer.numberOfChannels + ')') + .throw(DOMException, 'IndexSizeError'); + + let buffer2 = context.createBuffer(1, 1000, 24576); + let expectedDuration = 1000 / 24576; + + should( + buffer2.duration, 'context.createBuffer(1, 1000, 24576).duration') + .beEqualTo(expectedDuration); + + task.done(); + }); + + audit.run(); + </script> + </body> +</html> |