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

Unified Diff: third_party/WebKit/LayoutTests/webaudio/Panner/panner-distance-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/Panner/panner-distance-clamping.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/Panner/panner-distance-clamping.html b/third_party/WebKit/LayoutTests/webaudio/Panner/panner-distance-clamping.html
index edea8d6dcbb58dacb0f5c7a23522a2da9dc60839..a4df2ebd1778efd4149c2500dca5e2e128ea6192 100644
--- a/third_party/WebKit/LayoutTests/webaudio/Panner/panner-distance-clamping.html
+++ b/third_party/WebKit/LayoutTests/webaudio/Panner/panner-distance-clamping.html
@@ -1,193 +1,194 @@
-<!doctype html>
+<!DOCTYPE html>
<html>
<head>
- <title>Test Clamping of Distance for PannerNode</title>
+ <title>
+ Test Clamping of Distance for PannerNode
+ </title>
<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>
</head>
-
<body>
- <script>
+ <script id="layout-test-code">
// Arbitrary sample rate and render length.
- var sampleRate = 48000;
- var renderFrames = 128;
+ let sampleRate = 48000;
+ let renderFrames = 128;
- var audit = Audit.createTaskRunner();
+ let audit = Audit.createTaskRunner();
- audit.define("ref-distance-error", (task, should) => {
- testDistanceLimits(should, {name: "refDistance", isZeroAllowed: true});
+ audit.define('ref-distance-error', (task, should) => {
+ testDistanceLimits(should, {name: 'refDistance', isZeroAllowed: true});
task.done();
});
- audit.define("max-distance-error", (task, should) => {
- testDistanceLimits(should, {name: "maxDistance", isZeroAllowed: false});
+ audit.define('max-distance-error', (task, should) => {
+ testDistanceLimits(should, {name: 'maxDistance', isZeroAllowed: false});
task.done();
});
function testDistanceLimits(should, options) {
// Verify that exceptions are thrown for invalid values of refDistance.
- var context = new OfflineAudioContext(1, renderFrames, sampleRate);
+ let context = new OfflineAudioContext(1, renderFrames, sampleRate);
- var attrName = options.name;
- var prefix = "new PannerNode(c, {" + attrName + ": ";
+ let attrName = options.name;
+ let prefix = 'new PannerNode(c, {' + attrName + ': ';
- should(function () {
- var nodeOptions = {};
+ should(function() {
+ let nodeOptions = {};
nodeOptions[attrName] = -1;
new PannerNode(context, nodeOptions);
- }, prefix + "-1})").throw("RangeError");
+ }, prefix + '-1})').throw('RangeError');
if (options.isZeroAllowed) {
- should(function () {
- var nodeOptions = {};
+ should(function() {
+ let nodeOptions = {};
nodeOptions[attrName] = 0;
new PannerNode(context, nodeOptions);
- }, prefix + "0})").notThrow();
+ }, prefix + '0})').notThrow();
} else {
- should(function () {
- var nodeOptions = {};
+ should(function() {
+ let nodeOptions = {};
nodeOptions[attrName] = 0;
new PannerNode(context, nodeOptions);
- }, prefix + "0})").throw("RangeError");
+ }, prefix + '0})').throw('RangeError');
}
// The smallest representable positive single float.
- var leastPositiveDoubleFloat = 4.9406564584124654e-324;
+ let leastPositiveDoubleFloat = 4.9406564584124654e-324;
- should(
- function () {
- var nodeOptions = {};
- nodeOptions[attrName] = leastPositiveDoubleFloat;
- new PannerNode(context, nodeOptions);
- }, prefix + leastPositiveDoubleFloat + "})")
- .notThrow();
+ should(function() {
+ let nodeOptions = {};
+ nodeOptions[attrName] = leastPositiveDoubleFloat;
+ new PannerNode(context, nodeOptions);
+ }, prefix + leastPositiveDoubleFloat + '})').notThrow();
- prefix = "panner." + attrName + " = ";
+ prefix = 'panner.' + attrName + ' = ';
panner = new PannerNode(context);
- should(function () {
+ should(function() {
panner[attrName] = -1;
- }, prefix + "-1").throw("RangeError");
+ }, prefix + '-1').throw('RangeError');
if (options.isZeroAllowed) {
- should(function () {
+ should(function() {
panner[attrName] = 0;
- }, prefix + "0").notThrow();
+ }, prefix + '0').notThrow();
} else {
- should(function () {
+ should(function() {
panner[attrName] = 0;
- }, prefix + "0").throw("RangeError");
+ }, prefix + '0').throw('RangeError');
}
- should(function () {
+ should(function() {
panner[attrName] = leastPositiveDoubleFloat;
}, prefix + leastPositiveDoubleFloat).notThrow();
}
- audit.define("min-distance", (task, should) => {
+ audit.define('min-distance', (task, should) => {
// Test clamping of panner distance to refDistance for all of the
// distance models. The actual distance is arbitrary as long as it's
// less than refDistance. We test default and non-default values for
// the panner's refDistance and maxDistance.
- // correctly.
- Promise.all([
- runTest(should, {
- distance: 0.01,
- distanceModel: "linear",
- }),
- runTest(should, {
- distance: 0.01,
- distanceModel: "exponential",
- }),
- runTest(should, {
- distance: 0.01,
- distanceModel: "inverse",
- }),
- runTest(should, {
- distance: 2,
- distanceModel: "linear",
- maxDistance: 1000,
- refDistance: 10,
- }),
- runTest(should, {
- distance: 2,
- distanceModel: "exponential",
- maxDistance: 1000,
- refDistance: 10,
- }),
- runTest(should, {
- distance: 2,
- distanceModel: "inverse",
- maxDistance: 1000,
- refDistance: 10,
- }),
- ])
- .then(() => task.done());
+ // correctly.
+ Promise
+ .all([
+ runTest(should, {
+ distance: 0.01,
+ distanceModel: 'linear',
+ }),
+ runTest(should, {
+ distance: 0.01,
+ distanceModel: 'exponential',
+ }),
+ runTest(should, {
+ distance: 0.01,
+ distanceModel: 'inverse',
+ }),
+ runTest(should, {
+ distance: 2,
+ distanceModel: 'linear',
+ maxDistance: 1000,
+ refDistance: 10,
+ }),
+ runTest(should, {
+ distance: 2,
+ distanceModel: 'exponential',
+ maxDistance: 1000,
+ refDistance: 10,
+ }),
+ runTest(should, {
+ distance: 2,
+ distanceModel: 'inverse',
+ maxDistance: 1000,
+ refDistance: 10,
+ }),
+ ])
+ .then(() => task.done());
});
- audit.define("max-distance", (task, should) => {
+ audit.define('max-distance', (task, should) => {
// Like the "min-distance" task, but for clamping to the max
// distance. The actual distance is again arbitrary as long as it is
// greater than maxDistance.
- Promise.all([
- runTest(should, {
- distance: 20000,
- distanceModel: "linear",
- }),
- runTest(should, {
- distance: 21000,
- distanceModel: "exponential",
- }),
- runTest(should, {
- distance: 23000,
- distanceModel: "inverse",
- }),
- runTest(should, {
- distance: 5000,
- distanceModel: "linear",
- maxDistance: 1000,
- refDistance: 10,
- }),
- runTest(should, {
- distance: 5000,
- distanceModel: "exponential",
- maxDistance: 1000,
- refDistance: 10,
- }),
- runTest(should, {
- distance: 5000,
- distanceModel: "inverse",
- maxDistance: 1000,
- refDistance: 10,
- }),
- ])
- .then(() => task.done());
+ Promise
+ .all([
+ runTest(should, {
+ distance: 20000,
+ distanceModel: 'linear',
+ }),
+ runTest(should, {
+ distance: 21000,
+ distanceModel: 'exponential',
+ }),
+ runTest(should, {
+ distance: 23000,
+ distanceModel: 'inverse',
+ }),
+ runTest(should, {
+ distance: 5000,
+ distanceModel: 'linear',
+ maxDistance: 1000,
+ refDistance: 10,
+ }),
+ runTest(should, {
+ distance: 5000,
+ distanceModel: 'exponential',
+ maxDistance: 1000,
+ refDistance: 10,
+ }),
+ runTest(should, {
+ distance: 5000,
+ distanceModel: 'inverse',
+ maxDistance: 1000,
+ refDistance: 10,
+ }),
+ ])
+ .then(() => task.done());
});
function runTest(should, options) {
- var context = new OfflineAudioContext(2, renderFrames, sampleRate);
- var src = new OscillatorNode(context, {
- type: "sawtooth",
- frequency: 20*440,
+ let context = new OfflineAudioContext(2, renderFrames, sampleRate);
+ let src = new OscillatorNode(context, {
+ type: 'sawtooth',
+ frequency: 20 * 440,
});
// Set panner options. Use a non-default rolloffFactor so that the
// various distance models look distinctly different.
- var pannerOptions = {};
+ let pannerOptions = {};
Object.assign(pannerOptions, options, {rolloffFactor: 0.5});
- var pannerRef = new PannerNode(context, pannerOptions);
- var pannerTest = new PannerNode(context, pannerOptions);
+ let pannerRef = new PannerNode(context, pannerOptions);
+ let pannerTest = new PannerNode(context, pannerOptions);
// Split the panner output so we can grab just one of the output
// channels.
- var splitRef = new ChannelSplitterNode(context, {numberOfOutputs: 2});
- var splitTest = new ChannelSplitterNode(context, {numberOfOutputs: 2});
+ let splitRef = new ChannelSplitterNode(context, {numberOfOutputs: 2});
+ let splitTest = new ChannelSplitterNode(context, {numberOfOutputs: 2});
// Merge the panner outputs back into one stereo stream for the
// destination.
- var merger = new ChannelMergerNode(context, {numberOfInputs: 2});
+ let merger = new ChannelMergerNode(context, {numberOfInputs: 2});
src.connect(pannerTest).connect(splitTest).connect(merger, 0, 0);
src.connect(pannerRef).connect(splitRef).connect(merger, 0, 1);
@@ -198,30 +199,31 @@
// direction. For the reference panner, manually clamp the distance.
// All models clamp the distance to a minimum of refDistance. Only the
// linear model also clamps to a maximum of maxDistance.
- var xRef = Math.max(options.distance, pannerRef.refDistance);
+ let xRef = Math.max(options.distance, pannerRef.refDistance);
- if (pannerRef.distanceModel === "linear") {
+ if (pannerRef.distanceModel === 'linear') {
xRef = Math.min(xRef, pannerRef.maxDistance);
}
- var xTest = options.distance;
+ let xTest = options.distance;
pannerRef.positionZ.setValueAtTime(xRef, 0);
pannerTest.positionZ.setValueAtTime(xTest, 0);
src.start();
- return context.startRendering().then(function (resultBuffer) {
- var actual = resultBuffer.getChannelData(0);
- var expected = resultBuffer.getChannelData(1);
-
- should(xTest < pannerRef.refDistance || xTest > pannerRef.maxDistance,
- "Model: " + options.distanceModel + ": Distance (" + xTest +
- ") is outside the range [" + pannerRef.refDistance + ", " +
- pannerRef.maxDistance + "]")
- .beEqualTo(true);
- should(actual, "Test panner output " + JSON.stringify(options))
- .beEqualToArray(expected);
+ return context.startRendering().then(function(resultBuffer) {
+ let actual = resultBuffer.getChannelData(0);
+ let expected = resultBuffer.getChannelData(1);
+
+ should(
+ xTest < pannerRef.refDistance || xTest > pannerRef.maxDistance,
+ 'Model: ' + options.distanceModel + ': Distance (' + xTest +
+ ') is outside the range [' + pannerRef.refDistance + ', ' +
+ pannerRef.maxDistance + ']')
+ .beEqualTo(true);
+ should(actual, 'Test panner output ' + JSON.stringify(options))
+ .beEqualToArray(expected);
});
}

Powered by Google App Engine
This is Rietveld 408576698