Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-grain.html |
| diff --git a/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-grain.html b/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-grain.html |
| index a50b108010b1e1fcb9642115242b990d020991f7..0ac2da6be8fb230de80f89608b3f2de5ef81063a 100644 |
| --- a/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-grain.html |
| +++ b/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-grain.html |
| @@ -2,31 +2,30 @@ |
| <html> |
| <head> |
| <title>Test Start Grain with Delayed Buffer Setting </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> |
| + <script src="../resources/audit.js"></script> |
| </head> |
| <body> |
| <script> |
| - description("Test setting the source buffer after starting the grain"); |
| + let audit = Audit.createTaskRunner(); |
| + let context; |
| + let source; |
| + let buffer; |
| + let renderedData; |
| - var context; |
| - var source; |
| - var buffer; |
| - var renderedData; |
| + let sampleRate = 44100; |
| - var sampleRate = 44100; |
| + let testDurationSec = 1; |
| + let testDurationSamples = testDurationSec * sampleRate; |
| + let startTime = 0.9 * testDurationSec; |
| - var testDurationSec = 1; |
| - var testDurationSamples = testDurationSec * sampleRate; |
| - var startTime = 0.9 * testDurationSec; |
| - |
| - function runTest() { |
| - window.jsTestIsAsync = true; |
| - |
| - context = new OfflineAudioContext(1, testDurationSamples, sampleRate); |
| - context.oncomplete = checkResult; |
| + audit.define("Test setting the source buffer after starting the grain", |
| + function (task, should) { |
| + context = new OfflineAudioContext(1, testDurationSamples, |
| + sampleRate); |
| buffer = createConstantBuffer(context, testDurationSamples, 1); |
| source = context.createBufferSource(); |
| @@ -38,34 +37,32 @@ |
| source.buffer = buffer; |
| // Render it! |
| - context.startRendering(); |
| - } |
| + context.startRendering() |
| + .then(function (buffer) { |
| + checkResult(buffer, should); |
| + }) |
| + .then(task.done.bind(task));; |
| + }); |
| - function checkResult(event) { |
| - var success = false; |
| + function checkResult(buffer, should) { |
| + let success = false; |
| - renderedData = event.renderedBuffer.getChannelData(0); |
| + renderedData = buffer.getChannelData(0); |
| - // Check that the rendered data is not all zeroes. Any non-zero data means the test |
| - // passed. |
| - var startFrame = Math.round(startTime * sampleRate); |
| - for (k = 0; k < renderedData.length; ++k) { |
| - if (renderedData[k]) { |
| - success = true; |
| - break; |
| - } |
| + // Check that the rendered data is not all zeroes. Any non-zero data means the test |
| + // passed. |
|
hongchan
2017/01/04 21:40:55
Just a thought: perhaps we need should().beNonZero
Raymond Toy
2017/01/04 21:44:00
Only if we add should().beZero(). :-)
Both would
hongchan
2017/01/04 21:53:36
should().beZero() can be achieved by should().beCo
|
| + let startFrame = Math.round(startTime * sampleRate); |
| + for (k = 0; k < renderedData.length; ++k) { |
| + if (renderedData[k]) { |
| + success = true; |
| + break; |
| } |
| + } |
| - if (success) |
| - testPassed("Buffer was played."); |
| - else |
| - testFailed("Buffer was not played."); |
| - |
| - finishJSTest(); |
| + should(success, "Buffer was played").beTrue(); |
| } |
| - runTest(); |
| - successfullyParsed = true; |
| + audit.run(); |
| </script> |
| </body> |
| </html> |