Commit 7f51edae authored by rtoy's avatar rtoy Committed by Commit bot

Convert AudioBufferSource tests using Audit to testharness

Only the tests using Audit are converted here, using the script:

for f in `grep -l Audit *.html`
do
  # Replace js-test with testharness and add testharnessreport.js
  sed -i 's;\(.*\)\(<script.*\)js-test.js\(.*\);\1\2testharness.js\3\
\1\2testharnessreport.js\3 ;' $f
  # Remove old js-test methods that no longer exist.
  sed -i '/^[ 	]*\(description(".*")\|finishJSTest()\);[ 	]*/d' $f
  # Remove jsTestIsAsync stuff
  sed -i '/^[ 	]*window.jsTestIsAsync *= *true;[ 	]*$/d' $f
  # Remove expected results file.
  base=`basename $f .html`
  git rm $base-expected.txt
done

Additional manual changes were needed to replace methods defined by
js-test.  A few tests needed updated expectations due to how
audit-util.js needed to be changed for these tests.

BUG=676355
TEST=

Review-Url: https://codereview.chromium.org/2593043003
Cr-Commit-Position: refs/heads/master@{#442672}
parent d9293175
AudioBufferSourceNode: DC-driven detune modulation.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS Increasing detune to 1200 decreased the interval between impulses to half.
PASS successfullyParsed is true
TEST COMPLETE
......@@ -2,15 +2,14 @@
<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>
</head>
<body>
<script>
description('AudioBufferSourceNode: DC-driven detune modulation.');
window.jsTestIsAsync = true;
var sampleRate = 44100;
......@@ -84,17 +83,14 @@
i++;
}
if (passed) {
testPassed('Increasing detune to 1200 decreased the interval between impulses to half.');
} else {
testFailed('Increasing detune produced the incorrect result' +
'at the index ' + i + '.');
}
Should('Increasing detune', passed)
.summarize(
'to 1200 decreased the interval between impulses to half',
'produced the incorrect result' + 'at the index ' + i);
}).then(done);
});
audit.defineTask('finish', function (done) {
finishJSTest();
done();
});
......
AudioBufferSourceNode: oscillator-driven detune modulation.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS Exceeded SNR threshold of 93.31 dB.
PASS Maximum difference below threshold of 1.01 ulp (16-bits).
PASS Number of differences between results is 0 out of 11025.
PASS successfullyParsed is true
TEST COMPLETE
......@@ -2,7 +2,8 @@
<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/audiobuffersource-testing.js"></script>
......@@ -11,8 +12,6 @@
<body>
<script>
description('AudioBufferSourceNode: oscillator-driven detune modulation.');
window.jsTestIsAsync = true;
var sampleRate = 44100;
var duration = 0.25;
......@@ -83,7 +82,6 @@
});
audit.defineTask('finish', function (done) {
finishJSTest();
done();
});
......
Test the late call of start(0) of BufferSource.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS The output contains all the expected values in the correct order: [0,1].
PASS The index of value change is equal to 5504.
PASS The rendered buffer contains non-zero values after the first sample.
PASS successfullyParsed is true
TEST COMPLETE
......@@ -2,15 +2,14 @@
<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>
</head>
<body>
<script>
description('Test the late call of start(0) of BufferSource.');
window.jsTestIsAsync = true;
var renderQuantum = 128;
......@@ -69,17 +68,14 @@
Should('The index of value change', nonZeroValueIndex)
.beEqualTo(startIndex);
if (nonZeroValueIndex === 0)
testFailed('The first sample was non-zero value. It should be zero.');
else
testPassed('The rendered buffer contains non-zero values after the first sample.');
Should('The index of the first non-zero sample', nonZeroValueIndex)
.notBeEqualTo(0)
}).then(done);
});
audit.defineTask('finish-test', function (done) {
done();
finishJSTest();
});
audit.runTasks();
......
......@@ -3,25 +3,25 @@ Tests AudioBufferSourceNode looping with a variety of loop points.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS loop whole buffer by default with loopStart == loopEnd == 0
PASS loop whole buffer explicitly
PASS loop from middle to end of buffer
PASS loop from start to middle of buffer
PASS loop from 4 -> 6
PASS loop from 3 -> 7
PASS loop from 4 -> 6 with playbackRate of 0.5
PASS loop from 4 -> 6 with playbackRate of 1.5
PASS loop from 2 -> 5 with offset 6
PASS loop from 3 -> 6 with offset 1
PASS loop from 3 -> 6 with offset 4
PASS illegal playbackRate of 47 greater than loop length
PASS illegal loop: loopStartFrame > loopEndFrame
PASS illegal loop: loopStartFrame == loopEndFrame
PASS illegal loop: loopStartFrame < 0
PASS illegal loop: loopEndFrame > bufferLength
PASS loop from 3 -> 6 with offset 1 for 20 frames
PASS loop from 3 -> 8 with offset 1 for 3 frames
PASS loop from 3 -> 8 with offset 7 for 3 frames
PASS loop whole buffer by default with loopStart == loopEnd == 0.
PASS loop whole buffer explicitly.
PASS loop from middle to end of buffer.
PASS loop from start to middle of buffer.
PASS loop from 4 -> 6.
PASS loop from 3 -> 7.
PASS loop from 4 -> 6 with playbackRate of 0.5.
PASS loop from 4 -> 6 with playbackRate of 1.5.
PASS loop from 2 -> 5 with offset 6.
PASS loop from 3 -> 6 with offset 1.
PASS loop from 3 -> 6 with offset 4.
PASS illegal playbackRate of 47 greater than loop length.
PASS illegal loop: loopStartFrame > loopEndFrame.
PASS illegal loop: loopStartFrame == loopEndFrame.
PASS illegal loop: loopStartFrame < 0.
PASS illegal loop: loopEndFrame > bufferLength.
PASS loop from 3 -> 6 with offset 1 for 20 frames.
PASS loop from 3 -> 8 with offset 1 for 3 frames.
PASS loop from 3 -> 8 with offset 7 for 3 frames.
PASS successfullyParsed is true
TEST COMPLETE
......
Test AudioBufferSourceNode looping without explicit duration
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS The output of actual and expected loops is identical to the array [0,0.125,0.25,0.375,0.5,0.625,0.75,0.875,0,0.125,0.25,0.375,0.5,0.625,0.75,0.875,...].
PASS The content of the left and right channel is identical to the array [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...].
PASS successfullyParsed is true
TEST COMPLETE
......@@ -3,15 +3,14 @@
<head>
<title>Test AudioBufferSourceNode looping without explicit duration</title>
<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>
</head>
<body>
<script>
description("Test AudioBufferSourceNode looping without explicit duration");
window.jsTestIsAsync = true;
// Reasonably low sample rate for the optimum test speed.
var sampleRate = 4096;
......@@ -98,7 +97,6 @@
});
audit.defineTask('finish', function (done) {
finishJSTest();
done();
});
......
......@@ -3,21 +3,21 @@ Test if AudioBufferSourceNode.playbackRate can playback at different rates prope
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS Exceeded SNR threshold of 103.8508 dB.
PASS Maximum difference below threshold of 0.3028 ulp (16-bits).
PASS Number of differences between results is 0 out of 14400.
PASS Exceeded SNR threshold of 103.8657 dB.
PASS Maximum difference below threshold of 0.3029 ulp (16-bits).
PASS Number of differences between results is 0 out of 14400.
PASS Exceeded SNR threshold of 103.8141 dB.
PASS Maximum difference below threshold of 0.3047 ulp (16-bits).
PASS Number of differences between results is 0 out of 14400.
PASS Exceeded SNR threshold of 103.6818 dB.
PASS Maximum difference below threshold of 0.3262 ulp (16-bits).
PASS Number of differences between results is 0 out of 14400.
PASS Exceeded SNR threshold of 103.1514 dB.
PASS Maximum difference below threshold of 0.3946 ulp (16-bits).
PASS Number of differences between results is 0 out of 14400.
PASS SNR (103.85093009191795) is greater than or equal to 103.8508.
PASS Maximum difference (in ulp units (16-bits)) (0.302734375) is less than or equal to 0.3028.
PASS Number of differences between results (0) is less than or equal to 0.
PASS SNR (103.8658027256771) is greater than or equal to 103.8657.
PASS Maximum difference (in ulp units (16-bits)) (0.302734375) is less than or equal to 0.3029.
PASS Number of differences between results (0) is less than or equal to 0.
PASS SNR (103.81424611365298) is greater than or equal to 103.8141.
PASS Maximum difference (in ulp units (16-bits)) (0.3046875) is less than or equal to 0.3047.
PASS Number of differences between results (0) is less than or equal to 0.
PASS SNR (103.68193381522602) is greater than or equal to 103.6818.
PASS Maximum difference (in ulp units (16-bits)) (0.326171875) is less than or equal to 0.3262.
PASS Number of differences between results (0) is less than or equal to 0.
PASS SNR (103.1515278088242) is greater than or equal to 103.1514.
PASS Maximum difference (in ulp units (16-bits)) (0.39453125) is less than or equal to 0.3946.
PASS Number of differences between results (0) is less than or equal to 0.
PASS successfullyParsed is true
TEST COMPLETE
......
AudioBufferSourceNode: DC-driven playbackRate modulation.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS Doubling playbackRate decreased the interval between impulses to half.
PASS successfullyParsed is true
TEST COMPLETE
......@@ -2,15 +2,14 @@
<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>
</head>
<body>
<script>
description('AudioBufferSourceNode: DC-driven playbackRate modulation.');
window.jsTestIsAsync = true;
var sampleRate = 44100;
......@@ -85,17 +84,14 @@
i++;
}
if (passed) {
testPassed('Doubling playbackRate decreased the interval between impulses to half.');
} else {
testFailed('Doubling playbackRate produced the incorrect result' +
'at the index ' + i + '.');
}
Should('Doubling playbackRate', passed)
.summarize(
'decreased the interval between impulses to half',
'produced the incorrect result' + 'at the index ' + i)
}).then(done);
});
audit.defineTask('finish', function (done) {
finishJSTest();
done();
});
......
AudioBufferSourceNode: oscillator-driven playbackRate modulation.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS Exceeded SNR threshold of 92.72 dB.
PASS Maximum difference below threshold of 0.985 ulp (16-bits).
PASS Number of differences between results is 0 out of 11025.
PASS successfullyParsed is true
TEST COMPLETE
......@@ -2,7 +2,8 @@
<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/audiobuffersource-testing.js"></script>
......@@ -11,8 +12,6 @@
<body>
<script>
description('AudioBufferSourceNode: oscillator-driven playbackRate modulation.');
window.jsTestIsAsync = true;
var sampleRate = 44100;
var duration = 0.25;
......@@ -83,7 +82,6 @@
});
audit.defineTask('finish', function (done) {
finishJSTest();
done();
});
......
AudioBufferSourceNode: test the "zero" playbackRate.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS The zero playbackRate held the sample value correctly.
PASS successfullyParsed is true
TEST COMPLETE
......@@ -2,15 +2,14 @@
<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>
</head>
<body>
<script>
description('AudioBufferSourceNode: test the "zero" playbackRate.');
window.jsTestIsAsync = true;
// Sample rate should be power of 128 to observe the change of AudioParam at
// the beginning of rendering quantum. (playbackRate is k-rate) This is the
......@@ -63,18 +62,15 @@
}
}
if (passed) {
testPassed('The zero playbackRate held the sample value correctly.');
} else {
testFailed('The zero playbackRate should hold the sample value. ' +
'Expected ' + rampData[half] + ' but got ' + data[i] + ' at the index ' +
i + '.');
}
Should('The zero playbackRate', passed)
.summarize(
'held the sample value correctly',
'should hold the sample value. ' + 'Expected ' + rampData[half] +
' but got ' + data[i] + ' at the index ' + i);
}).then(done);
});
audit.defineTask('finish', function (done) {
finishJSTest();
done();
});
......
Test if AudioBufferSourceNode stops prematurely after the loop attribute change.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS Region #1 contains only the constant 1.
PASS Region #2 (looped) contains only the constant 2.
PASS Region #3 contains only the constant 3.
PASS successfullyParsed is true
TEST COMPLETE
......@@ -3,15 +3,14 @@
<head>
<title>Test AudioBufferSourceNode premature loop stop</title>
<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>
</head>
<body>
<script>
description("Test if AudioBufferSourceNode stops prematurely after the loop attribute change.");
window.jsTestIsAsync = true;
// Reasonably low sample rate for the optimum test speed.
var sampleRate = 4096;
......@@ -78,7 +77,6 @@
});
audit.defineTask('finish', function (done) {
finishJSTest();
done();
});
......
......@@ -2,15 +2,15 @@ Tests AudioBufferSourceNode start() with a variety of offsets and durations.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS start(when): implicitly play whole buffer from beginning to end
PASS start(when, 0): play whole buffer from beginning to end explicitly giving offset of 0
PASS start(when, 0, 8_frames): play whole buffer from beginning to end explicitly giving offset of 0 and duration of 8 frames
PASS start(when, 4_frames): play with explicit non-zero offset
PASS start(when, 4_frames, 4_frames): play with explicit non-zero offset and duration
PASS start(when, 7_frames): play with explicit non-zero offset near end of buffer
PASS start(when, 8_frames): play with explicit offset at end of buffer
PASS start(when, 9_frames): play with explicit offset past end of buffer
PASS start(when, 0, 15_frames): play with whole buffer, with long duration (clipped)
PASS start(when): implicitly play whole buffer from beginning to end.
PASS start(when, 0): play whole buffer from beginning to end explicitly giving offset of 0.
PASS start(when, 0, 8_frames): play whole buffer from beginning to end explicitly giving offset of 0 and duration of 8 frames.
PASS start(when, 4_frames): play with explicit non-zero offset.
PASS start(when, 4_frames, 4_frames): play with explicit non-zero offset and duration.
PASS start(when, 7_frames): play with explicit non-zero offset near end of buffer.
PASS start(when, 8_frames): play with explicit offset at end of buffer.
PASS start(when, 9_frames): play with explicit offset past end of buffer.
PASS start(when, 0, 15_frames): play with whole buffer, with long duration (clipped).
PASS successfullyParsed is true
TEST COMPLETE
......
Test onended event listener
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS AudioBufferSource.onended called when ended set directly.
PASS AudioBufferSource.onended called when using addEventListener.
PASS Oscillator.onended called when ended set directly.
PASS Oscillator.onended called when using addEventListener.
PASS successfullyParsed is true
TEST COMPLETE
......@@ -2,15 +2,14 @@
<html>
<head>
<title>Test Onended Event Listener</title>
<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>
</head>
<body>
<script>
description("Test onended event listener");
window.jsTestIsAsync = true;
var sampleRate = 44100;
var renderLengthSeconds = 1;
......@@ -32,7 +31,8 @@
source.buffer = buffer;
source.connect(context.destination);
source.onended = function (e) {
testPassed("AudioBufferSource.onended called when ended set directly.");
Should("AudioBufferSource.onended called when ended set directly", true)
.beEqualTo(true);
};
source.start();
context.startRendering().then(done);
......@@ -47,7 +47,8 @@
source.buffer = buffer;
source.connect(context.destination);
source.addEventListener("ended", function (e) {
testPassed("AudioBufferSource.onended called when using addEventListener.");
Should("AudioBufferSource.onended called when using addEventListener",
true).beEqualTo(true);
});
source.start();
context.startRendering().then(done);
......@@ -60,7 +61,7 @@
var source = context.createOscillator();
source.connect(context.destination);
source.onended = function (e) {
testPassed("Oscillator.onended called when ended set directly.");
Should("Oscillator.onended called when ended set directly", true).beEqualTo(true);
};
source.start();
source.stop(stopTime);
......@@ -74,7 +75,7 @@
var source = context.createOscillator();
source.connect(context.destination);
source.addEventListener("ended", function (e) {
testPassed("Oscillator.onended called when using addEventListener.");
Should("Oscillator.onended called when using addEventListener", true).beEqualTo(true);
});
source.start();
source.stop(stopTime);
......@@ -82,7 +83,6 @@
});
audit.defineTask("finish", function (done) {
finishJSTest();
done();
});
......
Test premature GC upon OscillatorNode and AudioBufferSourceNode
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS OscillatorNode 1 survived GC and onended event fired.
PASS BufferSourceNode 1 survived GC and onended event fired.
PASS successfullyParsed is true
TEST COMPLETE
......@@ -2,15 +2,14 @@
<html>
<head>
<title>Test premature GC upon OscillatorNode and AudioBufferSourceNode</title>
<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>
</head>
<body>
<script type="text/javascript">
description("Test premature GC upon OscillatorNode and AudioBufferSourceNode");
window.jsTestIsAsync = true;
var sampleRate = 44100;
var renderDuration = 1;
......@@ -39,7 +38,7 @@
// If the node is GCed, |onended| won't be fired. Then this test
// will be timed out because done() will not get called.
node.onended = function () {
testPassed(sourceNodeType + 'Node 1 survived GC and onended event fired.');
Should(sourceNodeType + 'Node 1 survived GC and onended event fired', true).beEqualTo(true);
done();
};
......@@ -66,7 +65,6 @@
});
audit.defineTask('finish', function (done) {
finishJSTest();
done();
});
......
Test Scheduled Sources with Huge Time Limits.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS Output from AudioBufferSource.stop(1e+300) contains only the constant 1.
PASS Peak amplitude from oscillator.stop(1e+300) is greater than 0.
PASS successfullyParsed is true
TEST COMPLETE
<!doctype html>
<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/audioparam-testing.js"></script>
......@@ -10,8 +11,6 @@
<body>
<script>
description("Test Scheduled Sources with Huge Time Limits.");
window.jsTestIsAsync = true;
var sampleRate = 48000;
var renderFrames = 1000;
......@@ -61,7 +60,6 @@
audit.defineTask("finish", function (done) {
finishJSTest();
done();
});
......
......@@ -45,8 +45,8 @@ function checkSingleTest(renderedBuffer, i) {
renderedArray[j] = renderedData[offsetFrame + j];
var s = description + ": expected: " + expected + " actual: " + renderedArray;
testFailed(s);
success = false;
Should(s, success).beEqualTo(true);
break;
}
}
......@@ -60,14 +60,14 @@ function checkSingleTest(renderedBuffer, i) {
renderedArray[j - framesToTest] = renderedData[offsetFrame + j];
var s = description + ": expected: all zeroes actual: " + renderedArray;
testFailed(s);
success = false;
Should(s, success).beEqualTo(true);
break;
}
}
if (success)
testPassed(description);
Should("", success)
.summarize(description, description);
return success;
}
......@@ -120,4 +120,4 @@ function createSawtoothWithModulation(context, modTarget, modOffset, modRange) {
lfo.start();
phasor.start();
}
\ No newline at end of file
}
......@@ -159,29 +159,13 @@ function compareBuffersWithConstraints(actual, expected, options) {
var snr = 10 * Math.log10(signalPower / noisePower);
var maxErrorULP = maxError * scaleFactor;
if (snr >= thresholdSNR) {
testPassed('Exceeded SNR threshold of ' + thresholdSNR + ' dB.');
} else {
testFailed('Expected SNR of ' + thresholdSNR + ' dB, but actual SNR is ' +
snr + ' dB.');
}
Should("SNR", snr).beGreaterThanOrEqualTo(thresholdSNR);
if (maxErrorULP <= thresholdDiffULP) {
testPassed('Maximum difference below threshold of ' +
thresholdDiffULP + ' ulp (' + bitDepth + '-bits).');
} else {
testFailed('Maximum difference of ' + maxErrorULP +
' at the index ' + errorPosition + ' exceeded threshold of ' +
thresholdDiffULP + ' ulp (' + bitDepth + '-bits).');
}
Should('Maximum difference (in ulp units (' + bitDepth + '-bits))',
maxErrorULP).beLessThanOrEqualTo(thresholdDiffULP);
if (diffCount <= thresholdDiffCount) {
testPassed('Number of differences between results is ' +
diffCount + ' out of ' + actual.length + '.');
} else {
testFailed(diffCount + ' differences found but expected no more than ' +
diffCount + ' out of ' + actual.length + '.');
}
Should('Number of differences between results', diffCount)
.beLessThanOrEqualTo(thresholdDiffCount);
}
// Create an impulse in a buffer of length sampleFrameLength
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment