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

Unified Diff: third_party/WebKit/LayoutTests/webaudio/resources/waveshaper-testing.js

Issue 2677453005: Convert WaveShaper tests to testharness (Closed)
Patch Set: Address review comments Created 3 years, 10 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 | « third_party/WebKit/LayoutTests/webaudio/WaveShaper/waveshaper-oversample-4x-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/webaudio/resources/waveshaper-testing.js
diff --git a/third_party/WebKit/LayoutTests/webaudio/resources/waveshaper-testing.js b/third_party/WebKit/LayoutTests/webaudio/resources/waveshaper-testing.js
index 923bb7dd5cc99b7d481b30abe27d4bcac4672990..b8b866fb85ce9d41c7dea99edba64ac38a987782 100644
--- a/third_party/WebKit/LayoutTests/webaudio/resources/waveshaper-testing.js
+++ b/third_party/WebKit/LayoutTests/webaudio/resources/waveshaper-testing.js
@@ -51,9 +51,7 @@ function generateWaveShapingCurve() {
return curve;
}
-function checkShapedCurve(event) {
- var buffer = event.renderedBuffer;
-
+function checkShapedCurve(buffer, should) {
var outputData = buffer.getChannelData(0);
var n = buffer.length;
@@ -114,15 +112,9 @@ function checkShapedCurve(event) {
// console.log("worstDeltaInDecibels: " + worstDeltaInDecibels);
- var success = worstDeltaInDecibels < acceptableAliasingThresholdDecibels;
-
- if (success) {
- testPassed(oversample + " WaveShaperNode oversampling within acceptable tolerance.");
- } else {
- testFailed(oversample + " WaveShaperNode oversampling not within acceptable tolerance. Error = " + worstDeltaInDecibels + " dBFS");
- }
-
- finishJSTest();
+ should(worstDeltaInDecibels, oversample +
+ " WaveshaperNode oversampling error (in dBFS)")
+ .beLessThan(acceptableAliasingThresholdDecibels);
}
function createImpulseBuffer(context, sampleFrameLength) {
@@ -145,31 +137,33 @@ function runWaveShaperOversamplingTest(testParams) {
fundamentalFrequency = testParams.fundamentalFrequency;
acceptableAliasingThresholdDecibels = testParams.acceptableAliasingThresholdDecibels;
- if (window.testRunner) {
- testRunner.dumpAsText();
- testRunner.waitUntilDone();
- }
+ let audit = Audit.createTaskRunner();
+
+ audit.define("test", function (task, should) {
+ task.describe(testParams.description);
- window.jsTestIsAsync = true;
+ // Create offline audio context.
+ var numberOfRenderFrames = sampleRate * lengthInSeconds;
+ context = new OfflineAudioContext(1, numberOfRenderFrames, sampleRate);
- // Create offline audio context.
- var numberOfRenderFrames = sampleRate * lengthInSeconds;
- context = new OfflineAudioContext(1, numberOfRenderFrames, sampleRate);
+ // source -> waveshaper -> destination
+ var source = context.createBufferSource();
+ source.buffer = createToneBuffer(context, fundamentalFrequency, lengthInSeconds, 1);
- // source -> waveshaper -> destination
- var source = context.createBufferSource();
- source.buffer = createToneBuffer(context, fundamentalFrequency, lengthInSeconds, 1);
+ // Apply a non-linear distortion curve.
+ waveshaper = context.createWaveShaper();
+ waveshaper.curve = generateWaveShapingCurve();
+ waveshaper.oversample = oversample;
- // Apply a non-linear distortion curve.
- waveshaper = context.createWaveShaper();
- waveshaper.curve = generateWaveShapingCurve();
- waveshaper.oversample = oversample;
+ source.connect(waveshaper);
+ waveshaper.connect(context.destination);
- source.connect(waveshaper);
- waveshaper.connect(context.destination);
+ source.start(0);
- source.start(0);
+ context.startRendering()
+ .then(buffer => checkShapedCurve(buffer, should))
+ .then(() => task.done());
+ });
- context.oncomplete = checkShapedCurve;
- context.startRendering();
+ audit.run();
}
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/WaveShaper/waveshaper-oversample-4x-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698