Chromium Code Reviews| 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..1c300effbe61a9864b04691a0e41555e9cd0f9b4 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); |
|
hongchan
2017/02/22 19:05:35
Ditto. How do we reconcile this with task.describe
Raymond Toy
2017/02/22 19:23:24
Wait until that's landed.
|
| - 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.bind(task)); |
|
hongchan
2017/02/22 19:05:35
() => task.done()
Raymond Toy
2017/02/22 19:23:24
Done.
|
| + }); |
| - context.oncomplete = checkShapedCurve; |
| - context.startRendering(); |
| + audit.run(); |
| } |