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

Unified Diff: third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-connect-audioratesignal.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-connect-audioratesignal.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-connect-audioratesignal.html b/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-connect-audioratesignal.html
index 6281e914e87e18962b88a431714ef338728e1448..522fb28214b0a04e08711d3ee80389c01b3b7f67 100644
--- a/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-connect-audioratesignal.html
+++ b/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-connect-audioratesignal.html
@@ -1,5 +1,4 @@
<!DOCTYPE html>
-
<!--
Tests that an audio-rate signal (AudioNode output) can be connected to an
AudioParam. Specifically, this tests that an audio-rate signal coming from an
@@ -9,98 +8,96 @@ AudioBufferSourceNode will be the audio source having its gain changed. We load
this one with an AudioBuffer containing a constant value of 1. Thus it's easy
to check that the resultant signal should be equal to the gain-scaling curve.
-->
-
<html>
-<head>
-<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>
-let audit = Audit.createTaskRunner();
-
-let sampleRate = 44100.0;
-let lengthInSeconds = 1;
-
-let context = 0;
-let constantOneBuffer = 0;
-let linearRampBuffer = 0;
-
-function checkResult(renderedBuffer, should) {
- let renderedData = renderedBuffer.getChannelData(0);
- let expectedData = linearRampBuffer.getChannelData(0);
- let n = renderedBuffer.length;
-
- should(n, 'Rendered signal length').beEqualTo(linearRampBuffer.length);
-
- // Check that the rendered result exactly matches the buffer used to control
- // gain. This is because we're changing the gain of a signal having constant
- // value 1.
- let success = true;
- for (let i = 0; i < n; ++i) {
- if (renderedData[i] != expectedData[i]) {
- success = false;
- break;
- }
- }
-
- should(
- success,
- 'Rendered signal exactly matches the audio-rate gain changing signal')
- .beTrue();
-}
-
-audit.define('test', function(task, should) {
- let sampleFrameLength = sampleRate * lengthInSeconds;
-
- // Create offline audio context.
- context = new OfflineAudioContext(1, sampleFrameLength, sampleRate);
-
- // Create buffer used by the source which will have its gain controlled.
- constantOneBuffer = createConstantBuffer(context, sampleFrameLength, 1);
-
- // Create buffer used to control gain.
- linearRampBuffer = createLinearRampBuffer(context, sampleFrameLength);
-
- // Create the two sources.
-
- let constantSource = context.createBufferSource();
- constantSource.buffer = constantOneBuffer;
-
- let gainChangingSource = context.createBufferSource();
- gainChangingSource.buffer = linearRampBuffer;
-
- // Create a gain node controlling the gain of constantSource and make the
- // connections.
- let gainNode = context.createGain();
-
- // Intrinsic baseline gain of zero.
- gainNode.gain.value = 0;
-
- constantSource.connect(gainNode);
- gainNode.connect(context.destination);
-
- // Connect an audio-rate signal to control the .gain AudioParam.
- // This is the heart of what is being tested.
- gainChangingSource.connect(gainNode.gain);
-
- // Start both sources at time 0.
- constantSource.start(0);
- gainChangingSource.start(0);
-
- context.startRendering().then(buffer => {
- checkResult(buffer, should);
- task.done();
- });
-});
-
-audit.run();
-
-</script>
-
-</body>
+ <head>
+ <title>
+ audioparam-connect-audioratesignal.html
+ </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 id="layout-test-code">
+ let audit = Audit.createTaskRunner();
+
+ let sampleRate = 44100.0;
+ let lengthInSeconds = 1;
+
+ let context = 0;
+ let constantOneBuffer = 0;
+ let linearRampBuffer = 0;
+
+ function checkResult(renderedBuffer, should) {
+ let renderedData = renderedBuffer.getChannelData(0);
+ let expectedData = linearRampBuffer.getChannelData(0);
+ let n = renderedBuffer.length;
+
+ should(n, 'Rendered signal length').beEqualTo(linearRampBuffer.length);
+
+ // Check that the rendered result exactly matches the buffer used to
+ // control gain. This is because we're changing the gain of a signal
+ // having constant value 1.
+ let success = true;
+ for (let i = 0; i < n; ++i) {
+ if (renderedData[i] != expectedData[i]) {
+ success = false;
+ break;
+ }
+ }
+
+ should(
+ success,
+ 'Rendered signal exactly matches the audio-rate gain changing signal')
+ .beTrue();
+ }
+
+ audit.define('test', function(task, should) {
+ let sampleFrameLength = sampleRate * lengthInSeconds;
+
+ // Create offline audio context.
+ context = new OfflineAudioContext(1, sampleFrameLength, sampleRate);
+
+ // Create buffer used by the source which will have its gain controlled.
+ constantOneBuffer = createConstantBuffer(context, sampleFrameLength, 1);
+
+ // Create buffer used to control gain.
+ linearRampBuffer = createLinearRampBuffer(context, sampleFrameLength);
+
+ // Create the two sources.
+
+ let constantSource = context.createBufferSource();
+ constantSource.buffer = constantOneBuffer;
+
+ let gainChangingSource = context.createBufferSource();
+ gainChangingSource.buffer = linearRampBuffer;
+
+ // Create a gain node controlling the gain of constantSource and make
+ // the connections.
+ let gainNode = context.createGain();
+
+ // Intrinsic baseline gain of zero.
+ gainNode.gain.value = 0;
+
+ constantSource.connect(gainNode);
+ gainNode.connect(context.destination);
+
+ // Connect an audio-rate signal to control the .gain AudioParam.
+ // This is the heart of what is being tested.
+ gainChangingSource.connect(gainNode.gain);
+
+ // Start both sources at time 0.
+ constantSource.start(0);
+ gainChangingSource.start(0);
+
+ context.startRendering().then(buffer => {
+ checkResult(buffer, should);
+ task.done();
+ });
+ });
+
+ audit.run();
+ </script>
+ </body>
</html>

Powered by Google App Engine
This is Rietveld 408576698