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/Analyser/handle-silent-inputs.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/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
index 596c3f559ab39784c62f63192f3e137bad8b5633..ffe4fe8822644803accabf657c648ebbdc7a9894 100644
--- a/third_party/WebKit/LayoutTests/webaudio/Analyser/handle-silent-inputs.html
+++ b/third_party/WebKit/LayoutTests/webaudio/Analyser/handle-silent-inputs.html
@@ -1,102 +1,106 @@
-<!doctype html>
+<!DOCTYPE html>
<html>
<head>
+ <title>
+ Handle Silent Inputs to AnalyserNode
+ </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>Handle Silent Inputs to AnalyserNode</title>
</head>
-
<body>
- <script>
+ <script id="layout-test-code">
let audit = Audit.createTaskRunner();
let sampleRate = 16000;
let renderDuration = 1;
let renderFrames = renderDuration * sampleRate;
- audit.define({
- label: 'connected',
- description: 'Test handling of silent inputs'
- }, function (task, should) {
- tester(should, false, '0').then(task.done.bind(task));
- });
-
- audit.define({
- label: 'auto-pull',
- description: 'Test handling of silent inputs'
- }, function(task, should) {
- tester(should, true, '1').then(task.done.bind(task));
- });
-
- audit.define({
- label: 'timing',
- description: 'Test shifting in of zeroes after source has stopped'
- }, function(task, should) {
- let renderQuantumFrames = 128;
-
- // sampleRate chosen to be a power of two so we don't have round-off
- // errors in computing the times for when to suspend the context.
- let context = new OfflineAudioContext(1, 16384, 16384);
- let source = new ConstantSourceNode(context);
-
- // The fftSize for the analyser is fairly arbitrary, except the code
- // assumes it is larger than 128.
- let analyser = new AnalyserNode(context, {fftSize: 2048});
-
- source.connect(analyser).connect(context.destination);
-
- source.start();
-
- // Stop the source after 1 fftSize frames.
- let time = analyser.fftSize / context.sampleRate;
- source.stop(time);
-
- // Verify that the time data at this point is constant.
- context.suspend(time)
- .then(() => {
- let data = new Float32Array(analyser.fftSize);
- analyser.getFloatTimeDomainData(data);
- should(
- data, 'At time ' + context.currentTime +
- ' Analyser frames [0, ' + analyser.fftSize + ')')
- .beConstantValueOf(1);
- })
- .then(context.resume.bind(context));
-
- // After each rendering quantum from the point at which the source
- // stopped, verify that zeroes are inserted into the time data one
- // rendering quantum at a time.
-
- let limit = analyser.fftSize / renderQuantumFrames;
-
- for (let k = 1; k <= limit; ++k) {
- let analyserTime =
- (analyser.fftSize + k * renderQuantumFrames) / context.sampleRate;
- context.suspend(analyserTime)
- .then(() => {
- let data = new Float32Array(analyser.fftSize);
- let indexNewest = analyser.fftSize - k * renderQuantumFrames;
- analyser.getFloatTimeDomainData(data);
- if (k < limit) {
+ audit.define(
+ {label: 'connected', description: 'Test handling of silent inputs'},
+ function(task, should) {
+ tester(should, false, '0').then(task.done.bind(task));
+ });
+
+ audit.define(
+ {label: 'auto-pull', description: 'Test handling of silent inputs'},
+ function(task, should) {
+ tester(should, true, '1').then(task.done.bind(task));
+ });
+
+ audit.define(
+ {
+ label: 'timing',
+ description: 'Test shifting in of zeroes after source has stopped'
+ },
+ function(task, should) {
+ let renderQuantumFrames = 128;
+
+ // sampleRate chosen to be a power of two so we don't have round-off
+ // errors in computing the times for when to suspend the context.
+ let context = new OfflineAudioContext(1, 16384, 16384);
+ let source = new ConstantSourceNode(context);
+
+ // The fftSize for the analyser is fairly arbitrary, except the code
+ // assumes it is larger than 128.
+ let analyser = new AnalyserNode(context, {fftSize: 2048});
+
+ source.connect(analyser).connect(context.destination);
+
+ source.start();
+
+ // Stop the source after 1 fftSize frames.
+ let time = analyser.fftSize / context.sampleRate;
+ source.stop(time);
+
+ // Verify that the time data at this point is constant.
+ context.suspend(time)
+ .then(() => {
+ let data = new Float32Array(analyser.fftSize);
+ analyser.getFloatTimeDomainData(data);
should(
- data.slice(0, indexNewest), 'At time ' +
- context.currentTime + ' Analyser frames [0, ' +
- indexNewest + ')')
+ data,
+ 'At time ' + context.currentTime +
+ ' Analyser frames [0, ' + analyser.fftSize + ')')
.beConstantValueOf(1);
- }
- should(
- data.slice(indexNewest), 'At time ' + context.currentTime +
- ' Analyser frames [' + indexNewest + ', ' +
- analyser.fftSize + ')')
- .beConstantValueOf(0);
- })
- .then(context.resume.bind(context));
- }
-
- // Start the test
- context.startRendering().then(() => task.done());
- });
+ })
+ .then(context.resume.bind(context));
+
+ // After each rendering quantum from the point at which the source
+ // stopped, verify that zeroes are inserted into the time data one
+ // rendering quantum at a time.
+
+ let limit = analyser.fftSize / renderQuantumFrames;
+
+ for (let k = 1; k <= limit; ++k) {
+ let analyserTime = (analyser.fftSize + k * renderQuantumFrames) /
+ context.sampleRate;
+ context.suspend(analyserTime)
+ .then(() => {
+ let data = new Float32Array(analyser.fftSize);
+ let indexNewest =
+ analyser.fftSize - k * renderQuantumFrames;
+ analyser.getFloatTimeDomainData(data);
+ if (k < limit) {
+ should(
+ data.slice(0, indexNewest),
+ 'At time ' + context.currentTime +
+ ' Analyser frames [0, ' + indexNewest + ')')
+ .beConstantValueOf(1);
+ }
+ should(
+ data.slice(indexNewest),
+ 'At time ' + context.currentTime +
+ ' Analyser frames [' + indexNewest + ', ' +
+ analyser.fftSize + ')')
+ .beConstantValueOf(0);
+ })
+ .then(context.resume.bind(context));
+ }
+
+ // Start the test
+ context.startRendering().then(() => task.done());
+ });
audit.run();
@@ -127,7 +131,9 @@
source.stop(stopTime);
context.suspend(dataTime)
- .then(() => { analyser.getFloatTimeDomainData(timeData); })
+ .then(() => {
+ analyser.getFloatTimeDomainData(timeData);
+ })
.then(context.resume.bind(context));
return context.startRendering().then(buffer => {

Powered by Google App Engine
This is Rietveld 408576698