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

Unified Diff: third_party/WebKit/LayoutTests/webaudio/Oscillator/osc-negative-freq.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/Oscillator/osc-negative-freq.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/Oscillator/osc-negative-freq.html b/third_party/WebKit/LayoutTests/webaudio/Oscillator/osc-negative-freq.html
index 3a06a025cfcf543dc5c9ceaee78f1a5a379f3752..503241ca06bd17f03457cf0a4e56ee2959d588c4 100644
--- a/third_party/WebKit/LayoutTests/webaudio/Oscillator/osc-negative-freq.html
+++ b/third_party/WebKit/LayoutTests/webaudio/Oscillator/osc-negative-freq.html
@@ -1,65 +1,69 @@
-<!doctype html>
+<!DOCTYPE html>
<html>
<head>
+ <title>
+ Test OscillatorNode with Negative Frequency
+ </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 OscillatorNode with Negative Frequency</title>
</head>
-
<body>
- <script>
+ <script id="layout-test-code">
// Some arbitrary sample rate for the offline context. But it MUST be
// at least twice the oscillator frequency that we're using for the
// test. (Currently 440 Hz.)
- var sampleRate = 16000;
+ let sampleRate = 16000;
// A fairly arbitrary duration that should have at least 1-2 sample
// periods of the oscillator (at a nominal 440 Hz).
- var renderDuration = 0.1;
- var renderFrames = renderDuration * sampleRate;
+ let renderDuration = 0.1;
+ let renderFrames = renderDuration * sampleRate;
- var audit = Audit.createTaskRunner();
+ let audit = Audit.createTaskRunner();
- audit.define("sine", (task, should) => {
+ audit.define('sine', (task, should) => {
runTest(should, {
- message: "Sum of positive and negative frequency sine oscillators",
- type: "sine",
+ message: 'Sum of positive and negative frequency sine oscillators',
+ type: 'sine',
threshold: 3.5763e-7
}).then(() => task.done());
});
- audit.define("square", (task, should) => {
+ audit.define('square', (task, should) => {
runTest(should, {
- message: "Sum of positive and negative frequency square oscillators",
- type: "square",
+ message: 'Sum of positive and negative frequency square oscillators',
+ type: 'square',
threshold: 1.4753e-6
}).then(() => task.done());
});
- audit.define("sawtooth", (task, should) => {
+ audit.define('sawtooth', (task, should) => {
runTest(should, {
- message: "Sum of positive and negative frequency sawtooth oscillators",
- type: "sawtooth",
+ message:
+ 'Sum of positive and negative frequency sawtooth oscillators',
+ type: 'sawtooth',
threshold: 1.4753e-6
}).then(() => task.done());
});
- audit.define("triangle", (task, should) => {
+ audit.define('triangle', (task, should) => {
runTest(should, {
- message: "Sum of positive and negative frequency triangle oscillators",
- type: "triangle",
+ message:
+ 'Sum of positive and negative frequency triangle oscillators',
+ type: 'triangle',
threshold: 2.9803e-7
}).then(() => task.done());
});
- audit.define("auto-sawtooth", (task, should) => {
+ audit.define('auto-sawtooth', (task, should) => {
runTest(should, {
- message: "Sum of positive and negative frequency-ramped sawtooth oscillators",
- type: "sawtooth",
+ message:
+ 'Sum of positive and negative frequency-ramped sawtooth oscillators',
+ type: 'sawtooth',
automation: {
- type: "linearRampToValueAtTime",
+ type: 'linearRampToValueAtTime',
startTime: 0,
endTime: renderDuration / 2,
startFrequency: 440,
@@ -69,17 +73,17 @@
}).then(() => task.done());
});
- audit.define("periodic-wave", (task, should) => {
+ audit.define('periodic-wave', (task, should) => {
// Test negative frequencies for a custom oscillator. Two channels are
// needed for the context; one for the expected result, and one for the
// actual, as explained below.
- var context = new OfflineAudioContext(2, renderFrames, sampleRate);
+ let context = new OfflineAudioContext(2, renderFrames, sampleRate);
- var oscPositive = context.createOscillator();
- var oscNegative = context.createOscillator();
+ let oscPositive = context.createOscillator();
+ let oscNegative = context.createOscillator();
- // The Fourier coefficients for our custom oscillator. The actual values
- // not important. The waveform for our custom oscillator is
+ // The Fourier coefficients for our custom oscillator. The actual
+ // values not important. The waveform for our custom oscillator is
//
// x(t) = sum(real[k]*cos(2*%pi*f*k/Fs), k, 1)
// + sum(imag[k]*sin(2*%pi*f*k/Fs), k, 0)
@@ -100,15 +104,13 @@
// imaginary coefficients are inverted. This second oscillator also
// gets a negative frequency. The combination of the two results in an
// oscillator that is the same as the first with gain of 2.
- var real = [0, 1, 1];
- var imag = [0, 1, 1];
+ let real = [0, 1, 1];
+ let imag = [0, 1, 1];
- var wavePositive = context.createPeriodicWave(
- Float32Array.from(real),
- Float32Array.from(imag));
- var waveNegative = context.createPeriodicWave(
- Float32Array.from(real),
- Float32Array.from(imag.map(x => -x)));
+ let wavePositive = context.createPeriodicWave(
+ Float32Array.from(real), Float32Array.from(imag));
+ let waveNegative = context.createPeriodicWave(
+ Float32Array.from(real), Float32Array.from(imag.map(x => -x)));
oscPositive.setPeriodicWave(wavePositive);
oscNegative.setPeriodicWave(waveNegative);
@@ -116,8 +118,8 @@
oscPositive.frequency.value = 440;
oscNegative.frequency.value = -oscPositive.frequency.value;
- var merger = context.createChannelMerger(2);
- var gain = context.createGain();
+ let merger = context.createChannelMerger(2);
+ let gain = context.createGain();
// As explained above, the expected result should be positive frequency
// oscillator but with a gain of 2.
@@ -135,16 +137,17 @@
oscPositive.start();
oscNegative.start();
- context.startRendering().then(function (buffer) {
- var expected = buffer.getChannelData(0);
- var actual = buffer.getChannelData(1);
-
- should(actual,
- "Sum of positive and negative frequency custom oscillators")
- .beCloseToArray(expected, {
- absoluteThreshold: 3.5763e-7
- });
- }).then(() => task.done());
+ context.startRendering()
+ .then(function(buffer) {
+ let expected = buffer.getChannelData(0);
+ let actual = buffer.getChannelData(1);
+
+ should(
+ actual,
+ 'Sum of positive and negative frequency custom oscillators')
+ .beCloseToArray(expected, {absoluteThreshold: 3.5763e-7});
+ })
+ .then(() => task.done());
});
audit.run();
@@ -154,16 +157,17 @@
// has a positive frequency and the other has a negative frequency.
// Sum the oscillator outputs; the output should be zero because all of
// the builtin oscillator types are odd functions of frequency.
- var context = new OfflineAudioContext(1, renderFrames, sampleRate);
+ let context = new OfflineAudioContext(1, renderFrames, sampleRate);
- var oscPositive = context.createOscillator();
- var oscNegative = context.createOscillator();
+ let oscPositive = context.createOscillator();
+ let oscNegative = context.createOscillator();
oscPositive.type = options.type;
oscNegative.type = oscPositive.type;
if (options.automation) {
- var {type, startTime, endTime, startFrequency, endFrequency} = options.automation;
+ let {type, startTime, endTime, startFrequency, endFrequency} =
+ options.automation;
oscPositive.frequency.setValueAtTime(startFrequency, startTime);
oscPositive.frequency[type](endFrequency, endTime)
@@ -180,13 +184,13 @@
oscPositive.start();
oscNegative.start();
- return context.startRendering().then(function (buffer) {
- var result = buffer.getChannelData(0);
+ return context.startRendering().then(function(buffer) {
+ let result = buffer.getChannelData(0);
should(result, options.message)
- .beCloseToArray(new Float32Array(result.length), {
- absoluteThreshold: options.threshold || 0
- });
+ .beCloseToArray(
+ new Float32Array(result.length),
+ {absoluteThreshold: options.threshold || 0});
});
}
</script>

Powered by Google App Engine
This is Rietveld 408576698