| Index: third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-multi-channels.html
|
| diff --git a/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-multi-channels.html b/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-multi-channels.html
|
| index 8fed30e3afd2243580e8d9a2ed3612a7e70b6b61..4139d3621b3ec194092eefb2f2038b97d42a0c0a 100644
|
| --- a/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-multi-channels.html
|
| +++ b/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-multi-channels.html
|
| @@ -6,38 +6,72 @@ Test AudioBufferSourceNode supports 5.1 channel.
|
|
|
| <html>
|
| <head>
|
| +<script src="../../resources/testharness.js"></script>
|
| +<script src="../../resources/testharnessreport.js"></script>
|
| <script src="../resources/audit-util.js"></script>
|
| -<script src="../resources/audio-testing.js"></script>
|
| -<script type="text/javascript" src="../resources/mix-testing.js"></script>
|
| +<script src="../resources/audit.js"></script>
|
| +<script src="../resources/mix-testing.js"></script>
|
| </head>
|
| <body>
|
|
|
| <script>
|
| +let audit = Audit.createTaskRunner();
|
| +let context;
|
| +let expectedAudio;
|
| +
|
| +audit.define('initialize', (task, should) => {
|
| + // Create offline audio context
|
| + let sampleRate = 44100.0;
|
| + should(() => {
|
| + context =
|
| + new OfflineAudioContext(6, sampleRate * toneLengthSeconds, sampleRate);
|
| + }, 'Creating context for testing').notThrow();
|
| + should(
|
| + Audit.loadFileFromUrl('audiobuffersource-multi-channels-expected.wav')
|
| + .then(arrayBuffer => {
|
| + context.decodeAudioData(arrayBuffer).then(audioBuffer => {
|
| + expectedAudio = audioBuffer;
|
| + });
|
| + }),
|
| + 'Fetching expected audio')
|
| + .beResolved()
|
| + .then(() => task.done());
|
|
|
| -function runTest() {
|
| - if (!window.testRunner)
|
| - return;
|
| +});
|
|
|
| - testRunner.waitUntilDone();
|
| +audit.define(
|
| + {label: 'test', description: 'AudioBufferSource with 5.1 buffer'},
|
| + (task, should) => {
|
| + let toneBuffer = createToneBuffer(context, 440, toneLengthSeconds, 6);
|
|
|
| - window.jsTestAsync = true;
|
| + let source = context.createBufferSource();
|
| + source.buffer = toneBuffer;
|
|
|
| - // Create offline audio context
|
| - var sampleRate = 44100.0;
|
| - var context = new OfflineAudioContext(6, sampleRate * toneLengthSeconds, sampleRate);
|
| - var toneBuffer = createToneBuffer(context, 440, toneLengthSeconds, 6);
|
| + source.connect(context.destination);
|
| + source.start(0);
|
|
|
| - var source = context.createBufferSource();
|
| - source.buffer = toneBuffer;
|
| + context.startRendering()
|
| + .then(renderedAudio => {
|
| + // Compute a threshold based on the maximum error, |maxUlp|, in ULP.
|
| + // This is experimentally determined. Assuming that the reference
|
| + // file is a 16-bit wav file, the max values in the wave file
|
| + // are +/- 32768.
|
| + let maxUlp = 1;
|
| + let threshold = maxUlp / 32768;
|
|
|
| - source.connect(context.destination);
|
| - source.start(0);
|
| + for (let k = 0; k < renderedAudio.numberOfChannels; ++k) {
|
| + should(
|
| + renderedAudio.getChannelData(k),
|
| + 'Rendered audio for channel ' + k)
|
| + .beCloseToArray(
|
| + expectedAudio.getChannelData(k),
|
| + {absoluteThreshold: threshold});
|
| + }
|
| + })
|
| + .then(() => task.done());
|
| + });
|
|
|
| - context.oncomplete = finishAudioTest;
|
| - context.startRendering();
|
| -}
|
| -
|
| -runTest();
|
| +audit.run();
|
| </script>
|
|
|
| </body>
|
|
|