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..fb36de2bc0853831cb69ba99167bd137e137fbb0 100644 |
| --- a/third_party/WebKit/LayoutTests/webaudio/resources/late-start-testing.js |
| +++ b/third_party/WebKit/LayoutTests/webaudio/resources/late-start-testing.js |
| @@ -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); |
|
Raymond Toy
2017/02/13 22:13:01
Nit: this is not a great message to print out. Don
hongchan
2017/02/13 22:33:58
Done.
|
| + success = Should('Non-zero value index', nonZeroValueIndex) |
| + .notBeEqualTo(0) && success; |
|
Raymond Toy
2017/02/13 22:13:02
Maybe say 'First non-zero value found at index'. O
hongchan
2017/02/13 22:33:58
I changed it in a slightly different way.
|
| + 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' |
| ); |
| -} |
| +} |