Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/webaudio/resources/late-start-testing.js |
| diff --git a/third_party/WebKit/LayoutTests/webaudio/resources/late-start-testing.js b/third_party/WebKit/LayoutTests/webaudio/resources/late-start-testing.js |
| index 96f709b1285e757504e96ddeddc592f981fa00bf..46ef671eea2b0b40281cd11bdcc3342eccc1bf7a 100644 |
| --- a/third_party/WebKit/LayoutTests/webaudio/resources/late-start-testing.js |
| +++ b/third_party/WebKit/LayoutTests/webaudio/resources/late-start-testing.js |
| @@ -1,4 +1,4 @@ |
| -function runLateStartTest(audit, context, node) { |
| +function runLateStartTest(audit, Should, context, node) { |
|
Raymond Toy
2017/02/13 21:51:44
IIRC, Should() is a global function. Does it need
hongchan
2017/02/13 22:08:31
Done.
|
| // Set up a dummy signal path to keep the audio context running and spend |
| // processing time before calling start(0). |
| @@ -12,29 +12,20 @@ function runLateStartTest(audit, context, node) { |
| node.connect(context.destination); |
| - // Task: define |onstatechange| and start rendering. |
| + // Task: schedule a suspend and start rendering. |
| audit.defineTask('test-late-start', function (done) { |
| - |
| - // Trigger playback at 0 second. The assumptions are: |
| - // |
| - // 1) The specified timing of start() call is already passed in terms of |
| - // the context time. So the argument |0| will be clamped to the current |
| - // context time. |
| - // 2) The |onstatechange| event will be fired later than the 0 second |
| - // context time. |
| - // |
| + // The node's start time will be clamped to the render quantum boundary |
| + // >0.1 sec. Thus the rendered buffer will have non-zero frames. |
| // See issue: crbug.com/462167 |
| - context.onstatechange = function () { |
| - if (context.state === 'running') { |
| - node.start(0); |
| - } |
| - }; |
| + context.suspend(0.1).then(() => { |
| + node.start(0); |
| + context.resume(); |
| + }); |
| // Start rendering and verify result: this verifies if 1) the rendered |
| // buffer contains at least one non-zero value and 2) the non-zero value is |
| // found later than the first output sample. |
| context.startRendering().then(function (buffer) { |
| - |
| var nonZeroValueIndex = -1; |
| var channelData = buffer.getChannelData(0); |
| for (var i = 0; i < channelData.length; i++) { |
| @@ -44,13 +35,13 @@ function runLateStartTest(audit, context, node) { |
| } |
| } |
| - if (nonZeroValueIndex === -1) { |
| - testFailed('The rendered buffer was all zeros.'); |
| - } else 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.'); |
| - } |
| + var success = Should('Non-zero value index', nonZeroValueIndex) |
| + .notBeEqualTo(-1); |
| + success = Should('Non-zero value index', nonZeroValueIndex) |
| + .notBeEqualTo(0) && success; |
| + Should('The rendered buffer', success) |
| + .summarize('contains non-zero values after the first sample', |
| + 'was all zeros or has non-zero first sample.'); |
| done(); |
| }); |
| @@ -66,4 +57,4 @@ function runLateStartTest(audit, context, node) { |
| 'finish-test' |
| ); |
| -} |
| +} |