Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(490)

Unified Diff: third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-automation-clamping.html

Issue 2895963003: Apply layout-test-tidy to LayoutTests/webaudio (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-automation-clamping.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-automation-clamping.html b/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-automation-clamping.html
index d49172e6c3fba26a9abd898b685e261f3c8a9628..8dfcddac132ba42429d60e9f0b586f377a6701c6 100644
--- a/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-automation-clamping.html
+++ b/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-automation-clamping.html
@@ -1,97 +1,102 @@
-<!doctype html>
+<!DOCTYPE html>
<html>
<head>
+ <title>
+ Test Clamping of 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>
- <title>Test Clamping of Automations</title>
</head>
-
<body>
- <script>
-
- // Some arbitrary sample rate for the offline context.
- var sampleRate = 48000;
+ <script id="layout-test-code">
+ // Some arbitrary sample rate for the offline context.
+ let sampleRate = 48000;
// Duration of test (fairly arbitrary).
- var renderDuration = 1;
- var renderFrames = renderDuration * sampleRate;
+ let renderDuration = 1;
+ let renderFrames = renderDuration * sampleRate;
+
+ let audit = Audit.createTaskRunner();
- var audit = Audit.createTaskRunner();
-
- audit.define("clamp", (task, should) => {
+ audit.define('clamp', (task, should) => {
// Test clamping of automations. Most AudioParam limits are essentially
// unbounded, so clamping doesn't happen. For most other AudioParams,
// the behavior is sufficiently complicated with complicated outputs
// that testing them is hard. However the output behavior of the
// frequency parameter for a BiquadFilter is relatively simple. Use
// that as the test.
- var context = new OfflineAudioContext(1, renderFrames, sampleRate);
+ let context = new OfflineAudioContext(1, renderFrames, sampleRate);
- var source = context.createBufferSource();
+ let source = context.createBufferSource();
source.buffer = createConstantBuffer(context, 1, 1);
source.loop = true;
- var filter = context.createBiquadFilter();
- filter.type = "lowpass";
+ let filter = context.createBiquadFilter();
+ filter.type = 'lowpass';
source.connect(filter);
filter.connect(context.destination);
- var V0 = 880;
- var T0 = 0;
+ let V0 = 880;
+ let T0 = 0;
filter.frequency.setValueAtTime(V0, T0);
- var V1 = -1000;
- var T1 = renderDuration / 4;
+ let V1 = -1000;
+ let T1 = renderDuration / 4;
filter.frequency.linearRampToValueAtTime(V1, T1);
- var V2 = 880;
- var T2 = renderDuration / 2;
+ let V2 = 880;
+ let T2 = renderDuration / 2;
filter.frequency.linearRampToValueAtTime(V2, T2);
source.start();
- context.startRendering().then(function (buffer) {
- var result = buffer.getChannelData(0);
-
- // When the cutoff frequency of a lowpass filter is 0, nothing gets
- // through. Hence the output of the filter between the clamping
- // period should be exactly zero. This tests passes if the output is 0
- // during the expected range.
- //
- // Compute when the frequency value of the biquad goes to 0. In
- // general, t = (T0*V1 -T1*V0)/(V1-V0) (using the notation from the
- // spec.)
- var clampStartTime = solveLinearRamp(0, V0, T0, V1, T1);
- var clampEndTime = solveLinearRamp(0, V1, T1, V2, T2);
-
- var clampStartFrame = Math.ceil(clampStartTime * sampleRate);
- var clampEndFrame = Math.floor(clampEndTime * sampleRate);
-
- var clampedSignal = result.slice(clampStartFrame, clampEndFrame + 1);
- var expectedSignal = new Float32Array(clampedSignal.length);
- expectedSignal.fill(0);
-
- // Output should be zero.
- should(clampedSignal,
- "Clamped signal in frame range [" + clampStartFrame + ", " +
- clampEndFrame + "]")
- .beCloseToArray(expectedSignal, 0);
-
- // Find the actual clamp range based on the output values.
- var actualClampStart = result.findIndex(x => x === 0);
- var actualClampEnd = actualClampStart + result.slice(actualClampStart).findIndex(
- x => x != 0);
-
- // Verify that the expected clamping range is a subset of the actual range.
- should(actualClampStart, "Actual Clamp start")
- .beLessThanOrEqualTo(clampStartFrame);
- should(actualClampEnd, "Actual Clamp end")
- .beGreaterThanOrEqualTo(clampEndFrame);
-
- }).then(() => task.done());
+ context.startRendering()
+ .then(function(buffer) {
+ let result = buffer.getChannelData(0);
+
+ // When the cutoff frequency of a lowpass filter is 0, nothing
+ // gets through. Hence the output of the filter between the
+ // clamping period should be exactly zero. This tests passes if
+ // the output is 0 during the expected range.
+ //
+ // Compute when the frequency value of the biquad goes to 0. In
+ // general, t = (T0*V1 -T1*V0)/(V1-V0) (using the notation from
+ // the spec.)
+ let clampStartTime = solveLinearRamp(0, V0, T0, V1, T1);
+ let clampEndTime = solveLinearRamp(0, V1, T1, V2, T2);
+
+ let clampStartFrame = Math.ceil(clampStartTime * sampleRate);
+ let clampEndFrame = Math.floor(clampEndTime * sampleRate);
+
+ let clampedSignal =
+ result.slice(clampStartFrame, clampEndFrame + 1);
+ let expectedSignal = new Float32Array(clampedSignal.length);
+ expectedSignal.fill(0);
+
+ // Output should be zero.
+ should(
+ clampedSignal,
+ 'Clamped signal in frame range [' + clampStartFrame + ', ' +
+ clampEndFrame + ']')
+ .beCloseToArray(expectedSignal, 0);
+
+ // Find the actual clamp range based on the output values.
+ let actualClampStart = result.findIndex(x => x === 0);
+ let actualClampEnd = actualClampStart +
+ result.slice(actualClampStart).findIndex(x => x != 0);
+
+ // Verify that the expected clamping range is a subset of the
+ // actual range.
+ should(actualClampStart, 'Actual Clamp start')
+ .beLessThanOrEqualTo(clampStartFrame);
+ should(actualClampEnd, 'Actual Clamp end')
+ .beGreaterThanOrEqualTo(clampEndFrame);
+
+ })
+ .then(() => task.done());
});
audit.run();

Powered by Google App Engine
This is Rietveld 408576698