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

Unified Diff: third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-connect-audioratesignal.html

Issue 2651253004: Convert non-Audit AudioParam tests to testharness (Closed)
Patch Set: Reindent Created 3 years, 11 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-connect-audioratesignal-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 fbd034a7738ba726db81e61b89be689ce258fef0..6281e914e87e18962b88a431714ef338728e1448 100644
--- a/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-connect-audioratesignal.html
+++ b/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-connect-audioratesignal.html
@@ -1,113 +1,104 @@
<!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 AudioBufferSourceNode
-playing an AudioBuffer containing a specific curve can be connected to an AudioGainNode's
-.gain attribute (an AudioParam). Another 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.
+<!--
+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
+AudioBufferSourceNode playing an AudioBuffer containing a specific curve can be
+connected to an AudioGainNode's .gain attribute (an AudioParam). Another
+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/js-test.js"></script>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
<script src="../resources/audit-util.js"></script>
-<script src="../resources/audio-testing.js"></script>
+<script src="../resources/audit.js"></script>
</head>
<body>
<script>
-
-var sampleRate = 44100.0;
-var lengthInSeconds = 1;
-
-var context = 0;
-var constantOneBuffer = 0;
-var linearRampBuffer = 0;
-
-function checkResult(event) {
- var renderedBuffer = event.renderedBuffer;
- var renderedData = renderedBuffer.getChannelData(0);
- var expectedData = linearRampBuffer.getChannelData(0);
- var n = renderedBuffer.length;
-
- if (n == linearRampBuffer.length) {
- testPassed("Rendered signal is of correct length.");
- } else {
- testFailed("Rendered signal is not of correct 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.
- var success = true;
- for (var i = 0; i < n; ++i) {
- if (renderedData[i] != expectedData[i]) {
- success = false;
- break;
- }
+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;
}
+ }
- if (success) {
- testPassed("Rendered signal exactly matches the audio-rate gain changing signal.");
- } else {
- testFailed("Rendered signal differs from the audio-rate gain changing signal.");
- }
-
- finishJSTest();
+ should(
+ success,
+ 'Rendered signal exactly matches the audio-rate gain changing signal')
+ .beTrue();
}
-function runTest() {
- if (window.testRunner) {
- testRunner.dumpAsText();
- testRunner.waitUntilDone();
- }
-
- window.jsTestIsAsync = true;
-
- var sampleFrameLength = sampleRate * lengthInSeconds;
+audit.define('test', function(task, should) {
+ let sampleFrameLength = sampleRate * lengthInSeconds;
- // Create offline audio context.
- context = new OfflineAudioContext(1, sampleFrameLength, sampleRate);
+ // 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 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 buffer used to control gain.
+ linearRampBuffer = createLinearRampBuffer(context, sampleFrameLength);
- // Create the two sources.
+ // Create the two sources.
- var constantSource = context.createBufferSource();
- constantSource.buffer = constantOneBuffer;
+ let constantSource = context.createBufferSource();
+ constantSource.buffer = constantOneBuffer;
- var gainChangingSource = context.createBufferSource();
- gainChangingSource.buffer = linearRampBuffer;
+ let gainChangingSource = context.createBufferSource();
+ gainChangingSource.buffer = linearRampBuffer;
- // Create a gain node controlling the gain of constantSource and make the connections.
- var gainNode = context.createGain();
+ // 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;
+ // Intrinsic baseline gain of zero.
+ gainNode.gain.value = 0;
- constantSource.connect(gainNode);
- gainNode.connect(context.destination);
+ 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);
+ // 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);
+ // Start both sources at time 0.
+ constantSource.start(0);
+ gainChangingSource.start(0);
- context.oncomplete = checkResult;
- context.startRendering();
-}
+ context.startRendering().then(buffer => {
+ checkResult(buffer, should);
+ task.done();
+ });
+});
-runTest();
-successfullyParsed = true;
+audit.run();
</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-connect-audioratesignal-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698