| Index: third_party/WebKit/LayoutTests/webaudio/Analyser/handle-silent-inputs.html
|
| diff --git a/third_party/WebKit/LayoutTests/webaudio/Analyser/handle-silent-inputs.html b/third_party/WebKit/LayoutTests/webaudio/Analyser/handle-silent-inputs.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7b8c50d310edc6422028f025b9637e3455ab4192
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/webaudio/Analyser/handle-silent-inputs.html
|
| @@ -0,0 +1,69 @@
|
| +<!doctype html>
|
| +<html>
|
| + <head>
|
| + <script src="../../resources/testharness.js"></script>
|
| + <script src="../../resources/testharnessreport.js"></script>
|
| + <script src="../resources/audit-util.js"></script>
|
| + <script src="../resources/audit.js"></script>
|
| + <title>Handle Silent Inputs to AnalyserNode</title>
|
| + </head>
|
| +
|
| + <body>
|
| + <script>
|
| + let audit = Audit.createTaskRunner();
|
| + let sampleRate = 16000;
|
| + let renderDuration = 1;
|
| + let renderFrames = renderDuration * sampleRate;
|
| +
|
| + audit.define('connected', function(task, should) {
|
| + task.describe('Test handling of silent inputs');
|
| +
|
| + tester(should, false).then(task.done.bind(task));
|
| + });
|
| +
|
| + audit.define('auto-pull', function(task, should) {
|
| + task.describe('Test handling of silent inputs');
|
| +
|
| + tester(should, true).then(task.done.bind(task));
|
| + });
|
| +
|
| + audit.run();
|
| +
|
| + function tester(should, isAutoPullTest) {
|
| + // Connect an oscillator to an analyser for testing the time data of the
|
| + // analyser after the oscillator stops.
|
| + let context = new OfflineAudioContext(1, renderFrames, sampleRate);
|
| + let source = new OscillatorNode(context);
|
| + let analyser = new AnalyserNode(context, {fftSize: 128});
|
| + let timeData = new Float32Array(analyser.fftSize);
|
| + timeData.fill(NaN);
|
| +
|
| + source.connect(analyser);
|
| +
|
| + // For the automatic pull test, leave the analyser output disconnected.
|
| + if (isAutoPullTest) {
|
| + source.connect(context.destination);
|
| + } else {
|
| + analyser.connect(context.destination);
|
| + }
|
| +
|
| + source.start();
|
| +
|
| + // Stop the source well in advance of when we want to get the time data
|
| + // from the analyser.
|
| + let stopTime = 0.1;
|
| + let dataTime = 0.5;
|
| +
|
| + source.stop(stopTime);
|
| + context.suspend(dataTime)
|
| + .then(() => { analyser.getFloatTimeDomainData(timeData); })
|
| + .then(context.resume.bind(context));
|
| +
|
| + return context.startRendering().then(buffer => {
|
| + should(timeData, 'Analyser time data at time ' + dataTime)
|
| + .beConstantValueOf(0);
|
| + });
|
| + }
|
| + </script>
|
| + </body>
|
| +</html>
|
|
|