| Index: third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-setValueCurve-end.html
|
| diff --git a/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-setValueCurve-end.html b/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-setValueCurve-end.html
|
| index d36e8975be9bca90969578c5dfb3724c03fc8001..54fa471d58bb67f83c845f013e5d3ce0c77230d3 100644
|
| --- a/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-setValueCurve-end.html
|
| +++ b/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-setValueCurve-end.html
|
| @@ -1,24 +1,25 @@
|
| -<!doctype html>
|
| +<!DOCTYPE html>
|
| <html>
|
| <head>
|
| - <title>Test Automation Following setValueCurveAtTime Automations</title>
|
| + <title>
|
| + Test Automation Following setValueCurveAtTime Automations
|
| + </title>
|
| <script src="../../resources/testharness.js"></script>
|
| - <script src="../../resources/testharnessreport.js"></script>
|
| + <script src="../../resources/testharnessreport.js"></script>
|
| <script src="../resources/audit-util.js"></script>
|
| <script src="../resources/audit.js"></script>
|
| <script src="../resources/audio-param.js"></script>
|
| </head>
|
| -
|
| <body>
|
| - <script>
|
| -
|
| - var sampleRate = 12800;
|
| - // Some short duration because we don't need to run the test for very long.
|
| - var testDurationFrames = 256;
|
| - var testDurationSec = testDurationFrames / sampleRate;
|
| - var curveDuration = testDurationSec / 2;
|
| + <script id="layout-test-code">
|
| + let sampleRate = 12800;
|
| + // Some short duration because we don't need to run the test for very
|
| + // long.
|
| + let testDurationFrames = 256;
|
| + let testDurationSec = testDurationFrames / sampleRate;
|
| + let curveDuration = testDurationSec / 2;
|
|
|
| - var audit = Audit.createTaskRunner();
|
| + let audit = Audit.createTaskRunner();
|
|
|
| // Configuration for each test.
|
| //
|
| @@ -32,64 +33,73 @@
|
| // curves that don't end on a frame boundary are handled
|
| // correctly.
|
| // threshold - Error threshold for the test; default is 0.
|
| - var testConfigs = [{
|
| - automation: "linearRampToValueAtTime",
|
| - time: testDurationSec,
|
| - threshold: 3.9737e-8
|
| - }, {
|
| - automation: "linearRampToValueAtTime",
|
| - time: testDurationSec,
|
| - extraDuration: 0.5 / sampleRate,
|
| - threshold: 1.8141e-8
|
| - }, {
|
| - automation: "exponentialRampToValueAtTime",
|
| - time: testDurationSec,
|
| - threshold: 3.9737e-8
|
| - }, {
|
| - automation: "exponentialRampToValueAtTime",
|
| - time: testDurationSec,
|
| - extraDuration: 0.5 / sampleRate,
|
| - threshold: 2.0312e-8
|
| - }, {
|
| - automation: "setTargetAtTime",
|
| - time: curveDuration,
|
| - threshold: 1.5895e-7
|
| - }, {
|
| - automation: "setTargetAtTime",
|
| - time: curveDuration + 0.5 / sampleRate,
|
| - extraDuration: 0.5 / sampleRate,
|
| - threshold: 1.3278e-7
|
| - }];
|
| + let testConfigs = [
|
| + {
|
| + automation: 'linearRampToValueAtTime',
|
| + time: testDurationSec,
|
| + threshold: 3.9737e-8
|
| + },
|
| + {
|
| + automation: 'linearRampToValueAtTime',
|
| + time: testDurationSec,
|
| + extraDuration: 0.5 / sampleRate,
|
| + threshold: 1.8141e-8
|
| + },
|
| + {
|
| + automation: 'exponentialRampToValueAtTime',
|
| + time: testDurationSec,
|
| + threshold: 3.9737e-8
|
| + },
|
| + {
|
| + automation: 'exponentialRampToValueAtTime',
|
| + time: testDurationSec,
|
| + extraDuration: 0.5 / sampleRate,
|
| + threshold: 2.0312e-8
|
| + },
|
| + {
|
| + automation: 'setTargetAtTime',
|
| + time: curveDuration,
|
| + threshold: 1.5895e-7
|
| + },
|
| + {
|
| + automation: 'setTargetAtTime',
|
| + time: curveDuration + 0.5 / sampleRate,
|
| + extraDuration: 0.5 / sampleRate,
|
| + threshold: 1.3278e-7
|
| + }
|
| + ];
|
|
|
| // Define tests from the configs
|
| for (k in testConfigs) {
|
| - audit.define(k + ": " + testConfigs[k].automation, (function (config) {
|
| - return (task, should) => {
|
| - runTest(should, config).then(() => task.done());
|
| - };
|
| - })(testConfigs[k]));
|
| + audit.define(k + ': ' + testConfigs[k].automation, (function(config) {
|
| + return (task, should) => {
|
| + runTest(should, config).then(() => task.done());
|
| + };
|
| + })(testConfigs[k]));
|
| }
|
|
|
| audit.run();
|
|
|
| function runTest(should, options) {
|
| // For the test, use a gain node with a constant input to test the
|
| - // automations.
|
| - var context = new OfflineAudioContext(1, testDurationFrames, sampleRate);
|
| - var source = context.createBufferSource();
|
| + // automations.
|
| + let context =
|
| + new OfflineAudioContext(1, testDurationFrames, sampleRate);
|
| + let source = context.createBufferSource();
|
| source.buffer = createConstantBuffer(context, 1, 1);
|
| source.loop = true;
|
|
|
| - var gain = context.createGain();
|
| + let gain = context.createGain();
|
|
|
| // Any valid curve is ok. We only use the last value for testing.
|
| - var curve = [0, 2, 0.3];
|
| - var actualDuration = curveDuration + (options.extraDuration || 0);
|
| - gain.gain.setValueCurveAtTime(Float32Array.from(curve), 0, actualDuration);
|
| + let curve = [0, 2, 0.3];
|
| + let actualDuration = curveDuration + (options.extraDuration || 0);
|
| + gain.gain.setValueCurveAtTime(
|
| + Float32Array.from(curve), 0, actualDuration);
|
|
|
| // Run the desired test automation. The extra parameter (0.01) is only
|
| // used for setTargetAtTime tests; it's ignored for other tests.
|
| - var automationValue = 2;
|
| + let automationValue = 2;
|
| gain.gain[options.automation](automationValue, options.time, 0.01);
|
|
|
| source.connect(gain);
|
| @@ -97,46 +107,42 @@
|
|
|
| source.start();
|
|
|
| - return context.startRendering().then(function (resultBuffer) {
|
| - var result = resultBuffer.getChannelData(0);
|
| + return context.startRendering().then(function(resultBuffer) {
|
| + let result = resultBuffer.getChannelData(0);
|
|
|
| // Only need to verify that the ramp started at the right
|
| // value. Figure the nearest sample frame to the end curve.
|
| - var curveEndFrame = Math.ceil(actualDuration * sampleRate);
|
| + let curveEndFrame = Math.ceil(actualDuration * sampleRate);
|
|
|
| - var expectedResult = curve[curve.length - 1];
|
| + let expectedResult = curve[curve.length - 1];
|
|
|
| - // Determine the expected value after the end of the setValueCurve event.
|
| - if (options.automation == "linearRampToValueAtTime") {
|
| + // Determine the expected value after the end of the setValueCurve
|
| + // event.
|
| + if (options.automation == 'linearRampToValueAtTime') {
|
| expectedResult = audioParamLinearRamp(
|
| - curveEndFrame / sampleRate,
|
| - curve[curve.length - 1], actualDuration,
|
| - automationValue, testDurationSec);
|
| - } else if (options.automation == "exponentialRampToValueAtTime") {
|
| + curveEndFrame / sampleRate, curve[curve.length - 1],
|
| + actualDuration, automationValue, testDurationSec);
|
| + } else if (options.automation == 'exponentialRampToValueAtTime') {
|
| expectedResult = audioParamExponentialRamp(
|
| - curveEndFrame / sampleRate,
|
| - curve[curve.length - 1], actualDuration,
|
| - automationValue, testDurationSec);
|
| - } else if (options.automation == "setTargetAtTime") {
|
| + curveEndFrame / sampleRate, curve[curve.length - 1],
|
| + actualDuration, automationValue, testDurationSec);
|
| + } else if (options.automation == 'setTargetAtTime') {
|
| expectedResult = audioParamSetTarget(
|
| - curveEndFrame / sampleRate,
|
| - curve[curve.length - 1], actualDuration,
|
| - automationValue, 0.01);
|
| + curveEndFrame / sampleRate, curve[curve.length - 1],
|
| + actualDuration, automationValue, 0.01);
|
| }
|
|
|
| - var message = "setValueCurve(..., " + 0 + ", " + actualDuration +
|
| - ")." + options.automation +
|
| - "(2, " + testDurationSec;
|
| + let message = 'setValueCurve(..., ' + 0 + ', ' + actualDuration +
|
| + ').' + options.automation + '(2, ' + testDurationSec;
|
|
|
| - if (options.automation == "setTargetAtTime")
|
| - message += ", 0.01";
|
| - message += ")";
|
| + if (options.automation == 'setTargetAtTime')
|
| + message += ', 0.01';
|
| + message += ')';
|
|
|
| - should(result[curveEndFrame],
|
| - message + ": value at time " + curveEndFrame / sampleRate)
|
| - .beCloseTo(expectedResult, {
|
| - threshold: options.threshold || 0
|
| - });
|
| + should(
|
| + result[curveEndFrame],
|
| + message + ': value at time ' + curveEndFrame / sampleRate)
|
| + .beCloseTo(expectedResult, {threshold: options.threshold || 0});
|
| });
|
| }
|
|
|
|
|